Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evm t8n returns incorrect difficulty on --state.fork Berlin #23818

Closed
marioevz opened this issue Oct 27, 2021 · 1 comment · Fixed by #23810
Closed

evm t8n returns incorrect difficulty on --state.fork Berlin #23818

marioevz opened this issue Oct 27, 2021 · 1 comment · Fixed by #23810
Labels

Comments

@marioevz
Copy link
Member

marioevz commented Oct 27, 2021

Running test BasicTests/difficultyEIP2384_random.json on evm t8n results in wrong difficulty being calculated.
The first test case from the test file, "TestHeight10001380", can be executed using the following Env:

{
    "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
    "currentNumber" : "0x989be4",
    "currentTimestamp" : "0xa325b17f",
    "currentGasLimit" : "0x0f4240",
    "previousHash" : "0x668c5d6c12a905b58fc597b3146d29b9d12280c1891449b06e19f9edee0fe86f",
    "currentBaseFee" : "0x10",
    "parentTimestamp" : "0xa325b151",
    "parentDifficulty" : "0x3d7463c8ec830cb1",
    "parentUncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
}

Test expects a difficulty value of 0x3d55a997080ccc2d, but the value returned by evm t8n is 0x3d56a997080ccb2d.
The expected difficulty is calculated by using the MuirGlacier block pushback value of 9,000,000, but the difficulty returned by evm seems to be using a block pushback value of 5,000,000.

@holiman
Copy link
Contributor

holiman commented Oct 27, 2021

Indeed, nice catch!
I've found the problem, will add the fix to the arrow glacier PR. With and without the fix:

[user@work evm]$ go run . t8n --input.env ./env.json --input.txs ./testdata/14/txs.json --input.alloc=./testdata/14/alloc.json --state.fork=Berlin --output.result=stdout | jq ".result .currentDifficulty"
INFO [10-27|09:39:44.851] Trie dumping started                     root=6f0588..7f4bdc
INFO [10-27|09:39:44.851] Trie dumping complete                    accounts=2 elapsed="72.481µs"
INFO [10-27|09:39:44.851] Wrote file                               file=alloc.json
"0x3d56a997080ccb2d"
[user@work evm]$ go run . t8n --input.env ./env.json --input.txs ./testdata/14/txs.json --input.alloc=./testdata/14/alloc.json --state.fork=Berlin --output.result=stdout | jq ".result .currentDifficulty"
INFO [10-27|09:41:23.659] Trie dumping started                     root=6f0588..7f4bdc
INFO [10-27|09:41:23.659] Trie dumping complete                    accounts=2 elapsed="83.766µs"
INFO [10-27|09:41:23.659] Wrote file                               file=alloc.json
"0x3d55a997080ccc2d"

holiman added a commit to holiman/go-ethereum that referenced this issue Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants