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

nethtest: blockhash doesn't match other clients, part II #4967

Open
holiman opened this issue Dec 6, 2022 · 0 comments
Open

nethtest: blockhash doesn't match other clients, part II #4967

holiman opened this issue Dec 6, 2022 · 0 comments

Comments

@holiman
Copy link
Contributor

holiman commented Dec 6, 2022

New version of #3201

What @MariusVanDerWijden in #3201 was almost true, but somewhat simplified.

Example case 565138.json which was submitted by @guidovranken
It has currentNumber set:

    "env": {
      "currentGasLimit": "0xb71b00",
      "currentTimestamp": "0x03e8",
      "previousHash": "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
      "currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
      "currentDifficulty": "0x020000",
      "currentBaseFee": "0x0a",
      "currentRandom": "0x0000000000000000000000000000000000000000000000000000000000020000",
      "currentNumber": "0xc5d488"

What @MariusVanDerWijden wrote is only true if we execute on BLOCKNUMBER 1 , in which case 0 is the only one "eligible" for blockhash. If we're on a later number, there are other blocks which are 'eligible'.
Some printouts from a run:

{"pc":27,"op":64,"gas":"0x8910","gasCost":"0x14","memSize":32,"stack":["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b","0x0","0x0","0x20","0x18","0x0"],"depth":97,"refund":0,"opName":"BLOCKHASH"}
Requested blockhash 0. Scope for blockhash: [12964744 - 12965000[
{"pc":28,"op":89,"gas":"0x88fc","gasCost":"0x2","memSize":32,"stack":["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b","0x0","0x0","0x20","0x18","0x0"],"depth":97,"refund":0,"opName":"MSIZE"}

In this case, blocks [12964744 - 12965000[ are eligible, and the test queries BLOCKHASH(0). Which is not part of the scope.

The geth implementation is here: https://github.com/ethereum/go-ethereum/blob/master/core/vm/instructions.go#L435 - it checks the eligible span of blocks before actually trying to "resolve" the hashes (via keccak-cheat or disk lookup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant