Skip to content

Update EIP-2780: move state-dependent charges to runtime (cold surcharge, new-account state gas) - #11844

Merged
eth-bot merged 12 commits into
ethereum:masterfrom
rakita:fixeip2780
Jul 7, 2026
Merged

eth-bot merged 12 commits into
ethereum:masterfrom
rakita:fixeip2780

Conversation

@rakita

@rakita rakita commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Updates EIP-2780 so that intrinsic gas is the bare minimum needed to include a transaction in a block, with all state-dependent charges moved to the runtime phase: account access is split into an intrinsic warm-access floor plus a runtime cold surcharge, and the create-transaction new-account state gas is charged conditionally at runtime.

Changes

  • Access split: WARM_ACCESS is charged at the intrinsic phase (state-independent floor); the cold surcharge COLD_ACCOUNT_ACCESS − WARM_ACCESS is charged at runtime only when the account is actually cold. Applied to both the recipient and EIP-7702 authorities. Totals are unchanged.
  • Create transactions: STATE_BYTES_PER_NEW_ACCOUNT × CPSB moves from the intrinsic phase to runtime and is charged only when the deployment target does not already exist — the existence check reads state, so it is part of the runtime phase. Added a reference case showing that a create to a pre-existing target (created_address.balance > 0) pays no new-account state gas.
  • Motivation: reworked the intrinsic/runtime framing — intrinsic gas as the state-independent minimum "gas to include the tx in a block," removal of the overcharging in worst-case flat reservations, and halting in the pre-execution phase metered like a CALL frame's OOG handling.
  • Runtime phase: noted the regular-gas / state-gas split per EIP-8037.
  • Consistency: updated the reference-cases table, test cases, and the EIP-2929 / EIP-7623 / EIP-7702 interaction notes; added the WARM_ACCESS term to the EIP-7623 floor base.

All intrinsic + runtime totals still match the legacy headline numbers (15,000 / 21,000 / 24,000 / 23,000 / 24,756, plus 183,600 state where applicable).

Split account access into an intrinsic warm floor (WARM_ACCESS) and a
runtime cold surcharge (COLD_ACCOUNT_ACCESS - WARM_ACCESS) for both the
recipient and EIP-7702 authorities. Rework the Motivation intrinsic/runtime
framing, note the regular/state gas split in the runtime phase, and update
the reference-cases table, test cases, and EIP-2929/7623/7702 interactions
for consistency. Totals are unchanged.
@github-actions github-actions Bot added c-update Modifies an existing proposal s-draft This EIP is a Draft t-core labels Jul 1, 2026
@eth-bot

eth-bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

✅ All reviewers have approved.

@eth-bot eth-bot added the a-review Waiting on author to review label Jul 1, 2026
@rakita rakita changed the title Update EIP-2780: warm-access floor intrinsic, cold surcharge at runtime Update EIP-2780: move state-dependent charges to runtime (cold surcharge, new-account state gas) Jul 2, 2026
@rakita
rakita marked this pull request as ready for review July 2, 2026 11:28
@rakita
rakita requested a review from eth-bot as a code owner July 2, 2026 11:28
Comment thread EIPS/eip-2780.md Resolved
Comment thread EIPS/eip-2780.md Resolved
Comment thread EIPS/eip-2780.md Outdated
The intrinsic gas is the state-independent cost of including the transaction in a block, computed without any state access, and is the sole input to the transaction-validity gas check. It is the sum of:

- `TX_BASE_COST` in regular gas — one ECDSA recovery, the sender's account access and write, and the inclusion of the transaction's bytes in the block — charged for every transaction;
- if `tx.to` is not `None` and the transaction is not a self-transfer (`tx.sender != tx.to`), `WARM_ACCESS` in regular gas — the state-independent floor of the recipient touch; the cold surcharge, if any, is charged at runtime;

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 don't think we should charge WARM_ACCESS here and then adjust to COLD_ACCESS_COST. We should always charge COLD_ACCESS_COST. In fact, I don't see why we are changing so much this part of the spec.

From my understanding, the only change should be delaying the STATE_BYTES_PER_NEW_ACCOUNT × CPSB charge for contract deployments.

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 don't think we should charge WARM_ACCESS here and then adjust to COLD_ACCESS_COST. We should always charge COLD_ACCESS_COST. In fact, I don't see why we are changing so much this part of the spec.

So we should overcharge and then refund if account is warm

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.

We will always charge, and skip the refund

Comment thread EIPS/eip-2780.md Resolved
Co-authored-by: Maria Inês Silva <[email protected]>
Comment thread EIPS/eip-2780.md Resolved
Comment thread EIPS/eip-2780.md Outdated

### Transaction's top-level gas costs
- if the authority address is cold — not already in `accessed_addresses`, per [EIP-2929](./eip-2929.md) — charge the cold surcharge `COLD_ACCOUNT_ACCESS − WARM_ACCESS` in regular gas;
- if the authority did not exist, charge `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` in state gas and `ACCOUNT_WRITE` in regular gas for the new account leaf;

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.

It's not true for AccountWrite.

The AccountWrite should be charged for any valid authorization, regardless of the authority was existent or not, or the delegation net change is empty or not.

For any valid authorization, the nonce of authority will be bumped and database write will happen anyway.

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.

Let's extend it with one more rule:

- if the authority account does not already exist, charge STATE_BYTES_PER_NEW_ACCOUNT × CPSB in state gas for creating the new account leaf;
- if this is the first update to the authority within the transaction(    differs from tx.to), charge ACCOUNT_WRITE in regular gas for updating the account.

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.

Thanks, have used those rules

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.

Just realize the authority can also be tx.from.

We should improve it with

- if this is the first update to the authority within the transaction(e.g. differ from tx.from and tx.to), charge ACCOUNT_WRITE in regular gas for updating the account.

Comment thread EIPS/eip-2780.md Resolved
Comment thread EIPS/eip-2780.md Outdated
During execution, before any opcode is executed, the recipient account is loaded and the following gas costs are charged:
`REGULAR_PER_AUTH_BASE_COST` prices the authority access at the warm rate; the cold surcharge above is the only account-access charge added at runtime for the authority.

Then the recipient account is loaded, and unless the transaction is a self-transfer or a contract creation:

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.

What if the self-transfer is to myself but I have a delegation set, this cannot just cost 12k

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.

It will cost an additional cold load for delegates.

Comment thread EIPS/eip-2780.md
- otherwise, there are no charges.
- if the recipient is an [EIP-7702](./eip-7702.md) delegated account, additionally charge the delegation-target access in regular gas — `COLD_ACCOUNT_ACCESS` if cold, `WARM_ACCESS` if warm.

For a contract-creation transaction, the account at the deployment address is loaded instead; if it does not already exist, per the existence rule of [EIP-8037](./eip-8037.md), charge `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` in state gas. Whether the target exists can only be determined by reading state, so the check is part of the runtime phase.

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.

This conflicts with 8037:
8037 says to chargs upfront and give it back afterwards if target existed, and this pr would first look at the target and only charge if it doesn't exist.

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.

True, i maybe rushed it. @chfast did propose to change this behaviour here

Will revert back to how it is currently specified in EIP-8037

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.

Flagging that this conflict still exists. I think part of confusion and contradictions come from the fact that both EIPs depend on each other (EIP-8037 depends on EIP-2780, and vice-versa), which makes it unclear what EIP should specify what exactly.

Comment thread EIPS/eip-2780.md Resolved
Comment thread EIPS/eip-2780.md Resolved
Comment thread EIPS/eip-2780.md Outdated
7. Contract-creation transaction, `value > 0`: `24,756` regular, `183,600` state.
8. EIP-7702 transaction: `TX_BASE_COST` is unchanged even when the sender assumes code; access-list and authorization costs are unchanged.
1. Self-transfer (`from == to`): `12,000` intrinsic, `0` runtime.
2. Zero-value transaction to any address (existing, empty, or contract): `12,100` intrinsic (`TX_BASE_COST + WARM_ACCESS`) + `COLD_ACCOUNT_ACCESS − WARM_ACCESS` runtime = `15,000` regular, `0` state. A self-target is `12,000` with no runtime charge.

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.

Suggested change
2. Zero-value transaction to any address (existing, empty, or contract): `12,100` intrinsic (`TX_BASE_COST + WARM_ACCESS`) + `COLD_ACCOUNT_ACCESS − WARM_ACCESS` runtime = `15,000` regular, `0` state. A self-target is `12,000` with no runtime charge.
2. Zero-value transaction to a cold recipient (existing, empty, or contract): 12,100 intrinsic (TX_BASE_COST + WARM_ACCESS) + COLD_ACCOUNT_ACCESS − WARM_ACCESS runtime = 15,000 regular, 0 state. If the recipient is already warm, a precompile, the COINBASE (per EIP-3651), or an EIP-2930 access-list entry, the runtime cold surcharge does not apply: 12,100 regular, 0 state. A self-target is 12,000 with no runtime charge.

Comment thread EIPS/eip-2780.md Resolved

@jochem-brouwer jochem-brouwer 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.

I did review up to but not including the test cases.

I get the idea, but this is extremely complex and the test cases here are exploding. We have the BAL interactions which depend on "when" a state is read, we have changes to EIP-7702 intrinsic gas costs, we seem to have a change in behavior of EIP-7702 delegations in case the pre-execution gas OOGs, it seems we can OOG but get a refund (?), we also have the interactions with the floor gas - is all the gas consumed as execution gas (I assume so, but this should be declared). There are also the interactions with EIP-2930 tx access lists.

For the EIP-7702 situation: the original idea was that we pay the 25k intrinsic to ensure that the gas to create an account is paid upfront. One gets 12.5k back if the account already exists. Why don't we do this here also? The intrinsic gas cost of EIP-7702 now covers the situation where we have to delegate a new account. Once we are charging this gas and see the account already exists, then the state gas is refunded to the reservoir.

I feel like this idea can be written down a bit more simple, for instance by explaining the execution costs (also in which order) for the CREATE- and CALL- like situations.

Comment thread EIPS/eip-2780.md Outdated
A plain ETH transfer to an existing account still costs `12,000 + 3,000 + 4,244 + 1,756 = 21,000` gas. The headline number is unchanged, but it is now built from measured components rather than a single legacy constant, so each transaction pays for the work it does and nothing it does not.

Transactions that grow the state — value transfers that create a new account and contract-creation transactions — additionally pay `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` in state gas, per [EIP-8037](./eip-8037.md). These transactions therefore cost more than `21,000`, internalizing the cost of state growth that the flat base previously left unpriced.
The gas charing is split across two phases. **Intrinsic gas** is the state-independent cost of including the transaction in a block and is the sole input to the transaction-validity check. **Runtime gas** covers the state-dependent charges — the recipient cold surcharge, new-account creation, and delegation resolution - charged as the first frame is entered, metered in same way as inside the frame. Running out of gas in runtime does not invalidate the transaction. Instead, the transaction is included, execution is skipped, and all state changes are reverted, as for any out-of-gas halt inside a frame.

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.

If I understand it correctly I think we can simplify this change.

Suggested change
The gas charing is split across two phases. **Intrinsic gas** is the state-independent cost of including the transaction in a block and is the sole input to the transaction-validity check. **Runtime gas** covers the state-dependent charges — the recipient cold surcharge, new-account creation, and delegation resolution - charged as the first frame is entered, metered in same way as inside the frame. Running out of gas in runtime does not invalidate the transaction. Instead, the transaction is included, execution is skipped, and all state changes are reverted, as for any out-of-gas halt inside a frame.
The gas charging is split across two phases. **Intrinsic gas** is the state-independent cost of including the transaction in a block and is the sole input to the transaction-validity check. **Runtime gas** covers the state-dependent charges — the recipient cold surcharge, new-account creation, and delegation resolution - charged as the first frame is entered from their respective gas dimension. In case that the transaction cannot pay for these costs, all the remaining gas is consumed and all state changes are reverted.

all state changes are reverted

is somewhat confusing, because the account nonce and the account balance (+coinbase balance if tx has priority fee) always changes, so that obviously should not be reverted.

The current text says:

as for any out-of-gas halt inside a frame.

This is not true, if the execution part of the tx OOGs currently, then all state changes in execution are rolled back, but the EIP-7702 delegations still persist. In this situation (insufficient gas to pay for all the state changes) it is different, as prior to entering the first frame we already OOG.

Currently (Osaka) the state creation gas for EIP-7702 authorizations is guaranteed to exist because it comes from the 25k intrinsic cost of a EIP-7702 transaction (get a refund if the account exists). However, now once we enter the frame we start charging state gas costs and also regular gas costs. The question is: in which order is this charged? What if we can pay state gas for a few EIP-7702 authorizations, but for others not? Do we rollback all authorizations we just made? Or do we keep those we can pay for and then OOG? This should be addressed. In case that we keep the ones we can pay for then it must be made clear in what specific order these gas costs are deducted, as this in some situations influences if an authorization could be paid for or not.

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.

This abstract is too large and already specifies some constants and describes behavior, the abstract should summarize what this EIP does and the respective details go in the relevant sections.

Comment thread EIPS/eip-2780.md
This EIP decomposes the flat `21,000` intrinsic transaction cost into explicit primitives, each priced to match the resources a transaction actually consumes:

- `TX_BASE_COST = 12,000` — ECDSA recovery plus the sender account's access and write.
- `TX_BASE_COST = 12,000` — ECDSA recovery, the sender account's access and write, and the inclusion of the transaction in the block (which is transient and expires with history).

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.

I think this should note that ECDSA recovery is 3000 gas, the sender account's access and write (what is this? COLD_ACCOUNT_ACCESS and ACCOUNT_WRITE, taken from EIP-8038?)

and the inclusion of the transaction in the block (which is transient and expires with history).

How much is this cost?

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.

Very early on, we decided to set the TX_BASE_COST based on benchmarks because otherwise there is not way for us to be below 21k for simple ETH transfers. ECDSA recovery at 3000 is overpriced, but changing the costs of this opcode is out of scope, so we decided this was the best way to approach this EIP.

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.

I guess this is compensated as can't be the same as in frame. For starters, ecdsa is done in parallel for all tx, so it can't be 3k gas. Caller and target are known and can be preloaded etc. I think this value is observed from benchmark, so it is fine to not specify EIP-8038 as they don't apply.

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.

@misilva73 In that case, I don't think we should settle on a calldata floor too early. From what I can see, the proposed EIP-8311 is deriving its calldata pricing based on this 21k baseline.

Comment thread EIPS/eip-2780.md Outdated
This EIP replaces the constant with a decomposition into named primitives, each priced to the resource it represents. The goal is to make every transaction's intrinsic cost reflect its actual work:
This EIP replaces the constant with a decomposition into named primitives, each priced to the resource it represents. The goal is to make every transaction's cost reflect its actual work.

Transaction costs fall into two groups. Some can be computed from the transaction's fields alone, such as signature recovery, the sender's account access and write, and the transaction's bytes in the block. Others require reading state, such as touching the recipient, creating a new account, or resolving a delegation. This EIP splits the two: intrinsic gas is reduced to the minimum needed to include the transaction in a block and remains the sole input to the validity check, while state-dependent costs are charged at runtime, using the same metering as inside a frame. This removes the overcharging of the flat worst-case reservation, since a transaction pays a state-dependent cost only when it actually incurs it. It also allows halting in the pre-execution phase: a transaction whose gas covers inclusion but not a state-dependent charge is included, charged for the gas consumed, and reverted, exactly like an out-of-gas inside a call frame.

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.

the transaction's bytes in the block

How does this compute work? Is this the payment for the tx-bytes which are not the data field (as that is paid for as calldata cost)?

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.

Yes, it is data fields and access list and auth list.

Comment thread EIPS/eip-2780.md Outdated
A transaction's intrinsic base cost is decomposed into the following explicit primitives:
The intrinsic gas is the state-independent cost of including the transaction in a block, computed without any state access, and is the sole input to the transaction-validity gas check. It is the sum of:

- `TX_BASE_COST` in regular gas — one ECDSA recovery, the sender's account access and write, and the inclusion of the transaction's bytes in the block — charged for every transaction;

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.

I would like to see a full breakdown on how this evaluates to 12k, where it is possible using EIP-8038 constants.

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.

There is no breakdown. This comes directly from benchmarks. Check the rationale section for more details

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.

You can't see that, and EIP-8038 does not translate here. Doing math on eip8038 does not work here as those values are for inside frame, for transaction to/target a lot is done before block even starts executing (for example parallel recovery) so it is compensated.

The value of 12k is obtained from benchmarking, iirc.

Comment thread EIPS/eip-2780.md
| :----: | :----: | :---- |
| `TX_BASE_COST` | 12,000 | Sender cost: ECDSA recovery, the sender's account access, and the sender's account write |
| `TX_BASE_COST` | 12,000 | Sender cost: ECDSA recovery, the sender's account access, the sender's account write and inclusion in block |
| `TX_VALUE_COST` | 4,244 | Recipient balance write performed by a value transfer |

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.

This constant should be expressed in EIP-8038 terms, right? In case of value sent, charge extra ACCOUNT_WRITE?

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.

They are not the same constants as some are compensated so we can't use ACCOUNT_WRITE

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.

Yes, not the same constants and with different benchmarked values

Comment thread EIPS/eip-2780.md Outdated
The first frame is then entered with the gas remaining after these runtime charges.

These top-level charges are applied during execution, after the transaction has already been validated and its [EIP-7702](./eip-7702.md) authorizations applied. If the remaining gas is insufficient to cover them — the new-account state-gas charge when the recipient is non-existent and `tx.value > 0`, or the additional `COLD_ACCOUNT_ACCESS` when the recipient is delegated — the transaction is **not** invalidated. It is instead treated as an exceptional halt (out-of-gas): the transaction is included, the sender pays for all gas consumed, and its state changes are reverted, exactly as for any out-of-gas condition during execution. Transaction validity is decided entirely by the intrinsic gas check, which requires no state access; these charges, which do require state access (resolving recipient existence and delegation only after authorizations are applied), can therefore never retroactively invalidate an already-validated transaction.
Running out of runtime gas does **not** invalidate the transaction. Validity is decided solely by the intrinsic gas check, which needs no state access; the runtime charges, which do, can never retroactively invalidate an already-validated transaction. On out-of-gas the transaction is included, halts, the sender pays for all gas consumed, and all state changes — including any [EIP-7702](./eip-7702.md) delegations applied by its authorizations — are reverted, exactly as for an out-of-gas inside any call frame.

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.

This changes behavior if we compare it to txs which currently OOG once it executes a contract. In that case, all state changes made during the contract execution are reverted, but all EIP-7702 authorizations are kept. If this behavior change is intended then this should be noted.

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.

Should clarify, only if pre execution halts, auth list is reverted. If call frame reverts auth list stays.

Comment thread EIPS/eip-2780.md Outdated
Running out of runtime gas does **not** invalidate the transaction. Validity is decided solely by the intrinsic gas check, which needs no state access; the runtime charges, which do, can never retroactively invalidate an already-validated transaction. On out-of-gas the transaction is included, halts, the sender pays for all gas consumed, and all state changes — including any [EIP-7702](./eip-7702.md) delegations applied by its authorizations — are reverted, exactly as for an out-of-gas inside any call frame.

If a contract-creation transaction's initcode reverts, the transaction remains valid. In that case `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` is not charged and is refilled to the `state_gas_reservoir`, per [EIP-8037](./eip-8037.md). A plain value transfer to a new account executes no code and so cannot revert; its new-account state charge is therefore never rolled back this way.
If a contract-creation transaction's initcode reverts, the transaction remains valid and any `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` charged at runtime is refilled to the `state_gas_reservoir`, per [EIP-8037](./eip-8037.md). A plain value transfer to a new account executes no code and so cannot revert; its new-account state charge is therefore never rolled back this way.

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.

So we go OOG, but then get this STATE_BYTES_PER_NEW_ACCOUNT x CPSB gas back? So lets say I send Y gas limit which OOGs pre-execution, since I could not pay for all of the costs combined. But my final gas usage will be Y - STATE_BYTES_PER_NEW_ACCOUNT * CPSB since I get this "refunded" to the state reservoir and which I thus did not spend / consume? 🤔

Also want to note: this new pre-execution OOG situation is rather nasty, because it is not directly visible if the OOG happened pre-execution or during the execution 🤔

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.

OOG consumes all the gas, there is no gas left (This is how the latest EIP-8037 behaves).

Comment thread EIPS/eip-2780.md

| Case | Intrinsic (regular / state) | Runtime (regular / state) | Total (regular / state) |
| :---- | :---- | :---- | :----: |
| ETH transfer to self | `TX_BASE_COST` / 0 | 0 / 0 | 12,000 / 0 |

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.

This table is super handy!

Comment thread EIPS/eip-2780.md Outdated
- **[EIP-2930](./eip-2930.md) (access lists).** Access lists keep their existing per-entry charges and warming semantics for execution-level touches.
- **[EIP-7623](./eip-7623.md) (calldata floor).** EIP-7623 floors a transaction's cost at `21,000 + TOTAL_COST_FLOOR_PER_TOKEN × tokens_in_calldata`, where the flat `21,000` is the intrinsic base this EIP decomposes. With this EIP active, that base term is replaced by the transaction's decomposed regular-gas intrinsic — the sum of the regular-gas primitives charged above (`TX_BASE_COST + COLD_ACCOUNT_ACCESS + TX_VALUE_COST + TRANSFER_LOG_COST` for value transfers, `TX_BASE_COST + CREATE_ACCESS` for contract creation) — so the floor and the floor's validity check rest on the same per-transaction base as the rest of intrinsic gas rather than a stale constant. The calldata schedule itself is unchanged; only the base the floor sits on moves. The new-account state-gas charge is metered in the separate `state_gas_reservoir` per [EIP-8037](./eip-8037.md) and does not enter the calldata floor.
- **[EIP-7702](./eip-7702.md) (set EOA code).** `TX_BASE_COST` is unchanged even when the sender temporarily assumes code; clients must not perform a disk code load to classify the sender, since EIP-7702 provides the code inline. When `tx.to` is a delegated account, resolving the delegation loads the target's code, charged `COLD_ACCOUNT_ACCESS` on first touch or warm thereafter, following the standard EIP-2929 `accessed_addresses` model. Setting a delegation (writing the 23-byte pointer) is distinct from resolving one (reading the target's code); the resolution charge is genuine work and is not prepaid by the authorization.
- **[EIP-7623](./eip-7623.md) (calldata floor).** EIP-7623 floors a transaction's cost at `21,000 + TOTAL_COST_FLOOR_PER_TOKEN × tokens_in_calldata`, where the flat `21,000` is the intrinsic base this EIP decomposes. With this EIP active, that base term is replaced by the transaction's decomposed regular-gas intrinsic — the sum of the regular-gas intrinsic primitives (`TX_BASE_COST + WARM_ACCESS + TX_VALUE_COST + TRANSFER_LOG_COST` for value transfers, `TX_BASE_COST + CREATE_ACCESS` for contract creation) — so the floor and its validity check rest on the same per-transaction base as the rest of intrinsic gas rather than a stale constant. Like the floor, this base is state-independent, so the state-dependent runtime charges (the recipient cold surcharge and the new-account state-gas charge) do not enter it. The calldata schedule itself is unchanged; only the base the floor sits on moves.

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.

I think https://eips.ethereum.org/EIPS/eip-3651 (warm coinbase) should be included here as well to note that coinbase is thus also warm (for completeness) and should also be added as required EIP if it is not added.

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 got changes after discord discussion, and cold cost is part of TX_BASE

Comment thread EIPS/eip-2780.md
- **[EIP-7702](./eip-7702.md) (set EOA code).** `TX_BASE_COST` is unchanged even when the sender temporarily assumes code; clients must not perform a disk code load to classify the sender, since EIP-7702 provides the code inline. When `tx.to` is a delegated account, resolving the delegation loads the target's code, charged `COLD_ACCOUNT_ACCESS` on first touch or warm thereafter, following the standard EIP-2929 `accessed_addresses` model. Setting a delegation (writing the 23-byte pointer) is distinct from resolving one (reading the target's code); the resolution charge is genuine work and is not prepaid by the authorization. Authorization cost itself is decomposed: `REGULAR_PER_AUTH_BASE_COST` — which already includes the authority's warm access — is charged per authorization at the intrinsic phase, while the state-dependent charges (the cold surcharge `COLD_ACCOUNT_ACCESS − WARM_ACCESS` for a cold authority, `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` plus `ACCOUNT_WRITE` for a non-existent authority, and `STATE_BYTES_PER_AUTH_BASE × CPSB` for net-new delegation bytes) are charged at runtime during authorization processing, replacing the worst-case `PER_EMPTY_ACCOUNT_COST` intrinsic charge and refund.
- **[EIP-7708](./eip-7708.md) (ETH transfers emit a log).** Every non-zero-value transfer to a different account emits a transfer log, priced explicitly as `TRANSFER_LOG_COST` rather than absorbed into the base.
- **[EIP-7928](./eip-7928.md) (block-level access lists).** Intrinsic costs already account for accessing `tx.sender` and `tx.to`, so these accounts are included in the BAL even when the transaction reverts.
- **[EIP-7928](./eip-7928.md) (block-level access lists).** `tx.sender` is accessed at the intrinsic phase and `tx.to` at the runtime phase, so both are included in the BAL even when the transaction reverts.

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.

This yields a lot of edge cases, because we now require the ordering of all gas operations and a very clear definition when state is accessed or not. For contract create transactions what do we charge first, state or regular gas? (when do we perform the check if the account exists or not? This is the moment to include it as "read" in the BAL)

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 is not a lot different from things that we do inside frame. We should follow same rules that we have there.

I should clarify it in text more. Order of operations is already set, auth list first than tx.to so if we halt in auth list, tx.to should not be part of BAL.

rakita and others added 3 commits July 3, 2026 12:26
…sic phase

Charge COLD_ACCOUNT_ACCESS for the recipient and the authority (via
REGULAR_PER_AUTH_BASE_COST = 7,816) unconditionally at the intrinsic
phase, removing the warm-floor-plus-runtime-surcharge split. The
delegation target remains a runtime warm/cold charge. Also correct the
initcode-revert wording: the new-account state charge is refilled in
LIFO order per EIP-8037, not credited straight to the reservoir.
Co-authored-by: Toni Wahrstätter <[email protected]>
Comment thread EIPS/eip-2780.md Outdated
Running out of runtime gas does **not** invalidate the transaction. Validity is decided solely by the intrinsic gas check, which needs no state access; the runtime charges, which do, can never retroactively invalidate an already-validated transaction. On out-of-gas the transaction is included, halts, the sender pays for all gas consumed, and all state changes — including any [EIP-7702](./eip-7702.md) delegations applied by its authorizations — are reverted, exactly as for an out-of-gas inside any call frame.

If a contract-creation transaction's initcode reverts, the transaction remains valid. In that case `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` is not charged and is refilled to the `state_gas_reservoir`, per [EIP-8037](./eip-8037.md). A plain value transfer to a new account executes no code and so cannot revert; its new-account state charge is therefore never rolled back this way.
If a contract-creation transaction's initcode reverts, the transaction remains valid and any `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` charged at runtime is refilled in last-in, first-out (LIFO) order, per [EIP-8037](./eip-8037.md): the portion the charge drew from `gas_left` is credited back to `gas_left`, and only the remainder returns to the `state_gas_reservoir`. On an exceptional halt the same refill applies, but `gas_left` is consumed, so only the reservoir portion survives. A plain value transfer to a new account executes no code and so cannot revert; its new-account state charge is therefore never rolled back this way.

@rjl493456442 rjl493456442 Jul 6, 2026 •

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.

On an exceptional halt the same refill applies, but gas_left is consumed, so only the reservoir portion survives.

It confuses me.

For example, if we have a contract creation transaction, and the top-level create frame halts (e.g. due to an address collision). Should we also burn the transaction's remaining regular gas after applying the LIFO refunds?

For comparison, for CREATE/CREATE2, if the child create frame halts, we:

  • revert its state changes and refund the child frame's state cost via LIFO (resetting the child's reservoir back to its original value);
  • refund the parent frame's state cost via LIFO.

The parent frame then continues execution normally; it is not itself considered halted.

My question is whether a top-level contract creation transaction should behave differently. Should the top-most frame also preserve its remaining regular gas after the LIFO refunds, or should the halt be treated as propagating to the top level, causing the remaining regular gas to be burned as a special case?

cc @misilva73

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.

A plain value transfer to a new account executes no code and so cannot revert; its new-account state charge is therefore never rolled back this way.

It's not true. In the spec test, there is a test case that:

  • transaction carries value
  • to was not existent
  • to is a precompile (0x07)
  • precompile execution is failed due to invalid parameter
  • the call frame is halted

In this special case, the account-creation will be reverted

The same question, in this special case, after applying the state refund with LIFO, should the halt be treated as propagating to the top level, causing the remaining regular gas to be burned as a special case?

@misilva73

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.

On the first point, we should burn the gas_left as we do today in both CREATE and create transactions. Or am I missing something?

Also, good point with the precompile edge-case. We should clarify this.

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.

Yeah, no special case, it should behave the same as in frame,

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.

There was a bug with state clear and empty precompile in the past, so all precompiles now have at least some balance. Dont mind adding this to EIP but just saying

Comment thread EIPS/eip-2780.md
This EIP decomposes the flat `21,000` intrinsic transaction cost into explicit primitives, each priced to match the resources a transaction actually consumes:

- `TX_BASE_COST = 12,000` — ECDSA recovery plus the sender account's access and write.
- `TX_BASE_COST = 12,000` — ECDSA recovery, the sender account's access and write, and the inclusion of the transaction in the block (which is transient and expires with history).

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.

Very early on, we decided to set the TX_BASE_COST based on benchmarks because otherwise there is not way for us to be below 21k for simple ETH transfers. ECDSA recovery at 3000 is overpriced, but changing the costs of this opcode is out of scope, so we decided this was the best way to approach this EIP.

Comment thread EIPS/eip-2780.md Resolved
Comment thread EIPS/eip-2780.md Resolved
Comment thread EIPS/eip-2780.md
| :----: | :----: | :---- |
| `TX_BASE_COST` | 12,000 | Sender cost: ECDSA recovery, the sender's account access, and the sender's account write |
| `TX_BASE_COST` | 12,000 | Sender cost: ECDSA recovery, the sender's account access, the sender's account write and inclusion in block |
| `TX_VALUE_COST` | 4,244 | Recipient balance write performed by a value transfer |

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.

Yes, not the same constants and with different benchmarked values

Comment thread EIPS/eip-2780.md
| `TX_BASE_COST` | 12,000 | Sender cost: ECDSA recovery, the sender's account access, and the sender's account write |
| `TX_BASE_COST` | 12,000 | Sender cost: ECDSA recovery, the sender's account access, the sender's account write and inclusion in block |
| `TX_VALUE_COST` | 4,244 | Recipient balance write performed by a value transfer |
| `TRANSFER_LOG_COST` | 1,756 | [EIP-7708](./eip-7708.md) transfer log: `GAS_LOG + 3 × GAS_LOG_TOPIC + 32 × GAS_LOG_DATA_PER_BYTE` |

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.

This was a proposal from @benaadams . I think we should maybe add this to 7708 to make it consistent

Comment thread EIPS/eip-2780.md
| `TRANSFER_LOG_COST` | 1,756 | [EIP-7708](./eip-7708.md) transfer log: `GAS_LOG + 3 × GAS_LOG_TOPIC + 32 × GAS_LOG_DATA_PER_BYTE` |

The following values are referenced from other EIPs and are not final:
The remaining values are defined in other EIPs and referenced here:

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 am not sure about adding these numbers here. If we end up updating this values with other EIPs, then this EIP will become obsolete. I would propose keeping this as it was before

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.

Even previously, there were numbers here:

 `COLD_ACCOUNT_ACCESS = 3,000` and `CREATE_ACCESS = 11,000`, per [EIP-8038](./eip-8038.md).
- `STATE_BYTES_PER_NEW_ACCOUNT × CPSB = 183,600`, per [EIP-8037](./eip-8037.md). This value changes whenever a fork changes `CPSB`.

I just put it in a table and added the missing ones.

I dont think we can do a lot here, and it is easier to read this EIP with these values, and to have examples of consumption is necessary.

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.

ok, good point. Let's leave the table then

Comment thread EIPS/eip-2780.md Outdated
A transaction's intrinsic base cost is decomposed into the following explicit primitives:
The intrinsic gas is the state-independent cost of including the transaction in a block, computed without any state access, and is the sole input to the transaction-validity gas check. It is the sum of:

- `TX_BASE_COST` in regular gas — one ECDSA recovery, the sender's account access and write, and the inclusion of the transaction's bytes in the block — charged for every transaction;

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.

There is no breakdown. This comes directly from benchmarks. Check the rationale section for more details

Comment thread EIPS/eip-2780.md Outdated
- value charges, from `tx.value` and whether the transaction is a self-transfer (`tx.sender == tx.to`):
- if `tx.value == 0`, or the transaction is a self-transfer, no charge;
- if `tx.value > 0` and contract creation, `TRANSFER_LOG_COST` in regular gas;
- otherwise, `TRANSFER_LOG_COST + TX_VALUE_COST` in regular gas;

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.

Again, this was proposed by @benaadams. And we should update 7708 accordingly. Happy to discuss this more, if you feel strongly about not including it.

Comment thread EIPS/eip-2780.md Outdated
The intrinsic gas is the state-independent cost of including the transaction in a block, computed without any state access, and is the sole input to the transaction-validity gas check. It is the sum of:

- `TX_BASE_COST` in regular gas — one ECDSA recovery, the sender's account access and write, and the inclusion of the transaction's bytes in the block — charged for every transaction;
- if `tx.to` is not `None` and the transaction is not a self-transfer (`tx.sender != tx.to`), `COLD_ACCOUNT_ACCESS` in regular gas — the recipient touch, charged at the cold rate unconditionally;

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 still prefer how the previous description was. I think it reads better and I don;t see why we need to change it.

@rakita rakita Jul 6, 2026 •

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.

Yeah, the previous list is better, will revert.

Comment thread EIPS/eip-2780.md Outdated
Running out of runtime gas does **not** invalidate the transaction. Validity is decided solely by the intrinsic gas check, which needs no state access; the runtime charges, which do, can never retroactively invalidate an already-validated transaction. On out-of-gas the transaction is included, halts, the sender pays for all gas consumed, and all state changes — including any [EIP-7702](./eip-7702.md) delegations applied by its authorizations — are reverted, exactly as for an out-of-gas inside any call frame.

If a contract-creation transaction's initcode reverts, the transaction remains valid. In that case `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` is not charged and is refilled to the `state_gas_reservoir`, per [EIP-8037](./eip-8037.md). A plain value transfer to a new account executes no code and so cannot revert; its new-account state charge is therefore never rolled back this way.
If a contract-creation transaction's initcode reverts, the transaction remains valid and any `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` charged at runtime is refilled in last-in, first-out (LIFO) order, per [EIP-8037](./eip-8037.md): the portion the charge drew from `gas_left` is credited back to `gas_left`, and only the remainder returns to the `state_gas_reservoir`. On an exceptional halt the same refill applies, but `gas_left` is consumed, so only the reservoir portion survives. A plain value transfer to a new account executes no code and so cannot revert; its new-account state charge is therefore never rolled back this way.

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.

On the first point, we should burn the gas_left as we do today in both CREATE and create transactions. Or am I missing something?

Also, good point with the precompile edge-case. We should clarify this.

Comment thread EIPS/eip-2780.md

| Case | Regular gas | State gas | Regular gas value | State gas value |
| :---- | :---- | :---- | :----: | :----: |
| ETH transfer to self | `TX_BASE_COST` | 0 | 12,000 | 0 |

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.

Why isn't there a case covering a self-transfer to an EIP-7702 delegated account (tx.sender == tx.to and tx.to contains EIP-7702 delegation code)?

I would expect the cost to be the same as in the first case, except for the additional cost of accessing the delegated address.

@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...

@misilva73

Copy link
Copy Markdown
Contributor

@nerolation , @jochem-brouwer and @Helkomine : your reviews requesting changes are blocking this PR to be merged. Can you approve so that we can merge it?

@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 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 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 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 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...

@jochem-brouwer
jochem-brouwer dismissed their stale review July 7, 2026 14:35

Dismissing my review, this is not an approval of this PR as I did not re-check, unblocking the write access to this EIP so this does not block the speed of the fork process.

@eth-bot
eth-bot merged commit e6d8f58 into ethereum:master Jul 7, 2026
27 of 28 checks passed
0xalpharush pushed a commit to 0xalpharush/revm that referenced this pull request Jul 9, 2026
Move the state-dependent transaction charges from the intrinsic phase to
a runtime gas phase applied as the first frame is entered, per the
EIP-2780 update in ethereum/EIPs#11844. Gated on
CfgEnv::enable_amsterdam_eip2780; older forks and 2780-disabled configs
are unchanged.

- Create transactions: the new-account state gas moves out of intrinsic
  gas and is charged at runtime, only when the deployment target does
  not already exist. Initcode revert/halt unwinds it LIFO via
  rollback_state_gas.
- EIP-7702: the pessimistic per-auth intrinsic charge and its refunds
  are replaced by an intrinsic REGULAR_PER_AUTH_BASE_COST (7,816) plus
  runtime charges per authority: new-account state gas and
  ACCOUNT_WRITE for a non-existent authority, and delegation-indicator
  state gas for net-new delegation bytes.
- Delegated recipient: the delegation-target access follows the
  standard EIP-2929 warm/cold model instead of a flat
  COLD_ACCOUNT_ACCESS.
- Running out of gas in the runtime phase no longer invalidates the
  transaction: it is included as an out-of-gas halt consuming all gas,
  with all runtime state changes (including applied delegations)
  reverted.
fjl pushed a commit to ethereum/go-ethereum that referenced this pull request Jul 14, 2026
Implement the spec changes of EIP-2780 and EIP-8037.

See the spec diffs in
- ethereum/EIPs#11844
- ethereum/EIPs#11891
- ethereum/EIPs#11906
-
ethereum/EIPs@a4801f3

---------

Co-authored-by: MariusVanDerWijden <[email protected]>
rakita added a commit to bluealloy/revm that referenced this pull request Jul 22, 2026
… phase, fixtures v7.0.0) (#3795)

* feat(amsterdam): EIP-2780 runtime gas phase (ethereum/EIPs#11844)

Move the state-dependent transaction charges from the intrinsic phase to
a runtime gas phase applied as the first frame is entered, per the
EIP-2780 update in ethereum/EIPs#11844. Gated on
CfgEnv::enable_amsterdam_eip2780; older forks and 2780-disabled configs
are unchanged.

- Create transactions: the new-account state gas moves out of intrinsic
  gas and is charged at runtime, only when the deployment target does
  not already exist. Initcode revert/halt unwinds it LIFO via
  rollback_state_gas.
- EIP-7702: the pessimistic per-auth intrinsic charge and its refunds
  are replaced by an intrinsic REGULAR_PER_AUTH_BASE_COST (7,816) plus
  runtime charges per authority: new-account state gas and
  ACCOUNT_WRITE for a non-existent authority, and delegation-indicator
  state gas for net-new delegation bytes.
- Delegated recipient: the delegation-target access follows the
  standard EIP-2929 warm/cold model instead of a flat
  COLD_ACCOUNT_ACCESS.
- Running out of gas in the runtime phase no longer invalidates the
  transaction: it is included as an out-of-gas halt consuming all gas,
  with all runtime state changes (including applied delegations)
  reverted.

* feat(amsterdam): glamsterdam devnet-7 alignment (fixtures v7.0.0)

Aligns Amsterdam to the [email protected] fixtures. All
state_tests and blockchain_tests pass (revme statetest/btest).

Spec changes:
- EIPs#11836: calldata floor anchored on the decomposed intrinsic base
  (TX_BASE + recipient/value charges) instead of flat TX_BASE.
- EIPs#11891: 7702 ACCOUNT_WRITE charged on the first write to each
  authority, skipped only when already paid (sender, value-bearing
  recipient, or a preceding valid authorization).
- EIPs#11858: CREATE/CREATE2 account-creation state gas charged
  conditionally at access in the creating frame before the 63/64 split,
  after the endowment/nonce pre-checks, only when the destination does
  not exist; refilled LIFO when the create fails. Top-frame charge for
  create transactions keeps the existing depth-0 path.
- EIPs#11854: SSTORE must cover the slot's access cost before the
  implicit storage read; an unaffordable cold access skips the read so
  the slot stays out of the block access list.
- EIP-8282: builder deposit/exit system-contract addresses updated.

Runtime gas phase is now charged incrementally on a gas tracker and
stops at the first unaffordable charge: later authorities and a cold
delegation target are never loaded, keeping them out of the EIP-7928
BAL; the recipient is read up front so its BAL read survives a runtime
out-of-gas.

JournalEntry::CodeChange now records the previous code hash/bytecode
and restores them on revert. The old revert-to-empty assumption breaks
once 7702 delegation set/clear on already-delegated accounts becomes
revertible; the corrupted account stayed untouched (state root correct)
but leaked a phantom code write into the BAL.

statetest runner updates for the v7 fixture format: explicit tx chainId
(including type-0), optional secretKey (bad_v_r_s expects rejection),
and >u64 nonces no longer panic the keep-going runner.

* chore: simplify SSTORE skip_cold_load, drop eip8037/eip2780 gating

* refactor(amsterdam): decide first-frame EIP-2780 charges at the handler

Move the depth-0 EIP-2780 state-gas decisions out of frame creation into
the runtime gas phase (apply_eip2780_runtime_gas), reusing the existing
runtime out-of-gas halt:

- The recipient new-account charge (value transfer to an empty
  recipient) and the create transaction's account-creation charge
  (deployment target does not exist) are decided and affordability-
  checked at the runtime phase. An unaffordable charge sets runtime_oog
  and the handler includes the transaction as an out-of-gas halt without
  entering the frame; a create transaction still bumps the sender nonce
  on that path.
- The decided charge travels to the first frame via
  FrameInit::state_gas_charge and InitialAndFloorGas::first_frame_state_gas
  and is recorded on the frame's gas tracker, keeping it refillable on
  revert/halt. make_call_frame/make_create_frame lose all cfg/journal/
  depth logic and only apply the passed charge (defensive backstop on
  failure).
- The runtime halt now returns the EIP-8037 reservoir instead of
  consuming it, matching the spec's top-frame halt settlement.

The CREATE opcode and SSTORE cold-load check drop their EIP-2780 gate:
the devnet-7 conditional account-creation charge and the
access-cost-before-read ordering are now the sole EIP-8037 behavior, and
the pre-devnet-7 unconditional-charge/refill path is removed, so the
CREATE refill in return_result is gated purely on the recorded charge.
The now-unused Host::is_amsterdam_eip2780_enabled is removed.

* chore(amsterdam): drop superseded pre-devnet-7 create state-gas paths

Each Amsterdam devnet supersedes the previous one, so the devnet-6
create accounting branches are removed rather than kept behind flag
combinations:

- The intrinsic `create_state_gas` fold for create transactions (and its
  `last_frame_result` refill on failed/alive-target creates) is gone;
  the charge is always decided at the runtime gas phase and recorded on
  the first frame's tracker.
- `target_was_alive` is removed from `CreateFrame`/`CreateOutcome`; the
  CREATE refill is driven solely by `charged_create_state_gas`.
- ee-tests and snapshots updated to the conditional-charge semantics.

All glamsterdam devnet-7 v7.0.0 state and blockchain fixtures pass.

* refactor(amsterdam): rename first_frame_state_gas to refundable_state_gas

Renames InitialAndFloorGas::first_frame_state_gas and
FrameInit::state_gas_charge to a single name, refundable_state_gas,
stating the property that distinguishes it from initial_state_gas:
it is recorded on the first frame's gas tracker and refunded when the
frame reverts or halts, while initial_state_gas is consumed
unconditionally.

* fix(amsterdam): read the recipient after the authorization charges

Drop the up-front recipient read from the EIP-2780 runtime gas phase:
the recipient is now loaded only after the authorization charges are
covered, so a runtime out-of-gas during authorization processing leaves
the recipient out of the EIP-7928 block access list.

* refactor(amsterdam): settle refundable first-frame state gas at the handler

Replace the FrameInit::refundable_state_gas plumbing with a
handler-level deduct/settle pair around the execution loop:

- deduct_refundable_state_gas takes the EIP-2780 first-frame charge out
  of the budget the first frame will see (reservoir first, deficit
  spilling into regular gas, mirroring record_state_cost) before
  first_frame_input.
- settle_refundable_state_gas seeds the charge onto the frame result's
  state-gas counters after the run, so last_frame_result reports it on
  success and rolls it back on revert or halt. A create that succeeds
  without deploying (sender nonce overflow) rolls it back directly.

make_call_frame/make_create_frame lose the charge recording, the
early-halt backstop, the precompile re-apply special case, and the
interpreter gas carry-over; FrameInit drops the field. The inspector
handler mirrors the deduct/settle pair.

* refactor(amsterdam): source the 7702 per-auth intrinsic cost from the gas table

Fold the hardcoded EIP7702_PER_AUTH_BASE_REGULAR branch in initial_tx_gas
into tx_eip7702_per_empty_account_cost: the Amsterdam table's
tx_eip7702_regular_gas slot now holds the state-independent
REGULAR_PER_AUTH_BASE_COST (7,816, previously assigned twice with the
pessimistic 15,816), and the accessor returns the slot alone for every
fork.

The pessimistic per-auth model this replaces is superseded by the
runtime gas phase, so its remnants go with it: the state-gas addition in
the accessor and the dead tx_eip7702_state_gas/tx_eip7702_state_refund
helpers, the Amsterdam tx_eip7702_regular_refund entry (zeroed — the
runtime phase charges per authority instead of refunding), and the
unused EIP7702_PER_EMPTY_ACCOUNT_REGULAR constants in eip8037/eip8038.

The legacy branch of test_initial_tx_gas_eip2780_runtime_split asserts
the bundled 25,000 cost on a PRAGUE table, since Amsterdam params no
longer model the eip2780-disabled combination.

* test(amsterdam): pin spilled refundable-charge gas accounting

Add ee-tests covering the EIP-2780 refundable first-frame charge when it
spills into the regular gas budget (zero reservoir): create initcode
success/revert/halt, the reservoir-laundering DELEGATECALL dance that
leaves the parent's state_gas_spilled counter stale, and value transfers
to empty precompile recipients (success and halting failure). Regression
net for any refactor of where the refundable charge is recorded.

* chore(amsterdam): drop devnet-7 mentions from EIP-8037 comments

* refactor(state): return previous code and hash from set_code_and_hash

* fix(amsterdam): bind EIP-7623 floor against block regular gas

The calldata floor is not discounted by state gas, so
block_regular_gas_used is max(total - state_gas, floor_gas).
Also tidy frame.rs clear() call sites.

* refactor(amsterdam): settle the transaction through a tx-level Gas

Create a transaction-level Gas right after validation and thread it
through pre-execution, execution and frame settle:

- The EIP-2780 runtime gas phase records its charges directly on the
  tx-level gas (snapshot/restore on out-of-gas) instead of folding them
  back into InitialAndFloorGas; runtime_oog becomes a None return and a
  dedicated Handler::runtime_oog_result builds the halt.
- The refundable first-frame state gas stays deducted on the tx-level
  gas; only the decision travels as charged_* flags on the first frame
  inputs, and last_frame_result refunds it from the outcome, mirroring
  how EthFrame::return_result refunds inner CALL/CREATE state charges.
- last_frame_result settles the first frame into the tx-level gas via
  handle_reservoir_remaining_gas, like a parent frame settling a child.
- Drop deduct_refundable_state_gas / settle_refundable_state_gas and
  checked_initial_gas_and_reservoir; add
  Gas::new_with_remaining_and_reservoir.

* refactor(amsterdam): carry the refundable charge decision in PreExecutionOutput

Remove charged_refundable_state_gas from InitialAndFloorGas: it is a
runtime-gas-phase decision, not validated gas. pre_execution and
apply_eip7702_auth_list now return Option<PreExecutionOutput> bundling
the EIP-7702 refund with the flag (None = runtime out-of-gas), and
execution takes the flag directly instead of InitialAndFloorGas, which
is immutable after validation again.

* refactor(amsterdam): unify the upfront state charge refund decision

Move the refund decision to FrameResult::refundable_state_gas, shared by
EthFrame::return_result and Handler::last_frame_result. The handler's
explicit halt branch reduces to refill_reservoir + spend_all since the
transaction-level remaining is zero on halt. Also replace the
!is_ok_or_revert() checks with is_halt() — ok/revert/error fully
partition InstructionResult.

* refactor(amsterdam): complete the runtime gas phase at first-frame creation

Remove apply_eip2780_runtime_gas: the authorization charges stay in
pre-execution (apply_auth_list_eip2780), while the recipient and
create-target charges move into create_init_frame, merging with the
target loading it already performed and deciding the charged_* input
flags in place. create_init_frame, first_frame_input and execution
return Result<Option<..>> so any runtime charge can out-of-gas; the
caller includes the transaction as an out-of-gas halt with pristine
rebuilt gas. The runtime-phase journal checkpoint travels open in
PreExecutionOutput and is settled by execution: committed once the
first frame is created, reverted (dropping applied delegations) on
runtime out-of-gas.

* refactor(amsterdam): charge delegate access as warm plus cold additional

Replace the WARM_ACCESS affordability pre-check with an upfront warm
charge and a COLD_ACCOUNT_ACCESS_ADDITIONAL charge after the load,
matching the EIP-2929 idiom. Charges made before an out-of-gas bail
need no undo since the runtime out-of-gas path rebuilds the
transaction-level gas.

* refactor(amsterdam): own the runtime gas phase checkpoint in pre_execution

apply_eip7702_auth_list returns just the EIP-7702 refund again (None on
authorization out-of-gas); Handler::pre_execution opens the runtime gas
phase checkpoint, reverts it when the authorization charges run out of
gas, and packs PreExecutionOutput for execution to settle.

* refactor(amsterdam): open the runtime gas phase checkpoint unconditionally

PreExecutionOutput.checkpoint is no longer optional: pre_execution
always opens it before the authorization list (pre-Amsterdam it is
always committed since no runtime charges apply), execution always
settles it, and run_system_call opens its own since it skips
pre-execution.

* chore(handler): derive the eip7702 refund from the pre-execution output

* refactor(handler): track the transaction-level gas with GasTracker

The handler never needs the memory-expansion half of Gas, so the
transaction-level gas becomes a bare GasTracker threaded through
pre-execution, execution and frame settle:

- tx_gas returns GasTracker; handle_reservoir_remaining_gas and the
  runtime-gas-phase helpers (create_init_frame, apply_auth_list_eip2780)
  take &mut GasTracker, with frame call sites going through
  Gas::tracker_mut. Drop Gas::new_with_remaining_and_reservoir and
  re-export GasTracker from the interpreter root.
- Move the forwarded-gas spend_all into last_frame_result: the settle
  consumes the forwarded regular gas and returns the frame's unused
  part, dropping the explicit calls in execution, inspect_execution and
  runtime_oog_result.
- create_init_frame derives the create target from tx.nonce() instead
  of loading the caller (the account nonce is bumped only at frame
  creation), and the first-frame new-account/create charges no longer
  gate on is_eip8037 (its gas params are zero pre-8037).

* fix(handler): load delegate bytecode at first-frame creation

The EIP-2780 first-frame delegate load metered the access correctly but
read the bytecode from an account load that does not fetch code, so with
a provider-style database (code only via code_by_hash) the delegated
recipient executed as empty code. Found as the glamsterdam-devnet-7
block 6371 gas divergence (bug017, -3,267 gas): the delegated code's
execution was skipped whenever the delegate was not already cached with
its code.

Load the delegate through the code-loading variant and add a regression
test with a database whose basic() omits bytecode.

* chore(scripts): bump devnet fixtures to glamsterdam-devnet v7.2.0

* docs(context-interface): fix broken GasParams eip7702 refund doc link

* refactor(handler): pass InitialAndFloorGas to apply_eip7702_auth_list

Restore the InitialAndFloorGas parameter alongside the transaction-level
GasTracker so chain variants that meter the authorizations against the
intrinsic/floor gas keep their override point. The default implementation
does not use it.

* fix(context-interface): saturate gas subtractions in initial_gas_and_reservoir
rakita added a commit to alloy-rs/evm2 that referenced this pull request Jul 30, 2026
)

Aligns Amsterdam to the **glamsterdam devnet-7** spec and the
`[email protected]` fixtures. All Amsterdam `state_tests`
and `blockchain_tests` pass (interpreter + JIT + AOT); no regressions in
earlier-fork state suites or the unit/ee-test suite.

Ports bluealloy/revm#3795 to evm2's architecture.

## EIP-2780 runtime gas phase (ethereum/EIPs#11844)

State-dependent transaction charges move from the intrinsic phase to a
runtime phase applied as the first frame is entered. Running out of gas
there is an **included out-of-gas halt** consuming all regular gas, not
a transaction rejection.

- **Create transactions**: account-creation state gas is charged at the
create frame's entry (`execute_create_message`), conditional on the
destination not already existing. The intrinsic `create_state_gas` and
its refund path are removed.
- **EIP-7702**: the intrinsic per-auth charge drops to the
state-independent `REGULAR_PER_AUTH_BASE_COST` (7,816); `ACCOUNT_WRITE`,
new-account, and delegation-bytes state gas are charged per authority at
runtime on a transaction-level `GasTracker` (the `RuntimeAuthCharges`
accounting), stopping at the first unaffordable charge. A runtime
out-of-gas reverts the applied delegations and includes the tx as an OOG
halt.
- **Delegated recipient (depth 0)**: resolution is deferred into the
frame (`apply_eip2780_call_charges`) and the target load is gated on gas
(`skip_cold_load`, as nested calls do), so a cold, unafforded target
stays out of the EIP-7928 block access list.
`MessageResult::runtime_gas_oog` signals a recipient-charge OOG back to
the 7702 handler so it drops the delegations too.

The CALL/CREATE runtime charges live in the shared
`execute_call_message` / `execute_create_message` (gated on `depth == 0`
+ feature, not tx type), so **all transaction types** get them; only the
authorization-specific charges are in the 7702 handler.

## Devnet-7 spec alignment

- **ethereum/EIPs#11836**: calldata floor anchored on the decomposed
intrinsic base instead of flat `TX_BASE`.
- **ethereum/EIPs#11891**: 7702 `ACCOUNT_WRITE` charged once per
authority, skipped when already paid (sender / value-recipient / a
preceding valid authorization).
- **ethereum/EIPs#11858**: `CREATE`/`CREATE2` account-creation state gas
charged conditionally at access (endowment/nonce pre-check + a single
destination read), refilled on failure. Mirrored in the JIT builtin.
- **ethereum/EIPs#11854**: `SSTORE` covers the slot's access cost before
the implicit read; an unaffordable cold access skips the read
(`Evm::sstore` now honors `skip_cold_load`).
- **EIP-8282**: builder deposit/exit system-contract addresses updated.
- **EIP-7623** floor binds the block regular-gas component
(`TxResult::regular_gas_spent = max(total - state, floor)`).

## Cleanups

- Remove the superseded devnet-6 create accounting
(`create_initial_state_gas`, `refund_create_state_gas`,
`MessageResult::created_target_was_alive`, `settle_gas`'s `is_create`
path).
- Remove `rollback_failed_execution`: failed execution is already rolled
back to the message's own checkpoint (and halt gas zeroed) inside
`execute_message`, so it was redundant.

## Follow-up refactors

- **Message construction**: `Message` now carries its `destination` —
the CREATE/CREATE2 address is derived when the message is constructed
(`Message::derive_destination`) instead of being re-derived at frame
entry.
- **EIP-7702 authorization unification**: both gas regimes share one
`apply_auth_list` loop (validate → account → apply) driven by an
`AuthAccounting` strategy — `RuntimeAuthCharges` (EIP-2780 runtime
metering, abortable mid-list) and `AuthRefunds` (pre-Amsterdam
pessimistic-intrinsic refunds, owning the EIP-8037 gating). The handler
tail funnels every exit through a single `settle` closure (`settle_oog`
for the runtime OOG halts), and `initial_gas_and_reservoir` loses its
always-zero `state_refund` parameter — the pre-Amsterdam state refund is
credited straight to the reservoir at the call site, matching
execution-specs `set_delegation`. Crate constants are now `pub`.

The `Message`-carries-bytecode refactor (with the EIP-8037 create depth
check) and the regular→execution gas rename are split out into the
stacked PR #329.

## Fixtures / harness

- Bump devnet fixtures to v7.2.0 (setup script, CI, `AGENTS.md`).
- eest: honor an explicit per-transaction `chainId` (v7 fixtures test
type-0 `INVALID_CHAINID`).

## Testing

- Amsterdam `state_tests`: 406/406; `blockchain_tests`: 657/657.
- JIT + AOT Amsterdam state suites pass on v7.2.0.
- Unit + ee-tests: 2829/2829; Prague/Osaka/Cancun/Berlin/London/Shanghai
state suites unchanged.

Two revm changes were no-ops in evm2: EIP-7708 (already implemented) and
`JournalEntry::CodeChange` recording prior code (evm2's `AccountChange`
already snapshots the full prior `AccountInfo`).
qianhh pushed a commit to bane-labs/go-ethereum that referenced this pull request Aug 14, 2026
Implement the spec changes of EIP-2780 and EIP-8037.

See the spec diffs in
- ethereum/EIPs#11844
- ethereum/EIPs#11891
- ethereum/EIPs#11906
-
ethereum/EIPs@a4801f3

---------

Co-authored-by: MariusVanDerWijden <[email protected]>
qianhh pushed a commit to bane-labs/go-ethereum that referenced this pull request Aug 19, 2026
Implement the spec changes of EIP-2780 and EIP-8037.

See the spec diffs in
- ethereum/EIPs#11844
- ethereum/EIPs#11891
- ethereum/EIPs#11906
-
ethereum/EIPs@a4801f3

---------

Co-authored-by: MariusVanDerWijden <[email protected]>
qianhh pushed a commit to bane-labs/go-ethereum that referenced this pull request Aug 31, 2026
Implement the spec changes of EIP-2780 and EIP-8037.

See the spec diffs in
- ethereum/EIPs#11844
- ethereum/EIPs#11891
- ethereum/EIPs#11906
-
ethereum/EIPs@a4801f3

---------

Co-authored-by: MariusVanDerWijden <[email protected]>
qianhh pushed a commit to bane-labs/go-ethereum that referenced this pull request Sep 16, 2026
Implement the spec changes of EIP-2780 and EIP-8037.

See the spec diffs in
- ethereum/EIPs#11844
- ethereum/EIPs#11891
- ethereum/EIPs#11906
-
ethereum/EIPs@a4801f3

---------

Co-authored-by: MariusVanDerWijden <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a-review Waiting on author to review 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.

9 participants