Skip to content

build: upgrade revm to tag v112 - #1590

Closed
anaPerezGhiglia wants to merge 5 commits into
mainfrom
build/upgrade-revm-tag-v112
Closed

build: upgrade revm to tag v112#1590
anaPerezGhiglia wants to merge 5 commits into
mainfrom
build/upgrade-revm-tag-v112

Conversation

@anaPerezGhiglia

@anaPerezGhiglia anaPerezGhiglia commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

⚠️ ON HOLD until a previous refactor lands on main

Removed hardforks: breaking change

REVM dropped hardofrks that were EVM-equivalent: Frontier Thawing, DAO Fork, Constantinople, Muir Glacier, Arrow Glacier, Gray Glacier

PENDING: Refactor EDR so that we no longer depend internally on REVM SpecId type. We care about all hardforks since we need to be protocol compliant, that means that we care about all hardforks, even if they don't introduce changes in the EVM semantics


Summary

Upgrades the revm dependency family from revm 38.0.0 to tag v112 - revm 40.0.3, the version required for implementing support of the Amsterdam hardfork.
The upgrade required resolving an ecosystem gap: no crates.io release of op-revm or foundry-fork-db supports revm 40:

  • op-revm's releases stop at revm ^38 (its revm-41 work is unreleased monorepo development)
  • foundry-fork-db jumped from ^38 (0.26.0) straight to ^41 (0.27.0)

Additionally, this PR contains a breaking change: the hardforks that revm removed as EVM-equivalent (Frontier Thawing, DAO Fork, Constantinople, Muir Glacier, Arrow Glacier, Gray Glacier) are removed from EDR's API as well. See the "Removed hardforks" section below.

Dependency resolution

op-revm: shallow mirror, pinned by tag

op-revm 20.0.0 on crates.io pins revm ^38; development moved to the Optimism monorepo, where the next bump targets revm 41. This PR consumes op-revm from a shallow mirror:

op-revm = { git = "https://github.com/anaPerezGhiglia/op-revm", tag = "op-reth-v2.4.0-b40d2ce", ... }
  • The mirror is a verified snapshot of ethereum-optimism/optimism@b40d2ce (rust/op-revm), the canonical monorepo commit matching the op-reth v2.4.0 release, whose workspace pins revm 40.0.3. For more details on this snapshot read its PROVENANCE.md
  • This runs op-revm code that has no crates.io release. Accepted trade-off: the commit is the exact state shipped in op-reth v2.4.0.
  • Side effect: this op-revm defines OpSpecId::KARST, unblocking the known Karst activation gap in edr_op (not wired up here; separate change).
  • The mirror approach is up for discussion — switching between the options below is a Cargo.toml-only change, so disagreeing here is cheap. Options considered:
    • Direct git dependency on the monorepo (dropped): fetches ~1.1 GB (full clone + submodules) per developer machine and CI cache; stable cargo cannot shallow-clone (-Zgit=shallow-deps is nightly-only).
    • Vendoring the crate in this repo (tried during development, dropped): the snapshot stays permanently in EDR's history and blurs the verbatim-upstream boundary.
    • Shallow mirror repo (chosen): ~128 KB clone, verifiable provenance, self-documenting tag pin, and dropping it later leaves no trace in EDR.
  • I initially created the mirror repository under my own namespace to unblock this PR; if the team agrees with the approach, it should move under the NomicFoundation organization (a URL-only change in Cargo.toml and the lock file).

foundry-fork-db git pin: the 0.26.0 release, recompiled against revm 40

foundry-fork-db 0.26.0 pins revm ^38 and 0.27.0 pins revm ^41; the revm-40 port exists only inside the foundry-rs/foundry-core monorepo. This PR pins the exact revision that upstream Foundry's own revm-40 upgrade (foundry-rs/foundry#14925) shipped:

foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-core", rev = "8027e5cc..." }
  • The pinned revision's Rust source is byte-identical to the released 0.26.0 package; only Cargo.toml differs (revm requirement bumped to 40.0.3, dependency floors tightened). The history of crates/fork-db up to the pinned commit shows the four commits since the fork-db-v0.26.0 tag (revm bump, dependency pins, changelog/release tooling), and the crate delta can be checked in a foundry-core clone with:

    git diff fork-db-v0.26.0 8027e5cc -- crates/fork-db

    A verification recipe against the published package is also in the Cargo.toml comment: diff the crates.io 0.26.0 package against crates/fork-db at the pinned rev.

  • Provenance: chosen by Foundry's maintainers for the identical upgrade, CI-tested there, and distributed in ~3 weeks of Foundry nightlies (e.g. nightly 9022115); it was never part of a stable Foundry release (v1.7.1 predates the bump).

  • A shared revm version is required because revm types are fork-db's public interface (SharedBackend: DatabaseRef, AccountInfo/Bytecode in the cache and snapshot types); two revm copies do not unify at the CacheDB<SharedBackend> seam.

  • Temporary by design: dissolves when the workspace moves to a revm for which fork-db has a crates.io release (0.27.0+ at revm 41+).

revm-inspectors

Bumped to 0.40.1 (crates.io, revm ^40).
This release removed the edge_cov module. Its main consumer, Foundry, took it in-tree.
The 0.39.0 implementation is vendored at crates/foundry/evm/evm/src/inspectors/edge_cov.rs, the same path where upstream Foundry maintains its copy, to keep coverage-guided fuzzing behavior-identical.
This file is part of the foundry-port surface: the next foundry backport sync replaces it with upstream's since-evolved version.

Other code changes

API adaptations
  • Account::original_info is now private; new TransactionId newtype. Construction sites use Account::from(AccountInfo) ; TransactionId::ZERO at slot-construction sites.
  • PrecompileProvider::warm_addresses now returns &AddressSet (was a boxed iterator). crates/precompile stores unique_addresses as an AddressSet; the public into_addresses() shape is preserved. AddressSet is re-exported from edr_primitives.
  • CallOutcome gained charged_new_account_state_gas (EIP-8037, feat(eip8037): Amsterdam bal-devnet-7 bluealloy/revm#3667): initialized false at the 8 inspector sites that construct CallOutcome literally. This matches upstream Foundry's sites verbatim and is exact on all pre-Amsterdam hardforks, where state gas is always zero. Each site carries a TODO: the value stays at upstream parity, and whether to diverge (copying the flag from CallInputs) is deferred until EIP-8037 is fully implemented.
  • Gas::state_gas_spent() changed u64i64 (per-frame state gas can be transiently negative when 0→x→0 storage restoration refills more than the frame charged). The tracing surface clamps at 0 for the unsigned ResultGas representation, with a TODO to carry the signed value through when EIP-8037 support is implemented (crates/tracing/src/lib.rs).
  • InternalResult::Suspend new variant handled in edr_solidity/nested_trace/conversion.rs.
  • Misc: initial_total_gas field→method (2 sites), is_error()is_halt().
Full version table
Crate Old New
revm 38.0.0 40.0.3
revm-primitives 23.0.0 24.0.1
revm-bytecode 10.0.0 11.0.1
revm-context 16.0.1 18.0.3
revm-context-interface 17.0.1 19.0.3
revm-database-interface =11.0.1 =12.1.1
revm-handler 18.1.0 20.0.3
revm-inspector 19.0.0 21.0.3
revm-interpreter 35.0.1 37.0.3
revm-precompile 34.0.0 36.0.3
revm-state 11.0.1 12.0.1
op-revm 19.0.0 (crates.io) 20.0.0 (mirror tag op-reth-v2.4.0-b40d2ce)
revm-inspectors 0.39.0 0.40.1
foundry-fork-db 0.26 (crates.io) 0.26.0 (git foundry-core@8027e5cc)
c-kzg 2.1.4 2.1.7

Follow-ups (out of scope)

  • Wire up OpSpecId::KARST activations in edr_op (now unblocked by the op-revm pin).
    • ⚠️ Known CI impact: the check-generated-files workflow (runs on push to main) will fail once this PR lands: now that OpSpecId::KARST enum variant exists in revm, the check will parse the karst activation points, so the regenerated configs will differ from the committed generated/op.rs.
    • A follow-up PR adding the Karst activations should land immediately after this one.
  • Replace the two git pins with crates.io releases when the workspace moves to a revm for which they exist (revm 41 era), and replace the vendored edge_cov.rs with upstream Foundry's evolved copy on the next foundry backport sync.
  • Decide the removed-hardforks API question: keep vs. move the mapping into Hardhat's translation layer as a coordinated breaking change.
  • EIP-8037 completeness: revisit the tracing state-gas clamp and the hardcoded charged_new_account_state_gas when Amsterdam support graduates from early-access.

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 264279e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/edr Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark July 30, 2026 18:38 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia requested a review from Copilot July 30, 2026 18:38

Copilot AI 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.

Pull request overview

This PR upgrades the workspace’s REVM dependency family to revm 40.0.3 (tag v112) to enable full EIP-8037 support for the Amsterdam hardfork, and adapts EDR/Foundry integration code to the updated REVM APIs (including removed SpecId variants, signed state gas accounting, and new types like TransactionId / AddressSet).

Changes:

  • Upgrade REVM crates and related dependencies; introduce git pins for op-revm (mirror) and foundry-fork-db (Foundry-core rev) to bridge missing crates.io releases for REVM 40.
  • Preserve JS-facing hardfork API compatibility via name constants and compatibility mappings for removed REVM hardfork discriminants.
  • Update EVM execution/inspection/tracing glue for API changes (signed state gas clamping, TransactionId, AddressSet, CallOutcome field additions) and vendor the removed edge_cov inspector.

Reviewed changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/tracing/src/lib.rs Clamp signed per-frame state gas to 0 when exporting unsigned trace gas fields.
crates/state/api/src/lib.rs Re-export TransactionId from revm_state for downstream callers.
crates/state/api/src/diff.rs Update account creation in diffs to use Account::from(AccountInfo) and new field visibility.
crates/primitives/src/lib.rs Re-export AddressSet for use across workspace boundaries.
crates/precompile/src/lib.rs Adapt precompile provider warm-address API to return &AddressSet and maintain a deduped cache.
crates/foundry/evm/evm/src/inspectors/stack.rs Switch edge coverage inspector wiring to the vendored implementation and update CallOutcome construction.
crates/foundry/evm/evm/src/inspectors/mod.rs Add and export the vendored edge_cov inspector module.
crates/foundry/evm/evm/src/inspectors/logs.rs Initialize the new charged_new_account_state_gas field in literal CallOutcome construction.
crates/foundry/evm/evm/src/inspectors/edge_cov.rs Vendor revm-inspectors 0.39 edge coverage inspector to replace the removed upstream module.
crates/foundry/evm/evm/src/executors/mod.rs Update initial_total_gas field access to method call form.
crates/foundry/evm/core/src/opts.rs Adjust rustdoc link target for configure_env reference after refactor/import changes.
crates/foundry/evm/core/src/backend/predeploy.rs Update predeploy account construction to use Account::from and new field visibility.
crates/foundry/evm/core/src/backend/mod.rs Adapt to TransactionId and updated precompile warm-address plumbing.
crates/foundry/cheatcodes/src/inspector.rs Update CallOutcome literals and replace is_error() with is_halt() usage.
crates/edr_solidity/src/nested_trace/conversion.rs Handle new InternalResult::Suspend variant during nested-trace conversion.
crates/edr_provider/tests/integration/issues/issue_361.rs Update test hardfork selection to the EVM-equivalent fork after REVM SpecId cleanup.
crates/edr_provider/tests/integration/eip7778.rs Use TransactionId::ZERO in storage-slot construction to match new API.
crates/edr_provider/src/requests/validation.rs Update validation test hardfork selection to the EVM-equivalent fork.
crates/edr_provider/src/data.rs Update storage-slot tracking and gas accounting API usages (TransactionId, initial_total_gas(), Account::from).
crates/edr_napi/src/chains/l1.rs Preserve JS enum/string hardfork API while mapping removed forks to semantic predecessors internally.
crates/edr_napi/src/account.rs Use TransactionId::ZERO when building storage overrides from JS input.
crates/edr_eth/src/block/reward.rs Adjust miner reward logic to match updated/reduced SpecId set.
crates/edr_coverage/src/collector.rs Initialize new CallOutcome field for coverage collector’s synthetic precompile outcomes.
crates/edr_chain_l1/src/chains.rs Re-introduce removed hardfork name constants and omit removed fork activations while preserving string API.
crates/blockchain/local/src/lib.rs Update tests to construct accounts via Account::from without now-private fields.
crates/blockchain/fork/src/lib.rs Update fork setup accounts to use Account::from without now-private fields.
crates/block/header/src/difficulty.rs Adjust difficulty bomb delay logic and document loss of distinguishability for removed glacier forks.
Cargo.toml Upgrade REVM family versions; add git pins for op-revm mirror and foundry-fork-db rev.
Cargo.lock Lockfile updates for upgraded REVM ecosystem and introduced git-sourced dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/foundry/evm/evm/src/inspectors/edge_cov.rs
Comment thread Cargo.toml
Comment on lines +217 to 222
# No op-revm release supports revm 40 (op-revm 20.0.0 on crates.io pins revm
# ^38), so a shallow mirror of the ethereum-optimism monorepo commit matching
# the op-reth v2.4.0 release (workspace pins revm 40.0.3, the revm version at
# tag v112) is used instead. See the mirror's PROVENANCE.md.
op-revm = { git = "https://github.com/anaPerezGhiglia/op-revm", tag = "op-reth-v2.4.0-b40d2ce", default-features = false, features = [
"c-kzg",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This repo checks in the Cargo.lock file which records the exact resolved commit, so builds are reproducible and a moved tag can't silently change CI. Also, if we are keeping the mirror repo, the intent is to migrate it to NomicFoundation organization

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.20513% with 73 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.76%. Comparing base (01e3c8d) to head (b2ec0e7).

Files with missing lines Patch % Lines
crates/foundry/evm/evm/src/inspectors/edge_cov.rs 0.00% 55 Missing ⚠️
crates/foundry/cheatcodes/src/inspector.rs 70.58% 4 Missing and 1 partial ⚠️
crates/foundry/evm/evm/src/inspectors/logs.rs 0.00% 4 Missing ⚠️
crates/foundry/evm/evm/src/inspectors/stack.rs 55.55% 4 Missing ⚠️
crates/precompile/src/lib.rs 71.42% 2 Missing ⚠️
crates/tracing/src/lib.rs 0.00% 2 Missing ⚠️
crates/edr_solidity/src/nested_trace/conversion.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1590      +/-   ##
==========================================
- Coverage   79.82%   79.76%   -0.07%     
==========================================
  Files         453      454       +1     
  Lines       79019    79054      +35     
  Branches    79019    79054      +35     
==========================================
- Hits        63078    63055      -23     
- Misses      13760    13821      +61     
+ Partials     2181     2178       -3     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anaPerezGhiglia anaPerezGhiglia added the no changeset needed This PR doesn't require a changeset label Jul 30, 2026
@anaPerezGhiglia
anaPerezGhiglia force-pushed the build/upgrade-revm-tag-v112 branch from 7d010d1 to 264279e Compare July 30, 2026 20:22
@anaPerezGhiglia
anaPerezGhiglia had a problem deploying to github-action-benchmark July 30, 2026 20:22 — with GitHub Actions Failure
@anaPerezGhiglia
anaPerezGhiglia requested a review from Copilot July 30, 2026 20:22

Copilot AI 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.

Pull request overview

Copilot reviewed 36 out of 38 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

crates/edr_napi/src/chains/l1.rs:156

  • This changeset removes support for several legacy hardfork names/variants (e.g. muirGlacier, arrowGlacier, daoFork) by rejecting them in SpecId::from_str, but the PR description states that the JS-facing API keeps all variants and name strings for backwards compatibility. Please align the PR description and the intended API surface: either reintroduce the removed variants/strings (mapping them to their EVM-equivalent successors internally), or update the PR description to reflect that these hardfork identifiers are now unsupported/rejected.
            edr_chain_l1::chains::name::CANCUN => Ok(SpecId::Cancun),
            edr_chain_l1::chains::name::PRAGUE => Ok(SpecId::Prague),
            edr_chain_l1::chains::name::OSAKA => Ok(SpecId::Osaka),
            edr_chain_l1::chains::name::AMSTERDAM => Ok(SpecId::Amsterdam),
            _ => Err(napi::Error::new(
                napi::Status::InvalidArg,
                format!("The provided hardfork `{s}` is not supported."),
            )),

ping op-revm to commit sha b40d2ce
pin foundry-fork-db to commit sha 8027e5c
No need to update HH@ patch since loads EDR fine
@anaPerezGhiglia

Copy link
Copy Markdown
Contributor Author

superseded by #1604

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

Labels

no changeset needed This PR doesn't require a changeset

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants