Skip to content

evm t8n calculate difficulty #23249

@winsvega

Description

@winsvega

The current env format is

{
   "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
   "currentDifficulty" : "0x020000",
   "currentGasLimit" : "0x05f5e100",
   "currentNumber" : "0x01",
   "currentTimestamp" : "0x03e8",
   "previousHash" : "0xe729de3fec21e30bea3d56adb01ed14bc107273c2775f9355afb10f594a10d9e",
   "blockHashes" : {
       "0" : "0xe729de3fec21e30bea3d56adb01ed14bc107273c2775f9355afb10f594a10d9e"
   }
}

want to extend the following format to be acceptable (as well as the old one)

{
   "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
   "parentDifficulty" : "0x020000",
   "currentGasLimit" : "0x05f5e100",
   "currentNumber" : "0x01",
   "parentTimestamp" : "0x03e7",
   "currentTimestamp" : "0x03e8",
   "previousHash" : "0xe729de3fec21e30bea3d56adb01ed14bc107273c2775f9355afb10f594a10d9e",
   "blockHashes" : {
       "0" : "0xe729de3fec21e30bea3d56adb01ed14bc107273c2775f9355afb10f594a10d9e"
   }
}

new fields: parentDifficulty instead of currentDifficulty
and parentTimestamp

the result file then

{
  "currentDifficulty" : "0x020001"
  "stateRoot": "0x1c99b01120e7a2fa1301b3505f20100e72362e5ac3f96854420e56ba8984d716",
  "txRoot": "0xb5eee60b45801179cbde3781b9a5dee9b3111554618c9cda3d6f7e351fd41e0b",
  "receiptRoot": "0x86ceb80cb6bef8fe4ac0f1c99409f67cb2554c4432f374e399b94884eb3e6562",
  "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "receipts": [
  ]
}

would report the new difficulty calculated with geth formula currentDifficulty

Rationale
To avoid point of failure when generating the tests. Currently retesteth calculates the difficulty, but retesteth difficulty formula might be wrong. Since we test the clients, it would make sense that retesteth asks t8ntool what geth evm thinks would be the new difficulty given parentTimestamp and parentDifficulty and currentTimestamp.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions