Skip to content

Amsterdam and fork selection - #22

Merged
sbillig merged 12 commits into
mainfrom
feat/amsterdam
Nov 12, 2026
Merged

sbillig merged 12 commits into
mainfrom
feat/amsterdam

Conversation

@sbillig

@sbillig sbillig commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Adds Amsterdam (Glamsterdam's execution layer, EIP-7773) and lets a host choose the fork.

The fork is a type. Rules gives a fork's rules as constants, each defined once from the fork it begins in (Self::FORK.since(Fork::Amsterdam)), so a fork is one line. transact, simulate, validate and Vm::run match Config.fork once and run code generic over its Rules type, as they are over the tracer. Each fork compiles to its own interpreter with its rules folded in: Osaka's dispatch sends the new opcodes to the invalid opcode path, and its code has no state gas in it. The world and Buffers are the same for every fork, so a host can switch between transactions.

Amsterdam:

  • EIP-8037 state gas: gas past the execution cap is the top frame's reservoir; new accounts, slots set from zero, new delegations and deposited code cost state gas, which failures refill. StateGas meters it per frame.
  • EIP-8038 repricing, and EIP-2780, EIP-7976 and EIP-7981 intrinsic gas and calldata floor; authorizations pay for their state at the top frame.
  • EIP-8024 DUPN, SWAPN and EXCHANGE (ERR_INVALID_IMMEDIATE for an immediate in the gap) and EIP-7843 SLOTNUM (BlockEnv.slot_number).
  • EIP-7708 transfer logs, EIP-8246's SELFDESTRUCT without a burn, and EIP-7954's code size limits in Config::amsterdam().
  • Receipts report what a transaction adds to its block's gas totals (execution_gas_used, state_gas_used: EIP-7778 and EIP-8037). The block-level EIPs (7928's access list, 7997, 8282) are for block execution, later.

Hosts and tools: fevm serve's configure request takes a fork byte and set block a slot number, as the Rust client does; fevm --fork amsterdam runs the CLI by Amsterdam's rules. The state-test runner runs each fixture's posts for every fork (or those --fork names) and checks the receipt's gas used and status that fixtures since v21.0.2 give; CI moves to tests@v21.0.2. fevm_tools bench --rules Amsterdam runs FeVM against evmone by Amsterdam's rules.

`Config.fork` selects a fork, and `Rules` gives its rules as constants.
`transact`, `simulate`, `validate` and `Vm::run` match the fork once and
run code generic over its `Rules` type, so each fork compiles to its own
interpreter and opcodes never check the fork. Handlers carry the type in
`Cursor<F>`. Osaka is the only fork; the cold account access cost is its
first rule.
Add `Fork::Amsterdam` with `Config::amsterdam()` (EIP-7954's code size
limits) and `BlockEnv.slot_number` (EIP-7843). The serve protocol's
configure request takes a fork byte and set block a slot number, as the
Rust client does. The state-test case format, version 5, carries the
fork and slot number. The conformance runner runs each fixture post of
every fork fevm runs, or those `--fork` names, tallies them by fork, and
checks the receipt's gas used and status that fixtures since v21.0.2
give. Amsterdam still runs Osaka's rules.
Amsterdam's SLOTNUM (EIP-7843) pushes the block's slot number, and DUPN,
SWAPN and EXCHANGE (EIP-8024) reach words past the sixteenth through an
immediate byte. They are handlers; earlier forks dispatch them to the
invalid opcode path. An immediate in the gap that keeps it from reading
as a JUMPDEST or PUSH halts with the new `ERR_INVALID_IMMEDIATE`.
From Amsterdam, moving ether between two accounts logs a Transfer from
0xff..fe (EIP-7708): a call or creation with value, the transaction's
own, and a SELFDESTRUCT to another account. The log belongs to the frame
that receives the ether, so its failure drops it. A SELFDESTRUCT no
longer burns ether (EIP-8246): settlement clears a self-destructed
account's code, nonce and storage but keeps its balance.
EIP-8037: gas past the execution cap (EIP-7825's 2^24) is the top
frame's state gas reservoir, and a transaction may have up to 2^32 - 1.
New accounts, storage set from zero, new delegations and deposited code
cost state gas, which the reservoir pays first and execution gas after.
A child takes the whole reservoir. A failed frame refills it to the
level it started at and returns the execution gas state charges took,
and the refills of storage reset to zero and of accounts a failed call
or creation charged for go back the way they were charged. Settlement
returns the reservoir left with the gas.

EIP-8038 reprices cold accounts, CALL value, CREATE, code reads, SSTORE
and SELFDESTRUCT. EIP-2780, EIP-7976 and EIP-7981 reprice intrinsic gas
and the calldata floor; authorizations pay for their state at the top
frame, whose failure before the message starts undoes them.
Describe the fork type and `Config::amsterdam()` in the README and the
conformance runner's forks and receipt checks, and run CI's state tests
on tests@v21.0.2. The session client tests SLOTNUM and a transfer log
under Amsterdam.
`fevm_tools bench --rules Amsterdam` runs FeVM and evmone by Amsterdam's
rules at mainnet's gas cap, past which gas is the state gas reservoir.
The evmone runner takes the revision from the case's fork byte; revm 33.1
has no EIP-8037 and sits out.
`LogBuffer::record` was out of line, so LOG passed it the topics by
value: LOG0 of nothing took 24% more instructions than before
`append_word`. Inlined, it takes 1% fewer.
Preparing the top frame built its `Vm` up front, and Osaka took a
checkpoint for it, so a transaction that runs no code paid for both:
12% more instructions for a plain transfer. EIP-8037's meter is now
`StateGas`, a value the preparation charges with the frame's gas and a
`Vm` takes when code runs. Osaka authorizes without a checkpoint, as
before Amsterdam.
`transact` matched the fork and called `apply` for it, which copied the
world, request and buffers once more on the way: three more `memcpy`s a
transaction. `apply` now builds the `Transaction` and then matches,
calling `apply_in` with everything in place. The receipt takes the logs
without an `Option`, whose `unwrap_or` had stopped inlining. A plain
transfer runs 22 fewer instructions than before Amsterdam.
From Amsterdam a block counts a transaction's gas before refunds
(EIP-7778) and its state gas apart (EIP-8037), which a host building
blocks cannot work out from the gas used. Receipts carry both, as
`execution_gas_used` and `state_gas_used`, through `fevm serve` and the
Rust client; before Amsterdam they are the gas used and zero. `StateGas`
keeps the spill the top frame commits for authorizations, which counts
as state gas used.
`fevm --fork amsterdam <hex-bytecode>` runs the code by Amsterdam's
rules; without `--fork` it runs Osaka's, as before.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T19:21:26.208770Z dd4378b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sbillig sbillig mentioned this pull request Nov 12, 2026
@sbillig
sbillig merged commit cd0b53f into main Nov 12, 2026
2 checks passed
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.

1 participant