Skip to content

chore(deps): upgrade to revm 43.0.3, alloy-evm 0.39.0 and the matching OP crates - #428

Draft
RealiCZ wants to merge 17 commits into
mainfrom
cz/chore/upgrade-revm-43
Draft

RealiCZ wants to merge 17 commits into
mainfrom
cz/chore/upgrade-revm-43

Conversation

@RealiCZ

@RealiCZ RealiCZ commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • revm 40.0.3 → 43.0.3, alloy-evm 0.36.0 → 0.39.0, revm-inspectors 0.40.1 → 0.44.3.
  • op-revm, alloy-op-evm, alloy-op-hardforks and op-alloy-{consensus,network,rpc-types} move from optimism commit f67d87cd to f84988888034, whose Rust workspace pins reth op-v2.7.0-1; alloy 2.x resolves to 2.5.0.
  • Toolchain nightly-2026-04-23 → nightly-2026-07-06 (rustc 1.99) in rust-toolchain.toml; MSRV 1.94 → 1.99 in Cargo.toml (rust-version) and clippy.toml, required by the OP crates at that commit. The workspace lint from_iter_instead_of_collect is dropped because this Clippy no longer has it.
  • For every transaction in blocks produced or accepted by the current MegaETH node line, on EQUIVALENCE through REX6, the receipt (status, gas used, logs), the post-state and the four resource dimensions are unchanged. The execution differences listed below require inputs or journal reuse outside canonical block execution, and tracing ordinary transactions can produce different output; regression-tested cases are marked.

Code changes

  • The transaction pipeline follows revm 43's handler:
    • run_without_catch_error and inspect_run_without_catch_error share one run_transaction, built on GasTracker;
    • caller state validation, the upfront fee debit and (for calls) the nonce bump (validate_against_state_and_deduct_caller) move from the start of pre_execution to the end of validate; only gas arithmetic (tx_gas) runs in between, so the order of state changes is unchanged;
    • a journal checkpoint opens after account loading, around authorization processing, and is committed before the execution loop or on the pre-frame out-of-gas result;
    • error handling leaves journal cleanup, including failed-deposit recovery, to op-revm; MegaEVM discards the journal only when that recovery itself fails, and clears its stashed error and ends transaction bookkeeping on every error path;
    • EIP-2780 is forced off next to EIP-8037; the EIP-7708 delayed-burn flag is renamed to the EIP-8246 delayed-clear flag.
  • mega-evme applies one transaction-type rule to raw and synthetic input; raw post-execution (type 0x7D) transactions are rejected.
  • New tests pin the call-trace, deposit gas price, delegation recovery and post-execution behaviour below, and that each failed transaction advances the journal exactly once.
  • README and spec docs carry the new dependency versions; comments that describe current upstream behaviour are updated.
  • Mutation suppressions re-anchored after the pipeline change.

Execution differences outside canonical blocks

  • Post-execution transactions (type 0x7D) — tested. Supplied directly to the block executor, the revm 40 build accepts one at nonce 0 when the zero address can pay the L1 data fee, as a zero-price call from the zero address (measured, not observed on chain); this build rejects it as an invalid transaction on all 11 specs. The current node line cannot decode the type.
  • Deposits with fee fields set by hand (simulation only) — verified on both builds. GASPRICE now returns the deposit's gas price instead of an EIP-1559 effective price. Tested: deposits from blocks carry no fee fields and see GASPRICE 0; promoted system transactions see 0 on the nine specs with MINI_REX behaviour or later (EQUIVALENCE and MINI_REX_1 run them as legacy transactions at the signed price); the fee-free keyless-deploy sandbox from REX5 sees 0 (earlier specs use the signed legacy price).
  • Reusing an EVM after an execution error without finalizing — tested. A rolled-back EIP-7702 delegation change now restores the previous delegation; revm 40 cleared the code. Block execution finalizes and never reuses such a journal.

Trace (inspector) output changes

These can appear when tracing ordinary transactions:

  • With call tracing and log collection on, a transaction that reverts at the top level because a LOG instruction hits a MegaETH resource limit now shows that log in the trace; the result and receipt still carry no logs (tested). Logs of failed nested frames follow the tracer's own filter.
  • Default prestate mode omits accounts that were empty before the transaction; this filter applies only in default mode.
  • Call errors use geth-style text (for example stack underflow, invalid opcode, write protection, return data out of bounds).
  • A full call trace no longer attributes a stale SELFDESTRUCT's source, beneficiary and value to a later synthetic SELFDESTRUCT frame (the frame remains, with no destination or value); onlyTopCall traces omit the synthetic child frame even for a genuine SELFDESTRUCT.
  • A nested CREATE whose creator nonce overflows reports the error and no destination.
  • Parity stateDiff reports setting or clearing an EIP-7702 delegation as a code change of the authority; revm-inspectors 0.40.1 reported a code change only for accounts created in the transaction and showed = here.
  • Parity traces and flatCallTracer render a reverted CREATE as a call result (gasUsed and the revert data as output) with no address, instead of a create result carrying the would-be address and the revert data as code.
  • The struct logger records memory when enableMemory is set, or when it is absent and disableMemory is false, and honours limit, recording and returning at most that many steps per transaction; 0.40.1 ignored limit.
  • An empty tracer name selects the default struct logger, as an omitted one does.
  • DebugInspector::get_result recovers the root frame (caller, destination and error) of a transaction that runs out of gas before its first frame, for the call tracer and muxTracer, and sets the transaction's gas limit and caller on the muxTracer root as it already did for the call tracer.

Verification

  • Upstream review against the frozen specs: all 111 revm commits in v112..v120, 19 alloy-evm commits in v0.36.0..v0.39.0, 77 revm-inspectors commits in v0.40.1..v0.44.3, the 51 optimism commits in f67d87cd..f8498888 that touch the Rust crates MegaEVM uses (plus 5 later commits considered and not taken), and every dependency version change in Cargo.lock. Beyond the differences above, no change is needed for canonical block replay.
  • Outcome comparison of main (revm 40) and this branch:
    • 2,261,534 compared records across the EEST and legacy state tests (all 11 specs), the in-repo MegaETH fixtures, a run with tightened resource limits and the captured mainnet replay corpus, all identical (inputs both builds reject are skipped). Executed state fixtures were compared on status, gas used, logs, full post-state root and resource usage; CLI and partial-replay cases on execution state deltas; the mainnet corpus on receipts and state deltas (22,985 transactions) plus the header fields replay can recompute, including receipts root and logs bloom (63 block verdicts).
    • The EEST and legacy state tests with the pure-Rust crypto backends a no_std build uses: 2,231,056 compared records, identical.
  • Mainnet replay with mega-evme replay --block <n> --verify-block --verify-receipt: 231 recorded blocks (200 consecutive REX6 blocks from 26,400,000 and 31 blocks across MINI_REX to REX5) give byte-identical output on both builds.
  • Full mainnet history, every block replayed with the same command against an archive node (in progress, last updated 2026-11-23):
    • blocks 1–6,097,000: complete, 183,643,162 transactions, all match;
    • blocks 6,917,001–32,372,956: 9,744,500 blocks and 276,571,026 transactions so far, all match; 112 ranges of 500 blocks between 8,140,001 and 10,500,000 wait for a re-run, because some of their blocks list a system transaction's hash twice, which mega-evme handles since fix(mega-evme): replay repeated transaction hashes by block index #427;
    • blocks 6,097,001–6,917,000, which hold the largest blocks (about 17,400 transactions per block across most of the range), come last and are sampled: the first and last 1,000 blocks and every 100th block.
  • Local checks: cargo fmt, cargo clippy, cargo sort, the RISC-V no_std check, release tests with -D warnings (2,327 passed, 16 ignored), all eight bench targets in test mode, docs lint and the suppression orphan check pass. A diff-scoped mutation run (cargo-mutants 27.1.0, as the PR gate runs it) kills 17 of 17 viable mutants; the spec-gate pack generates no mutants on the changed lines.
Commands to reproduce the local checks
cargo check -p mega-evm --target riscv64imac-unknown-none-elf --no-default-features
RUSTFLAGS="-D warnings" cargo test --workspace --release --locked
for b in attack_replay block_bench comp_cost ctt enriched_tx mega_bench revm_bench transact; do
  cargo bench -p mega-evm --locked --bench "$b" -- --test
done
scripts/mutation_test.sh diff "$(git merge-base origin/main HEAD)"

Benchmarks

CodSpeed reports a regression on this PR, largest in transfer_multi_1000 and the storage benchmarks.
main and this branch were measured with CodSpeed's simulation instrument on one x86 Linux host, so hardware and environment are the same for both:

  • The toolchain bump has no effect: main built with the old and the new nightly differs by a median of 0.00% (largest +0.93%).
  • main → this branch changes instruction counts by a median of +3.83%, with 145 of 343 benchmarks above +5%. The plain revm and op-revm lanes regress as much as the MegaEVM lanes, and MegaEVM's own code accounts for under 2% of the increase in the REX6 transfer benchmark.
  • Main cause: alloy-primitives 1.6.1 (alloy-rs/core#1153) moves the fixed-key maps (AddressMap, U256Map, B256Map) from unseeded FxHash to randomly seeded foldhash. revm 43 uses these maps for the journal's accounts and storage and for CacheDB. The number of lookups is unchanged, but each costs more: a journal storage lookup goes from 145 to 254 instructions. A build of this branch with only those maps switched back to FxHash recovers 93–98% of each sstore_heavy regression and brings the median to +0.46%.
  • transfer_multi_1000 recovers only 39–46% in that build. The remaining +8% to +13%, in the plain revm lane as well, runs in revm's own transaction code; the per-transaction GasTracker and journal checkpoint added in revm 43 are the likely source.
  • The random seed also makes reruns of the same build differ by up to 3.7%.
  • This PR does not work around it. The random seed gives foldhash its HashDoS resistance (alloy-rs/core#1253 keeps its fixed-seed option off by default for that reason), and storage keys are chosen by contract code. alloy-primitives cannot stay at 1.6.0, because alloy-sol-types 1.6.1 requires ^1.6.1.
  • These benchmarks run in memory and are dominated by map lookups. The wall-clock effect on a node, where state reads dominate, was not measured.

Notes for embedders

  • Rust ≥ 1.99. Hold the alloy 2.x family at 2.5.0 (2.6.1 does not compile with op-alloy-consensus at this commit) and alloy-trie at 0.9.7 (0.9.9 does not compile with reth op-v2.7.0-1).
  • MegaHandler::validate now settles the caller's upfront cost and, for calls, bumps the caller nonce.
  • Handler hooks: pre_execution takes a GasTracker and returns Result<Option<PreExecutionOutput>, _>; execution takes the checkpoint and a GasTracker and returns Result<Option<FrameResult>, _>; first_frame_input takes the tracker and returns Result<Option<FrameInit>, _>; last_frame_result takes the tracker; refund returns Result; tx_gas is a new hook that builds the transaction's GasTracker.
  • OnStateHook::on_state takes EvmState by value and runs after the state cache update.
  • PrecompilesMap / DynPrecompile are no longer Clone, Send or Sync; Evm::BlockEnv and EvmFactory::BlockEnv must be BlockEnvironment + Clone.
  • Custom Cfg implementations need is_amsterdam_eip2780_enabled and the renamed is_eip8246_delayed_clear_disabled; CfgEnv gains enable_amsterdam_eip2780 and renames the delayed-burn field to amsterdam_eip8246_delayed_clear_disabled. Struct literals need the new InputsImpl.depth and CreateOutcome.charged_create_state_gas. OpSpecId::INTEROP is now LAGOON.
  • revm's provided transact_commit, inspect, inspect_tx, inspect_tx_commit and inspect_commit finalize the journal on error, and the mainnet EVM's replay finalizes on both outcomes; the _one methods keep the caller's journal, and the upstream system_call_with_caller still returns early on error (MegaEVM's override finalizes).
  • Saved revm 40 configuration: a 256-entry GasParams table still loads but has no refund quotient and makes refund settlement divide by zero, and a whole CfgEnv JSON needs the new and renamed fields; rebuild both from the spec.
  • Decoding: an explicitly supplied "isSystemTx":"0x0" must now be a JSON boolean (false may still be omitted); TxDeposit::fallback_decode rejects an untagged deposit envelope, while plain RLP decoding of a deposit body still works; op-alloy-consensus adds a strict decode_2718_canonical helper.
  • Nodes moving to this optimism commit can decode post-execution (0x7D) transactions; keep them out at decode or admission.
  • When mega-reth adopts these pins, the second pass of eth_createAccessList applies the discovered list to legacy requests, which can change the gas estimate even when the returned access list is identical.
  • alloy-rpc-types-trace adds GethDebugBuiltInTracerType::StateGasTracer and GethTrace::StateGasTracer; exhaustive matches need an arm. Its TraceFilterMode default changes from Union to Intersection, so a trace_filter request that sets both address lists and omits mode matches fewer traces.
  • Code that mirrors the struct logger's recording rules, such as a response-size budget, must follow GethDefaultTracingOptions::is_memory_enabled() and the per-transaction limit. Renderers that call MuxInspector::try_into_mux_frame directly skip the new root finalization, which DebugInspector::get_result applies.

Not in this PR

  • The 1.8.0 version bump (release pipeline after merge).
  • ruint stays at 1.19.0; its shift-operation advisory (RUSTSEC-2026-0220) predates this change and is not reachable through the EVM shift opcodes, which bound the shift below 256.

@RealiCZ RealiCZ added api:breaking Crate interface change — downstream users must update comp:mega-evme Changes to the `mega-evme` tool comp:core Changes to the `mega-evm` core crate spec:unchanged No change to any `mega-evm`'s behavior dependencies Pull requests that update a dependency file comp:doc Changes in the documentation labels Nov 23, 2026
@mega-maxwell

mega-maxwell Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude review status

Living comment — rewritten in place. The review workflow keeps this single comment up to date instead of posting a new one each round, so it always describes the latest reviewed commit and the earlier text is intentionally gone. No reply is needed here; reply to a finding in its own review thread, and answer an open question in a reply on this PR. The next review round reconciles your answer.

✅ Review clean

Last reviewed: f0281f1e..31426009 · updated 2026-11-26T04:25:03+00:00

New this round: 0 finding(s), 0 question(s) · Resolved this round: 0 · Open questions: 0

@github-actions

Copy link
Copy Markdown

🧬 Spec-gate mutation — ✅ PASS

Nothing to test — no mutants were generated on the changed lines.

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.46341% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.8%. Comparing base (cdcc66e) to head (3142600).

Files with missing lines Patch % Lines
crates/mega-evm/src/evm/execution.rs 90.5% 4 Missing and 3 partials ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RealiCZ RealiCZ added spec:stable Touches stable spec code — must not change behavior and removed spec:unchanged No change to any `mega-evm`'s behavior labels Nov 23, 2026
@RealiCZ RealiCZ added the comp:misc Changes to the miscellaneous part of this repo label Nov 23, 2026
@codspeed

codspeed Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 7.87%

3 warnings, 1 note

⚠️ Unable to measure the execution of 16 benchmarks

These benchmarks measured no execution time, so their results are not comparable and count as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

⚠️ 129 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 129 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

ℹ️ 16 benchmarks have no flamegraph

The flamegraph wasn't generated: no execution data was recorded while the benchmark ran. Make sure the compiler didn't optimize the benchmark out.

See affected benchmarks

⚡ 3 improved benchmarks
❌ 126 (👁 126) regressed benchmarks
✅ 230 untouched benchmarks
⏩ 30 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ revm_pinned 647.6 ms 591.1 ms +9.56%
⚡ mini_rex 647.8 ms 591.3 ms +9.56%
⚡ rex5 647.9 ms 591.4 ms +9.55%
👁 rex4/10_txs 977.8 µs 1,029.3 µs -5.01%
👁 mini_rex/5_mixed_txs 393.9 µs 423.8 µs -7.06%
👁 equivalence/empty_account_50 187.3 µs 199.3 µs -6.03%
👁 equivalence/existing_account_50 188.1 µs 199.7 µs -5.79%
👁 mini_rex/empty_account_50 242.7 µs 257 µs -5.58%
👁 mini_rex/existing_account_50 239.9 µs 254.2 µs -5.63%
👁 op_revm_pinned/empty_account_50 163.9 µs 175.9 µs -6.83%
👁 op_revm_pinned/existing_account_50 164.7 µs 176.4 µs -6.59%
👁 revm_pinned/empty_account_50 155.1 µs 165.2 µs -6.11%
👁 revm_pinned/existing_account_50 155.4 µs 165.8 µs -6.28%
👁 equivalence/create_10 135.6 µs 146.5 µs -7.41%
👁 equivalence/create2_10 164.5 µs 175.3 µs -6.12%
👁 mini_rex/create_10 179.6 µs 190.6 µs -5.75%
👁 op_revm_pinned/create_10 122.3 µs 132.4 µs -7.66%
👁 op_revm_pinned/create2_10 150.2 µs 159.1 µs -5.61%
👁 revm_pinned/create_10 111.5 µs 120.4 µs -7.35%
👁 revm_pinned/create2_10 138.6 µs 146.7 µs -5.48%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cz/chore/upgrade-revm-43 (3142600) with main (cdcc66e)

Open in CodSpeed

Footnotes

  1. 30 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@github-actions

Copy link
Copy Markdown

🧬 Mutation testing — ✅ PASS

Diff mutation score: 100.0% (6/6 viable mutants killed)

  • caught: 6
  • survived (real gaps): 0
  • timed out (inconclusive): 0
  • suppressed (equivalent/dead-code): 0
  • unviable: 42 · timeout total: 0

No new test gaps introduced by this change. 🎉

@flyq flyq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@RealiCZ
RealiCZ marked this pull request as draft November 28, 2026 00:16
@RealiCZ

RealiCZ commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Moving to draft: mega-evm stays on revm 40 for now, with selected revm fixes picked onto that line. This branch stays as the revm 43 port for when the node moves to a newer reth / op-reth.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:breaking Crate interface change — downstream users must update comp:core Changes to the `mega-evm` core crate comp:doc Changes in the documentation comp:mega-evme Changes to the `mega-evme` tool comp:misc Changes to the miscellaneous part of this repo dependencies Pull requests that update a dependency file spec:stable Touches stable spec code — must not change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants