Skip to content

feat(tests): EIP-8037 - code deposit halt must discard initcode state gas#2595

Merged
spencer-tb merged 2 commits into
ethereum:eips/amsterdam/eip-8037from
qu0b:qu0b/test/eip8037-code-deposit-halt-state-gas
Apr 1, 2026
Merged

feat(tests): EIP-8037 - code deposit halt must discard initcode state gas#2595
spencer-tb merged 2 commits into
ethereum:eips/amsterdam/eip-8037from
qu0b:qu0b/test/eip8037-code-deposit-halt-state-gas

Conversation

@qu0b

@qu0b qu0b commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

🗒️ Description

Summary

  • Adds blockchain_test verifying that state gas consumed during initcode execution is discarded from the block state gas accumulator when code deposit triggers an exceptional halt
  • Three parametrized cases: CALL to new account + oversized code, inner CREATE + oversized code, CALL to new account + OOG during deposit

Root cause

When CREATE initcode performs a state-creating operation (CALL to new account or inner CREATE, charging GAS_NEW_ACCOUNT = 112 * cpsb) and then the code deposit fails (code too large or OOG), the exceptional halt reverts all state changes. The GAS_NEW_ACCOUNT state gas for the reverted operation must NOT count in block_state_gas_used.

A client that retains the reverted state gas in the block accumulator will compute block_gas_used = max(block_regular_gas, block_state_gas) incorrectly — the inflated block_state_gas produces a different header gasUsed.

Motivation

BAL devnet-3 chain split at block 17: nethermind's block header gasUsed was exactly 131,488 (= GAS_NEW_ACCOUNT) lower than the EELS reference. Traced via EVM step comparison to RevertRefundToHalt not properly discarding the child frame's StateGasUsed accumulated during initcode execution.

🔗 Related Issues or PRs

N/A.

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx tox -e 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).

qu0b added a commit to qu0b/execution-specs that referenced this pull request Apr 1, 2026
…ses)

Replace broken 2-tx test at 100M gas limit that didn't actually
catch the divergence. Use the original single-tx test from ethereum#2595
with all 3 parametrized cases (oversized code x2, OOG deposit)
at 60M gas limit which correctly exposes the bug.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
qu0b added a commit to qu0b/execution-specs that referenced this pull request Apr 1, 2026
EELS patch: on top-level revert or exceptional halt, restore all
execution state gas to the reservoir and reset state_gas_used to
zero. Mirrors incorporate_child_on_error for child frames.

Test from PR ethereum#2595: single-tx at 60M, 3 parametrized cases
(oversized code x2, OOG deposit).

Spec change: ethereum/EIPs#11476

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
qu0b added a commit to qu0b/execution-specs that referenced this pull request Apr 1, 2026
EELS patch: on top-level revert or exceptional halt, restore all
execution state gas to the reservoir and reset state_gas_used to
zero. Mirrors incorporate_child_on_error for child frames.

Test: 2-tx blockchain test at 100M where state gas is the binding
dimension. TX1 deploys 14 KiB contract (high state gas). TX2 is a
failing CREATE whose initcode state gas (GAS_NEW_ACCOUNT) is the
observable delta in header.gas_used.

This is the opposite of ethereum#2595 which tests that state gas IS counted
at the top level (#11468). This test verifies state gas is NOT
counted at the top level (#11476).

Spec change: ethereum/EIPs#11476

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
qu0b added a commit to qu0b/execution-specs that referenced this pull request Apr 1, 2026
EELS patch: on top-level revert or exceptional halt, restore all
execution state gas to the reservoir and reset state_gas_used to
zero. Mirrors incorporate_child_on_error for child frames.

Test: 2-tx blockchain test at 100M where state gas is the binding
dimension. TX1 deploys 14 KiB contract (high state gas). TX2 is a
failing CREATE whose initcode state gas (GAS_NEW_ACCOUNT) is the
observable delta in header.gas_used.

This is the opposite of ethereum#2595 which tests that state gas IS counted
at the top level (#11468). This test verifies state gas is NOT
counted at the top level (#11476).

Spec change: ethereum/EIPs#11476

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
qu0b added a commit to qu0b/execution-specs that referenced this pull request Apr 1, 2026
EELS patch: on top-level revert or exceptional halt, restore all
execution state gas to the reservoir and reset state_gas_used to
zero. Mirrors incorporate_child_on_error for child frames.

Test: 2-tx blockchain test at 100M where state gas is the binding
dimension. TX1 deploys 14 KiB contract (high state gas). TX2 is a
failing CREATE whose initcode state gas (GAS_NEW_ACCOUNT) is the
observable delta in header.gas_used.

This is the opposite of ethereum#2595 which tests that state gas IS counted
at the top level (#11468). This test verifies state gas is NOT
counted at the top level (#11476).

Spec change: ethereum/EIPs#11476

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@spencer-tb spencer-tb left a comment

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.

LGTM! @qu0b I just moved the test updated it to be more fork agnostic. PTAL

@spencer-tb spencer-tb changed the base branch from devnets/bal/3 to eips/amsterdam/eip-8037 April 1, 2026 16:52
@spencer-tb spencer-tb force-pushed the qu0b/test/eip8037-code-deposit-halt-state-gas branch from 64f8162 to 9bf9dd0 Compare April 1, 2026 16:54
@qu0b

qu0b commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

@spencer-tb have you verified that it still fails against nethermind after your refactor?

@spencer-tb spencer-tb changed the title test(eip8037): code deposit halt must discard initcode state gas feat(tests): EIP-8037 - code deposit halt must discard initcode state gas Apr 1, 2026
@spencer-tb

Copy link
Copy Markdown
Contributor

@spencer-tb have you verified that it still fails against nethermind after your refactor?

Was just about to ping! Will check just now :)

@qu0b

qu0b commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

but looks good to me changes seem minor

@spencer-tb spencer-tb requested a review from kclowes April 1, 2026 16:57
@spencer-tb

Copy link
Copy Markdown
Contributor

Confirmed Nethermind still fails and Geth passes.

Move test_code_deposit_halt_discards_initcode_state_gas from
test_devnet3_repro.py into test_state_gas_create.py alongside other
CREATE state gas tests. Replace hardcoded constants with fork methods
(max_code_size), use nonexistent_account fixture, and expand coverage
to all state_op x deposit_fail combinations (4 cases, up from 3).
@spencer-tb spencer-tb force-pushed the qu0b/test/eip8037-code-deposit-halt-state-gas branch from 9bf9dd0 to 4cc65c1 Compare April 1, 2026 18:11
If EIP-8037 adopts the top-level state gas refund
(ethereum/EIPs#11476), block gas accounting
in these tests will need updating.
@spencer-tb spencer-tb force-pushed the qu0b/test/eip8037-code-deposit-halt-state-gas branch from 4cc65c1 to 2515b77 Compare April 1, 2026 22:20
@codecov

codecov Bot commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

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

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

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 merged commit 2420c18 into ethereum:eips/amsterdam/eip-8037 Apr 1, 2026
16 of 17 checks passed
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 1, 2026
… gas (ethereum#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
marioevz pushed a commit that referenced this pull request Apr 9, 2026
… gas (#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
marioevz pushed a commit that referenced this pull request Apr 10, 2026
… gas (#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
felix314159 pushed a commit to felix314159/execution-specs that referenced this pull request Apr 14, 2026
… gas (ethereum#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
felix314159 pushed a commit that referenced this pull request Apr 16, 2026
… gas (#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit that referenced this pull request Apr 17, 2026
… gas (#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
qu0b added a commit to qu0b/execution-specs that referenced this pull request Apr 17, 2026
EELS patch: on top-level revert or exceptional halt, restore all
execution state gas to the reservoir and reset state_gas_used to
zero. Mirrors incorporate_child_on_error for child frames.

Test: 2-tx blockchain test at 100M where state gas is the binding
dimension. TX1 deploys 14 KiB contract (high state gas). TX2 is a
failing CREATE whose initcode state gas (GAS_NEW_ACCOUNT) is the
observable delta in header.gas_used.

This is the opposite of ethereum#2595 which tests that state gas IS counted
at the top level (#11468). This test verifies state gas is NOT
counted at the top level (#11476).

Spec change: ethereum/EIPs#11476

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
qu0b added a commit to qu0b/execution-specs that referenced this pull request Apr 17, 2026
EELS patch: on top-level revert or exceptional halt, restore all
execution state gas to the reservoir and reset state_gas_used to
zero. Mirrors incorporate_child_on_error for child frames.

Test: 2-tx blockchain test at 100M where state gas is the binding
dimension. TX1 deploys 14 KiB contract (high state gas). TX2 is a
failing CREATE whose initcode state gas (GAS_NEW_ACCOUNT) is the
observable delta in header.gas_used.

This is the opposite of ethereum#2595 which tests that state gas IS counted
at the top level (#11468). This test verifies state gas is NOT
counted at the top level (#11476).

Spec change: ethereum/EIPs#11476

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
marioevz pushed a commit that referenced this pull request Apr 20, 2026
… gas (#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit that referenced this pull request Apr 20, 2026
… gas (#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 21, 2026
… gas (ethereum#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 21, 2026
… gas (ethereum#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit that referenced this pull request Apr 21, 2026
… gas (#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
fselmo pushed a commit that referenced this pull request May 5, 2026
… gas (#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request May 22, 2026
… gas (ethereum#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants