Skip to content

statetest: tx chainId parsed as uint8 (rejects chainId > 255) #1489

@chfast

Description

@chfast

Summary

evmone-statetest rejects valid state tests when transaction chainId > 0xff because loader parses chainId as uint8_t.

go-ethereum evm statetest accepts and executes the same test.

This parsing path is shared with blockchain-test transaction loading, so blockchaintest fixtures with high chainId txs are likely affected as well.

Reproducer (state test, Cancun)

chainid300_state_test.json

{
  "statetest_chainid_300": {
    "_info": { "comment": "State test transaction chainId=300" },
    "env": {
      "currentCoinbase": "0x8888f1f195afa192cfee860698584c030f4c9db1",
      "currentNumber": "0x01",
      "currentTimestamp": "0x54c99069",
      "currentGasLimit": "0x2fefd8",
      "currentDifficulty": "0x0",
      "currentRandom": "0x0000000000000000000000000000000000000000000000000000000000000001",
      "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "currentBaseFee": "0x1",
      "currentExcessBlobGas": "0x0",
      "withdrawals": []
    },
    "pre": {
      "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
        "code": "0x",
        "nonce": "0x00",
        "balance": "0xde0b6b3a7640000",
        "storage": {}
      }
    },
    "transaction": {
      "data": ["0x"],
      "gasLimit": ["0x5208"],
      "value": ["0x0"],
      "to": "0x095e7baea6a6c7c4c2dfeb977efac326af552d87",
      "nonce": "0x0",
      "chainId": "0x12c",
      "gasPrice": "0x1",
      "sender": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
    },
    "post": {
      "Cancun": [
        {
          "indexes": { "data": 0, "gas": 0, "value": 0 },
          "hash": "0x5a605f957d4aa4145411d63287ddf1bae2202c30cc6ec86ae003423bb6343778",
          "logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
        }
      ]
    }
  }
}

Commands

# evmone
evmone-statetest chainid300_state_test.json

# geth
evm statetest --statetest.fork Cancun chainid300_state_test.json

Observed divergence

  • evmone exits early:
    • from_json<uint8_t>: value > 0xFF
  • geth:
    • test passes ("pass": true)

Suspected root cause

chainId is narrowed to uint8 in common tx loader:

  • test/utils/statetest_loader.cpp
    • o.chain_id = from_json<uint8_t>(*chain_id_it);

state::Transaction::chain_id is uint64_t, so this narrowing is unintended/inconsistent.

Impact scope

  • Confirmed: evmone-statetest
  • Likely: evmone-blockchaintest transaction parsing path (uses same from_json<Transaction> common loader)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions