Skip to content

feat: Base Foundry - #16224

Draft
lukasrosario wants to merge 28 commits into
foundry-rs:masterfrom
lukasrosario:lukas/base-foundry
Draft

lukasrosario wants to merge 28 commits into
foundry-rs:masterfrom
lukasrosario:lukas/base-foundry

Conversation

@lukasrosario

@lukasrosario lukasrosario commented Aug 17, 2026

Copy link
Copy Markdown

Motivation

Add support for Base precompiles + EVM following the precedent set by Monad support (#15343), building on shared native-network abstractions that landed with it.

Solution

Adds a non-default base feature providing BaseEvmNetwork and BaseEvmFactory on top of Base's own base-common-evm and BasePrecompiles, so execution semantics come from Base rather than a reimplementation in Foundry, and routes Base through Forge, Cast, Script, Chisel, Verify, and Anvil without any Ethereum or generic OP fallback.

Highlights:

  • Upgrade-gated precompiles. Azul excludes Beryl's set; Beryl installs the activation registry, B-20 factory, and policy registry with a chain-resolved activation admin; Cobalt adds the EIP-8130 nonce manager and transaction context. Tests assert the upgrades are behaviorally distinguishable rather than merely configured.
  • Anvil. Base-native execution with the complete post-Cobalt EIP-8130 surface: RPC, receipts carrying payer, metadata, and phaseStatuses, txpool lane replacement, expiry, payer reservations and replay protection, tracing, and lifecycle operations.
  • Deterministic replay. Fixtures captured once from Base mainnet across Jovian, Azul, and Beryl re-execute locally and compare status, gas, logs, L1 fee accounting, and touched-account deltas against node-reported values. No RPC at test time.
  • Trace decoding. The five fixed precompiles register labels and ABIs per address, gated on the upgrade that installs each. The B-20 token surface is registered globally by selector, as Tempo does for TIP20, since tokens live at factory-derived addresses. It deliberately omits the ERC-20, EIP-2612, and AccessControl members: the global map is not network-scoped, so competing candidates for transfer or balanceOf could change how ordinary token traces decode on other networks. A test pins that exclusion.
  • Code sentinel on state-holding precompiles. Solidity guards high-level calls to functions returning no data with an extcodesize check, which a code-less precompile fails in the caller. Base's 0xEF EIP-3541 sentinel is planted on the installed precompiles in both Anvil genesis and the executor, matching what Base's own tests expect a harness to do.
  • CI. A reusable base.yml mirroring monad.yml, wired into ci.yml as a required check, plus a Base+Optimism build and an explicit base_replay run because --lib skips that target.

Changes beyond the base feature

Four parts of this PR affect builds that don't enable base:

  • --hardfork on EvmArgs (crates/cli/src/opts/evm.rs) is a new shared flag for forge, cast, chisel, and script. It surfaces the existing Config::hardfork key, which previously could only be set in foundry.toml. Namespaced values such as base:Beryl or monad:MonadNine go through the existing FoundryHardfork parser.
  • Network inference in cast tx and cast block --raw. Both now resolve the network family rather than requiring an explicit --network, so Base deposit and EIP-8130 transactions decode by default. When neither --network nor a configured chain identifies the network, this costs one eth_chainId request; previously both defaulted to Ethereum with no round trip. Resolution now also reports a family that isn't compiled into the binary as an error, so these commands agree with cast call.
  • Monad in Cast's network dispatch. Making that dispatch exhaustive removed the _ catch-all Monad relied on, so both sites carry explicit NetworkVariant::Monad arms that use the Ethereum-typed provider. Behavior for Monad is unchanged.
  • Release binaries build with the base feature (.github/workflows/release.yml), matching how monad and optimism ship.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@github-actions

Copy link
Copy Markdown
Contributor

✅ Changelog found

The deterministic check will validate the changed entry.

@mablr mablr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @lukasrosario 👋

It already looks pretty good overall.

We are currently doing some post Monad clean-ups to fix several design footguns, ideally by the end of the week, only after we will able to start deep reviewing process.

The 2 main requirements we want to strongly enforce for external chains:

  • complete/robust feature gating, no logic, structure, or anything else should leak
  • FoundryEvmNetwork/FoundryEvmFactory/NestedEvm surface must stay as pre-#15343, no chain-specific methods or types will be accepted except if very very well justified/documented and contained. Specific custom evm logic must go behind FoundryContextExt.

Some merge conflicts may appear due to clean-ups, I'll notice you when stabilized. In the meantime please check the 2 requirements above are properly enforced.

@lukasrosario

Copy link
Copy Markdown
Author

thanks @mablr ! did another pass & pushed up a few changes, should be abiding by both requirements now. lmk when cleanup is done & will rebase

@mablr

mablr commented Aug 20, 2026

Copy link
Copy Markdown
Member

Nice!

After internal discussion, we will certainly ship this integration in several steps by cherry-pick from current PR. This will reduce round-trips.

@lukasrosario

Copy link
Copy Markdown
Author

@mablr sounds good let me know if you need me to assist with anything. will leave the PR as is for now

@figtracer

Copy link
Copy Markdown
Member

@mablr sounds good let me know if you need me to assist with anything. will leave the PR as is for now

we'll come back to this next week

@stevencartavia

Copy link
Copy Markdown
Member

@lukasrosario, several shared changes that this implementation can build on have now landed: #16406, #16407, #16415, #16417, #16419, #16420, #16438, #16443, #16448, #16449, #16450, and #16458.

@lukasrosario

Copy link
Copy Markdown
Author

@stevencartavia thank you, i'll rebase now

@lukasrosario
lukasrosario force-pushed the lukas/base-foundry branch 2 times, most recently from fa31e05 to 99381b7 Compare September 1, 2026 13:58
@lukasrosario

Copy link
Copy Markdown
Author

@stevencartavia @figtracer @mablr just rebased, should be good now. lmk anything else

Comment thread crates/common/fmt/src/ui.rs Outdated
Comment thread crates/anvil/src/eth/backend/mem/mod.rs Outdated
@lukasrosario

Copy link
Copy Markdown
Author

looks like some new conflicts, rebasing again now

@lukasrosario
lukasrosario force-pushed the lukas/base-foundry branch 3 times, most recently from cd8fffe to c988b70 Compare September 3, 2026 15:21
@lukasrosario

Copy link
Copy Markdown
Author

on it

Skip network discovery in curl mode and allow RPC commands without a compiled local EVM. Honor configured networks during DA estimation and reject unsupported Base blob options before transaction construction.

Add regression coverage for curl output, network precedence, feature combinations, blob rejection, and transaction encoding. Repair the Base-disabled call test to use the current network API.
@lukasrosario

Copy link
Copy Markdown
Author

@mablr looks like reth doesn't yet have a release on 43, i think we'd need to wait for that on the base/base side

Pin Base dependencies to the Foundry fork at 2aa8bc46e6b4272ef3bf0905e1a5660ee2525e72 and allow its source in deny.toml. Remove the obsolete revm 42 dependency graph while preserving unrelated lockfile resolutions.

AI-assisted dependency update.
@mablr

mablr commented Sep 11, 2026

Copy link
Copy Markdown
Member

Accept serializable receipt logs to preserve Base timestamp fields. Move EIP-8130 transaction and RPC gates to Zenith while retaining Cobalt precompile activation, and map Denim and Zenith to Osaka.

Update regression coverage and the Base changelog entry. AI-assisted.
Import Base types directly where names are unambiguous and replace
qualified Base references with feature-gated imports. Retain aliases for
name collisions.
Expose the selected network type through the provider dispatch macro so raw header encoding can select the consensus header inline.

AI-assisted.
Inline activation-admin resolution and sentinel planting, and accept BaseUpgrade directly in the shared sentinel selector. Focus adapter tests on constructor behavior and halt conversion.

AI-assisted.
Adopt the shared transaction network resolver from foundry-rs#16790 for Base dispatch. Report Base hardfork metadata through the concrete execution spec and resolve active trace labels using foundry-rs#16789's shared path. Preserve Base-only feature gates and extend focused regression coverage.

AI-assisted
@mablr mablr self-assigned this Sep 11, 2026
@lukasrosario

Copy link
Copy Markdown
Author

@mablr what's the plan for this going forward? will you all continue to maintain that fork and bump deps accordingly before we pull them into base/base?

Disambiguate Base and Tempo request fields while preserving existing routing for ambiguous untyped requests. Project EIP-8130 transactions into simulation requests, reuse supplied encoded bytes, and preserve phase statuses through RPC receipt conversions and JSON roundtrips.

Share deposit helpers between Base and Optimism and rationalize regression coverage across feature configurations.
@mablr

mablr commented Sep 11, 2026

Copy link
Copy Markdown
Member

@lukasrosario Not so far, I'd like to extract a minimal shippable scope from here (1 or 2 smaller PRs) today (current PR stays the working branch).

Basically if we leave anvil behind for next week, it's 90% ready. Pushing hard on the review, I'll tag you once minimal scope PR(s) are open.

@mablr

mablr commented Sep 11, 2026

Copy link
Copy Markdown
Member

It's fine for us to maintain a lean fork https://github.com/foundry-rs/base until your reth is fully bumped (it's even better for our supply chain sec tbh).

Ofc it would help us a lot if u maintain base/base frequently (revm/alloy bumps right after releases)

Retain Base EIP-8130 admission checks alongside upstream Tempo pool validation. Use genesis configuration for the Zenith nonce-manager transition, since ChainUpgrades excludes Zenith, and mark ambiguous Base simulation fixtures with their explicit transaction type.
@lukasrosario

Copy link
Copy Markdown
Author

makes sense, thanks

@mablr
mablr marked this pull request as draft September 11, 2026 16:56
@mablr

mablr commented Sep 11, 2026

Copy link
Copy Markdown
Member

@lukasrosario I've just opened #16809, which lands all what I reviewed/approved (basically everything except Anvil). Once merged, I'll rebase current PR and rescope it to land Anvil.

@lukasrosario

Copy link
Copy Markdown
Author

cool sgtm, thanks!

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants