Skip to content

feat(spec-specs): EIP-8037 spec changes for bal-devnet-4#2697

Closed
spencer-tb wants to merge 4 commits intoethereum:eips/amsterdam/eip-8037from
spencer-tb:eips/amsterdam/eip-8037-devnet-4
Closed

feat(spec-specs): EIP-8037 spec changes for bal-devnet-4#2697
spencer-tb wants to merge 4 commits intoethereum:eips/amsterdam/eip-8037from
spencer-tb:eips/amsterdam/eip-8037-devnet-4

Conversation

@spencer-tb
Copy link
Copy Markdown
Contributor

@spencer-tb spencer-tb commented Apr 16, 2026

🗒️ Description

Stale PR as only used for reference initially, PTAL at seperate PRs for each spec change:

  1. feat(spec-specs, tests): EIP-8037 - zero execution state gas on top-level failure #2689
  2. feat(spec-specs, tests): EIP-8037 - 0 to x to 0 SSTORE refunds to state gas #2698
  3. feat(spec-specs, tests): EIP-8037 - CREATE failure refunds state gas to reservoir #2704
  4. feat(spec-specs, tests): EIP-8037 - SELFDESTRUCT same-tx refunds state gas at end of tx #2707
  5. feat(tests): EIP-8037 - CALL with value to selfdestructed account #2646
  6. feat(spec-specs, tests): EIP-8037 - immutable intrinsic state gas for EIP-7702 #2711
  7. feat(spec-specs, tests): EIP-8037 - per-dimension block gas limit check at tx inclusion #2703

1) Top-level failure zeros execution state gas: 57a6385

On top-level revert or exceptional halt, all state changes are rolled back. Return consumed execution state gas to the reservoir (state_gas_left += state_gas_used) and zero state_gas_used for block accounting. Intrinsic state gas remains unchanged (immutable).

2) SSTORE 0 to x to 0 refunds state gas to reservoir: 3feb782

When a storage slot is restored to its original zero value (0 to x to 0), the net state growth is zero. Refund 32 * cost_per_state_byte directly to the reservoir instead of through the refund_counter. The regular gas write cost refund still goes through refund_counter. The refund happens immediately after the x to 0 change.

3) CREATE failure refunds account state gas to reservoir: 6b6f3c8

CREATE/CREATE2 charges 112 * cost_per_state_byte upfront. On a silent failure (insufficient balance, nonce overflow, stack depth, address collision) or child revert/halt, no account is created. Refund the account creation state gas to the reservoir.

4) SELFDESTRUCT same-tx refunds state gas at end of tx: 9ca780d

When an account is created and self-destructed in the same transaction, the state doesn't persist. At the end of tx, refund all state gas for:

  • Account creation: 112 * cost_per_state_byte
  • Created storage slots: 32 * cost_per_state_byte per non-zero slot
  • Code deposit: len(code) * cost_per_state_byte

No double refund with point 2: slots that went 0 to x to 0 have a final value of 0 and are not counted.

5) CALL to self-destructed account, no change: e6beb15

After a same-tx CREATE+SELFDESTRUCT, the account still has nonce=1 from the CREATE, so is_account_alive returns true and a subsequent CALL with value does not charge GAS_NEW_ACCOUNT state gas. The account is destroyed at end of tx regardless, and any value transferred via the CALL is burned with it, so no persisted state results from the CALL. Combined with 4)'s refund, the net state gas across the CREATE+SELFDESTRUCT+CALL lifecycle is zero, matching the zero persisted state. No spec change.

6) Immutable intrinsic_state_gas for EIP-7702: fd76b10

Stop mutating intrinsic_state_gas during execution. The worst case charge is kept. When an authorization targets an existing account, refund STATE_BYTES_PER_NEW_ACCOUNT * cost_per_state_byte to the reservoir only. Block accounting uses the original immutable intrinsic_state_gas.

7) 2D transaction inclusion check: 928b819

Both regular gas and state gas are validated before executing a transaction using intrinsic-aware worst-case per-dimension contributions.

regular_gas_available = (
    block_env.block_gas_limit - block_output.block_gas_used
)
state_gas_available = (
    block_env.block_gas_limit - block_output.block_state_gas_used
)
regular_gas_contribution = min(
    TX_MAX_GAS_LIMIT, tx.gas - intrinsic_state_gas
)
if regular_gas_contribution > regular_gas_available:
    raise GasUsedExceedsLimitError("regular gas exceeds limit")
state_gas_contribution = tx.gas - intrinsic_regular_gas
if state_gas_contribution > state_gas_available:
    raise GasUsedExceedsLimitError("state gas exceeds limit")

🔗 Related Issues or PRs

✅ Checklist

  • All: Ran fast static checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    just static
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).

@spencer-tb spencer-tb added this to the Pre-interop - BAL milestone Apr 16, 2026
@spencer-tb spencer-tb added A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) C-feat Category: an improvement or new feature labels Apr 16, 2026
@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037-devnet-4 branch 2 times, most recently from db7d367 to 5e3cab2 Compare April 16, 2026 15:01
@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037-devnet-4 branch from 5e3cab2 to 4b22798 Compare April 17, 2026 10:31
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (eips/amsterdam/eip-8037@5450513). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                     @@
##             eips/amsterdam/eip-8037    #2697   +/-   ##
==========================================================
  Coverage                           ?   88.18%           
==========================================================
  Files                              ?      524           
  Lines                              ?    31120           
  Branches                           ?     3036           
==========================================================
  Hits                               ?    27444           
  Misses                             ?     3161           
  Partials                           ?      515           
Flag Coverage Δ
unittests 88.18% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037-devnet-4 branch from 928b819 to d44d011 Compare April 19, 2026 13:24
@spencer-tb spencer-tb closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) C-feat Category: an improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant