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

Reth statetest blockhash issue #151

Closed
holiman opened this issue May 17, 2024 · 5 comments
Closed

Reth statetest blockhash issue #151

holiman opened this issue May 17, 2024 · 5 comments

Comments

@holiman
Copy link
Owner

holiman commented May 17, 2024

Reth returns 0 for BLOCKHASH(0), should return 0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d as described in #17. This is a regression which used to work previously.

prev:           both: {"depth":1,"pc":15,"gas":7977705,"op":64,"opName":"BLOCKHASH","stack" ["0x45","0xa6","0x38","0x51","0x2c","0x0"]}
diff:    gethbatch-0: {"depth":1,"pc":16,"gas":7977685,"op":72,"opName":"BASEFEE","stack":["0x45","0xa6","0x38","0x51","0x2c","0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"]}
diff:         revm-0: {"depth":1,"pc":16,"gas":7977685,"op":72,"opName":"BASEFEE","stack":["0x45","0xa6","0x38","0x51","0x2c","0x0"]}

Reth

root@5ef08fb2382f:/# /revme statetest --json /fuzztmp/00000728-mixed-3.json.tmp 1>/dev/null
{"pc":0,"op":96,"gas":"0x2b","gasCost":"0x3","stack":[],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
{"pc":2,"op":96,"gas":"0x28","gasCost":"0x3","stack":["0xb4"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
{"pc":4,"op":96,"gas":"0x25","gasCost":"0x3","stack":["0xb4","0xb2"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
{"pc":6,"op":96,"gas":"0x22","gasCost":"0x3","stack":["0xb4","0xb2","0x45"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
{"pc":8,"op":96,"gas":"0x1f","gasCost":"0x3","stack":["0xb4","0xb2","0x45","0xa6"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
{"pc":10,"op":96,"gas":"0x1c","gasCost":"0x3","stack":["0xb4","0xb2","0x45","0xa6","0x38"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
{"pc":12,"op":96,"gas":"0x19","gasCost":"0x3","stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
{"pc":14,"op":61,"gas":"0x16","gasCost":"0x2","stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51","0x2c"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"RETURNDATASIZE"}
{"pc":15,"op":64,"gas":"0x14","gasCost":"0x14","stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51","0x2c","0x0"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"BLOCKHASH"}
{"pc":16,"op":72,"gas":"0x0","gasCost":"0x0","stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51","0x2c","0x0"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"BASEFEE","error":"OutOfGas"}
{"stateRoot":"0xb3ac2973542b10ea21f11897a5cf406338c518d8d4ee0058a017453bec359aee","logsRoot":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","output":"0x","gasUsed":22315,"pass":false,"errorMsg":"logs root mismatch: got 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, expected 0x0000000000000000000000000000000000000000000000000000000000000000","evmResult":"Halt: OutOfGas(Basic)","postLogsHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","fork":"CANCUN","test":"00000728-mixed-3","d":0,"g":0,"v":0}

Geth

root@5ef08fb2382f:/# /gethvm --json statetest /fuzztmp/00000728-mixed-3.json.tmp 1>/dev/null
{"pc":0,"op":96,"gas":"0x2b","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":2,"op":96,"gas":"0x28","gasCost":"0x3","memSize":0,"stack":["0xb4"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":4,"op":96,"gas":"0x25","gasCost":"0x3","memSize":0,"stack":["0xb4","0xb2"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":6,"op":96,"gas":"0x22","gasCost":"0x3","memSize":0,"stack":["0xb4","0xb2","0x45"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":8,"op":96,"gas":"0x1f","gasCost":"0x3","memSize":0,"stack":["0xb4","0xb2","0x45","0xa6"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":10,"op":96,"gas":"0x1c","gasCost":"0x3","memSize":0,"stack":["0xb4","0xb2","0x45","0xa6","0x38"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":12,"op":96,"gas":"0x19","gasCost":"0x3","memSize":0,"stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":14,"op":61,"gas":"0x16","gasCost":"0x2","memSize":0,"stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51","0x2c"],"depth":1,"refund":0,"opName":"RETURNDATASIZE"}
{"pc":15,"op":64,"gas":"0x14","gasCost":"0x14","memSize":0,"stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51","0x2c","0x0"],"depth":1,"refund":0,"opName":"BLOCKHASH"}
{"pc":16,"op":72,"gas":"0x0","gasCost":"0x2","memSize":0,"stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51","0x2c","0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"],"depth":1,"refund":0,"opName":"BASEFEE","error":"out of gas"}
{"output":"","gasUsed":"0x2b","error":"out of gas"}
{"stateRoot": "0xb3ac2973542b10ea21f11897a5cf406338c518d8d4ee0058a017453bec359aee"}

example testcase

{
  "00000728-mixed-3": {
    "env": {
      "currentCoinbase": "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "currentDifficulty": "0x200000",
      "currentRandom": "0x0000000000000000000000000000000000000000000000000000000000200000",
      "currentGasLimit": "0x26e1f476fe1e22",
      "currentNumber": "0x1",
      "currentTimestamp": "0x3e8",
      "previousHash": "0x044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d",
      "currentBaseFee": "0x10"
    },
    "pre": {
      "0x00000000000000000000000000000000000000f1": {
        "code": "0x60b460b2604560a660386051602c3d4048",
        "storage": {},
        "balance": "0x0",
        "nonce": "0x0"
      },
      "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
        "code": "0x",
        "storage": {},
        "balance": "0xffffffffff",
        "nonce": "0x0"
      }
    },
    "transaction": {
      "gasPrice": "0x10",
      "nonce": "0x0",
      "to": "0x00000000000000000000000000000000000000f1",
      "data": [
        "0x353d692500df388342c86d03f1102c56c21a36b66d66b38cf03f934b9a91c4404de032605718b92af0436d4fd3525a894bef0053b45d7dce59182d95def1bb19449055c798f8edcd8e7a8c669c24c2822c"
      ],
      "gasLimit": [
        "0x572b"
      ],
      "value": [
        "0x5e"
      ],
      "sender": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
    },
    "out": "0x",
    "post": {
      "Cancun": [
        {
          "hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "logs": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "indexes": {
            "data": 0,
            "gas": 0,
            "value": 0
          }
        }
      ]
    }
  }
}

cc @rakita

@holiman
Copy link
Owner Author

holiman commented May 20, 2024

user@debian-work:~/workspace/revm$ git bisect good
7046d5e30e08e913ea160de32a5a338868b62e40 is the first bad commit
commit 7046d5e30e08e913ea160de32a5a338868b62e40
Author: rakita <[email protected]>
Date:   Thu May 16 18:35:14 2024 +0300

    fix: blockchash for devnet-0  (#1427)
    
    * fix: load blockchash only from serve_window
    
    * fix: devnet-0 blockchash behaviour

 crates/interpreter/src/instructions/host.rs | 36 ++++-------------------
 crates/revm/src/context.rs                  | 44 +++++++++++++++++++++++++----
 2 files changed, 44 insertions(+), 36 deletions(-)

bluealloy/revm@7046d5e

@holiman
Copy link
Owner Author

holiman commented May 24, 2024

Ping @rakita ?

@holiman
Copy link
Owner Author

holiman commented May 27, 2024

Can confirm, fixed

@holiman holiman closed this as completed May 27, 2024
@holiman
Copy link
Owner Author

holiman commented May 27, 2024

However, another slight regression popped up:

root@abb464f81b77:/# /revme statetest --json /fuzztmp/00000728-mixed-3.json 1>/dev/null
{"pc":0,"op":96,"gas":"0x2b","gasCost":"0x3","stack":[],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
...
{"pc":16,"op":72,"gas":"0x0","gasCost":"0x0","stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51","0x2c","0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"BASEFEE","error":"OutOfGas"}
{"stateRoot":"0xb3ac2973542b10ea21f11897a5cf406338c518d8d4ee0058a017453bec359aee","logsRoot":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","output":"0x","gasUsed":22315,"pass":false,"errorMsg":"logs root mismatch: got 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, expected 0x0000000000000000000000000000000000000000000000000000000000000000","evmResult":"Halt: OutOfGas(Basic)","postLogsHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","fork":"CANCUN","test":"00000728-mixed-3","d":0,"g":0,"v":0}
Error: Statetest(TestError { name: "00000728-mixed-3", kind: LogsRootMismatch { got: 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, expected: 0x0000000000000000000000000000000000000000000000000000000000000000 } })

It spits out a line of non-jsonl.
Not a biggie, the fuzzer will just ignore it, but just so you know, @rakita

@rakita
Copy link

rakita commented May 27, 2024

However, another slight regression popped up:

root@abb464f81b77:/# /revme statetest --json /fuzztmp/00000728-mixed-3.json 1>/dev/null
{"pc":0,"op":96,"gas":"0x2b","gasCost":"0x3","stack":[],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"PUSH1"}
...
{"pc":16,"op":72,"gas":"0x0","gasCost":"0x0","stack":["0xb4","0xb2","0x45","0xa6","0x38","0x51","0x2c","0x44852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"],"depth":1,"returnData":"0x","refund":"0x0","memSize":"0","opName":"BASEFEE","error":"OutOfGas"}
{"stateRoot":"0xb3ac2973542b10ea21f11897a5cf406338c518d8d4ee0058a017453bec359aee","logsRoot":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","output":"0x","gasUsed":22315,"pass":false,"errorMsg":"logs root mismatch: got 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, expected 0x0000000000000000000000000000000000000000000000000000000000000000","evmResult":"Halt: OutOfGas(Basic)","postLogsHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","fork":"CANCUN","test":"00000728-mixed-3","d":0,"g":0,"v":0}
Error: Statetest(TestError { name: "00000728-mixed-3", kind: LogsRootMismatch { got: 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, expected: 0x0000000000000000000000000000000000000000000000000000000000000000 } })

It spits out a line of non-jsonl. Not a biggie, the fuzzer will just ignore it, but just so you know, @rakita

This is done by rust and if i dont have main() -> Result<> to return error on bash, it will not fail in CI. Either way thanks for report!

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

2 participants