holiman / goevmlab

Evm laboratory
GNU Lesser General Public License v3.0
225 stars 42 forks source link

EVMOne minor incompatibility #127

Closed namiloh closed 3 months ago

namiloh commented 3 months ago
root@a72fba356d78:/# /evmone --trace /fuzztmp/00161676-mixed-1.json.min 
Note: Google Test filter = -stCreateTest.CreateOOGafterMaxCodesize:stQuadraticComplexityTest.Call50000_sha256:stTimeConsuming.static_Call50000_sha256:stTimeConsuming.CALLBlake2f_MaxRounds:VMTests/vmPerformance.*:
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from /fuzztmp
[ RUN      ] /fuzztmp.00161676-mixed-1.json
unknown file: Failure
C++ exception with description "unexpected code with EOF prefix at 0x00000000000000000000000000000000000000f4" thrown in the test body.

[  FAILED  ] /fuzztmp.00161676-mixed-1.json (0 ms)
[----------] 1 test from /fuzztmp (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] /fuzztmp.00161676-mixed-1.json

testcase

{
  "00161676-mixed-1": {
    "env": {
      "currentCoinbase": "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "currentDifficulty": "0x200000",
      "currentRandom": "0x0000000000000000000000000000000000000000000000000000000000020000",
      "currentGasLimit": "0x26e1f476fe1e22",
      "currentNumber": "0x1",
      "currentTimestamp": "0x3e8",
      "previousHash": "0x044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d",
      "currentBaseFee": "0x10"
    },
    "pre": {
      "0x00000000000000000000000000000000000000f4": {
        "code": "0xef00",
        "storage": {},
        "balance": "0x0",
        "nonce": "0x0"
      }
    },
    "transaction": {
      "gasPrice": "0x10",
      "nonce": "0x0",
      "to": "0x00000000000000000000000000000000000000f1",
      "data": [
        "0x38"
      ],
      "gasLimit": [
        "0x0"
      ],
      "value": [
        "0x"
      ],
      "sender": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
    },
    "out": "0x",
    "post": {
      "Cancun": [
        {
          "hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "logs": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "indexes": {
            "data": 0,
            "gas": 0,
            "value": 0
          }
        }
      ]
    }
  }
}

Geth accepts the state, and spits out a stateroot.

 /gethvm --json --noreturndata --nomemory statetest /fuzztmp/00161676-mixed-1.json.min
{"stateRoot": "0x53f6733a696cb3bbf77b635d96ace97f25ffee2d08d3e3d4ae1e566bfc060d6f"}
[
  {
    "name": "00161676-mixed-1",
    "pass": false,
    "stateRoot": "0x53f6733a696cb3bbf77b635d96ace97f25ffee2d08d3e3d4ae1e566bfc060d6f",
    "fork": "Cancun",
    "error": "unexpected error: intrinsic gas too low: have 0, want 21016"
  }
]
holiman commented 3 months ago

@chfast is it intentional/to be expected behaviour that evmone rejects state with eof-code in it?

chfast commented 3 months ago

Yes, this is a test sanity check: there should be no deployed code with EOF prefix.

holiman commented 3 months ago

Ok, added as expected failure, also added a workaround in https://github.com/holiman/goevmlab/pull/128 to prevent it from happening during fuzzing: https://github.com/holiman/goevmlab/pull/128/commits/dec3cf9d294aac71171954a14d6d2143e3886a04