This repository was archived by the owner on Nov 11, 2026. It is now read-only.
Repository navigation
Conversation
…oy-rs#842) ## Summary Count the state gas a system call pays from its EIP-8037 reservoir in `total_gas_spent`. The reservoir is funded on top of `gas_limit`, but `total_gas_spent` was `gas_limit - remaining`, so it could be smaller than `state_gas_spent` and `execution_gas_spent()` saturated to zero. Fixes alloy-rs#841. ## Changes - `Evm::execute_system_call`: add the consumed reservoir (`reservoir - result.gas.reservoir()`) to `total_gas_spent`. - Test `system_call_total_includes_reservoir_funded_state_gas`: a system call that writes one new slot on Amsterdam reports `state_gas_spent` = `SstoreSetState`, `total_gas_spent` = regular + state gas, and `execution_gas_spent()` = regular gas. Without the fix it reports `total_gas_spent` 12,105 instead of 110,025. ## Validation - `cargo test -p evm2 --lib`: 717 passed. - `cargo fmt --all --check` and `cargo clippy -p evm2 --all-targets --all-features`: clean. - Workspace-wide `cargo cl` / `cargo docs` need LLVM for the JIT crate and were not run locally.
…#744) The step cost the tracing inspector records for a call or create step was the gas consumed over the whole opcode, measured after the child returned its unused gas. evm2 runs the child inside the opcode, so a CALL that forwards 65535 gas and gets all of it back reported 2600, where geth logs 68135, and struct logs and Parity `vmTrace` both read that value. This PR copies geth's model: the interpreter hands the inspector the cost the step charged, and the inspector records it. Geth captures the gas at the top of each step, charges the constant gas, meters the dynamic gas, and passes the resulting cost to the tracer before it runs the opcode. The CALL family's dynamic gas function adds the forwarded gas but not the stipend, so a call's cost includes the gas it forwards. CREATE and CREATE2 take their 63/64 share while the opcode executes, so their cost does not include it. In evm2, `Inspector::step` is geth's capture point, the interpreter's static and dynamic gas charges are the same charges, and the child call runs between `step` and `step_end`. The interpreter now keeps the gas at the start of an inspected step, and a call or create marks the point where it finished charging: right after it spends the forwarded gas in a call, before the stipend is added, and in a create after it spends the creation cost and the EIP-8037 account creation state gas, which spills into regular gas when the reservoir is short, before the child gas split. `Interpreter::step_cost()` returns the gas at the start of the step minus the gas at that mark, or minus the gas at the end of the step for any other opcode. `TracingInspector` stores it as `gas_cost`, and struct logs and `vmTrace` report the same value. The Parity `ex.used` of a call or create step reports the gas after the child returns. A call cost no longer shows that gas, so the inspector records the gas balance after a call or a gas credit whenever steps are enabled, and only the memory and storage deltas depend on `record_step_deltas`. Out-of-gas steps still report the gas delta as on main, and `step_cost()` can take failing charges in a follow-up. The costs below change on a Prague fixture. The main column is the gas consumed over the opcode, the reth column is the previous reth tracer on a parent with 1M gas, and the geth column is what this PR reports and what geth 1.17.10 `evm run --trace` logs for the same code. | Step | main | previous reth tracer | geth and this PR | | --- | --- | --- | --- | | CALL, CALLCODE, DELEGATECALL or STATICCALL, child returns | 2600 | 68135 | 68135 | | CALL, child spends 4 gas | 2604 | 68135 | 68135 | | cold CALL forwarding 1024 gas | 2600 | not measured | 3624 | | CALL to precompile 0x04 forwarding 65535 | 115 | 65635 | 65635 | | value CALL that cannot be funded, target has code | 9300 | 12600 | 12600 | | value CALL that cannot be funded, empty target | 34300 | 37600 | 37600 | | CREATE, empty initcode | 32000 | 984870 | 32000 | | CREATE2, empty initcode | 32000 | 984868 | 32000 | | CREATE, initcode that spends 8 gas | 32010 | 984857 | 32002 | | CREATE that cannot be funded | 32000 | 984869 | 32000 | CREATE and CREATE2 costs that include memory expansion, initcode words or keccak words (32023 and 32008 in the tests) are unchanged from main. Only the gas a CREATE's initcode spends leaves its cost. The interpreter stores the mark unconditionally when a call or create finishes charging, with no inspector check. Counting instructions with callgrind over the `usdc_proxy` and `universal_router` benchmark suites, `prepare_call` costs 41k instructions more than on main in both, and the whole run changes by +0.0014% and +0.013%. Two identical runs of one binary differ by about 70k instructions. Found while comparing paradigmxyz/reth#25002 against main. # PR stack Review in order: 1. alloy-rs#744 — forwarded CALL/CREATE trace gas — this PR 2. alloy-rs#746 — underfunded creation nonce 3. alloy-rs#747 — empty-code inspection 4. alloy-rs#748 — normal REVERT struct logs 5. alloy-rs#750 — uncharged gas in opcode totals --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
…s#848) The JIT runtime built its compilers with the default `BackendConfig`, which enables `debug_support` and `simple_perf`. Both apply once per process to the global LLJIT. `debug_support` keeps a full copy of every linked object in memory for debugger registration until the code is freed, and `simple_perf` appends every JIT symbol to `/tmp/perf-<pid>.map` forever, which its own docs call unsuitable for long-running programs. The worker compilers in `create_compiler` and the backend-thread `JitObjectLinker` now turn both off. `BackendConfig::default()` is unchanged, so the CLI and the benches keep the perf map for profiling. Generated code does not change. Measured by linking 1000 distinct small programs through `JitObjectLinker` and reading `VmRSS` before and after (three runs each): | | RSS per resident program | | --- | --- | | before | 22.5 KiB 🔴 | | after | 17.9 KiB 🟢 | The programs are tiny (about 217 bytes of JIT memory each), so larger contracts save more; the debug copy scales with object size.
…eads (alloy-rs#844) A slot of an account created in the transaction reads zero without a database read, since the creation discards the address's old storage. That shortcut also skipped the strict BAL coverage check that `CacheDB::get_storage` performs, so a BAL that covered the account but omitted the slot was accepted for `SLOAD` and `storage_slot_untracked`, although rebuilding the BAL records the slot. Both reads now run the same coverage check before returning zero; the zero value itself is unchanged. The regression test attaches a BAL that covers a created account with one slot and expects a `BalError` for an uncovered slot on both read paths, while the covered slot still reads zero. It fails without the fix. Found by the Cyclops audit of alloy-rs#562 (rakita), which flagged this path in main's existing created-account read.
…lloy-rs#845) A slot first loaded while its account is created in the transaction caches zero without a database read. Rolling the creation back restored the account flags but left that zero in the overlay, so later reads in the transaction returned zero instead of the backing value, and the slot reported zero as its original. This is reachable when a creation targets an existing account with nonce zero, empty code and nonzero storage and the constructor reads such a slot before reverting. When a rollback ends an account's storage discard, `State::rollback` now rereads the overlay slots that still hold zero from the database, after every journal entry of the rolled-back scope is reverted. Slots keep their entries, so their reads and warmth stay visible to the BAL; a slot whose read fails is evicted so its next load reports the error. This departs from the earlier behavior of keeping the cached zero. A slot already loaded before a retried creation keeps its value, as slots loaded before a creation already did. `created_account_reads_old_storage_as_zero` asserted the stale zero after the rollback, so it now expects the backing value, and the new `rollback_of_creation_reloads_slots_read_as_zero` and `rollback_reloads_slots_written_through_the_creating_handle` fail without the fix. Found by the Cyclops audit of alloy-rs#562 (rakita), which flagged this in main's existing created-account read path.
… BALANCE_CHECK (alloy-rs#746) Pins how a top-level value transfer that the sender cannot fund behaves on each side of `BALANCE_CHECK`, end to end through `transact`. The change is test-only; no behavior changes. With `BALANCE_CHECK` on, `validate_sender_and_bump_nonce` already rejects a transaction whose balance is below `max_upfront`, and every transaction type passes the gas cost plus the value (plus blob gas for EIP-4844) as `max_upfront`. This matches go-ethereum's pre-check together with its top-call affordability check (`core/state_transition.go:765-773` at `a0cba163b1f17f6044df84502ff13036dffb5de1`): an underfunded call or create is rejected with `InsufficientFunds`, the nonce is unchanged and no state changes. With `BALANCE_CHECK` and `BALANCE_TOP_UP` off, as in `eth_call`-style simulation and custom fee systems, the transaction still executes. The transfer halts with `OutOfFunds` and the sender nonce is consumed, so the same signed transaction cannot be replayed. Embedders depend on this opt-out, so it stays as it is. The new matrix test covers create and call, values 0, 1 and 2 against a balance of 1, legacy, EIP-2930 and EIP-1559 transactions, Prague and Amsterdam, and fee charging on and off. Found while comparing paradigmxyz/reth#25002 against main with trace-interop. Checked against go-ethereum master `a0cba163` with the geth parity harness from alloy-rs#859, run in a scratch copy because alloy-rs#859 is not on main yet. The case sends a create and a call whose value (2) exceeds what the sender has left after paying for gas (balance covers gas plus 1), followed by a create with value 1. Geth rejects the first two with `insufficient funds for gas * price + value` and runs the third; evm2 rejects and runs the same transactions, with the same receipts, state root and post state on Cancun, Prague, Osaka and Amsterdam. The case moves into `crates/cli/testdata/geth-parity/cases/` once alloy-rs#859 is on main. ``` $ scripts/geth_parity.py tx_rejected_underfunded_value 4 case/fork pairs, 8 comparisons: 0 differences (0 known, 0 new), 0 errors, 0 stale known entries, 0 skipped because both tools reject the input ``` --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
The transaction environment was a handler-local value that every frame borrowed, so nothing outside the handler could change it once a transaction started. This moves it into `Evm` next to the block environment. Handlers and system calls write it before the initial frame, the interpreter and compiled code read it through `Host::tx_env`, and `Evm::tx_env_mut` lets an inspector change it during execution, the same way `Evm::set_block` already works for the block environment. Validation, fees, and nonces never read it, so a change affects only what the running code observes. This replaces the use case of alloy-rs#838. Instead of a dedicated origin override, Foundry sets the origin of a nested transaction from its top-level call or create hook: ```rust interp.host().tx_env_mut().origin = outer_origin; ``` The same call overrides every other field that opcodes read: the gas price (`GASPRICE`), the chain ID (`CHAINID`), the blob hashes (`BLOBHASH`), and the type-specific `ext`, such as a fee token. Cheatcodes that change these mid-transaction no longer need a step hook. `Host::execute_message` and `Interpreter::new` no longer take a transaction environment, and `Host` gains `tx_env`. Network handlers built on evm2 write `*host.tx_env_mut()` where they used to build a local environment.
…s#869) fix(jit): bump ABI_VERSION for the Interpreter layout change
) Switches the default EEST fixtures from the glamsterdam devnet-8 release (`tests-glamsterdam-devnet@v8.1.4`) to the mainline execution-specs release `tests@v21.0.1`, the first mainline release that includes Amsterdam. It is the fixture version go-ethereum master pins. The setup script now extracts it to `test-fixtures/eest` and leaves out the engine, sync and transaction test formats, which the runner does not execute. `EEST_VERSION`, `EEST_TAR` and `EEST_BASE_URL` replace the `DEVNET_*` overrides, and `EVM2_STATETEST_EEST_ONLY` replaces `EVM2_STATETEST_DEVNET_ONLY`. The unused `devnet` branches of the CI fixture step are removed. Of 23368 tests in the new roots, 18 fail. They are skipped here, each with a comment, so the suite stays green: | Skipped fixtures | Cause | | --- | --- | | `frontier/validation/transaction/unrecoverable_signature.json` (15 forks) | The state-test runner takes the sender from the fixture and recovers no signatures, like the already skipped `bad_v_r_s.json`. | | `eip8037…/block_2d_gas_accounting/tx_total_gas_limit_cap.json` | The Amsterdam total gas cap of 2^32-1 is not enforced yet. The PR that enforces it deletes the entry. | | `eip8037…/state_gas_system_calls/system_call_execution_boundary.json`, `eip7928…/block_access_lists_cross_index/bal_pre_execution_call_failure_keeps_read_drops_write.json` | The runner treats a failed EIP-4788 call as an invalid block; the spec runs it unchecked. A follow-up fixes the runner. | With the skips, the interpreter run over the new roots plus the legacy suites passes 28468 tests. The larger corpus also compiles more distinct programs in the JIT run than a default `vm.max_map_count` allows, so the last compilations failed and fell back to the interpreter. The compiled runs now cap resident programs with an 8 MiB code budget, which keeps about 7000 resident.
geth's `keccak256PreimageTracer` returns a JSON object that maps the hash of every KECCAK256 operation of a transaction to its preimage (`eth/tracers/native/keccak256_preimage.go`). evm2 did not know the tracer: `debug_traceTransaction` with it, standalone or inside a `muxTracer`, treated the name as JavaScript and failed with `ReferenceError: keccak256PreimageTracer is not defined`. `Keccak256PreimageInspector` records the preimage on each KECCAK256 step with geth's operand rules: offset and size are truncated to 64 bits, a range that reaches past memory is zero padded, and a range that reaches more than 1 MiB past the end of memory is skipped. `alloy-rpc-types-trace` has no built-in variant for the tracer, so the name arrives as `GethDebugTracerType::JsTracer`. Like geth's tracer directory, `DebugInspector` and `MuxInspector` look the name up before they evaluate the string as JavaScript, and the result is a `GethTrace::JS` object. geth ignores the tracer config, and so does this. Like geth, it records a KECCAK256 that then fails, and `MEMORY_PAD_LIMIT` (1 MiB, geth's `memoryPadLimit`) bounds the zero padding per operation: a preimage that needs more padding is skipped, as geth does. geth also retains every preimage without a limit, which a transaction can use to make the tracer hold gigabytes; the inspector counts the retained bytes against `TraceLimits`, 64 MiB by default (`DEFAULT_MAX_RECORDED_BYTES`), and stops recording once the limit is reached. The output therefore differs from geth only after 64 MiB of retained preimages. `limit_exceeded()` reports it, and `json_result()` then fails with `LimitExceeded` instead of returning a truncated map: `DebugInspector` and `MuxInspector` return it as an error, and `MuxInspector::try_into_mux_frame` now returns the mux `Error`, which has a database variant. Checked against go-ethereum master `a0cba163` with the parity harness of the `dani/geth-parity-harness` branch (a new case with an in-memory, an empty, a padded, a past-memory and an oversized range on Cancun, Prague, Osaka and Amsterdam, run standalone and in the mux config of the harness with the tracer added): | Output of `keccak256PreimageTracer` | geth master | origin/main | this PR | | --- | --- | --- | --- | | standalone, the new case on 4 forks | preimage map | 🔴 `ReferenceError: keccak256PreimageTracer is not defined` | 🟢 identical | | inside a mux, all 311 case and fork pairs of the harness | preimage map | 🔴 the mux rejects the tracer | 🟢 identical | The harness is not merged yet, so its case is not part of this PR; I will add it once it lands. Rust tests cover the zero padding, the skipped oversize range, the padding limit and the byte above it, the byte limit, and the mux key.
…y-rs#863) `AccessListInspector` read the target of CALL, CALLCODE, DELEGATECALL and STATICCALL from the second stack item whenever two items were present. go-ethereum's access list tracer (`eth/tracers/logger/access_list_tracer.go`) reads it only when the stack holds at least five items. Its hook also runs for an opcode that is about to fail, so a call that underflows with fewer than five items must add nothing, while one that underflows with five or more items still adds the address. evm2 added whatever sat in the second slot: the address for `73<addr>6000f1`, address zero for three zero pushes followed by an address and `CALL`. The inspector now reads the target only from five items. ## Parity run geth `a0cba163` (`geth --dev`, Osaka), `eth_createAccessList` with state overrides, call from `0x…1001`, 30 cases. The same inputs and geth's lists are in `crates/inspectors/tests/it/accesslist.rs` (`access_list_matches_geth`). Like geth, the test reruns the call with the list found so far, as both the transaction access list and the inspector seed, until the list stops changing. The cases cover the five-item rule for all four call opcodes (two to six items), the single-item opcodes (BALANCE, EXTCODE*, SELFDESTRUCT, SLOAD, SSTORE) with an empty or short stack, out-of-gas and static-context failures, DELEGATECALL and CALLCODE storage, reverted frames, a create transaction and a nested CREATE, a seeded request list with excluded entries, and exclusion of the sender, callee and precompiles. The other opcode branches already match geth: their guards (one item for the single-item opcodes) are the same, and the hook also fires for opcodes that fail on stack underflow or gas. | case | geth | evm2 main | this PR | | --- | --- | --- | --- | | `PUSH20 X; PUSH0; CALL` (2 items) | `[]` | `[X]` 🔴 | `[]` ✅ | | 3 pushes, `PUSH20 X`, `CALL` (4 items, second slot is zero) | `[]` | `[0x0]` 🔴 | `[]` ✅ | | STATICCALL with 4 items | `[]` | `[X]` 🔴 | `[]` ✅ | | CALLCODE with 4 items | `[]` | `[X]` 🔴 | `[]` ✅ | | CALL with 5 or 6 items, CALLCODE, STATICCALL and DELEGATECALL with 5 items (underflow) | `[X]` | `[X]` | `[X]` ✅ | | 21 other cases | | match | match ✅ | geth's raw output for the first case (`stateOverrides: {0x…c1: {code: 0x73…b0016000f1}}`, call `{from: 0x…1001, to: 0x…c1}`): ```json {"accessList":[],"error":"stack underflow (2 <=> 7)","gasUsed":"0x4c4b40"} ```
…-rs#861) A create with empty initcode, either a create transaction with empty data or `CREATE` and `CREATE2` with size 0, ran its frame anyway. The empty bytecode's padding `STOP` executed, so a step-recording inspector saw an extra `STOP` step at depth one more than the creator and an `initialize_interp` hook for a frame that has no code. go-ethereum's `Run` returns at once on empty code (`core/vm/interpreter.go:112-115`), so no step is logged, and the create still succeeds and deploys an empty contract. Calls to accounts without code already skip the interpreter the same way (`execute_call_message`), and this PR does the same for creates. `execute_create_message` now completes an empty-initcode create with a `Stop` result, the full gas and reservoir, and an empty output, then runs the usual `finish_create_message_run` (code size and deposit checks, nonce and account creation, commit). `finish_create_message_run` takes the gas and output as arguments instead of reading them from the interpreter pool, so both paths share it. Gas, state and logs do not change: the `STOP` cost nothing before and the result is the same. A new test asserts that a create transaction and a `CREATE` of size 0 record no steps and use no gas. One existing evm2 test used `CREATE(0, 0, 0)` to observe the create frame's checkpoint through `initialize_interp`; it now creates a one-byte `STOP` initcode so it still runs a frame. Parity harness (alloy-rs#859, geth master `a0cba163`), new case `create_empty_initcode` (an empty create transaction, then a call to a factory that runs `CREATE` and `CREATE2` with empty initcode, on Cancun, Prague, Osaka and Amsterdam). The differences that disappear, by tracer and field, with the same case run on main and on this branch: | tracer | field | before | after | | --- | --- | --- | --- | | `jsonl` | `steps[]`, `steps[].op`, `.opName`, `.pc`, `.depth`, `.gas`, `.stack[]` | 🔴 extra `STOP` step per empty create, every later step shifted | 🟢 equal | | `structlog` | `structLogs[]`, `.op`, `.pc`, `.depth`, `.gas`, `.stack[]`, `.storage` | 🔴 extra `STOP` entry | 🟢 equal | | `js-opcount` | `STOP` | 🔴 evm2 counts 1 and 5, geth none and 3 | 🟢 equal | The remaining differences of the case (`gasCost` of the `CREATE` step, EIP-8037 gas fields, prestate code hashes, `ctx.gasPrice`) are the existing known classes and not part of this change. The case is not committed here because the harness is not on main yet; I add it with the known-diffs entries for those classes once alloy-rs#859 lands. Benchmarks, `cargo bench -p evm2-cli --bench evm` interpreter shard, pinned to one core, median of three runs, main against this branch: | bench | main | this PR | ratio | | --- | --- | --- | --- | | weth | 1.974 µs | 1.959 µs | 0.992 | | erc20_transfer | 1307.6 µs | 1308.9 µs | 1.001 | | uniswap_v2_pair | 1.402 µs | 1.355 µs | 0.966 | | univ2_router | 1.376 µs | 1.379 µs | 1.003 | | seaport | 1.579 µs | 1.538 µs | 0.974 | | usdc_proxy | 1.500 µs | 1.528 µs | 1.019 | | universal_router | 30.051 µs | 29.948 µs | 0.997 | | uniswap_v3_pool | 9.255 µs | 9.161 µs | 0.990 | | snailtracer | 30262 µs | 29707 µs | 0.982 | | factorial | 28.605 µs | 28.648 µs | 1.002 | None of these benchmarks creates a contract, and the ratios stay within ±3.4% with no consistent sign, which is the run-to-run noise on this machine.
…from struct logs (alloy-rs#864) Struct logs now omit what geth's struct logger omits: a zero `refund`, an empty `memory` and an empty `returnData`. Before, a step with no refund printed `"refund":0`, a step before the first memory write printed `"memory":[]`, and a step with empty return data printed `"returnData":"0x"` when `enableReturnData` was set. geth's JSON struct omits each of them when empty (`eth/tracers/logger/logger.go`, `structLogLegacy`), and I confirmed on a `geth --dev` node at master a0cba163 that `debug_traceCall` with `enableMemory` and `enableReturnData` prints neither field on steps where they are empty. `storage` has no change here: geth always records the slot of an `SLOAD` or `SSTORE` in the snapshot, so it is never empty, and its snapshot rules are a separate change. The parity harness normalises these fields away on both sides (`OMIT_EMPTY` in `scripts/geth_parity.py`), so it could not show the difference. I ran it offline on alloy-rs#859 plus this branch with `OMIT_EMPTY` reduced to `storage`, with an empty known-diffs file and only the `structlog` tracer. Lines about `refund`, `memory` and `returnData` fall from 15940 to 177. What remains is the refund timing (geth logs the refund after the gas function of `SSTORE`, so evm2 lags one step; that belongs to the refund change) and the `stateGasReservoir`, `stateGasCost`, `executionGasUsed` and `gasRefund` fields that evm2 prints and geth master does not. No `memory` or `returnData` difference remains. Once alloy-rs#859 is on main, this PR drops `memory`, `returnData` and `refund` from `OMIT_EMPTY` in the script and removes their known-diff entries.
`TransferInspector::with_logs` now behaves like go-ethereum's `eth_simulateV1` tracer (`internal/ethapi/logtracer.go`). The inspector keeps one log list per open call or create frame, adds the logs the EVM emits (through the `log` hook) and the `0xeee…eee` transfer logs, drops a frame's list when the frame fails, and merges it into its parent otherwise. The result is read with `logs()` / `take_logs()`. Nothing is written to the EVM's own logs any more. Differences from go-ethereum found by running both on the same inputs, and fixed here: - **Receipts.** evm2 inserted the transfer logs into the EVM's log list, so the transaction result, receipt and logs bloom contained logs that geth's receipts do not (every simulated block's `logsBloom` is empty when only transfers happen). They now stay in the inspector. - **SELFDESTRUCT.** geth's `OnEnter` for SELFDESTRUCT carries the contract's balance, so a non-zero balance yields a transfer log (also when the beneficiary is the contract itself). evm2 never emitted one, and kept zero-balance selfdestructs in `transfers()`; both now follow the `value > 0` rule. - **CALLCODE.** geth skips CALLCODE (and DELEGATECALL) in `OnEnter`. evm2 recorded a `X → X` transfer for every CALLCODE with value. Merged alloy-rs#531 (dropping transfers of failed frames) matches geth: the cleared-frame cases below (reverted and invalid children, failed and nonce-overflowing creates, insufficient balance, reverted top level, oversized code) give the same result on main and on this branch. ## Parity run geth `a0cba163` (`geth --dev`, Osaka), `eth_simulateV1` with `traceTransfers: true`, `validation: false`, state overrides for the accounts, call from `0x…1001` (balance 1e18). 23 cases; the same inputs and geth's logs are in `crates/inspectors/tests/it/transfer.rs` (`simulate_transfer_logs_match_geth`), which runs them through evm2 on Osaka and also checks that `transfers()` equals the transfer logs and that the receipt logs hold only the emitted logs. `T(a→b, v)` is a log from `0xeee…eee` with topics `Transfer, a, b` and data `v`. | case | geth | evm2 main | this PR | | --- | --- | --- | --- | | CALLCODE with value 3 to `0xa003` | none | `T(c2→c2, 3)` 🔴 | none ✅ | | contract with balance 7 selfdestructs to `0xa002` | `T(c6→a002, 7)` | none 🔴 | `T(c6→a002, 7)` ✅ | | same, tx value 5 | `T(1001→c6, 5)`, `T(c6→a002, 12)` | `T(1001→c6, 5)` 🔴 | same as geth ✅ | | selfdestruct to self, balance 4 | `T(c8→c8, 4)` | none 🔴 | `T(c8→c8, 4)` ✅ | | CALLCODE (value 1) into code that selfdestructs, balance 50 | `T(d4→a002, 50)` | `T(d4→d4, 1)` 🔴 | `T(d4→a002, 50)` ✅ | | 18 other cases (tx value, zero value, zero-balance selfdestruct, interleaved emitted logs, reverted/invalid/oversized frames, CREATE/CREATE2, precompile, EOA, STATICCALL, DELEGATECALL, nonce overflow, insufficient balance) | | match | match ✅ | On main the selfdestruct-in-reverted-frame case only matched because selfdestructs were never logged; it now exercises the clearing. geth's raw output for the tx-value selfdestruct case (`selfdestruct_tx_value`), the evm2 logs after this PR are identical except for `logIndex`, which evm2 does not number: ```json [{"address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000001001","0x00000000000000000000000000000000000000000000000000000000000000c6"],"data":"0x0000000000000000000000000000000000000000000000000000000000000005","logIndex":"0x0"}, {"address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x00000000000000000000000000000000000000000000000000000000000000c6","0x000000000000000000000000000000000000000000000000000000000000a002"],"data":"0x000000000000000000000000000000000000000000000000000000000000000c","logIndex":"0x1"}] ``` Input: `stateOverrides: {0x…c6: {code: 0x73…a002ff, balance: 0x7}}`, call `{from: 0x…1001, to: 0x…c6, value: 0x5}`. Once EIP-7708 is active the EVM emits the transfer logs itself, so the inspector then collects only those and synthesizes none, as geth's `eth_simulateV1` turns its transfer tracing off at Amsterdam for the same reason. The EIP-7708 case is covered by `simulate_transfer_logs_use_eip7708_logs`; geth's dev chain does not run Amsterdam, so that case follows geth's source rather than a node run.
The JS tracer's constructor and `ctx` object differed from geth's goja
tracer. This makes them match: `setup()` receives the config as a JSON
string (`{}` when there is none), a tracer that exposes only one of
`enter()` and `exit()` is rejected with geth's message, and a
non-callable `setup` is ignored. `ctx.gasPrice` is the effective tip
(`min(tip, maxFee - baseFee)`) as a bigint instead of the effective gas
price as a number. `ctx.intrinsicGas` and `ctx.time` do not exist in
geth, so they are removed. `ctx.txIndex` and `ctx.txHash` are set only
for a non-zero block hash and a non-zero transaction hash, as in geth's
constructor. `isPrecompiled` exists from construction and returns false
until the transaction starts, instead of being registered on the first
call hook with the error discarded.
I ran each tracer through geth master (`a0cba163`, evm 1.17.11-unstable)
`evm t8n --trace.tracer` (Cancun, one EIP-1559 tx with maxFee 10 gwei,
tip 1 gwei, base fee 5 gwei, calling a contract with code `00`) and
through this branch and `origin/main` on the same transaction. The
`--trace.jsonconfig` column is the config passed to the tracer.
| Tracer | geth master | `origin/main` | this PR |
| --- | --- | --- | --- |
| `setup(c){this.t=typeof c+":"+c}`, config `{"a":1}` |
`"string:{\"a\":1}"` | 🔴 `"object:[object Object]"` | 🟢
`"string:{\"a\":1}"` |
| same, no config | `"string:{}"` | 🔴 `"object:null"` | 🟢 `"string:{}"`
|
| `{enter(){},fault(){},result(){}}` | `trace object must expose either
both or none of enter() and exit()` | 🔴 constructs | 🟢 same error |
| `[c.intrinsicGas, c.time, c.gasPrice.toString()]` |
`[null,null,"1000000000"]` | 🔴 `[0,"1","6000000000"]` | 🟢
`[null,null,"1000000000"]` |
| `Object.keys(ctx)` | `type, from, to, input, gas, gasUsed, gasPrice,
value, block, coinbase, output` | 🔴 also `intrinsicGas`, `time` | 🟢 same
set |
| `isPrecompiled("0x01")` in `setup`, then in `step` | `[false,true]` |
🔴 `["ReferenceError: isPrecompiled is not defined",true]` | 🟢
`[false,true]` |
`t8n` passes no tracer context, so the `blockHash`/`txIndex`/`txHash`
rules from `eth/tracers/js/goja.go` (L168-181 at `a0cba163`) are covered
by a unit test rather than by a geth run.
EIP-8037 caps the total transaction gas limit, including the state-gas reservoir, at 2^32-1 under Amsterdam (execution-specs `TX_MAX_TOTAL_GAS_LIMIT`, checked in `validate_transaction`). evm2 left `tx.gas` uncapped when EIP-8037 is active and only bounded the required execution gas by 2^24. `Version::tx_gas_caps` now returns 2^32-1 as the `tx.gas` bound under EIP-8037, so the transaction handlers (`validate_tx_gas_limit_cap`) and stateless callers such as a transaction pool reject larger gas limits with `TxGasLimitGreaterThanCap`. The 2^24 bound on `max(intrinsic, floor)` and the execution/reservoir split are unchanged. Block-level gas accounting uses `u64` and already holds twice the cap. The `tx_total_gas_limit_cap` state fixture in `tests@v21.0.1` fails without this change (the above-cap transactions are accepted) and passes with it, so the EEST runner no longer ignores it.
alloy-rs#865) The default tracer now builds the struct log `storage` snapshot the way geth's struct logger does. Before, it inferred the slot and value from the last journal entry of the step. A warm `SLOAD` (the slot is in the access list, or an earlier opcode touched it) adds no journal entry and got no snapshot, an `SSTORE` that writes the unchanged value got none either, and a step that fails before it runs, such as an `SSTORE` that runs out of gas, still printed a snapshot because the journal had already recorded the slot. Now the inspector records the key and value of every `SLOAD` and `SSTORE` on the step: the key and written value come from the stack before the opcode runs, and the value an `SLOAD` read comes from the state when the opcode ends (it does not change the slot). The builder adds that slot to one map per contract for the whole transaction, without undoing it on a revert, and snapshots the map at each such step, except at a step that fails before it runs. This is what `OnOpcode` does in `eth/tracers/logger/logger.go` at master a0cba163. On the parity harness (offline, alloy-rs#859 plus this branch, `structlog` tracer only, empty known-diffs file), `structLogs[].storage` differences fall from 17 lines in 5 cases (`call_revert_gas_accounting`, `eip7702_delegation`, `oog_cold_sstore`, `static_call_violation`, `tx_access_list`, across forks) to none. For example, before the change `oog_cold_sstore` printed a snapshot on the failed `SSTORE` that geth omits, and `tx_access_list` printed no snapshot for a warm `SLOAD`. The regression test `struct_log_storage_snapshots_match_geth` covers a cold `SLOAD`, a warm `SLOAD`, an `SSTORE` of the unchanged value, an `SSTORE` of a new value, and a failing `SSTORE`. Once alloy-rs#859 is on main, this PR removes the `storage` entry from `OMIT_EMPTY` in `scripts/geth_parity.py` and the matching known-diff entries.
Follow-up to alloy-rs#744. The geth reference is now go-ethereum master at `a0cba163b1f17f6044df84502ff13036dffb5de1` (`evm 1.17.11-unstable-a0cba163`, Amsterdam-capable) instead of 1.17.10. On master the interpreter passes each opcode's execution gas and state gas separately (`core/vm/interpreter.go`), and the struct logger records the execution gas only (`core/tracing/hooks.go`, `EmitOpcode`). State gas is never part of the reported cost: `gasCreateEip8037` leaves it out and `chargeAccountCreation` charges it inside `opCreate` after the tracer hook (`core/vm/evm.go`, `core/vm/instructions.go`), and `makeCallVariantGasCallEIP8037` charges the new-account state gas directly and leaves it out of `totalCost` (`core/vm/operations_acl.go`). `Interpreter::step_cost()` took the delta of the remaining gas, so on Amsterdam it also counted state gas drawn from regular gas when the reservoir was short, and missed state gas refilled into it. It now counts the remaining gas together with the spilled state gas (the new public `Gas::remaining_excluding_state_spill` and `GasTracker::remaining_excluding_state_spill`), at step start and at the charge mark, so spills and refills cancel for every opcode. The state gas still shows in the step's `state_gas_cost`. The CREATE and CALL marks keep their place; the state gas of both stays out of the cost because of this change, not because of where the mark sits. Every geth-derived value in `parity.rs` was rerun against the pinned build on Prague (unchanged from 1.17.10) and Amsterdam, and the call, call-family, precompile, unfunded and create cases now assert both forks in vmTrace and struct logs. A new `state_gas_cost` module covers SSTORE to a new slot, a restoring SSTORE, SELFDESTRUCT to a new account, value CALL to a new account and CREATE, each with an empty, a short (100,000 gas) and a full reservoir. The Cyclops finding on alloy-rs#744 "Parity vmTrace ex.used understates remaining gas after calls when step deltas are off" no longer holds on main: a new test builds the vmTrace from `default_geth()`, `parity_vm_trace()`, the same without step deltas and `all()`, and checks that a call or create step's `ex.used` equals the parent's gas after the child returns, for CALL, CREATE and CREATE2 on Prague and Amsterdam and for a nested call. It passes on main as well, so no code change was needed. Cyclops should recheck it. Step costs that change against main, all on Amsterdam with an empty reservoir (limit 1,000,000), against geth a0cba163: | Step | main | this PR | geth a0cba163 | | --- | --- | --- | --- | | SSTORE to a new slot | 110,020 🔴 | 12,100 | 12,100 | | restoring SSTORE (0→x→0) | 0 🔴 | 100 | 100 | | SELFDESTRUCT to a new account with balance | 200,600 🔴 | 17,000 | 17,000 | | CALL with value 1 to a new account, forwarding 0xffff | 263,435 🔴 | 79,835 | 79,835 | | CALL with value 1 to a new account without funds, forwarding 1000 | 198,900 🔴 | 15,300 | 15,300 | | CREATE / CREATE2 with empty initcode | 195,600 🔴 | 12,000 | 12,000 | With a 100,000 gas reservoir the main values drop by the part the reservoir covers (for example CREATE 95,600 → 12,000); with a reservoir above the charge nothing changes. Prague costs and the Amsterdam costs of calls that need no state gas (cold CALL forwarding 1024 = 4,024; CREATE with initcode `5f5f5f5f00` = 12,002) are the same as on main. The interpreter change is one add in the call and create charge mark and one add at the start of an inspected step. The `evm` criterion bench (interpreter shard, no inspector, one pinned core, median of six interleaved runs against main 34209d5) shows no change beyond run-to-run noise: | case | main | this PR | | --- | --- | --- | | push0_proxy | 1362 ns | 1381 ns | | usdc_proxy | 1502 ns | 1508 ns | | uniswap_v2_pair | 1374 ns | 1379 ns | | univ2_router | 1407 ns | 1401 ns | | seaport | 1556 ns | 1550 ns | alloy-rs#859 (`scripts/geth_parity.py`, geth a0cba163) is not on main yet, so I ran it in a scratch copy of this branch and of main, each with `origin/dani/geth-parity-harness` merged, over all 317 case and fork pairs and 4591 comparisons. Main reports 9774 differences, all known, 0 new, 212 stale known entries. This branch reports 9672 differences, all known, 0 new, 265 stale entries. The 53 additional stale entries are Amsterdam `steps[].gasCost` (jsonl) and `structLogs[].gasCost` (structlog) differences of call_basic, call_nested, call_new_account, call_stipend, callcode_basic, delegatecall_basic, staticcall_basic, create_code_rules, create_init_revert, create_selfdestruct_in_init, create_success, selfdestruct_existing, selfdestruct_new_account, selfdestruct_same_tx, sstore_sload_refund, tx_multi, tx_blob and the precompile cases; the PR that lands after alloy-rs#859 deletes them from `known-diffs.json`. No new difference appears.
…y-rs#850) A nested `CREATE` or `CREATE2` whose creator nonce is `u64::MAX` returned `InstrStop::Return` from the EVM as a stand-in, and `TracingInspector::create_end` rebuilt `NonceOverflow` from `depth > initial && created_address.is_none() && stop == Return`. Every other inspector (the JavaScript tracer, any custom `create_end`) saw a successful create with no error. go-ethereum fails the frame with `ErrNonceUintOverflow` from `createFramePreCheck` (`core/vm/evm.go:506-518`): `OnExit` fires with that error and `reverted = true`, no gas is used, the gas goes back to the parent, and the return data buffer is cleared. `NonceOverflow` is now a real stop and counts as a revert-class precheck failure beside `CallTooDeep` and `OutOfFunds`, so `merge_child_gas` still returns the whole forwarded gas and `CREATE` still clears return data. Gas, state and logs do not change. The inspector patch and the matching `NonceOverflow` special case in the call frame builder are gone. Since Amsterdam, `chargeAccountCreation` runs the same precheck in the parent frame (`core/vm/evm.go:530-538`) and fires no child frame; evm2 already does this in `create_inner` (depth, balance, nonce, then clear return data and push zero), and a new test pins it. With the parity harness of alloy-rs#859 (geth master `a0cba163`), the `create_nonce_overflow` case (two nested creates from a creator at nonce `u64::MAX`, run on Cancun, Prague, Osaka and Amsterdam) compares equal for the JavaScript tracer after this change. Before it, evm2 gave the two create frames no `error`, where geth reports `nonce uint64 overflow`, so alloy-rs#859 lists the case under the known `js-frames` `frames[].error` differences. With this change the script reports: ``` STALE known diff no longer occurs, delete it: create_nonce_overflow Cancun js-frames frames[].error STALE known diff no longer occurs, delete it: create_nonce_overflow Prague js-frames frames[].error STALE known diff no longer occurs, delete it: create_nonce_overflow Osaka js-frames frames[].error ``` The Amsterdam run has no difference either: the parent runs the precheck and opens no child frame in both. This PR removes the three entries once alloy-rs#859 is on main. The call, geth and parity trace outputs of `TracingInspector` do not change, because the old patch produced the same values. Other differences of that case (`gasPrice`, JSONL memory prefix, CREATE step `gasCost`) are unrelated and belong to other work. Benchmarks, `cargo bench -p evm2-cli --bench evm` interpreter shard, pinned to one core, median of three runs per commit, main against this branch: | bench | main | this PR | ratio | | --- | --- | --- | --- | | weth | 1.937 µs | 1.904 µs | 0.983 | | erc20_transfer | 1289.3 µs | 1291.3 µs | 1.001 | | uniswap_v2_pair | 1.359 µs | 1.395 µs | 1.026 | | univ2_router | 1.370 µs | 1.375 µs | 1.003 | | seaport | 1.593 µs | 1.546 µs | 0.970 | | usdc_proxy | 1.465 µs | 1.501 µs | 1.024 | | universal_router | 30.033 µs | 29.935 µs | 0.997 | | uniswap_v3_pool | 9.115 µs | 9.145 µs | 1.003 | | snailtracer | 29713 µs | 29716 µs | 1.000 | | factorial | 28.613 µs | 28.659 µs | 1.002 | Ratios stay within ±3% in both directions with no consistent sign, which is the run-to-run noise on this machine.
…te (alloy-rs#853) In diff mode, geth removes every account that was empty before the transaction from `pre` (OnTxEnd in `prestate.go`). We removed only the accounts the transaction created, so a plain transfer to a fresh account, or a fresh coinbase receiving the tip, was listed in `pre` as `{"balance":"0x0"}`. `pre` now drops every account that was empty before the transaction, and `post` is still diffed against the empty state first. The case below sends 5 wei to an empty account with an empty coinbase and a non-zero tip. geth is `evm t8n --trace.tracer prestateTracer --trace.jsonconfig '{"diffMode":true}'` at go-ethereum `a0cba163`. | Account | geth `pre` | `main` `pre` | this PR `pre` | | :-- | :-- | :-- | :-- | | sender | balance `0x16345785d8a0000` | same | same | | recipient (empty) | absent | `{"balance":"0x0"}` 🔴 | absent 🟢 | | coinbase (empty) | absent | `{"balance":"0x0"}` 🔴 | absent 🟢 | `post` is identical in all three. I also checked that an access-list-only account is not listed (matches geth) and that a non-empty coinbase with a zero tip stays listed in non-diff mode (matches geth). Two prestate options are not covered here and stay known differences until alloy releases them: `includeEmpty` (alloy-rs/alloy#4467 adds the config field) and `codeHash` in pre and post (in alloy `main`, not in a release yet).
alloy-rs#858) In diff mode, geth sets `post.code` whenever the code after the transaction differs from the code before it, and writes `"code":"0x"` when the new code is empty (`processDiffState` in `prestate.go`). We built the post state with `AccountState::from_account_info`, which drops empty code, so an account whose code a transaction cleared had no `code` field in `post` and a reader could not tell the code was gone. `post` now carries empty code when the account had code before the transaction. The case is an EIP-7702 transaction whose authorization to the zero address clears an account's delegation. geth is `evm t8n --state.fork Prague --trace.tracer prestateTracer --trace.jsonconfig '{"diffMode":true}'` at go-ethereum `a0cba163`; the table shows the delegating account's entry. | | geth `post` | `main` `post` | this PR `post` | | :-- | :-- | :-- | :-- | | `code` | `"0x"` | absent 🔴 | `"0x"` 🟢 | | `nonce` | `1` | `1` | `1` | | `pre` | `{"balance":"0x1","code":"0xef0100…aaaa"}` | same | same | geth also prints `codeHash` for these accounts. alloy-rs/alloy#4467 added `include_empty` to the prestate config but no release has `AccountState.code_hash` or `include_empty` yet, so `codeHash` and `includeEmpty` remain known differences until evm2 bumps to a release that has both.
The blockchain runner treated every failed system call to a contract as an invalid block. In the spec only the withdrawal, consolidation and builder calls are checked; the EIP-4788 beacon roots and EIP-2935 history storage calls run unchecked, so a failure never invalidates the block and the accesses of the call stay in the block access list as reads. The runner now commits the recorded access of a failed unchecked call and keeps the old behaviour for the checked ones. This removes the skips for `system_call_execution_boundary.json` and `bal_pre_execution_call_failure_keeps_read_drops_write.json`, which both run a block whose beacon roots call runs out of gas. No evm2 change is needed.
The blockchain runner skipped every transition fork, such as `BPO2ToAmsterdamAtTime15k`, so fixtures like `tx_total_gas_limit_cap_at_transition.json` never ran. The runner now maps a transition fork to the spec before it and the spec after it, with the activation at block 5 or at timestamp 15000, and picks the spec of each block from its header. The DAO fork and the BPO blob schedule forks (Osaka to BPO1 through BPO3 to BPO4) stay skipped: the first needs the DAO state change, and the others share a spec with the fork before them, which evm2 distinguishes only by the mainnet timestamps in `blob_params_for_timestamp`. This runs about 90 more fixture files across Paris to Shanghai, Shanghai to Cancun, Cancun to Prague, Prague to Osaka and BPO2 to Amsterdam, and the 4 invalid-header fixtures among them join the header validation skips.
…lloy-rs#868) The struct logger `limit` option now counts bytes of JSON, as in geth. Before, evm2 read it as a number of steps, so `{"limit": 1000}` kept 1000 struct logs where geth keeps about ten. geth's `StructLogger.OnOpcode` skips a step once the JSON it has written is over the limit (`l.resultSize > l.cfg.Limit`), and each logged step adds the length of its compact legacy JSON entry to `resultSize` (`eth/tracers/logger/logger.go` at master a0cba163). So a step is logged while the earlier entries total at most `limit` bytes, and the step that crosses the limit is the last one. The builder now sums `struct_log_json_len` of each log, which reproduces that JSON size field by field: the field order and omitted fields, the minimal hex of stack words, 66-byte memory words, 64-byte storage keys and values, and the six-byte `\u003c` and `\u003e` escapes geth writes for the `<=>` in `stack underflow (0 <=> 2)`. A zero limit still means unlimited. Because every entry takes at least 48 bytes, capture stops after `limit / 48 + 1` steps instead of recording the whole transaction. The size leaves out the fields geth omits when empty or zero (`refund`, `returnData`, `memory`, `storage`, `error`), whether or not the struct log carries them. I compared a bytecode with memory writes and a `KECCAK256` on a `geth --dev` node at master a0cba163 and on this branch merged with alloy-rs#864 (for the error text of failing steps the byte count also needs alloy-rs#849): the number of logs for limits 1, 50, 100, 150, 200, 250, 300, 400, 500, 600, 800, 1000 and 100000 is 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8 and 17 on both. A unit test checks the length function against entries written by geth, including an error with escaped characters, a memory snapshot, a storage snapshot and a stack of 256-bit words, and the existing limit tests now count bytes.
…eation zeros (alloy-rs#855) Follow-up to alloy-rs#845, which merged while its Cyclops audit still had two findings open. `reload_zeroed` evicted a slot whose reread failed. With a BAL attached and database fallback off, a slot the BAL omits fails the reread, so the slot and its read vanished from the overlay and a rebuilt BAL matched the malformed one. The slot now stays loaded with its zero, so the read reaches the BAL, and its next load, or the next `storage_slot_untracked`, rereads it and reports the error instead of serving the zero. The reload also rescanned every zero-valued slot of the account on each rolled-back creation, so retrying a creation at one address M times with N slots cost about N times M database lookups. Slots first loaded under a creation are now marked with `StorageSlot::created_zero`, and a rollback rereads only those, once each. Two new tests pin the failed-reload path and that slots loaded outside the creation are left alone.
…tracers (alloy-rs#882) geth's `muxTracer` creates each of its tracers through the tracer directory: a name is looked up first, and anything else is evaluated as JavaScript (`eth/tracers/native/mux.go`, `eth/tracers/dir.go`). The mux of evm2 accepted only 4byte, call, prestate, flatCall, noop and stateGas tracers, plus the keccak256 preimage tracer from alloy-rs#867. A nested `muxTracer`, an `erc7562Tracer` or a JavaScript source in a mux config failed with `unsupported tracer type` or `unexpected config`. A tracer that does not share the mux's recording now runs as a child `DebugInspector` that receives every hook and reports under its own key: nested `muxTracer`, `erc7562Tracer` and JavaScript sources. `keccak256PreimageTracer` goes through the same path, so the mux keeps no special field for it. Because a JavaScript tracer needs the transaction, the block and the transaction context to produce its result, `MuxInspector::try_into_mux_frame` now takes them, derives the `TransactionInfo` itself, and recovers the transaction root itself instead of leaving that to `DebugInspector`. `MuxInspector` is no longer `Clone`, since a JavaScript child cannot be cloned; it has `try_clone` and `fuse` that clone and reset its children instead, and `set_js_interrupt` hands a `JsInspectorInterrupt` to the JavaScript tracers of the mux and of nested muxes. The mux error enum drops `UnexpectedConfig` and gains a variant for the error of a child. Checked against go-ethereum master `a0cba163` with the parity harness of the `dani/geth-parity-harness` branch, running a mux of callTracer, a nested mux of noopTracer and 4byteTracer, keccak256PreimageTracer, erc7562Tracer and a JavaScript step counter on all 334 case and fork pairs: | Mux config with a nested mux and a JavaScript tracer | geth master | origin/main | this PR | | --- | --- | --- | --- | | nested `muxTracer` result | nested object | 🔴 `unsupported tracer type` | 🟢 identical on all pairs | | JavaScript source result | step count | 🔴 `unsupported tracer type` | 🟢 identical on all pairs | | `keccak256PreimageTracer` result | preimage map | 🟢 identical | 🟢 identical | | `erc7562Tracer` result | frame | 🔴 `unexpected config` | 🔴 runs, but its frame differs from geth in `usedOpcodes`, `contractSize` and `outOfGas`, the same differences as the standalone tracer, which another PR owns | The remaining differences of the callTracer entry in this mux are the Amsterdam gas fields and error strings that other PRs handle. The harness is not merged yet, so its mux case is not part of this PR; I will add it once it lands. Rust tests cover a nested mux with an erc7562Tracer and a JavaScript tracer next to a built-in one.
Several JS tracer values differed from geth's goja tracer. `log.memory.getUint(offset)` returns a bigint, not a byte array. `frame.getValue()` is `undefined` for STATICCALL, where geth passes no value. Arguments to `memory.slice`, `memory.getUint` and `stack.peek` now convert the way goja converts them for geth's `int64` Go parameters: `undefined`, `null`, NaN and infinities become 0, fractions truncate toward zero, and values outside the `int64` range become the minimum `int64`. Out-of-bounds memory errors use geth's texts (`offset %d, end %d` for `slice`, `available %d, offset %d, size 32` for `getUint`), and `stack.peek` reports the signed index. I ran each tracer through geth master (`a0cba163`, evm 1.17.11-unstable) `evm t8n --trace.tracer` (Cancun, code `602a6000526001600200`, so memory holds 42 at word 0 and the stack holds `[1, 2]` at STOP) and through `origin/main` and this branch on the same transaction. All 30 `memory`/`stack` expressions I tried now match geth; the table shows a sample. | Expression at STOP | geth master | `origin/main` | this PR | | --- | --- | --- | --- | | `memory.getUint(0).toString()` | `"42"` | 🔴 `"0,0,…,42"` (byte array) | 🟢 `"42"` | | `memory.getUint(NaN).toString()` | `"42"` | 🔴 error `invalid memory offset: NaN` | 🟢 `"42"` | | `memory.getUint(33)` | `tracer accessed out of bound memory: available 32, offset 33, size 32` | 🔴 `invalid memory offset: 33` | 🟢 same as geth | | `memory.slice(5, null)` | `tracer accessed out of bound memory: offset 5, end 0` | 🔴 `…available 32, offset 5, size 0` | 🟢 same as geth | | `toHex(memory.slice(0, Infinity))` | `"0x"` | 🔴 error `invalid memory end: inf` | 🟢 `"0x"` | | `memory.slice(0, 1e30)` | `…offset 0, end -9223372036854775808` | 🔴 `RangeError: Index must be between 0 and 2^53 - 1` | 🟢 same as geth | | `stack.peek(NaN).toString()` | `"2"` | 🔴 error `…index NaN` | 🟢 `"2"` | | `stack.peek(-1)` | `…size 2, index -1` | 🟢 same | 🟢 same | | STATICCALL `frame.getValue()` | `undefined` | 🔴 `0n` | 🟢 `undefined` | Two differences remain in how errors surface, and I did not change them here: evm2 prefixes the message with the error kind (`TypeError: …`) while geth prints the bare message, and a `try`/`catch` in the tracer can catch these errors while geth's interrupt cannot be caught. Opcode names for undefined and EOF opcodes are left for after alloy-rs#849, which adds the geth name table.
AOT mode spawned `cc -shared -fuse-ld=lld` for every artifact and then `dlopen`ed the result. The link costs a constant ~37M user instructions and 8–21 ms whatever the contract size, because almost all of it is starting `cc` and `ld.lld`. For small contracts it costs as much as the compile, and it requires `cc` and `lld` on the host. An AOT artifact is now the relocatable object that the out-of-process JIT path already produces. The artifact store persists it, and loading an artifact (after a compile, from a persisted artifact on a miss, and in the startup preload) links it with JITLink through the existing `JitObjectLinker`. The builtin symbols are derived from `Builtin::ALL` at load time, so the manifest does not change. The store API says `object` instead of `dylib` (`object_bytes`, `object_path`, `.o` files), and the runtime drops `LoadedLibrary` and `libloading`. Linked AOT code now counts in `jit_total_bytes()`, so the memory budget evicts AOT entries as well (they reload from the store), and `ABI_VERSION` is bumped because stored artifacts are objects now. Linked AOT code is anonymous memory, so it no longer shows up in `/proc/maps` or perf by file name. The artifact key, manifest checks, atomic persist, and preload semantics are unchanged, and `evm2_jit_codegen::Linker` and the CLI `--aot` path still produce shared libraries. Measured on one runner with a scratch test around `JitBackend::prepare_aot_sync` (AOT config, one worker, fresh process, `perf stat -e instructions:u` minus a run that only creates the backend, median of 5; times are medians of the same runs on a shared machine): | bytecode | bytes | compile + link + load, before | after | prepare time, before → after | | :-- | --: | --: | --: | --: | | push0_proxy | 44 | 59.0M | 26.3M 🟢 | 12.3 ms → 4.3 ms | | counter | 367 | 78.9M | 46.2M 🟢 | 14.4 ms → 7.0 ms | | usdc_proxy | 2186 | 272.6M | 240.1M 🟢 | 30.7 ms → 24.2 ms | | weth | 3124 | 569.4M | 536.9M 🟢 | 57.3 ms → 48.0 ms | | erc20_transfer | 3446 | 609.0M | 576.5M 🟢 | 59.8 ms → 51.7 ms | | uniswap_v2_pair | 11293 | 2054.3M | 2022.9M 🟢 | 174.1 ms → 162.9 ms | | seaport | 24367 | 9903.0M | 9872.8M 🟢 | not stable | Every compile saves about 32M instructions. Loading a persisted artifact costs more, because JITLink replaces `dlopen`: restarting a backend over one stored artifact (preload) goes from 0.2M instructions and 0.2 ms to 2.2–2.8M and 0.4–0.8 ms 🔴, which includes creating the linker's LLVM backend once per preload.
…te diff (alloy-rs#881) In diff mode, geth does not diff an account that selfdestructed in the transaction (`processDiffState` skips `deleted` accounts in `prestate.go`), so its `pre` entry stays as the tracer first looked it up: balance, nonce, code and every storage slot an SLOAD or SSTORE touched, including slots that did not change and slots that held zero. We kept only the changed non-zero slots of such an account. `pre` now lists every slot the transaction read for a selfdestructed account, with its value before the transaction, and the zero-slot filter no longer applies to it. Other accounts keep the old filtering. The case is a London contract that reads slot 1 (`0x2a`) and slot 2 (zero) and then selfdestructs. London selfdestructs every contract; from Cancun only a contract created in the same transaction selfdestructs, and that contract is empty before the transaction, so `pre` already drops it. geth is `evm t8n --state.fork London --trace.tracer prestateTracer --trace.jsonconfig '{"diffMode":true}'` at go-ethereum `a0cba163`; the table shows the contract's `pre.storage`. | | geth | `main` | this PR | | :-- | :-- | :-- | :-- | | slot 1 | `0x2a` | absent 🔴 | `0x2a` 🟢 | | slot 2 | `0x0` | absent 🔴 | `0x0` 🟢 | | `post` entry | none | none | none | The parity harness has no London cases yet, so the geth output above comes from running `evm t8n` by hand on the same alloc and transaction as the regression test.
## Summary Adds `call_with` and `create_with`, the `sstore_with` (alloy-rs#771) shape for the CALL family and CREATE/CREATE2, as proposed in alloy-rs#843. Custom call or create instructions can now reuse the base bodies instead of copying `load_acc_and_calc_gas` / `prepare_call` / `create_inner`. Closes alloy-rs#843. ## Changes - `call_with(stack, gas, state, kind, before, after)`: the body of `call` / `callcode` / `delegatecall` / `staticcall`. - `before` runs after every charge of the opcode (the EIP-8037 new-account state gas included) and after the forward is taken, right before `execute_message`. It may charge or credit `gas`, edit the child message (`gas_limit`, `reservoir`, `ext`) or fail the instruction. - `after` runs after `merge_child_gas` and the refund of the upfront state gas for a failed child, before the return data is copied and the success word pushed. A fatal child result returns before it. - `create_with(stack, gas, state, is_create2, before, after)`: the same for CREATE/CREATE2. `before` does not run when EIP-8037's balance/nonce/depth checks refuse the creation before the forward. - `call_inner` / `create_inner` call them with no-op closures; the checks, comments and charges are unchanged. - Gas charged by the hooks is not part of the step cost reported to inspectors (it happens after `finish_step_charge`); documented on both helpers. - Tests (in `system.rs`, a test opcode table that installs hooked CALL/CREATE next to the base ones, on Amsterdam): - the hooks can keep part of the forward in the caller and charge after the child (child `gas_limit` and caller gas compared with the base opcode); - `before` sees the new-account state gas already charged for a value call to an empty account; - `after` can fail the instruction; - CREATE with both hooks; - CREATE refused before the forward runs neither hook. ## A related point, raised here rather than added The issue proposed two callbacks, and this PR implements exactly those. We have one more need that the issue did not mention: a point **right before the opcode's own state-gas charge** (`spend_state` for the CALL new-account charge and the CREATE account-creation charge). The case: a chain that keeps part of a frame's gas withheld (not spendable by the frame's own execution, but allowed to pay certain charges) wants the opcode's state-gas spill to draw from the withheld part first. When the reservoir cannot cover the state charge and the spill is larger than `remaining`, the base body halts out of gas inside `spend_state`, before `before` runs, so no later hook can change the outcome. A closure `before_state_charge(&mut Gas, &mut InterpreterState, Address, price) -> Result` called just before `spend_state` would cover it. We have it implemented and tested locally (one more closure on both helpers). Happy to add it to this PR, open it separately, or drop it if you would rather not carry it. ## Validation - `cargo test -p evm2 --lib`: 739 passed (default backend and `EVM2_DISPATCH_BACKEND=packed`). - Without the two hook calls, 4 of the 5 new tests fail (the fifth checks that the hooks do not run). - `cargo +nightly fmt --all --check`, `cargo clippy -p evm2 --all-targets --all-features` (nightly) and `cargo clippy -p evm2 --all-targets` (1.97): clean. `cargo doc -p evm2 --no-deps` with `-D warnings`: clean. `cargo build -p evm2 --examples`: ok. - Not measured locally: codegen / instruction counts of the base CALL and CREATE paths (the helpers are `#[inline]` and called from the `#[inline(never)]` base bodies with no-op closures). Workspace-wide `cargo cl` / `cargo docs` need LLVM for the JIT crate and were not run locally.
…y-rs#1043) The tail-call dispatch backend passes `RawStack`'s length between handlers in a register. On x86-64 an address scale stops at 8, so with a word count every handler shifts the length left by 5 to address the top of the stack and keeps a copy of the old length for the update. `RawStack` now stores the length in bytes for the tco backend on x86-64, and `set_len` adds the instruction's word delta to it. Handlers address `[base + len - 64]` directly and update the length with an add or sub of 32. `Stack`, `StackMut` and all public APIs keep word lengths. Everything else is unchanged: the packed and unpacked backends, aarch64 (where `lsl alloy-rs#5` addressing is free) and other targets keep the word length and compile as on main. Adding the word delta rather than storing `len * 32` matters, because the latter leaves `((bytes >> 5) - 1) << 5` in JUMP, JUMPI and MSTORE and makes them longer than before. Handlers that call out of line through `&mut usize` (EXP, KECCAK256, the copy opcodes, SLOAD, LOG, CALL) pay a few extra instructions to convert at the boundary. Callgrind instructions, as CodSpeed builds it (`cargo codspeed build --profile profiling -p evm2-cli --bench evm`, generic x86-64), main against this PR: | Bench | main | PR | Δ | | --- | ---: | ---: | ---: | | factorial | 387,306 | 360,965 | 🟢 −6.80% | | fibonacci-calldata | 325,235 | 304,120 | 🟢 −6.49% | | onchain_lm_v2 | 3,153,957,573 | 2,968,577,124 | 🟢 −5.88% | | burntpix | 391,058,625 | 369,770,519 | 🟢 −5.44% | | snailtracer | 485,181,094 | 466,511,319 | 🟢 −3.85% | | mainnet replay | 1,118,688,510 | 1,100,677,541 | 🟢 −1.61% | | geomean of 32 benches | | | 🟢 −2.83% | Criterion wall time on an AMD EPYC 4484PX (Zen 5), medians of 5 alternating rounds with each binary pinned to one core, `80f24751` against its base `37fb326b`: | Build | Geomean of 32 cases | Best | Worst | | --- | ---: | --- | --- | | x86-64-v3, `-align-all-functions=6` | 🟢 −1.27% | factorial −12.0%, snailtracer −8.2%, burntpix −6.1% | 🔴 balancer_vault +3.4%, counter +1.9% | | generic x86-64 | 🟢 −2.03% | fibonacci −13.7%, balancer_vault −5.9%, uniswap_v3_pool −4.4% | 🔴 hash_10k +0.4% | The large precompile cases are flat within ±0.2%. The ~1 µs identity and sha256 cases move by up to +3.9%, which is noise on transactions that short.
Bumps the ci-weekly group with 3 updates: [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv), [taiki-e/install-action](https://github.com/taiki-e/install-action) and [CodSpeedHQ/action](https://github.com/codspeedhq/action). Updates `astral-sh/setup-uv` from 10.3.2 to 10.3.3 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/setup-uv/releases">astral-sh/setup-uv's releases</a>.</em></p> <blockquote> <h2>v10.3.3 🌈 Use Astral mirror for version manifests with GitHub fallback</h2> <h2>Changes</h2> <p>This release contains something that should have been included a very long time ago. Sorry for sleeping on that.</p> <p>This action now retrieves the release manifest that contains the available versions, their download links and checksums from the Astral mirror, rather than trying GitHub first. This should present much more stable. (Known checksums are still checked, so the security impact does not change)</p> <p>Also a big thank you to <a href="https://github.com/soujasK"><code>@soujasK</code></a> for a set of bugfixes 👏</p> <h2>🐛 Bug fixes</h2> <ul> <li>Use Astral mirror for version manifests with GitHub fallback <a href="https://github.com/eifinger"><code>@eifinger</code></a> (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1119">#1119</a>)</li> <li>fix: allow whitespace in uv requirement specifiers <a href="https://github.com/soujasK"><code>@soujasK</code></a> (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1112">#1112</a>)</li> <li>fix: resolve ~= specifiers with PEP 440 semantics <a href="https://github.com/soujasK"><code>@soujasK</code></a> (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1111">#1111</a>)</li> <li>fix: only report a saved cache when saving succeeded <a href="https://github.com/soujasK"><code>@soujasK</code></a> (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1110">#1110</a>)</li> </ul> <h2>🧰 Maintenance</h2> <ul> <li>chore: update known checksums for 0.13.6 @<a href="https://github.com/apps/github-actions">github-actions[bot]</a> (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1117">#1117</a>)</li> </ul> <h2>📚 Documentation</h2> <ul> <li>docs: use JSDoc for compatible release specifier comment <a href="https://github.com/eifinger"><code>@eifinger</code></a> (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1113">#1113</a>)</li> <li>docs: update version references to v10.3.2 @<a href="https://github.com/apps/github-actions">github-actions[bot]</a> (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1104">#1104</a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/astral-sh/setup-uv/commit/68559e99cc807c1eb7e9238fd43a15bba460eec2"><code>68559e9</code></a> Use Astral mirror for version manifests with GitHub fallback (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1119">#1119</a>)</li> <li><a href="https://github.com/astral-sh/setup-uv/commit/0192b6951893e558e24cfbd971d641a8cd336a95"><code>0192b69</code></a> chore: update known checksums for 0.13.6 (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1117">#1117</a>)</li> <li><a href="https://github.com/astral-sh/setup-uv/commit/2f29784424ba0f5755e2d0bbc18227082a5daff1"><code>2f29784</code></a> docs: use JSDoc for compatible release specifier comment (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1113">#1113</a>)</li> <li><a href="https://github.com/astral-sh/setup-uv/commit/9c7332190cf7291329c770bedb2ba1b3e441b37c"><code>9c73321</code></a> fix: allow whitespace in uv requirement specifiers (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1112">#1112</a>)</li> <li><a href="https://github.com/astral-sh/setup-uv/commit/80fbe0140ccf08d50eff5eeb98dff9021c415a21"><code>80fbe01</code></a> fix: resolve ~= specifiers with PEP 440 semantics (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1111">#1111</a>)</li> <li><a href="https://github.com/astral-sh/setup-uv/commit/36b7b57007634b5d947fd73fcd85c7b44863efec"><code>36b7b57</code></a> fix: only report a saved cache when saving succeeded (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1110">#1110</a>)</li> <li><a href="https://github.com/astral-sh/setup-uv/commit/56618cab7a58e3efc9b282dd3de75bbf1075db9b"><code>56618ca</code></a> docs: update version references to v10.3.2 (<a href="https://redirect.github.com/astral-sh/setup-uv/issues/1104">#1104</a>)</li> <li>See full diff in <a href="https://github.com/astral-sh/setup-uv/compare/07a047e608db84b3d8c06cd9a7c7dcc9c355c18e...68559e99cc807c1eb7e9238fd43a15bba460eec2">compare view</a></li> </ul> </details> <br /> Updates `taiki-e/install-action` from 2.87.31 to 2.89.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/taiki-e/install-action/releases">taiki-e/install-action's releases</a>.</em></p> <blockquote> <h2>2.89.0</h2> <ul> <li> <p>Support <code>yq</code>. (<a href="https://redirect.github.com/taiki-e/install-action/pull/2036">#2036</a>, thanks <a href="https://github.com/FirelightFlagboy"><code>@FirelightFlagboy</code></a>)</p> </li> <li> <p>Support <code>mold</code>. (<a href="https://redirect.github.com/taiki-e/install-action/pull/2044">#2044</a>, thanks <a href="https://github.com/FirelightFlagboy"><code>@FirelightFlagboy</code></a>)</p> </li> <li> <p>Fix an error when old cargo-binstall had already been installed at non-standard location. (<a href="https://redirect.github.com/taiki-e/install-action/pull/2048">#2048</a>)</p> </li> <li> <p>Update <code>wasm-tools@latest</code> to 1.263.0.</p> </li> <li> <p>Update <code>wasm-pack@latest</code> to 0.15.1.</p> </li> <li> <p>Update <code>wasm-bindgen@latest</code> to 0.2.130.</p> </li> <li> <p>Update <code>vacuum@latest</code> to 0.36.1.</p> </li> <li> <p>Update <code>prek@latest</code> to 0.5.9.</p> </li> <li> <p>Update <code>mise@latest</code> to 2026.10.25.</p> </li> <li> <p>Update <code>kingfisher@latest</code> to 2.16.0.</p> </li> <li> <p>Update <code>cargo-binstall@latest</code> to 1.26.2.</p> </li> </ul> <h2>2.88.1</h2> <ul> <li> <p>Update <code>wasmtime@latest</code> to 50.0.1.</p> </li> <li> <p>Update <code>vacuum@latest</code> to 0.36.0.</p> </li> <li> <p>Update <code>tombi@latest</code> to 1.9.8.</p> </li> <li> <p>Update <code>mise@latest</code> to 2026.10.23.</p> </li> <li> <p>Update <code>kingfisher@latest</code> to 2.15.0.</p> </li> <li> <p>Update <code>espup@latest</code> to 0.19.0.</p> </li> <li> <p>Update <code>deepsource@latest</code> to 0.10.2.</p> </li> <li> <p>Update <code>biome@latest</code> to 2.6.4.</p> </li> </ul> <h2>2.88.0</h2> <ul> <li>Support <code>similarity-rs</code>. (<a href="https://redirect.github.com/taiki-e/install-action/pull/2017">#2017</a>, thanks <a href="https://github.com/HardMax71"><code>@HardMax71</code></a>)</li> </ul> <h2>2.87.33</h2> <ul> <li> <p>Update <code>vacuum@latest</code> to 0.35.4.</p> </li> <li> <p>Update <code>uv@latest</code> to 0.13.6.</p> </li> <li> <p>Update <code>trunk@latest</code> to 0.22.1.</p> </li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md">taiki-e/install-action's changelog</a>.</em></p> <blockquote> <h1>Changelog</h1> <p>All notable changes to this project will be documented in this file.</p> <p>This project adheres to <a href="https://semver.org">Semantic Versioning</a>.</p> <!-- raw HTML omitted --> <h2>[Unreleased]</h2> <h2>[2.90.3] - 2026-11-08</h2> <ul> <li> <p>Update <code>yq@latest</code> to 4.54.2.</p> </li> <li> <p>Update <code>vacuum@latest</code> to 0.39.3.</p> </li> <li> <p>Update <code>syft@latest</code> to 1.57.0.</p> </li> <li> <p>Update <code>rclone@latest</code> to 1.76.0.</p> </li> <li> <p>Update <code>protoc-gen-connect-openapi@latest</code> to 0.30.0.</p> </li> <li> <p>Update <code>mise@latest</code> to 2026.11.3.</p> </li> <li> <p>Update <code>kingfisher@latest</code> to 2.17.0.</p> </li> <li> <p>Update <code>biome@latest</code> to 2.6.6.</p> </li> </ul> <h2>[2.90.2] - 2026-11-06</h2> <ul> <li> <p>Update <code>trivy@latest</code> to 0.76.2.</p> </li> <li> <p>Update <code>tombi@latest</code> to 1.10.0.</p> </li> <li> <p>Update <code>prek@latest</code> to 0.5.10.</p> </li> <li> <p>Update <code>mise@latest</code> to 2026.11.2.</p> </li> <li> <p>Update <code>mdbook-d2@latest</code> to 0.3.10.</p> </li> <li> <p>Update <code>cargo-zigbuild@latest</code> to 0.24.1.</p> </li> <li> <p>Update <code>cargo-tarpaulin@latest</code> to 0.37.6.</p> </li> <li> <p>Update <code>biome@latest</code> to 2.6.5.</p> </li> </ul> <h2>[2.90.1] - 2026-11-04</h2> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/taiki-e/install-action/commit/1919c4a95903d2c33e4a221102edca87309fc14b"><code>1919c4a</code></a> Release 2.89.0</li> <li><a href="https://github.com/taiki-e/install-action/commit/010423f11fb037578c525bcf64bc2faecd08230c"><code>010423f</code></a> Update changelog</li> <li><a href="https://github.com/taiki-e/install-action/commit/cb869a6319a39f095de788bb82fd1d14043f993c"><code>cb869a6</code></a> Support <code>yq</code> (<a href="https://redirect.github.com/taiki-e/install-action/issues/2036">#2036</a>)</li> <li><a href="https://github.com/taiki-e/install-action/commit/eacbab5a1fa656b2b2f3879a6ada69c735d784bd"><code>eacbab5</code></a> Do not assume that existing cargo-binstall is installed at ${cargo_bin}</li> <li><a href="https://github.com/taiki-e/install-action/commit/e49373f8633ec815a2f0592a59a294c0103f1af3"><code>e49373f</code></a> ci: Add test for issue 2047</li> <li><a href="https://github.com/taiki-e/install-action/commit/f4fa742f6b59fd71ace3b2bc902da1f0074aa91f"><code>f4fa742</code></a> Support <code>mold</code> (<a href="https://redirect.github.com/taiki-e/install-action/issues/2044">#2044</a>)</li> <li><a href="https://github.com/taiki-e/install-action/commit/dfff5d30681b63f15a120e12f31e022db58a17c7"><code>dfff5d3</code></a> tools: Update tidy.sh</li> <li><a href="https://github.com/taiki-e/install-action/commit/4d0d80988f03b4009d9eef3457b76a9ac7d103b0"><code>4d0d809</code></a> ci: Test alpine:3.24</li> <li><a href="https://github.com/taiki-e/install-action/commit/c6d3cd41d7556ab684abe1ffd32b309621463695"><code>c6d3cd4</code></a> ci: Update taiki-e/github-actions workflows</li> <li><a href="https://github.com/taiki-e/install-action/commit/032e621c161c8d99c9423691e08bcb6d651a823d"><code>032e621</code></a> ci: Mark wasm-bindgen as glibc_pre_2_39_incompat</li> <li>Additional commits viewable in <a href="https://github.com/taiki-e/install-action/compare/1e29709c0ec63babbe8f266397a465f29a825f91...1919c4a95903d2c33e4a221102edca87309fc14b">compare view</a></li> </ul> </details> <br /> Updates `CodSpeedHQ/action` from 5.6.0 to 5.6.1 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/codspeedhq/action/releases">CodSpeedHQ/action's releases</a>.</em></p> <blockquote> <h2>v5.6.1</h2> <p>Bumps the CodSpeed runner to <a href="https://github.com/CodSpeedHQ/codspeed/releases/tag/v5.6.1">v5.6.1</a>.</p> <h3>Fixes</h3> <ul> <li>Walltime: the runner no longer hangs after the benchmark exits when a Python process forks and leaves a corrupted perf jitdump (<a href="https://redirect.github.com/CodSpeedHQ/codspeed/pull/599">#599</a>)</li> <li>Simulation: stop the libpython symlink warning from firing falsely (<a href="https://redirect.github.com/CodSpeedHQ/codspeed/pull/594">#594</a>)</li> </ul> <h3>🐛 Bug Fixes</h3> <ul> <li>Stop the libpython symlink warning from firing falsely by <a href="https://github.com/not-matthias"><code>@not-matthias</code></a> in <a href="https://redirect.github.com/CodSpeedHQ/runner/pull/594">#594</a></li> </ul> <h3>💼 Other</h3> <ul> <li>Bump submodule to not loop on corrupted jit dump by <a href="https://github.com/GuillaumeLagrange"><code>@GuillaumeLagrange</code></a> in <a href="https://redirect.github.com/CodSpeedHQ/runner/pull/599">#599</a></li> </ul> <p><strong>Full Runner Changelog</strong>: <a href="https://github.com/CodSpeedHQ/codspeed/blob/main/CHANGELOG.md">https://github.com/CodSpeedHQ/codspeed/blob/main/CHANGELOG.md</a></p> <h2>What's Changed</h2> <ul> <li>docs(examples): update the example workflows by <a href="https://github.com/SuperMuel"><code>@SuperMuel</code></a> in <a href="https://redirect.github.com/CodSpeedHQ/action/pull/252">CodSpeedHQ/action#252</a></li> <li>chore: bump runner version to 5.6.1 by <a href="https://github.com/github-actions"><code>@github-actions</code></a>[bot] in <a href="https://redirect.github.com/CodSpeedHQ/action/pull/254">CodSpeedHQ/action#254</a></li> </ul> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/SuperMuel"><code>@SuperMuel</code></a> made their first contribution in <a href="https://redirect.github.com/CodSpeedHQ/action/pull/252">CodSpeedHQ/action#252</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/CodSpeedHQ/action/compare/v5.6.0...v5.6.1">https://github.com/CodSpeedHQ/action/compare/v5.6.0...v5.6.1</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/CodSpeedHQ/action/commit/61efe07e57e55bedeab750c434504de272a56e8c"><code>61efe07</code></a> Release v5.6.1 🚀</li> <li><a href="https://github.com/CodSpeedHQ/action/commit/2dea609d0e11606d0e71f7146874637081bb2b81"><code>2dea609</code></a> chore: bump runner version to 5.6.1 (<a href="https://redirect.github.com/codspeedhq/action/issues/254">#254</a>)</li> <li><a href="https://github.com/CodSpeedHQ/action/commit/e0fab22a3bfcc49ceafbc31a62f55e53d98bc2d3"><code>e0fab22</code></a> docs(examples): update the example workflows (<a href="https://redirect.github.com/codspeedhq/action/issues/252">#252</a>)</li> <li>See full diff in <a href="https://github.com/codspeedhq/action/compare/78102a468f96d8e0ccb92d0ec49425753fc42062...61efe07e57e55bedeab750c434504de272a56e8c">compare view</a></li> </ul> </details> <br /> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…loy-rs#1047) Follow-up to alloy-rs#1043. `RawStack::len` asserts that the stored length is a multiple of the scale and at most `CAPACITY * scale`. On the table backends the scale is 1, so these asserts hand LLVM range facts that it did not have before alloy-rs#1043. That changes register allocation in `Interpreter::run_inner` and `run_inspected_table` and the padding in front of the packed dispatch loop, which moves the hot loop within its cache line. The asserts now apply only when the scale is above 1, which is the tco backend on x86-64, so the table backends compile as they did before the byte length and the tco code is untouched. With this change, the packed binaries (generic `-Copt-level=3` and x86-64-v3 with `-align-all-functions=6`, for both the criterion bench binary and the `evm2` CLI) have 0 differing lines in every `evm2::interpreter` function against the code before alloy-rs#1043, `.text` size is identical, and the hot dispatch call in `run_inner` sits at the same offset in its 64-byte line. The cycle drift below is therefore removed. It was measured on the merged alloy-rs#1043 state against its base, with `evm2 run <case> N --interpret` under `perf stat`, pinned to 4.0 GHz, 7 rounds. Instructions were unchanged (±0.00%) in every case. | Case | Cycles generic | Cycles v3a | | --- | ---: | ---: | | snailtracer | 🔴 +0.84% | 🟢 −0.55% | | burntpix | 🔴 +0.41% | 🟢 −0.65% | | factorial | 🔴 +0.03% | 🔴 +0.36% | | fibonacci-calldata | 🔴 +0.02% | 🟢 −0.02% | | onchain_lm_v2 | 🔴 +0.25% | 🔴 +0.01% | | hash_10k | 🟢 −0.01% | 🟢 −0.02% | | erc20_transfer | 🔴 +0.42% | 🔴 +0.69% | | uniswap_v3_pool | 🟢 −0.43% | 🟢 −0.36% | | mainnet replay | 🔴 +0.19% | |
…ctor (alloy-rs#1040) `TransferInspector` only recorded logs inside a call frame. Embedders can emit logs before the first call or after the last, like Tempo's post-transaction fee transfer, and reth's `eth_simulateV1` with `traceTransfers` replaces a call's logs with the inspector's, so those logs vanished from the response. They now go straight to the transaction's logs, in emission order; no frame failure reverts them.
…#1053) Aligns every tco instruction handler to 64 bytes on x86-64. Without it, each handler's start offset inside its 64-byte line depends on unrelated code size, so run time shifts with link layout. Aligned handlers run faster and vary less across layouts. Instruction counts are unchanged and `.text` grows by 16.9 KB (0.04%). Aligning all functions with `-Cllvm-args=-align-all-functions=6` gives about the same gain but costs 291 KB. On Apple M4 Pro (aarch64) the same attribute was neutral to slightly slower (+0.0% to +0.4%), so it applies on x86-64 only. Measured on an AMD EPYC 4484PX (Zen 4) pinned at 4.0 GHz with `perf stat` cycles, `evm2 run <case> N --interpret`, bench profile. Each build was relinked with 6 lld `--shuffle-sections` seeds, over 4 rounds. The table shows the median over the 6 layouts, against main. | case | cycles | main's spread across layouts | aligned spread | |---|---:|---:|---:| | snailtracer | 🟢 −1.64% | 3.3% | 2.9% | | burntpix | 🟢 −4.68% | 5.1% | 3.3% | | factorial | 🟢 −1.26% | 2.6% | 0.6% | | fibonacci-calldata | 🟢 −7.00% | 16.5% | 1.9% | | onchain_lm_v2 | 🟢 −2.06% | 3.5% | 1.7% | | hash_10k | 🟢 −0.19% | | | | erc20_transfer | 🟢 −0.30% | | | | uniswap_v3_pool | 🟢 −2.12% | | |
…s#1052) The packed, unpacked and single_return backends spin in `run_inner`'s dispatch loop, which is about 32 bytes. Where it starts inside its 64-byte cache line depends on the size of unrelated code before it. On x86-64, a loop that starts at offset 48 crosses the line and runs 12% to 24% slower with identical instructions. This caused alloy-rs#1043's earlier packed regression. This PR puts `.p2align 6` in the loop preheader on x86-64 and aarch64, so the loop head always starts a line. The padding nops run once per `run_inner` call, and the function section becomes 64-byte aligned, which keeps the alignment under any link order. I measured on a Zen 4 (EPYC 4484PX, 4.0 GHz, `perf stat` cycles), `evm2 run <case> N --interpret`, packed backend, generic x86-64. I relinked each build 6 times with lld `--shuffle-sections=.text*` and report the median over 4 rounds. On main, 1 of 6 layouts puts the loop at offset 48. With the change, the spread across layouts is 1.4% to 3.5% and instructions are unchanged. Worst layout, cycles: | case | main | this PR | change | | :-- | --: | --: | --: | | snailtracer | 248.2M | 214.8M | 🟢 −13.5% | | burntpix | 214.7M | 179.8M | 🟢 −16.3% | | factorial | 210.1k | 174.8k | 🟢 −16.8% | | fibonacci | 207.0k | 171.1k | 🟢 −17.3% | The unpacked backend behaves the same. On main, one layout in six runs 8.9% to 19.7% slower (snailtracer +17.3%, burntpix +19.7%, fibonacci +16.5%), a 10% to 22% spread across layouts. With the change the spread is 0.3% to 2.7% (6.1% for factorial), the medians move by −0.7% to +0.03%, and instructions are unchanged. On an Apple M4 Pro (aarch64) main shows no such cliff, and the change is neutral (snailtracer −0.03%, burntpix −0.5%, fibonacci +0.1%, erc20 +0.8%). The tco backend and the handlers are unchanged.
…oy-rs#938) `compile_jit_object_artifact` collected the pending ORC symbol names and fell back to every builtin name when that list was empty. JIT objects compile on the AOT backend, which has no ORC state, so the list was always empty and the fallback always ran. The function now calls `builtin_symbol_names` directly. I confirmed the premise first: with an assertion that the pending list is empty, the `evm2-jit-runtime` tests and the EEST JIT and AOT state and blockchain suites all passed.
…n the transaction (alloy-rs#976) `Erc7562Inspector` reads the code size of the account an `EXTCODE*` or call instruction addresses when the instruction runs, like geth, so an account that an earlier instruction of the same transaction created has a size. This adds the test for that case: a `CREATE` of a contract with 5 bytes of runtime code, then `EXTCODESIZE` of the created address, which reports size 5 for the `EXTCODESIZE` opcode. It passes on main, so the PR changes no inspector code. The test comes from alloy-rs#915, which alloy-rs#936 superseded.
…y-rs#954) `__revmc_builtin_do_return_cc` was a hand-written copy of the body of `__revmc_builtin_do_return`. Both now convert their arguments (stack words or raw `u64`s) and call one private `do_return_range`, so the memory check and output setup cannot drift apart. The builtin signatures are unchanged. The generated builtins do not regress: `do_return_cc` disassembles to the same instructions as on `origin/main`, and `do_return` has the same instruction count with only the empty-output block moved. `bench.py --diff origin/main` reports `opt.s changed in 0/31`.
…lloy-rs#1023) EIP-8037 caps the total transaction gas limit, including the state-gas reservoir, at 2^32-1 (`TX_MAX_TOTAL_GAS_LIMIT`, issue alloy-rs#807). alloy-rs#862 enforces that cap in `Version::tx_gas_caps`, which rejects larger `tx.gas` with `TxGasLimitGreaterThanCap`. The cap is hard-coded. A chain whose block gas limit goes above 2^32-1 cannot use EIP-8037 at all: any transaction large enough to fill such a block is rejected before execution. This adds `Version::tx_total_gas_cap` so the limit is configurable per chain. - The field defaults to `MAX_TX_TOTAL_GAS_LIMIT_AMSTERDAM` in every base version, so Ethereum behaviour from alloy-rs#862/alloy-rs#807 is unchanged and still enforced by default. - `tx_gas_caps` reads it under EIP-8037, where it bounds `tx.gas`; the 2^24 execution cap and the execution/reservoir split are untouched. - `u64::MAX` disables the total cap, matching how the other caps are disabled. - Without EIP-8037 the field is unused, and `tx_gas_limit_cap` (EIP-7825) still bounds `tx.gas`. Tests in `crates/evm2/src/version/mod.rs` and `crates/evm2/src/ethereum/mod.rs` cover the default rejecting `2^32`, a raised cap accepting it, `u64::MAX` disabling it, the cap still applying only with EIP-8037, and the base version exposing the default value. Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
…s#1025) Closes alloy-rs#1024 The pending state already keeps each account's start-of-transaction info (the `original` side of `AccountChanges`/`AccountChangeRef`, exposed through `TxStateChanges` by alloy-rs#840 and used by the `stateDiff` inspector after alloy-rs#899). Callers that hold an `AccountHandle` during execution cannot see it: `get`/`balance`/`nonce`/`code_hash` all report the live overlay, and `original_code` is the only way to reach the transaction boundary, for bytecode only. This adds `AccountHandle::original()`, returning the account info at the transaction boundary as `Option<&AccountInfo>` (`None` when the account did not exist then). It is the account's own baseline, so it is unaffected by mutations made through any frame and by loading bytecode into the present cache. State-diff tooling and chain rules that compare an account against its start-of-transaction state can use it instead of re-reading the backing database mid-transaction, without detaching the pending state. The existing `is_changed` helper on the internal account entry is left private: `original()` plus `get()` is enough to compute the same transition, so no extra API is added. A unit test in `crates/evm2/src/evm/state/account.rs` covers an unchanged account, changed balance and nonce, an account created during the transaction (`None`), and code loaded into the cache not moving the baseline.
…vel call (alloy-rs#1048) AccessListInspector pruned excluded addresses before every top-level call, so in a transaction with several top-level calls, such as an account-abstraction batch, a later call to a contract dropped the slots earlier calls had touched in it. Seeded entries are now pruned only before the first top-level call.
) The out-of-gas step cost rule was written three times in `crates/inspectors`: a step that stops out of gas costs the whole gas remaining at step, except `ReentrancySentryOOG`, which costs 0, and any other step costs what it charged. A crate-private `step_cost` helper now holds the rule, and `TracingInspector` and `OpcodeGasInspector` call it. Each keeps its own gas measure, and `TracingInspector` keeps its precedence: the sentry first, then `gas_after_charge`, then out of gas, then the plain difference. No reported value changes. The JS tracer keeps its copy. It has no sentry arm and reports the whole remainder for the sentry, so the helper would change its output. The EIP-3155 tracer in `crates/eest/src/trace.rs` keeps its own copy because `evm2-eest` does not depend on `evm2-inspectors`. Follows alloy-rs#956.
…o provider (alloy-rs#963) This PR makes EIP-7702 authority recovery use the crypto provider, like the ecrecover precompile: the installed `Crypto` provider, or the default one when none is installed. I found this while comparing the SP1 proving cost of evm2 against reth's guest on the zkevm benchmark blocks ([comment](paradigmxyz/stateless#59 (comment))). The 16 test_auth_transaction blocks cost about 8.6x as much, since recover_authority() called ecrecover_bytes(), which uses the secp256k1 backend picked at compile time (k256 in our guests). So authority recovery ran in software inside the zkVM, without using the guest's provider. alloy-rs#692 and alloy-rs#707 also argued that a custom provider could change which authorizations are valid. I don't think that's a problem, since the provider already decides the ecrecover precompile, and the y-parity and low-s checks still run outside of it. With the default provider the result is the same as before. cc @figtracer --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
…1056) Moves `initial_call_depth` from `Version` to `Evm` and lets transaction handlers and callers set it at runtime. ### Why `Version` is fork and chain configuration, but `initial_call_depth` describes where execution is nested. Callers already have to change it per transaction: Foundry builds a modified `Version` for every isolated call or nested transaction. Tempo needs the same thing per AA batch. Under revm, Tempo's batch journal checkpoint made AA calls appear at depth 1 to inspectors, while the frame depth that enforces the limit stayed at 0. Under evm2 they appear at depth 0. Running the batch with an initial depth of 1 restores revm's traces without shrinking the 1024 call budget. ### Changes - `Evm::initial_call_depth()` and `Evm::set_initial_call_depth(depth)`. The setter panics inside a running interpreter frame, or for a depth above `u16::MAX - CALL_DEPTH_LIMIT - 1` (64510). The value persists until set again, so a handler that changes it should restore it. - `Host::initial_call_depth()`, a new required method: the CREATE opcode, the JIT CREATE builtin and inspectors read the depth through it. - Removed `Version::initial_call_depth` and `Version::max_call_depth()`. `Version::assert_valid` no longer checks the depth (the setter does). - `create_preaccess_failure` takes `initial_call_depth: u16` instead of `&Version`. - evm2-inspectors (opcode, access list, otterscan, transfer) compare against the host's initial depth. - Tests that set the depth through `Version` now call the setter. The runner-support test varies `chain_id` instead. ### Downstream impact Checked against the default branches of reth, tempo and foundry-rs/evm2-networks, and against foundry's `mablr/evm2-migration` branch: - **reth, tempo:** no references to the removed items and no `Host` impls. Tempo's `tempo-evm` (with tests) builds against this PR unchanged (`cargo check -p tempo-evm --tests` with the evm2 patch pointed here); reth was checked by search only. - **evm2-networks:** one line, `crates/base/src/eip8130.rs`: `host.version().initial_call_depth` becomes `host.initial_call_depth()`. With that change it builds against this PR (`cargo check --workspace --all-targets`). - **foundry (`mablr/evm2-migration`):** sets `env.version.initial_call_depth` before building nested EVMs (`inspectors/stack.rs` 3 sites, `backend/mod.rs` 1), reads `interp.version().initial_call_depth` in `cheatcodes/src/inspector.rs`, and destructures `Version` in `executors/mod.rs::same_execution_config`. Those sites need to carry the depth next to the env and call `set_initial_call_depth` on the nested `Evm`. ### Tests `cargo +nightly cl` (workspace), `cargo +nightly test -p evm2 -p evm2-inspectors --all-features`, `cargo +nightly test -p evm2-jit-runtime --all-features`, `cargo +nightly docs`. Requested from Pyramid thread https://pyramid.tehq.net/threads/bfd18995-32f1-4c24-a869-f2e95dc3f853
…mpty root, as in revm-inspectors (alloy-rs#1059) Restores revm-inspectors' root handling in the call tracer arena. ### Why revm-inspectors' arena starts with an empty root node and lets a call replace it only at depth 0. A call with no parent at a greater depth attaches under that empty root. Tempo relied on this under revm: its AA batch checkpoint put every batch call at depth 1, so each call became a child of one empty `to=0x0` root. evm2-inspectors instead let any parentless call replace the root, whatever its depth. So even with the batch running at initial depth 1 (alloy-rs#1056), every AA call overwrote the root, and the trace kept only the last call (verified on mainnet replays: 0/1101 `trace_get` and 0/1101 callTracer matches against v1.17). ### Change - `CallTraceArena::push_trace`: a parentless trace at depth 0 replaces the root; one at a greater depth attaches under the root, which stays an empty placeholder. Traces with a parent are unchanged. - As with revm-inspectors, struct logs and the default frame's `failed` flag follow the root's own steps and status, so a trace whose top-level calls start above depth 0 has no struct logs and reports `failed: true` (v1.17's behavior for AA transactions). - Tests: two arena unit tests (parentless depth-1 traces share an empty root; a depth-0 trace replaces it), and the nested-root input test now expects the placeholder root above depth 0. ### Impact Only tracers whose top-level call starts above depth 0 with no outer frame change. That is the Tempo AA batch with alloy-rs#1056, and a nested root (such as Foundry's isolated calls) traced by a fresh tracer with no outer frame; nested roots traced under an outer frame already have a parent and are unchanged. Requested from Pyramid thread https://pyramid.tehq.net/threads/bfd18995-32f1-4c24-a869-f2e95dc3f853
…lloy-rs#1061) alloy-rs#1053 aligns the tco handlers with `#[rustc_align(64)]` on x86-64 only, but `crates/evm2/src/lib.rs` enables the feature for every tco build: ```rust #![cfg_attr(tco, feature(fn_align))] ``` Other targets also use tco by default on a nightly toolchain, for example aarch64-apple-darwin. On those the feature is declared but never used, so `unused_features` fires and `cargo clippy -p evm2 --all-targets -- -D warnings` fails: ``` error: feature `fn_align` is declared but not used --> crates/evm2/src/lib.rs:3:26 | 3 | #![cfg_attr(tco, feature(fn_align))] | ^^^^^^^^ | = note: `-D unused-features` implied by `-D warnings` ``` CI doesn't hit this because clippy and the test matrix run on x86-64 Linux only. This PR enables the feature under the same condition as its use: `#![cfg_attr(all(tco, target_arch = "x86_64"), feature(fn_align))]`. Tested on aarch64-apple-darwin with `nightly-2026-04-23`. `cargo clippy -p evm2 --all-targets -- -D warnings` fails on `main` and passes with this change, and `cargo test -p evm2 --lib` passes.
…ep (alloy-rs#910) The JS tracer's `step` hook has to see the stack as it was before the opcode ran. evm2 reports `step_end`, so `StackView` rebuilds that stack from the post-execution stack plus the top `OpCode::inputs()` items it saved before the opcode. SWAPN and EXCHANGE (EIP-8024) declare `stack_io(0, 0)` but swap two items in place at depths taken from their immediate, so nothing was saved and `log.stack.peek(i)` returned the swapped values at the top and at the swapped depth. Geth emits the opcode hook before it executes the operation (`core/vm/interpreter.go`, `EmitOpcode` at line 236 precedes `operation.execute` at line 246, go-ethereum a0cba163), and the JS tracer takes `scope.StackData()` in that hook (`eth/tracers/js/goja.go`, `OnOpcode`), so `step` sees the pre-execution stack. The step snapshot now receives the instruction's immediate, and `StackView::record` decodes it with core's `decode_single` and `decode_pair` to save the items down to the deepest depth SWAPN or EXCHANGE swaps. An invalid immediate halts the opcode before it touches the stack, so nothing is saved for it. DUPN only pushes, so it was already correct. The JS tracer snapshot tests now run on a chosen spec, and new Amsterdam cases compare the reconstructed steps for DUPN, SWAPN and EXCHANGE with valid, invalid and underflowing immediates and an EXCHANGE at the end of the code. They come from alloy-rs#1065 by @mattsse. --------- Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com>
…loy-rs#1046) With an inspector installed, `Evm` copied every call's input out of the caller's memory before the hooks ran (`make_owned` in `execute_message_inspected`), and `call_with` did the same. That kept the O(input size) copy that alloy-rs#1030 removed from the plain path: a frame pays for memory expansion once, and then each warm `CALL` costs about 100 gas while copying the whole range. That is the incident's DoS, and it stayed open on every inspected path (tracing RPCs). This PR makes the input of a call instruction's message a range of the caller frame's memory on every path. `MessageInput` is a private enum, `Owned(Bytes)` or `Borrowed(Range<usize>)`, so it never holds a pointer that can outlive the memory it names. Inspector hooks read a borrowed input with `message.input.as_bytes(interp.memory())`, or `to_bytes` to keep it, and change it by copying it out and assigning an owned input: ```rust let mut input = message.input.to_bytes(interp.memory()).to_vec(); patch(&mut input); message.input = Bytes::from(input).into(); ``` The child frame resolves the range once, when `Evm` enters it, against the running caller frame and stores the slice in `Interpreter::input`. CALLDATALOAD, CALLDATASIZE, CALLDATACOPY and the JIT's `EvmContext::input` read that slice, so they carry no branch on the kind of input. Nothing can change the caller's memory while the slice is live: the caller is suspended until the child returns, and the hooks of the messages the child sends get the child, which is the running frame, never the caller. The hooks of the child's own message (`call`, `call_end`), the `call_with` hooks and the EIP-7708 transfer log run before the frame is entered or after it returns, so they see and may change the caller's memory, and what they leave there is what the child reads. A precompile reads its input through `Evm::message_input`, which borrows the EVM, so the compiler stops a precompile from sending a message, and so from running hooks that write the caller's memory, while it holds the bytes. A precompile that sends a message and needs its input afterwards copies it first. Resolving a range checks its bounds in release builds too, and a borrowed input records the entry number `Evm` gave the frame that made it, so a clone forwarded from another frame, a sibling at the same depth included, panics instead of reading that frame's memory. The top-level frame that only runs the hooks of a top-level message has an empty input slice, since a hook may replace the message's input. `Interpreter::call_input` no longer needs `unsafe`, and `call_with` is a single function again. `Interpreter` grows by 24 bytes for the slice and the frame's entry number, and `Message` shrinks by 8, so the field offsets the JIT reads move and `ABI_VERSION` goes from 7 to 8. Codegen is otherwise unchanged: `opt.s` totals are equal, and a few `unopt.ll` and `opt.ll` lines appear where a `Message` field offset is no longer zero. ## Behaviour changes A `call` hook, or a `call_with` `before` hook, that writes the caller's memory without replacing the input now changes what the child reads. Two alloy-rs#1030 tests asserted the opposite, one for a `call` hook and one for a `call_with` hook; both now assert the new behaviour, and `call_hook_replacing_input_keeps_caller_memory` covers replacing the input. `MessageInput` no longer derefs to its bytes or converts into `Bytes`; use `as_bytes`, `to_bytes` or `as_owned`. `MessageInput::to_bytes` takes the caller's `&Memory`, and precompiles read `Evm::message_input(message)` instead of `message.input`. ## Benchmarks Callgrind instructions, one process per benchmark, `profiling` profile, over all 174 cases of the `evm` bench, against `origin/main` at 53fe0ef. The mainnet replay and the ten mainnet contracts are the primary workloads. | Workload | origin/main | this PR | Change | | :--- | ---: | ---: | :--- | | Mainnet replay, 10 blocks | 1,100,516,499 | 1,101,074,560 | +0.05% 🔴 | | Interpreter, 10 mainnet contracts (geomean) | | | -2.1% 🟢 | | Interpreter, all 99 cases (geomean) | | | -0.78% 🟢 | | JIT run, 10 mainnet contracts (geomean) | | | -3.6% 🟢 | | JIT run, all 29 cases (geomean) | | | -2.8% 🟢 | | JIT translate, 29 cases (geomean) | | | +0.09% 🔴 | | JIT compile, 16 cases (geomean) | | | +0.05% 🔴 | The replay is the one workload that does not improve. In its function-level difference the `evm2` functions this change touches net to about +70,000 instructions: frame entry gains what `prepare_call` and `call_inner` lose, plus a little. The other +490,000 is `FbHasher` hash calls and `read_unloaded_slot` that the compiler inlines differently in the two builds, and glibc `_int_malloc`. The same effect moves single cases by up to ±4% between builds of this branch, and adding 16 bytes of padding to `Interpreter` on `origin/main` alone moves `weth` by -1.0% and `succinct_staking` by -0.3%, in the same functions, so the per-contract figures are as much a layout effect as a measure of this change. `scripts/jit/bench.py` reports equal totals for instructions per iteration and for compile instructions. --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
# Conflicts: # crates/evm2/src/evm/mod.rs # crates/evm2/src/evm/system.rs
billettc
approved these changes
Nov 11, 2026
|
Not needed: our only patch on |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merges
alloy-rs/evm2@66687c18, the evm2 revision reth v2.11.0 pins, intosf/reth. Once merged, tag the merge commitreth-v2.11.0-sf.Our only patch on
sf/reth, opt-in inspection of system calls, is now upstream (alloy-rs#888). The two conflicts incrates/evm2/src/evm/{mod,system}.rswere resolved with upstream's side, so this branch has the same tree as66687c18(git diff 66687c18 HEADis empty).Merge with a merge commit, not a squash or rebase. streamingfast/reth#95 pins this PR's head commit
ed6a07c214c47df13d82f568d9f255ef4b3f5d22, which has to end up onsf/reth.Tests
66687c18, which upstream's CI tested.Open questions
[patch]tostreamingfast/evm2. This PR keeps the fork in the chain, as before. A maintainer can decide whether to drop it on a later bump.