Skip to content

Update EIP-8037: fixed CPSB + frame accounting#11573

Open
misilva73 wants to merge 12 commits intoethereum:masterfrom
misilva73:update-eip-8037
Open

Update EIP-8037: fixed CPSB + frame accounting#11573
misilva73 wants to merge 12 commits intoethereum:masterfrom
misilva73:update-eip-8037

Conversation

@misilva73
Copy link
Copy Markdown
Contributor

@misilva73 misilva73 commented Apr 27, 2026

Cost-per-state-byte: dynamic → fixed

  • Replaces the dynamic, quantized cost_per_state_byte with a single constant CPSB = 1174, derived from a 100 GiB/year target at a 96M-gas reference limit.
  • Removes TARGET_STATE_GROWTH_PER_YEAR, CPSB_SIGNIFICANT_BITS, CPSB_OFFSET, and the entire quantization section.
  • Adds named byte-count constants: STATE_BYTES_PER_STORAGE_SET, STATE_BYTES_PER_NEW_ACCOUNT, STATE_BYTES_PER_AUTH_BASE.

State-gas accounting rules (opcode-level)

  • SSTORE: charged/refilled at end of opcode based on original/current/new value (handles the 0→x→0 case directly without a separate refund section).
  • CALL* / CREATE / CREATE2: state-gas charged at end of successful call frame; reverted or exceptionally-halted frames produce no debit.
  • SELFDESTRUCT: accounting deferred to end of transaction; refunds the account, code, and per-slot state-gas for accounts both created and destroyed in the same tx (per EIP-6780), bypassing the 20% refund cap.
  • Removes the now-subsumed sections on SSTORE 0→x→0 refund, frame-failure handling, CREATE-failure refund, same-tx SELFDESTRUCT refund, CALL-with-value to selfdestructed accounts, and the detailed contract-deployment gas formulas.

System contracts and system transactions

  • Adds a new section adjusting SYSTEM_CALL_GAS_LIMIT to 30M + STATE_BYTES_PER_STORAGE_SET × CPSB × SYSTEM_MAX_SSTORES_PER_CALL so existing system contracts retain their execution margin under the higher state-creation cost.

@github-actions github-actions Bot added c-update Modifies an existing proposal s-draft This EIP is a Draft t-core labels Apr 27, 2026
@eth-bot
Copy link
Copy Markdown
Collaborator

eth-bot commented Apr 27, 2026

✅ All reviewers have approved.

@eth-bot eth-bot changed the title Update EIP 8037: fixed CPSB + frame accounting Update EIP-8037: fixed CPSB + frame accounting Apr 27, 2026
Comment thread EIPS/eip-8037.md Outdated

On **revert** or **exceptional halt** of the top-level frame, all state changes are reverted and no state gas is charged. On exceptional halt specifically, remaining `gas_left` is set to zero and `execution_regular_gas_used` is increased consistently.

##### Top-level frame end (transaction end)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, this is very useful for creating temporary contracts, however, refunding gas at the end of the transaction will make this mechanism ineffective on Monad.

Comment thread EIPS/eip-8037.md Outdated
Comment on lines +96 to +97
- `execution_regular_gas_used` encodes the total regular-gas used by the transaction, and it is initialized as `execution_regular_gas_used = intrinsic_regular_gas`.
- `execution_state_gas_used` encodes the total state-gas used by the transaction, and it is initialized as `execution_state_gas_used = intrinsic_state_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.

Imo this does not belong here. I dont think evm is going to have those two counters as they are more specific for the block. So would propose to move those two inside Block-level gas accounting

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 added these counters because we need to know how much gas was spend on state and regular gas at the end of the transaction. I don't think we can derive it only from the gas_left and reservoir counters, right?

Copy link
Copy Markdown
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

Partial review!

Comment thread EIPS/eip-8037.md Outdated
Comment thread EIPS/eip-8037.md Outdated
Comment thread EIPS/eip-8037.md
Before transaction execution, inclusion of a transaction in a block requires that:

`intrinsic_regular_gas` and `intrinsic_state_gas` must be passed to `check_transaction` to perform the regular gas availability check.
1. The transaction's **intrinsic costs are not higher than [EIP-7825](./eip-7825.md)'s transaction cap**. Concretely, `max(intrinsic_regular_gas, calldata_floor_gas_cost) <= TX_MAX_GAS_LIMIT`, where `intrinsic_regular_gas` includes all the intrinsic costs not associated with state created (i.e., base transaction cost, calldata, access lists, authorization base costs).
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.

calldata_floor_cost is ambiguous because https://eips.ethereum.org/EIPS/eip-7981 adds authorization lists to floor costs

Comment thread EIPS/eip-8037.md
Comment thread EIPS/eip-8037.md Outdated
Comment thread EIPS/eip-8037.md Outdated
Comment thread EIPS/eip-8037.md Outdated
Comment thread EIPS/eip-8037.md
Comment thread EIPS/eip-8037.md
Comment thread EIPS/eip-8037.md Outdated

For each storage slot whose value differs between the frame's entry and exit states, the frame is charged or refunded as follows:

- **New slot.** The slot's frame-exit value is non-zero and its transaction-entry value was zero. Charge `STATE_BYTES_PER_STORAGE_SET × CPSB` of state gas and increase `execution_state_gas_used` by the same amount.
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.

(did not explicitly check this accounting)

misilva73 and others added 3 commits April 28, 2026 13:27
Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>
Comment thread EIPS/eip-8037.md Outdated

##### Top-level frame end (transaction end)

At the end of a successful transaction, the top-level frame applies the frame-end accounting above and additionally performs deferred `SELFDESTRUCT` processing. [EIP-6780](./eip-6780.md) defers actual account removal to the end of the transaction for accounts that were created and self-destructed in the same transaction; the corresponding state-gas effect is therefore also computed only at this point.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I want the gas refund for selfdestruct to happen immediately, similar to sstore, accepting a partial semantic break of eip6780.

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 possible. A self-destructed account can still be called during execution and, in that scenario, the gas accounting will be a mess. We need to give the refund at the point where the account is destroyed, which is at the end of transaction.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is not possible. A self-destructed account can still be called during execution and, in that scenario, the gas accounting will be a mess. We need to give the refund at the point where the account is destroyed, which is at the end of transaction.

Can you provide more details about the implementation issues? According to eip6780, an account still has execution logic after a selfdestruct operation. However, we cannot redeploy that address due to eip684. Therefore, we are left with only one option: revert. We can apply similar semantics to sstore. I know this isn't ideal, but it's necessary to support temporary contracts because we don't have dedicated opcodes for them, and also because late refunds wouldn't be possible on Monad because the amount of gas consumed is based on the gas limit, not the amount of gas used. We also expect that the gas supply should be used as efficiently as possible, as it is locked in until the end of the transaction.

danceratopz added a commit to danceratopz/execution-specs that referenced this pull request Apr 28, 2026
danceratopz added a commit to ethereum/execution-specs that referenced this pull request Apr 28, 2026
@github-actions github-actions Bot added the w-ci Waiting on CI to pass label Apr 29, 2026
Co-authored-by: Copilot <copilot@github.com>
@github-actions github-actions Bot removed the w-ci Waiting on CI to pass label Apr 30, 2026
@github-actions
Copy link
Copy Markdown

The commit 06b5c46 (as a parent of e632762) contains errors.
Please inspect the Run Summary for details.

@github-actions github-actions Bot added the w-ci Waiting on CI to pass label Apr 30, 2026
@github-actions github-actions Bot removed the w-ci Waiting on CI to pass label May 1, 2026
@misilva73 misilva73 marked this pull request as ready for review May 2, 2026 11:57
@misilva73 misilva73 requested a review from eth-bot as a code owner May 2, 2026 11:57
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.

5 participants