Skip to content

feat(arbitrum): port Nitro execution to evm2 - #5

Open
figtracer wants to merge 4 commits into
mainfrom
arbitrum
Open

figtracer wants to merge 4 commits into
mainfrom
arbitrum

Conversation

@figtracer

@figtracer figtracer commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Adds an arbitrum crate that runs signed Ethereum transactions on evm2 with Arbitrum Nitro's rules: ArbOS versions mapped onto their Ethereum specs, L1-based NUMBER and BLOCKHASH, the L1 poster gas charged before execution and kept out of refunds, the ArbOS gas cap, tip dropping, fee distribution and backlog updates, and Nitro's per-version precompile sets with ArbSys, ArbInfo and the ArbGasInfo getters ported.

It also covers foundry-rs/foundry#15729 without the AnyNetwork workaround: is_arbitrum_chain recognizes the Robinhood Chain IDs, poster gas is an input on ArbTxEnvelope taken from the receipt's gasUsedForL1, and Nitro's own transaction types are exposed so block decoding can skip them. Chain-ID recognition only identifies the chain: execution is checked against Arbitrum One only, so Robinhood Chain runs these rules only if its ArbOS version, batch poster and precompiles match. Those transaction types, Stylus, the multi-gas pricing model and the other ArbOS precompiles are not ported; Stylus code, unported precompile calls and ArbSys.myCallersAddressWithoutAliasing below the top-level frame abort the transaction instead of diverging.

A replay of 302 Arbitrum One transactions from ArbOS 10 through 61 matched on status, gas, logs, balances and storage. The branch is merged with main and uses its evm2 pin.

Gustavo Figueiredo and others added 2 commits October 22, 2026 17:30
Add an `arbitrum` crate that executes signed Ethereum transactions with
Arbitrum Nitro's rules: ArbOS versions mapped onto evm2 specs, the L1 poster
gas charged before execution and excluded from refunds, the ArbOS gas cap,
dropped tips, the opt-in EIP-7623 floor, fee distribution to the network,
infrastructure and L1 pricer accounts, L2 backlog growth, the per-version
precompile sets, and the NUMBER, BLOCKHASH, GASPRICE and BLOBBASEFEE overlays.
ArbSys, ArbInfo and the ArbGasInfo getters are ported; other ArbOS
precompiles, Stylus programs and Nitro's own transaction types abort or are
left to block execution.

Robinhood Chain (4663, 46630) is recognized as an Arbitrum chain, covering
the chain-ID part of foundry-rs/foundry#15729.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1647f-fd32-700c-be1e-0705332186c6
Model ArbOS versions as an enum of the versions Nitro defines upgrades for,
replacing the numeric newtype, and decode the header version fallibly. Turn
the ArbOS subspaces into constants, drop the wrapper and helper types the
crate did not need, move imports to the top and constants before const
functions, and replace the module unit tests with end-to-end tests,
including one pinning the ArbOS state layout to Arbitrum One's slots.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1647f-fd32-700c-be1e-0705332186c6
@figtracer
figtracer requested a review from mablr October 23, 2026 09:29

@speedmax speedmax left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review

Verdict: Comment. The Nitro port is scoped honestly, and the ArbOS storage layout, header mixHash split, and poster-gas exclusion from the refund look right. Two claims are stronger than the evidence, and one ported method diverges instead of aborting.

This crate replays a signed Ethereum transaction against a database the caller already filled. It does not follow a sequencer feed, compute poster gas, or serve RPC. Chain-id recognition is not execution coverage.

Warnings

  • crates/arbitrum/src/precompiles.rs:284 — getStorageGasAvailable returns 0. The module says unported methods abort rather than diverge. This one is ported and diverges.
  • crates/arbitrum/src/chain.rs:45 — Robinhood 4663/46630 is a match arm. Every test and the 302-tx replay use Arbitrum One. A Hood header past ArbOS 61 will not decode; the enum stops at 61.
  • crates/arbitrum/src/precompiles.rs:298 — myCallersAddressWithoutAliasing aborts below the top frame. A contract that calls ArbSys through another contract dies.
  • No checks on the PR. The replay harness is not in the diff, so the 302-tx claim is not reviewable here.

Suggestions

  • Add one test that is_arbitrum_chain(4663) is true and that version(spec, 4663) still applies the same rules. Chain id does not change the rules; the test should say that.
  • getStorageGasAvailable should fatal-abort, same as withdrawEth, until it returns Nitro's remaining storage gas.

Looks good

  • Stylus and unported precompiles abort the transaction instead of returning a fake success.
  • NUMBER / BLOCKHASH stay on the L1 view; arbBlockNumber uses the L2 number.
  • Poster gas is charged and then excluded from the refund. Tests cover the zero-basefee and held-gas cases.
  • System addresses are Nitro constants, not Arbitrum One deployments, so the same slots work on an Orbit fork if the caller supplies that chain's state.

Reviewed by Hermes Agent

Comment thread crates/arbitrum/src/precompiles.rs Resolved
Comment thread crates/arbitrum/src/chain.rs Resolved
Comment thread crates/arbitrum/src/precompiles.rs Resolved
Comment thread crates/arbitrum/src/tests.rs Resolved
Take main's alloy-rs/evm2 pin and adapt the arbitrum crate: precompiles read their input through Evm::message_input, the call depth is measured from Evm::initial_call_depth, and GASPRICE reads the transaction environment from the host.
Document that myCallersAddressWithoutAliasing aborts below the top-level frame, since Nitro walks its call stack there, and test the three depths. Note that getStorageGasAvailable returns 0 as in Nitro. Narrow is_arbitrum_chain to chain identification, and run arbChainID under the Robinhood Chain ID.
@figtracer
figtracer requested review from mattsse and speedmax and removed request for mattsse and speedmax November 19, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants