Skip to content

Update EIP-8038: Add preliminary numbers - #11802

Merged
eth-bot merged 1 commit into
ethereum:masterfrom
misilva73:update-eip-8038
Jun 18, 2026
Merged

eth-bot merged 1 commit into
ethereum:masterfrom
misilva73:update-eip-8038

Conversation

@misilva73

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot added c-update Modifies an existing proposal s-draft This EIP is a Draft t-core labels Jun 12, 2026
@eth-bot

eth-bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Collaborator

✅ All reviewers have approved.

Comment thread EIPS/eip-8038.md
| `ACCOUNT_WRITE` | Surcharge for when writing to an account changes one account leaf value for the first time | 6,700¹ | 8,000 | +19% | `*CALL` opcodes, `SELFDESTRUCT`, EOA delegations and ETH transfers |
| `COLD_STORAGE_ACCESS` | Cold touch of a storage slot | 2,100 | 3,000 | +43% | `SSTORE` and `SLOAD` |
| `STORAGE_WRITE` | Surcharge for when writing to a storage slot changes its value for the first time | 2,800² | 10,000 | +257% | `SSTORE` |
| `WARM_ACCESS` | Touch of an already-warm account or storage slot | 100 | 100 | +0% | `SSTORE`, `SLOAD`, `*CALL` opcodes, `BALANCE` and `EXT*` opcodes |

@Helkomine Helkomine Jun 13, 2026 •

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.

For some read-only operations from memory, such as warm SLOAD, should we charge a lower cost, similar to MLOAD? The 100 gas cost should only be applied to operations that may result in REVERT path processing, such as warm SSTORE and warm CALL.

Comment thread EIPS/eip-8038.md
Refunds are also updated as follows:

1. `STORAGE_CLEAR_REFUND` is refunded if the original value is non-zero, the current value is non-zero and the new value is zero.
2. `STORAGE_WRITE` is refunded if the original value is the same as the new value.

@Helkomine Helkomine Jun 13, 2026 •

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.

Except for STORAGE_CLEAR_REFUND, all costs should be refill instead of refund because these costs originate from the transaction itself. Including them in a refund counter would render the gas inefficient, perhaps we should record them in a separate counter.

Comment thread EIPS/eip-8038.md

#### `CALL`/`CALLCODE`

For `CALL` and `CALLCODE` operations, `CALL_VALUE` is set to `ACCOUNT_WRITE + CALL_STIPEND`, where `CALL_STIPEND` = 2,300.

@Helkomine Helkomine Jun 13, 2026 •

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.

I expect this to be the maximum value calculated for each transfer, while the final value will depend on whether the target account has been previously updated and the amount of gas it consumes.
Additionally, we should also consider refunds in cases where the balance update is in the pattern x -> y -> x.

Comment thread EIPS/eip-8038.md
| :--- | :---: | :--- | :--- |
| `CALL` / `CALLCODE` | `COLD_ACCOUNT_ACCESS` or `WARM_ACCESS` | when value is transferred (via `CALL_VALUE` = `ACCOUNT_WRITE` + `CALL_STIPEND`) | — |
| `DELEGATECALL` / `STATICCALL` | `COLD_ACCOUNT_ACCESS` or `WARM_ACCESS` | never (no value transfer) | — |
| `CREATE` / `CREATE2` | `CREATE_ACCESS` (= `ACCOUNT_WRITE` + `COLD_STORAGE_ACCESS`) | always (folded into `CREATE_ACCESS`) | `GAS_NEW_ACCOUNT` in state-gas (per [EIP-8037](./eip-8037.md)) |

@Helkomine Helkomine Jun 13, 2026 •

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.

If the target account have been previously written (a target account that complies with EIP-684 receives ether in the same transaction but before CREATE is executed), the expected cost is CREATE_ACCESS - ACCOUNT_WRITE

Comment thread EIPS/eip-8038.md
Refunds are also updated as follows:

1. `STORAGE_CLEAR_REFUND` is refunded if the original value is non-zero, the current value is non-zero and the new value is zero.
2. `STORAGE_WRITE` is refunded if the original value is the same as the new value.

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.

I also didn't see any refunds when processing REVERT paths, which resulted in some update operations being charged even though no changes were actually written.

Comment thread EIPS/eip-8038.md

Cases and their corresponding costs are detailed in the table below:

| Original value | Current value | New value | Access status | Description | Regular-gas charges/refunds | State-gas charges/refills |

@Helkomine Helkomine Jun 13, 2026 •

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.

When a slot is updated, storage root is also updated, which also means the account needs to be updated, so we should surcharge an additional ACCOUNT_WRITE for the first update.

danceratopz added a commit to danceratopz/execution-specs that referenced this pull request Jun 16, 2026
Replace the provisional flat-3x placeholders with the final
benchmark-derived values from the updated EIP-8038 spec, across the
spec, the EEST fork gas model, and the Amsterdam tests:

- `WARM_ACCESS` stays 100, `COLD_ACCOUNT_ACCESS` 3000,
  `COLD_STORAGE_ACCESS` 3000, `STORAGE_WRITE` 10000, `ACCOUNT_WRITE`
  8000, `CALL_VALUE` 10300.
- `CREATE_ACCESS` 11000, `REFUND_STORAGE_CLEAR` 12480,
  `TX_ACCESS_LIST_ADDRESS` 3000, `TX_ACCESS_LIST_STORAGE_KEY` 3000.
- Test constants follow suit: `REGULAR_GAS_CREATE` 11000,
  `PER_AUTH_BASE_COST` 15816, `GAS_COLD_STORAGE_WRITE` 13000.

The derived parameters now match the EIP derivation formulas exactly,
so the provisional deviation comments are dropped.

Ref: ethereum/EIPs#11802
@misilva73
misilva73 marked this pull request as ready for review June 18, 2026 14:29
@misilva73
misilva73 requested a review from eth-bot as a code owner June 18, 2026 14:29
@misilva73

Copy link
Copy Markdown
Contributor Author

@eth-bot rerun

@eth-bot
eth-bot enabled auto-merge (squash) June 18, 2026 14:31

@eth-bot eth-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All Reviewers Have Approved; Performing Automatic Merge...

@eth-bot
eth-bot merged commit 803ee8d into ethereum:master Jun 18, 2026
22 checks passed
danceratopz added a commit to danceratopz/execution-specs that referenced this pull request Jun 18, 2026
Replace the provisional flat-3x placeholders with the final
benchmark-derived values from the updated EIP-8038 spec, across the
spec, the EEST fork gas model, and the Amsterdam tests:

- `WARM_ACCESS` stays 100, `COLD_ACCOUNT_ACCESS` 3000,
  `COLD_STORAGE_ACCESS` 3000, `STORAGE_WRITE` 10000, `ACCOUNT_WRITE`
  8000, `CALL_VALUE` 10300.
- `CREATE_ACCESS` 11000, `REFUND_STORAGE_CLEAR` 12480,
  `TX_ACCESS_LIST_ADDRESS` 3000, `TX_ACCESS_LIST_STORAGE_KEY` 3000.
- Test constants follow suit: `REGULAR_GAS_CREATE` 11000,
  `PER_AUTH_BASE_COST` 15816, `GAS_COLD_STORAGE_WRITE` 13000.

The derived parameters now match the EIP derivation formulas exactly,
so the provisional deviation comments are dropped.

Ref: ethereum/EIPs#11802
danceratopz added a commit to danceratopz/execution-specs that referenced this pull request Jun 18, 2026
Replace the provisional flat-3x placeholders with the final
benchmark-derived values from the updated EIP-8038 spec, across the
spec, the EEST fork gas model, and the Amsterdam tests:

- `WARM_ACCESS` stays 100, `COLD_ACCOUNT_ACCESS` 3000,
  `COLD_STORAGE_ACCESS` 3000, `STORAGE_WRITE` 10000, `ACCOUNT_WRITE`
  8000, `CALL_VALUE` 10300.
- `CREATE_ACCESS` 11000, `REFUND_STORAGE_CLEAR` 12480,
  `TX_ACCESS_LIST_ADDRESS` 3000, `TX_ACCESS_LIST_STORAGE_KEY` 3000.
- Test constants follow suit: `REGULAR_GAS_CREATE` 11000,
  `PER_AUTH_BASE_COST` 15816, `GAS_COLD_STORAGE_WRITE` 13000.

The derived parameters now match the EIP derivation formulas exactly,
so the provisional deviation comments are dropped.

Ref: ethereum/EIPs#11802
@misilva73
misilva73 deleted the update-eip-8038 branch June 19, 2026 12:31
rakita pushed a commit to bluealloy/revm that referenced this pull request Jun 22, 2026
* feat(eip8038): finalize gas parameters to ethereum/EIPs#11802 values

Replaces the `previous_value + 1` placeholders introduced in #3697 with the
parameters proposed in ethereum/EIPs#11802:

  COLD_ACCOUNT_ACCESS  2,600 -> 3,000    STORAGE_WRITE         2,800 -> 10,000
  COLD_STORAGE_ACCESS  2,100 -> 3,000    STORAGE_CLEAR_REFUND  4,800 -> 12,480
  ACCOUNT_WRITE        6,700 -> 8,000    CREATE_ACCESS         7,000 -> 11,000
  ACCESS_LIST_ADDRESS  2,400 -> 3,000    ACCESS_LIST_KEY       1,900 -> 3,000

- WARM_ACCESS is restored to 100; the placeholder bumped it to 101 but the spec
  leaves it unchanged.
- CREATE_ACCESS, the access-list costs and CALL_VALUE now use the spec's
  derivations (ACCOUNT_WRITE + COLD_STORAGE_ACCESS, COLD_*_ACCESS, and
  ACCOUNT_WRITE + CALL_STIPEND).
- EIP7702_PER_EMPTY_ACCOUNT_REGULAR is recomputed from the EIP-8037 base plus
  the EIP-8038 deltas (ACCOUNT_WRITE, COLD_ACCOUNT_ACCESS); the ecRecover and
  calldata terms are unchanged by EIP-8038.
- Adds constant and gas-table conformance tests.

ethereum/EIPs#11802 is still an open draft, so these values are preliminary.

* test(eip8038): regenerate eip8037 snapshots for finalized values

The eip8037 ee-test snapshots run at SpecId::AMSTERDAM and therefore bake in the
EIP-8038 parameters. Regenerated for the finalized values: state gas is
unchanged; regular gas reflects the new access/write costs (e.g. CREATE +3,999,
SELFDESTRUCT-to-empty +1,698, SSTORE clear now hitting the 20% refund cap).
rakita added a commit to alloy-rs/evm2 that referenced this pull request Jun 22, 2026
… execution-specs

Implements the Glamsterdam state-access gas changes for AMSTERDAM, taking
execution-specs (EELS, [email protected]) as the authority rather than
revm, which has several gas bugs here that the EELS fixtures reject.

EIP-8038 (state-access gas cost update, ethereum/EIPs#11802):
  WARM_ACCESS 100 (unchanged), COLD_ACCOUNT_ACCESS/COLD_STORAGE_ACCESS 3000,
  ACCOUNT_WRITE 8000, STORAGE_WRITE 10000, STORAGE_CLEAR_REFUND 12480,
  CREATE_ACCESS 11000. EXTCODESIZE/EXTCODECOPY get a second-read WARM_ACCESS in
  the static table. Cold SSTORE access is the full COLD_STORAGE_ACCESS (3000),
  so the cold add-on is the premium (2900) on top of the always-charged warm
  base, dropping the pre-8038 EIP-2929 warm double-count.

EIP-2780 (reduce intrinsic transaction gas):
  Decomposed intrinsic TX_BASE(12000) + to-cost + value-cost, replacing the flat
  21000 base; the EIP-7623 calldata floor base also drops to TX_BASE. Call
  value-cost is TRANSFER_LOG_COST + TX_VALUE_COST(4244); self-transfers pay
  neither to- nor value-cost. New `EIP2780` feature (auto-on at AMSTERDAM) and
  GasIds TxTransferLogCost/TxValueCost/TxCreateAccessCost. Top-level (depth-0)
  charges: an extra COLD_ACCOUNT_ACCESS for EIP-7702-delegated recipients (and
  warming the delegation target), and new_account_state_gas for empty recipients
  receiving value; precompiles are exempt.

Diverges from revm per EELS: TX_BASE 12000 (revm 12300), floor base 12000 (revm
21000), value-cost via TX_VALUE_COST 4244 (revm ACCOUNT_WRITE 8000), SSTORE cold
3000 (revm 3100), and warming the delegation target.
rakita added a commit to bluealloy/revm that referenced this pull request Jun 29, 2026
…1.0) (#3778)

* feat(eip8038): finalize gas parameters per ethereum/EIPs#11802 (#3771)

* feat(eip8038): finalize gas parameters to ethereum/EIPs#11802 values

Replaces the `previous_value + 1` placeholders introduced in #3697 with the
parameters proposed in ethereum/EIPs#11802:

  COLD_ACCOUNT_ACCESS  2,600 -> 3,000    STORAGE_WRITE         2,800 -> 10,000
  COLD_STORAGE_ACCESS  2,100 -> 3,000    STORAGE_CLEAR_REFUND  4,800 -> 12,480
  ACCOUNT_WRITE        6,700 -> 8,000    CREATE_ACCESS         7,000 -> 11,000
  ACCESS_LIST_ADDRESS  2,400 -> 3,000    ACCESS_LIST_KEY       1,900 -> 3,000

- WARM_ACCESS is restored to 100; the placeholder bumped it to 101 but the spec
  leaves it unchanged.
- CREATE_ACCESS, the access-list costs and CALL_VALUE now use the spec's
  derivations (ACCOUNT_WRITE + COLD_STORAGE_ACCESS, COLD_*_ACCESS, and
  ACCOUNT_WRITE + CALL_STIPEND).
- EIP7702_PER_EMPTY_ACCOUNT_REGULAR is recomputed from the EIP-8037 base plus
  the EIP-8038 deltas (ACCOUNT_WRITE, COLD_ACCOUNT_ACCESS); the ecRecover and
  calldata terms are unchanged by EIP-8038.
- Adds constant and gas-table conformance tests.

ethereum/EIPs#11802 is still an open draft, so these values are preliminary.

* test(eip8038): regenerate eip8037 snapshots for finalized values

The eip8037 ee-test snapshots run at SpecId::AMSTERDAM and therefore bake in the
EIP-8038 parameters. Regenerated for the finalized values: state gas is
unchanged; regular gas reflects the new access/write costs (e.g. CREATE +3,999,
SELFDESTRUCT-to-empty +1,698, SSTORE clear now hitting the 20% refund cap).

* feat(amsterdam): align EIP-2780/8037/8038/7702 gas with devnet-6 (v6.1.0)

Fixes near-universal Amsterdam state-test failures by correcting gas
parameters to the finalized glamsterdam-devnet-6 (EELS v6.1.0) values,
matching the reference implementation:

- EIP-8038: cherry-pick finalized parameters (#3771): COLD_*_ACCESS 3000,
  ACCOUNT_WRITE 8000, STORAGE_WRITE 10000, etc.
- EIP-8038: cold SSTORE folds warm base into cold cost - cold_storage_cost
  uses the additional (2900) since sstore_static (warm 100) is charged
  separately, fixing a 100-gas overcharge on nearly every SSTORE.
- EIP-8038: new_account_cost is 0 (value CALL already pays ACCOUNT_WRITE via
  CALL_VALUE); SELFDESTRUCT keeps the separate ACCOUNT_WRITE.
- EIP-2780: TX_BASE 12300->12000, add TX_VALUE_COST (4244) for value calls,
  implement the self-transfer carve-out (base only), floor base ->12000.
- EIP-7702: per-auth regular gas 15816 (incl. ACCOUNT_WRITE), refund
  ACCOUNT_WRITE (8000) per existing auth, and refund rejected auths under
  EIP-8037 (regular + state).
- Update eip2780 ee-tests and regenerate eip8037 snapshots.

Amsterdam state-test failures: 2289 -> 204.

* fix(eip8037): track spilled state gas so halts consume it (reservoir model)

revm's GasTracker did not distinguish state gas drawn from the reservoir
from state gas that spilled into regular gas when the reservoir was empty.
On an exceptional halt the spilled portion was wrongly credited back to the
reservoir (and refunded via the gas_used = spent - reservoir formula)
instead of consumed, so every revert/halt/OOG test that charged state gas
computed too little gas.

Mirror evm2's GasTracker: add a state_gas_spilled counter, credit it back to
remaining (LIFO) on rollback via rollback_state_gas, and propagate it to the
parent on success. handle_reservoir_remaining_gas and the top-level
last_frame_result now settle a failing frame (rollback state gas, drop the
refund counter) and, on halt, additionally spend_all the regular gas — so
the spilled state gas is consumed while the reservoir is restored to its
inherited value. refill_reservoir credits remaining-before-reservoir to match.

Update the spend_all ee-test and regenerate snapshots.

Amsterdam state-test failures: 204 -> 68.

* fix(revme): map modern fork names, skip unknown specs in statetest

State-test fixtures key the post section by fork name, and newer EEST
fixtures use the descriptive names 'TangerineWhistle' / 'SpuriousDragon'
instead of 'EIP150' / 'EIP158'. These deserialized to SpecName::Unknown,
whose to_spec_id() panics, aborting the runner thread (observed running
the glam-v601 fixtures with stest --keep-going).

- Add serde aliases so TangerineWhistle->EIP150 and SpuriousDragon->EIP158
  map to the correct spec and those tests actually run.
- Skip SpecName::Unknown in the statetest runner (alongside the existing
  Constantinople skip) so any genuinely unmapped fork is skipped instead
  of panicking.

* fix(eip2780): apply depth-0 delegate/state-gas charges to the executing frame

The EIP-2780 top-level (depth-0) charges — the extra COLD_ACCOUNT_ACCESS for a
7702-delegated recipient and the new_account state gas for an empty value
recipient — were applied to a local Gas only used on early-return paths (empty
bytecode, precompile, halt). When the recipient executed code, EthFrame::clear
rebuilt the interpreter's gas from the raw gas_limit, discarding the charges.

- Load the recipient with code so the 7702 designator is read.
- Carry the charged Gas into the interpreter after clear() so the charges affect
  remaining/reservoir/state gas during execution.

Amsterdam state-test failures: 68 -> 32.

* fix(eip8037): refund upfront new_account_state_gas when a CALL fails

A CALL transferring value to an empty recipient charges new_account_state_gas
upfront on the parent's tracker. When the call does not create the account
(revert, halt, or early failure such as insufficient balance), that charge must
be refunded to the parent's reservoir. The child-frame rollback in
handle_reservoir_remaining_gas cannot do it because the charge lives on the
parent. Mirror the CREATE path's create_state_gas refill using the propagated
charged_new_account_state_gas flag.

Amsterdam state-test failures: 32 -> 23.

* fix(eip8037): refund create_state_gas when CREATE targets an already-alive account

Per EIP-8037 (execution-specs created_target_alive), a CREATE/CREATE2 that
succeeds at a pre-existing alive (non-empty, e.g. balance-only) address does
not create a new account leaf, so the upfront create_state_gas must be
refunded — the same refill the create-failed path already performs.

Track target_was_alive (captured before the create checkpoint) through
CreateFrame and CreateOutcome, and refund create_state_gas when the create
failed OR the target was already alive.

Amsterdam state-test failures: 23 -> 8 (clears CREATE-to-existing-account
cases across eip7997 factory, stCreate2 collisions, selfdestruct, etc.).

* fix(eip7702): mirror execution-specs auth-base refund (delegated_before_tx + double-refill)

revm's apply_auth_list only refunded the per-auth AUTH_BASE state gas when the
authority was currently delegated or being cleared. Execution-specs (and evm2)
also refund it when the authority was delegated at the start of the transaction
(delegated_before_tx, using the account's original code), and refund it twice
when clearing a delegation that was freshly installed earlier in the same tx.

Recompute existed/delegated_now/delegated_before_tx/clearing per authorization
and apply the spec's refund rules.

Amsterdam state-test failures: 8 -> 4.

* fix(eip8037): refund create_state_gas for top-level CREATE at an alive target

Extend the create_state_gas refund to the top-level CREATE transaction: when
the create succeeds at a pre-existing alive (balance-only) address, no new
account leaf is created, so the intrinsic create_state_gas charged at tx entry
is refunded — matching the nested-create path. Threads target_was_alive from
the CreateOutcome into last_frame_result.

Amsterdam state-test failures: 4 -> 0. The full glam-v601 state-test suite
now passes (all forks).

* feat(revme): print an error for unknown post-state spec instead of skipping silently

An unmapped post-state fork (SpecName::Unknown) is still skipped to avoid
panicking in to_spec_id, but now reports the offending test path on stderr so
unsupported specs are visible rather than silently ignored.

* feat(revme): EIP-8282 builder system calls in btest + ForkSpec fork aliases

- Add the EIP-8282 builder execution-request system calls (builder deposit
  0x..884d type 0x03, builder exit 0x..14574a type 0x04) to the blockchain-test
  post-block transition, gated on Amsterdam, so they are warmed and appear in
  the Block Access List (EIP-7928) as the v6.1.0 fixtures expect.
- Map the modern ForkSpec names TangerineWhistle->EIP150 and
  SpuriousDragon->EIP158 (serde aliases) so those blockchain-test fixtures decode.

Blockchain-test failures: 2852 -> 7.

* fix(eip7928): record SSTORE slot access in BAL even when the cold load OOGs

SSTORE skipped the cold storage load when there was not enough gas to pay the
cold cost (an optimization to avoid a DB read before a certain out-of-gas).
That also skipped warming the slot, so EIP-7928 block access lists omitted the
accessed slot. Always cold-load the slot for SSTORE: the out-of-gas outcome is
unchanged (the cold charge still fails), but the access is now recorded. The
skip is retained for CALL, where EIP-7928 defers EIP-7702 delegation warming.

Blockchain-test failures: 7 -> 6.

* fix(eip7928): preserve self-destructed slot accesses in BAL under EIP-8246

When EIP-8246 preserves a self-destructed account's balance, it cleared the
account's storage map (storage.clear()) before the block access list was
captured, dropping the slot accesses that occurred during execution. EIP-7928
records those accesses, so the BAL was missing read-only (and write-to-zero)
slots on created-then-self-destructed accounts.

Wipe the storage values in place (present_value = 0) instead of dropping the
entries: the committed state is still an empty balance-only account, but the
slot accesses survive into the BAL — read-only slots stay read-only and written
slots become writes-to-zero.

Blockchain-test failures: 6 -> 0. The full glam-v601 blockchain-test and
state-test suites now pass.

* fix(eip2780): charge new_account_state_gas for value transfers to precompiles

The glamsterdam v6.1.0 fixtures (glam-v610) charge the EIP-8037
new_account_state_gas when a top-level transaction transfers value to an empty
precompile/special address. revm skipped the EIP-2780 depth-0 charges entirely
for precompile recipients, so the state gas was missing.

- Remove the precompile carve-out from the depth-0 EIP-2780 charge so an empty
  precompile recipient with value is charged new_account_state_gas (matching
  evm2's eip2780_call_charges, which has no precompile exception).
- The precompile path returns its own result gas (not the local depth-0 gas), so
  re-apply the state-gas charge to result.gas. Gate it on depth == 0: a precompile
  reached by a CALL opcode already had the charge applied on the parent's tracker
  (avoiding a double charge).

glam-v610 blockchain-test failures: 7 -> 0. State tests and full workspace pass.

---------

Co-authored-by: CPerezz <[email protected]>
rakita added a commit to alloy-rs/evm2 that referenced this pull request Jul 1, 2026
…38 gas model (#206)

Implements the Amsterdam (Glamsterdam) gas model, aligned to
`ethereum/execution-specs` (EELS). The core is the **EIP-8037 dual-limit
reservoir**; the remaining Amsterdam gas EIPs are layered on top.

## EIP-8037 — state-gas reservoir
**State gas** (storage / account / code creation) draws from a
**reservoir** threaded through call frames, separate from regular
execution gas.
- **`gas.rs`** — `state_gas_spent` is `i64` (can go negative within a
frame when 0→x→0 restorations refill more than the frame charged);
`refill_reservoir`.
- **Child-frame reconciliation** — moved onto `MessageResult` /
`merge_child_gas`: on success the parent takes the child's final
reservoir and accumulates `state_gas_spent`; on revert/halt it restores
`reservoir + state_gas_spent` (signed). Wired into `call_inner` /
`create_inner`.
- **Reservoir threading** — `Message.reservoir`, interpreter `Gas` via
`new_with_regular_gas_and_reservoir`, preserved across precompile/error
results.
- **Charge sites** — CREATE/CREATE2 upfront `create_state_gas` (+ refill
on child failure), CALL new-account state gas, SELFDESTRUCT topup,
code-deposit state gas + keccak hash cost, SSTORE 0→x→0 reservoir
refill.
- **Spill semantics** — track spilled state gas, **burn on halt / return
on revert**.
- **Block header** — validate block-level regular/state gas; on-failure
state-gas breakdown.
- **Top level** — `initial_gas_and_reservoir` splits tx gas into a
regular budget + reservoir across all 5 tx handlers; leftover reservoir
reimbursed to the caller.
- **CPSB** — `CPSB=1530`, 64 SSTORE bytes, 120 account/create bytes.

## EIP-7702 (Amsterdam) — set-code transactions
- Auth-list **state gas**, intrinsic validation, and failed-create
refund wired through the reservoir.
- Per-auth **regular** gas = `ACCOUNT_WRITE +
REGULAR_PER_AUTH_BASE_COST` = `8000 + (101·16 + 3000 + 3000 + 2·100)` =
**15816** per EELS (was a stale 9200).

## EIP-2780 / EIP-8038 — intrinsic + state-access gas
- **EIP-8038**: finalized state-access gas values
(`ethereum/EIPs#11802`) — COLD_ACCOUNT_ACCESS 3000, ACCOUNT_WRITE 8000,
STORAGE_WRITE 10000, etc. (WARM_ACCESS unchanged at 100).
- **EIP-2780**: decomposed intrinsic tx gas (sender base 12000 +
`tx.to`- and `tx.value`-based charges), aligned to EELS.

## EIP-7976 / EIP-7981 — calldata floor + access list
- **EIP-7976**: calldata floor counts every byte uniformly (zero bytes
weigh 4 tokens, not 1) via new `TxFloorZeroByteMultiplier` gas param.
- **EIP-7981**: access-list data cost (64 gas/byte) baked into per-item
costs and added to the floor token count.

## EIP-3529
- Exclude the idle state-gas reservoir from the refund cap (`spent =
gas_limit − remaining − reservoir`); otherwise a large idle reservoir
inflates `spent` and disables the cap.

## Validation
- **All Amsterdam state tests pass: 3365 / 3365.**
- Full devnet EEST suite (`EVM2_STATETEST_DEVNET_ONLY=1`): **26948 /
26948 pass** (341 skip).
- `eip7981_increase_access_list_cost`: **12/12**.
- All `evm2` unit tests pass; `cargo cl` and `cargo fmt` clean.

---------

Co-authored-by: DaniPopes <[email protected]>
rakita added a commit to bluealloy/revm that referenced this pull request Jul 6, 2026
* feat(eip8038): implement state-access gas cost update

Adds EIP-8038 parameters (gated at AMSTERDAM alongside EIP-7904/EIP-8037).
Per the user-supplied rule, every TBD value in the draft spec is set to
`previous_value + 1`:

  WARM_ACCESS                  100 -> 101
  COLD_ACCOUNT_ACCESS        2,600 -> 2,601
  ACCOUNT_WRITE              6,700 -> 6,701
  COLD_STORAGE_ACCESS        2,100 -> 2,101
  STORAGE_WRITE              2,800 -> 2,801
  STORAGE_CLEAR_REFUND       4,800 -> 4,801
  CREATE_ACCESS              7,000 -> 7,001
  ACCESS_LIST_ADDRESS_COST   2,400 -> 2,401
  ACCESS_LIST_STORAGE_KEY_COST 1,900 -> 1,901

Wires the new values through the GasParams table (account/storage access,
SSTORE charges and refunds, CREATE/CREATE2, EIP-7702 per-auth regular cost,
access-list per-item costs) and bumps the static gas table for warm-access
opcodes. EXTCODESIZE and EXTCODECOPY get an extra WARM_ACCESS baked into
their static cost per the EIP "EXT* family update" rule. Existing EIP-8037
snapshot tests refreshed; one Amsterdam access-list unit test updated.

* feat(eip2780): reduce intrinsic transaction gas

Adds EIP-2780 (Reduce intrinsic transaction gas) on top of EIP-8037 /
EIP-8038, tracking the
https://github.com/misilva73/EIPs/blob/update-eip-2780/EIPS/eip-2780.md
draft. Replaces the legacy 21,000 stipend with a decomposed model:

  TX_BASE_COST                 12,300  (sender base + ECDSA + sender access/write)
  + to-based  (per recipient kind)
    - cold EOA/contract        COLD_ACCOUNT_ACCESS  (sourced from eip8038)
    - create                   CREATE_ACCESS        (sourced from eip8038)
  + value-based
    - zero                     0
    - create with value        TRANSFER_LOG_COST
    - other                    TRANSFER_LOG_COST + ACCOUNT_WRITE

The current draft's self-transfer and precompile zero-charge carve-outs
are intentionally not implemented — a future revision is expected to
drop them, so self-transfers and precompile transfers pay the same
to/value charges as any other recipient.

Adds an `enable_amsterdam_eip2780` config flag (auto-enabled at AMSTERDAM,
paired with `Cfg::is_amsterdam_eip2780_enabled`) and `Eip2780TxInfo`
(just the transferred value) plumbed into `GasParams::initial_tx_gas`.
Validation in the handler builds the info when EIP-2780 is enabled.
`tx_transfer_log_cost`, `tx_account_write_cost`, and
`tx_create_access_cost` GasIds are added and populated in the AMSTERDAM
block.

Implements the top-level execution charges from EIP-2780 in
`EthFrame::make_call_frame` (depth == 0):
- If recipient is EIP-7702-delegated, charge an additional
  `COLD_ACCOUNT_ACCESS` of regular gas.
- If recipient is empty per EIP-161 and `tx.value > 0`, charge
  `new_account_state_gas(cpsb)` of state gas. The existing
  `last_frame_result` reservoir reconciliation refunds it on revert.

Existing EIP-8037 helpers in `eip8037.rs` explicitly disable EIP-2780
so the state-gas-reservoir tests stay focused. Bumps one EIP-7708 test's
gas limit to fit the new ~207k intrinsic for value transfer creating a
new account. Adds an `eip2780.rs` ee-tests module covering self-transfer,
EOA, empty-with-value, create with/without value, and the
legacy-fallback path.

* feat(eip7954): bump max code size to 64 KiB and initcode to 128 KiB (#3707)

Raises EIP-7954 limits for the glam devnet: MAX_CODE_SIZE from
0x8000 → 0x10000 (65,536 bytes) and MAX_INITCODE_SIZE from
0x10000 → 0x20000 (131,072 bytes). Updates the affected validation
test to push the new oversize threshold and refreshes related
comments.

* feat(context): implement EIP-8246 (remove SELFDESTRUCT burn) (#3717)

Replace the EIP-7708 burn-log mechanism with EIP-8246 semantics: at
transaction finalization, self-destructed accounts that still hold a
balance keep it and have their code, storage and nonce cleared instead
of the balance being burned. Self-destruct to self no longer burns the
balance either.

- Rename `eip7708_emit_burn_remaining_balance_logs` to
  `eip8246_clear_selfdestructed_accounts`; clear accounts (code,
  storage, nonce) and drop the self-destruct flag instead of emitting
  burn logs, preserving the balance.
- Stop zeroing the balance / emitting a burn log for self-destruct to
  self under Amsterdam.
- Remove the now-dead `eip7708_burn_log` helper.
- Rename the `eip7708_delayed_burn_disabled` flag to
  `eip8246_delayed_clear_disabled` (CfgEnv field, Cfg accessor and
  JournalCfg field).

* fix(eip-8037): exclude floor and refund from block_regular_gas_used (#3719)

* fix(eip-8037): apply EIP-7778 branching to block_regular_gas_used

Replace `max(total_gas_spent - state_gas_spent, floor_gas)` with the
conditional formula from EIP-8037 + EIP-7778 (PR ethereum/EIPs#11706):

- Floor-dominant (floor_gas >= total_gas_spent - refunded):
  block_regular = tx_gas_used - state_gas_spent
- Refund-dominant: block_regular = total_gas_spent - state_gas_spent
  (pre-refund, since refunds are excluded from block accounting)

Floor gas no longer participates as a `max(...)` against the regular
component; it only contributes through `tx_gas_used` when it dominates
the post-refund total.

* fix(eip-8037): exclude floor and refund from block_regular_gas_used

Per EIP-8037 + EIP-7778, block-level regular gas accounting is the
pre-refund regular component of execution. Refund and floor are scalar
adjustments on the combined `state + regular` total and only affect the
receipt's `tx_gas_used`, not the block-level split.

block_regular_gas_used = total_gas_spent - state_gas_spent

* feat(amsterdam): align gas accounting & test runners to devnet-6 (v6.1.0) (#3778)

* feat(eip8038): finalize gas parameters per ethereum/EIPs#11802 (#3771)

* feat(eip8038): finalize gas parameters to ethereum/EIPs#11802 values

Replaces the `previous_value + 1` placeholders introduced in #3697 with the
parameters proposed in ethereum/EIPs#11802:

  COLD_ACCOUNT_ACCESS  2,600 -> 3,000    STORAGE_WRITE         2,800 -> 10,000
  COLD_STORAGE_ACCESS  2,100 -> 3,000    STORAGE_CLEAR_REFUND  4,800 -> 12,480
  ACCOUNT_WRITE        6,700 -> 8,000    CREATE_ACCESS         7,000 -> 11,000
  ACCESS_LIST_ADDRESS  2,400 -> 3,000    ACCESS_LIST_KEY       1,900 -> 3,000

- WARM_ACCESS is restored to 100; the placeholder bumped it to 101 but the spec
  leaves it unchanged.
- CREATE_ACCESS, the access-list costs and CALL_VALUE now use the spec's
  derivations (ACCOUNT_WRITE + COLD_STORAGE_ACCESS, COLD_*_ACCESS, and
  ACCOUNT_WRITE + CALL_STIPEND).
- EIP7702_PER_EMPTY_ACCOUNT_REGULAR is recomputed from the EIP-8037 base plus
  the EIP-8038 deltas (ACCOUNT_WRITE, COLD_ACCOUNT_ACCESS); the ecRecover and
  calldata terms are unchanged by EIP-8038.
- Adds constant and gas-table conformance tests.

ethereum/EIPs#11802 is still an open draft, so these values are preliminary.

* test(eip8038): regenerate eip8037 snapshots for finalized values

The eip8037 ee-test snapshots run at SpecId::AMSTERDAM and therefore bake in the
EIP-8038 parameters. Regenerated for the finalized values: state gas is
unchanged; regular gas reflects the new access/write costs (e.g. CREATE +3,999,
SELFDESTRUCT-to-empty +1,698, SSTORE clear now hitting the 20% refund cap).

* feat(amsterdam): align EIP-2780/8037/8038/7702 gas with devnet-6 (v6.1.0)

Fixes near-universal Amsterdam state-test failures by correcting gas
parameters to the finalized glamsterdam-devnet-6 (EELS v6.1.0) values,
matching the reference implementation:

- EIP-8038: cherry-pick finalized parameters (#3771): COLD_*_ACCESS 3000,
  ACCOUNT_WRITE 8000, STORAGE_WRITE 10000, etc.
- EIP-8038: cold SSTORE folds warm base into cold cost - cold_storage_cost
  uses the additional (2900) since sstore_static (warm 100) is charged
  separately, fixing a 100-gas overcharge on nearly every SSTORE.
- EIP-8038: new_account_cost is 0 (value CALL already pays ACCOUNT_WRITE via
  CALL_VALUE); SELFDESTRUCT keeps the separate ACCOUNT_WRITE.
- EIP-2780: TX_BASE 12300->12000, add TX_VALUE_COST (4244) for value calls,
  implement the self-transfer carve-out (base only), floor base ->12000.
- EIP-7702: per-auth regular gas 15816 (incl. ACCOUNT_WRITE), refund
  ACCOUNT_WRITE (8000) per existing auth, and refund rejected auths under
  EIP-8037 (regular + state).
- Update eip2780 ee-tests and regenerate eip8037 snapshots.

Amsterdam state-test failures: 2289 -> 204.

* fix(eip8037): track spilled state gas so halts consume it (reservoir model)

revm's GasTracker did not distinguish state gas drawn from the reservoir
from state gas that spilled into regular gas when the reservoir was empty.
On an exceptional halt the spilled portion was wrongly credited back to the
reservoir (and refunded via the gas_used = spent - reservoir formula)
instead of consumed, so every revert/halt/OOG test that charged state gas
computed too little gas.

Mirror evm2's GasTracker: add a state_gas_spilled counter, credit it back to
remaining (LIFO) on rollback via rollback_state_gas, and propagate it to the
parent on success. handle_reservoir_remaining_gas and the top-level
last_frame_result now settle a failing frame (rollback state gas, drop the
refund counter) and, on halt, additionally spend_all the regular gas — so
the spilled state gas is consumed while the reservoir is restored to its
inherited value. refill_reservoir credits remaining-before-reservoir to match.

Update the spend_all ee-test and regenerate snapshots.

Amsterdam state-test failures: 204 -> 68.

* fix(revme): map modern fork names, skip unknown specs in statetest

State-test fixtures key the post section by fork name, and newer EEST
fixtures use the descriptive names 'TangerineWhistle' / 'SpuriousDragon'
instead of 'EIP150' / 'EIP158'. These deserialized to SpecName::Unknown,
whose to_spec_id() panics, aborting the runner thread (observed running
the glam-v601 fixtures with stest --keep-going).

- Add serde aliases so TangerineWhistle->EIP150 and SpuriousDragon->EIP158
  map to the correct spec and those tests actually run.
- Skip SpecName::Unknown in the statetest runner (alongside the existing
  Constantinople skip) so any genuinely unmapped fork is skipped instead
  of panicking.

* fix(eip2780): apply depth-0 delegate/state-gas charges to the executing frame

The EIP-2780 top-level (depth-0) charges — the extra COLD_ACCOUNT_ACCESS for a
7702-delegated recipient and the new_account state gas for an empty value
recipient — were applied to a local Gas only used on early-return paths (empty
bytecode, precompile, halt). When the recipient executed code, EthFrame::clear
rebuilt the interpreter's gas from the raw gas_limit, discarding the charges.

- Load the recipient with code so the 7702 designator is read.
- Carry the charged Gas into the interpreter after clear() so the charges affect
  remaining/reservoir/state gas during execution.

Amsterdam state-test failures: 68 -> 32.

* fix(eip8037): refund upfront new_account_state_gas when a CALL fails

A CALL transferring value to an empty recipient charges new_account_state_gas
upfront on the parent's tracker. When the call does not create the account
(revert, halt, or early failure such as insufficient balance), that charge must
be refunded to the parent's reservoir. The child-frame rollback in
handle_reservoir_remaining_gas cannot do it because the charge lives on the
parent. Mirror the CREATE path's create_state_gas refill using the propagated
charged_new_account_state_gas flag.

Amsterdam state-test failures: 32 -> 23.

* fix(eip8037): refund create_state_gas when CREATE targets an already-alive account

Per EIP-8037 (execution-specs created_target_alive), a CREATE/CREATE2 that
succeeds at a pre-existing alive (non-empty, e.g. balance-only) address does
not create a new account leaf, so the upfront create_state_gas must be
refunded — the same refill the create-failed path already performs.

Track target_was_alive (captured before the create checkpoint) through
CreateFrame and CreateOutcome, and refund create_state_gas when the create
failed OR the target was already alive.

Amsterdam state-test failures: 23 -> 8 (clears CREATE-to-existing-account
cases across eip7997 factory, stCreate2 collisions, selfdestruct, etc.).

* fix(eip7702): mirror execution-specs auth-base refund (delegated_before_tx + double-refill)

revm's apply_auth_list only refunded the per-auth AUTH_BASE state gas when the
authority was currently delegated or being cleared. Execution-specs (and evm2)
also refund it when the authority was delegated at the start of the transaction
(delegated_before_tx, using the account's original code), and refund it twice
when clearing a delegation that was freshly installed earlier in the same tx.

Recompute existed/delegated_now/delegated_before_tx/clearing per authorization
and apply the spec's refund rules.

Amsterdam state-test failures: 8 -> 4.

* fix(eip8037): refund create_state_gas for top-level CREATE at an alive target

Extend the create_state_gas refund to the top-level CREATE transaction: when
the create succeeds at a pre-existing alive (balance-only) address, no new
account leaf is created, so the intrinsic create_state_gas charged at tx entry
is refunded — matching the nested-create path. Threads target_was_alive from
the CreateOutcome into last_frame_result.

Amsterdam state-test failures: 4 -> 0. The full glam-v601 state-test suite
now passes (all forks).

* feat(revme): print an error for unknown post-state spec instead of skipping silently

An unmapped post-state fork (SpecName::Unknown) is still skipped to avoid
panicking in to_spec_id, but now reports the offending test path on stderr so
unsupported specs are visible rather than silently ignored.

* feat(revme): EIP-8282 builder system calls in btest + ForkSpec fork aliases

- Add the EIP-8282 builder execution-request system calls (builder deposit
  0x..884d type 0x03, builder exit 0x..14574a type 0x04) to the blockchain-test
  post-block transition, gated on Amsterdam, so they are warmed and appear in
  the Block Access List (EIP-7928) as the v6.1.0 fixtures expect.
- Map the modern ForkSpec names TangerineWhistle->EIP150 and
  SpuriousDragon->EIP158 (serde aliases) so those blockchain-test fixtures decode.

Blockchain-test failures: 2852 -> 7.

* fix(eip7928): record SSTORE slot access in BAL even when the cold load OOGs

SSTORE skipped the cold storage load when there was not enough gas to pay the
cold cost (an optimization to avoid a DB read before a certain out-of-gas).
That also skipped warming the slot, so EIP-7928 block access lists omitted the
accessed slot. Always cold-load the slot for SSTORE: the out-of-gas outcome is
unchanged (the cold charge still fails), but the access is now recorded. The
skip is retained for CALL, where EIP-7928 defers EIP-7702 delegation warming.

Blockchain-test failures: 7 -> 6.

* fix(eip7928): preserve self-destructed slot accesses in BAL under EIP-8246

When EIP-8246 preserves a self-destructed account's balance, it cleared the
account's storage map (storage.clear()) before the block access list was
captured, dropping the slot accesses that occurred during execution. EIP-7928
records those accesses, so the BAL was missing read-only (and write-to-zero)
slots on created-then-self-destructed accounts.

Wipe the storage values in place (present_value = 0) instead of dropping the
entries: the committed state is still an empty balance-only account, but the
slot accesses survive into the BAL — read-only slots stay read-only and written
slots become writes-to-zero.

Blockchain-test failures: 6 -> 0. The full glam-v601 blockchain-test and
state-test suites now pass.

* fix(eip2780): charge new_account_state_gas for value transfers to precompiles

The glamsterdam v6.1.0 fixtures (glam-v610) charge the EIP-8037
new_account_state_gas when a top-level transaction transfers value to an empty
precompile/special address. revm skipped the EIP-2780 depth-0 charges entirely
for precompile recipients, so the state gas was missing.

- Remove the precompile carve-out from the depth-0 EIP-2780 charge so an empty
  precompile recipient with value is charged new_account_state_gas (matching
  evm2's eip2780_call_charges, which has no precompile exception).
- The precompile path returns its own result gas (not the local depth-0 gas), so
  re-apply the state-gas charge to result.gas. Gate it on depth == 0: a precompile
  reached by a CALL opcode already had the charge applied on the parent's tracker
  (avoiding a double charge).

glam-v610 blockchain-test failures: 7 -> 0. State tests and full workspace pass.

---------

* ci: fix failing checks on glam-devnet-6

- run-tests.sh: download [email protected] fixtures instead of
  [email protected], which predates the Amsterdam consensus changes in
  this branch and expected stale intrinsic-gas values.
- gas_params.rs: drop private intra-doc link to fix `cargo doc` under
  -D rustdoc::private_intra_doc_links.
- Cargo.lock: bump anyhow 1.0.102 -> 1.0.103 to clear RUSTSEC-2026-0190.

* docs: fix unescaped backtick from multi-line code span in eip8038
kevaundray added a commit to kevaundray/ethrex that referenced this pull request Aug 12, 2026
…pecs

ethrex implemented EIP-8038 as merged in ethereum/EIPs#11802 and the EIP has
since been revised. Values are taken from
execution-specs `src/ethereum/forks/amsterdam/vm/gas.py::GasCosts`:

  COLD_STORAGE_ACCESS         3000  -> 2100
  ACCOUNT_WRITE               8000  -> 9000
  CALL_VALUE                 10300  -> 11300   (ACCOUNT_WRITE + CALL_STIPEND)
  CREATE_ACCESS              11000  -> 12000   (ACCOUNT_WRITE + COLD_ACCOUNT_ACCESS)
  TX_ACCESS_LIST_STORAGE_KEY  3000  ->  2000   (COLD_STORAGE_ACCESS - WARM_ACCESS)
  TX_ACCESS_LIST_ADDRESS      3000  ->  2900   (COLD_ACCOUNT_ACCESS - WARM_ACCESS)
  REFUND_STORAGE_CLEAR       12480  -> 11616   ((STORAGE_WRITE + COLD_STORAGE_ACCESS) * 4800 / 5000)

Only COLD_STORAGE_ACCESS and ACCOUNT_WRITE actually move; the other five are
now written as the derivations the spec writes, so the next repricing moves one
literal instead of five. COLD_ACCOUNT_ACCESS (3000), STORAGE_WRITE (10000),
TX_BASE (12000), PER_AUTH_BASE_COST (7816) and the EIP-8037 constants already
agreed and are untouched.

Tests updated. Every one of them pinned a DRIFTED CONSTANT and is retuned to
the spec value, not to whatever the code now emits:

  test/tests/levm/eip8038_tests.rs
    test_cold_sload_amsterdam_is_3000 -> ..._is_2100, test_access_list_selectors,
    test_access_list_intrinsic_per_address_amsterdam,
    test_access_list_intrinsic_per_key_amsterdam, and the eight SSTORE
    table rows (cold access 3000 -> 2100, clear refund 12480 -> 11616);
    test_call_positive_value_selector_amsterdam_is_10300 -> ..._is_11300,
    test_call_upfront_value_amsterdam_is_10300 -> ..._is_11300;
    test_selfdestruct_amsterdam_adds_account_write_regular and
    test_selfdestruct_full_vm_positive_balance_to_empty (8000 -> 9000).
    The Osaka controls in the same file are untouched, as are every
    COLD_ACCOUNT_ACCESS (3000) expectation.

  test/tests/levm/eip8037_tests.rs
    test_set_delegation_self_sponsored_no_account_write_amsterdam had its own
    `const ACCOUNT_WRITE: u64 = 8000` copy of the drifted value; 9000 per
    execution-specs amsterdam/vm/eoa_delegation.py:299.

  test/tests/levm/eip2780_tests.rs, test/tests/blockchain/mempool_tests.rs
    CREATE_ACCESS_AMSTERDAM 11000 -> 12000 in the local copy and the doc
    comments derived from it.

One test changed what it covers, and it is NOT a drifted-constant retune:

  test_sstore_cold_access_boundary_amsterdam_no_bal_read_on_oog pinned GENUINE
  behaviour — an SSTORE that fails the pre-state gas gate must not record the
  slot to the BAL (EIP-7928) — but it probed that gate at 2500 gas remaining,
  a window that only existed because cold storage access was above the 2300
  stipend. At the spec's 2100 the gate is always `max(2100, 2301) = 2301`, so
  the window is gone. The BAL assertion is kept and re-anchored at 2200 gas;
  the comment records that the `max()` is now inert for storage, that this
  case no longer covers "access cost exceeds the stipend", and that nothing
  else does either.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c-update Modifies an existing proposal s-draft This EIP is a Draft t-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants