feat(tests): EIP-8037 - code deposit halt must discard initcode state gas#2595
Conversation
…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>
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>
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>
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>
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
left a comment
There was a problem hiding this comment.
LGTM! @qu0b I just moved the test updated it to be more fork agnostic. PTAL
64f8162 to
9bf9dd0
Compare
|
@spencer-tb have you verified that it still fails against nethermind after your refactor? |
Was just about to ping! Will check just now :) |
|
but looks good to me changes seem minor |
|
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).
9bf9dd0 to
4cc65c1
Compare
If EIP-8037 adopts the top-level state gas refund (ethereum/EIPs#11476), block gas accounting in these tests will need updating.
4cc65c1 to
2515b77
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2420c18
into
ethereum:eips/amsterdam/eip-8037
… gas (ethereum#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (ethereum#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
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>
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>
… gas (#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (ethereum#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (ethereum#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
… gas (ethereum#2595) Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
🗒️ Description
Summary
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. TheGAS_NEW_ACCOUNTstate gas for the reverted operation must NOT count inblock_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 inflatedblock_state_gasproduces a different headergasUsed.Motivation
BAL devnet-3 chain split at block 17: nethermind's block header
gasUsedwas exactly 131,488 (=GAS_NEW_ACCOUNT) lower than the EELS reference. Traced via EVM step comparison toRevertRefundToHaltnot properly discarding the child frame'sStateGasUsedaccumulated during initcode execution.🔗 Related Issues or PRs
N/A.
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.