Skip to content

fix(ported_static): bump gas budgets for EIP-8037 state-gas headroom on Amsterdam#2796

Merged
marioevz merged 2 commits into
ethereum:devnets/bal/7from
leolara:wt-snobal-4-amsterdam-state-gas-fixes
May 11, 2026
Merged

fix(ported_static): bump gas budgets for EIP-8037 state-gas headroom on Amsterdam#2796
marioevz merged 2 commits into
ethereum:devnets/bal/7from
leolara:wt-snobal-4-amsterdam-state-gas-fixes

Conversation

@leolara
Copy link
Copy Markdown
Member

@leolara leolara commented May 4, 2026

🗒️ Description

Make tests/ported_static/ pass on Amsterdam under EIP-8037's two-dimensional gas model. Fix categories:

  1. Gas-bump tests (OoG headroom): hardcoded tx_gas / inner-CALL gas in tests authored against pre-EIP-8037 budgets is too tight on Amsterdam (EIP-8037 splits SSTORE-set / CALL-with-value-to-new-account / SELFDESTRUCT-to-new-account into a smaller regular portion plus state-gas; when the reservoir is empty the state-gas spills back into regular gas). Each affected literal is replaced with a fork-conditional variable that keeps the original value on pre-EIP-8037 forks and uses a higher bump on Amsterdam.

  2. Gas-measurement tests (Op.GAS before/after a state-changing op, value stored as post-state): the observed regular-gas consumption changes by deterministic deltas under EIP-8037:

    • fork.sstore_state_gas() - 17 100 per fresh SSTORE-set spill (17 100 = the SSTORE-set base regular drop)
    • fork.create_state_gas() - 25 000 per NEW_ACCOUNT spill (25 000 = old CALL_NEW_ACCOUNT / SELFDESTRUCT base)
    • sum of both for SELFDESTRUCT-with-write paths

    Expected storage values become original_value + (delta if fork.is_eip_enabled(8037) else 0). The fork-helper expressions auto-adapt to any future COST_PER_STATE_BYTE change (this branch already saw 1 174 → 1 530 mid-flight without further hand-tuning).

  3. stCallCodes / stCallDelegateCodes* family (35 files): all share the same nested CALL/CALLCODE/DELEGATECALL pattern with three hardcoded inner gas values (0x3D090 / 0x493E0 / 0x55730). Replaced with fork-conditional inner_call_gas / middle_call_gas / outer_call_gas variables across the family.

Per review feedback (#2796 by @marioevz), every gas change preserves the original value as the else branch of if fork.is_eip_enabled(8037), so behavior on Cancun / Prague / Osaka is unchanged.

Stats

Count
Test files modified 52
Skip-list entries removed 165 (× 3 fixture variants = 495 test runs unskipped)
Skip list before (bal/7) 1 062
Skip list after 897

Verification

uv run fill -m "not slow" --fork Amsterdam tests/ported_static/  →  16 482 passed, 0 failed, 2 448 skipped
uv run fill -m "not slow"                 tests/ported_static/  →  60 476 passed, 0 failed (Cancun/Prague/Osaka/Amsterdam)

Files by category

Gas-bump (fork-conditional tx_gas / inner CALL gas):

File Pre-8037 → Amsterdam
stCreate2/test_create2collision_selfdestructed.py tx 400 000 → 1 000 000, inner CALL 0xC350 → 0x40000
stCreate2/test_create2collision_selfdestructed2.py tx 400 000 → 1 000 000, inner CALL 0xC350 → 0x40000
stCreate2/test_create2_smart_init_code.py tx 400 000 → 1 000 000
stCreate2/test_create2_contract_suicide_during_init_then_store_then_return.py tx 600 000 → 5 000 000, inner CALL 0x249F0 → 0x100000
stCreateTest/test_create_transaction_call_data.py tx 100 000 → 500 000
stCreateTest/test_create_transaction_high_nonce.py tx 90 000 → 500 000
stCodeSizeLimit/test_codesize_valid.py tx 15M → 40M
stRevertTest/test_revert_opcode_in_init.py tx 160 000 → 800 000
stSStoreTest/test_sstore_change_from_external_call_in_init_code.py (bal/7's intrinsic-derived fix; this branch defers)
stInitCodeTest/test_call_the_contract_to_create_empty_contract.py tx 100 000 → 500 000
stWalletTest/test_day_limit_construction.py tx [817 083, 1 217 083] → [5 000 000, 7 000 000]
stWalletTest/test_wallet_construction.py tx [1 225 023, 1 825 023] → [8 000 000, 10 000 000]
stHomesteadSpecific/test_create_contract_via_transaction_cost53000.py tx 100 000 → 500 000, sender 0xF4240 → 0x4C4B40
stPreCompiledContracts2/test_call_ecrecover_overflow.py tx 100 000 → 500 000 (inner ecrecover CALL 0xBB8 unchanged — that's the test premise)

Gas-measurement (fork-conditional expected-value deltas via fork helpers):

File Delta added on Amsterdam
stEIP2930/test_storage_costs.py + fork.sstore_state_gas() - 17 100 to 10 SSTORE-set measurements
stEIP2930/test_varied_context.py SSTORE-set, NEW_ACCOUNT, and SELFDESTRUCT-with-write deltas to 28 measurements
stEIP2930/test_manual_create.py SSTORE-set delta to 2 measurements
stPreCompiledContracts/test_precomps_eip2929_cancun.py NEW_ACCOUNT delta to 2 expect-entries (87 parametrizations)

stCallCodes / stCallDelegateCodes* (35 files): uniform inner_call_gas / middle_call_gas / outer_call_gas fork-conditional refactor.

✅ 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).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

Cute Animal Picture

Quokka at Rottnest Island

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (devnets/bal/7@bcc2a87). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             devnets/bal/7    #2796   +/-   ##
================================================
  Coverage                 ?   85.59%           
================================================
  Files                    ?      630           
  Lines                    ?    39606           
  Branches                 ?     3937           
================================================
  Hits                     ?    33899           
  Misses                   ?     5083           
  Partials                 ?      624           
Flag Coverage Δ
unittests 85.59% <ø> (?)

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.

@leolara leolara marked this pull request as ready for review May 4, 2026 15:59
@leolara leolara changed the base branch from devnets/snøbal/4 to devnets/snobal/6 May 5, 2026 08:58
@leolara leolara requested a review from spencer-tb May 6, 2026 13:30
@leolara leolara changed the base branch from devnets/snobal/6 to devnets/bal/7 May 8, 2026 12:56
@leolara leolara force-pushed the wt-snobal-4-amsterdam-state-gas-fixes branch from cc41427 to 052496d Compare May 8, 2026 12:56
Comment on lines +75 to +79
@@ -70,7 +76,7 @@ def test_create2_contract_suicide_during_init_then_store_then_return(
contract_0 = pre.deploy_contract( # noqa: F841
code=Op.POP(
Op.CALL(
gas=0x249F0,
gas=0x100000,
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.

Can we create a call_gas variable that has a different value depending on whether EIP-8037 is enabled in the fork where the test is being executed?

call_gas = 0x249F0
if fork.is_eip_enabled(8037):
  call_gas = 0x100000
# { (CALL 150000 0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b 1 0 0 0 32) (SSTORE 1 (MLOAD 0)) }  # noqa: E501
contract_0 = pre.deploy_contract(  # noqa: F841
code=Op.POP(
Op.CALL(
                gas=call_gas,

This will allow us to preserve the original gas value in case we need to do further modifications, and it also makes it more clear why this gas bump was done in the first place.

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.

Same comment for the rest of the tests.

@spencer-tb
Copy link
Copy Markdown
Contributor

Feel free to rebase on the latest devnets/bal/7! :)

leolara added a commit to leolara/execution-specs that referenced this pull request May 11, 2026
Per review feedback (ethereum#2796 review by marioevz), all hardcoded gas
bumps for EIP-8037 state-gas headroom on Amsterdam are now wrapped in
an `if fork.is_eip_enabled(8037)` guard that preserves the original
pre-EIP-8037 gas value as the default branch. The same call sites
keep their bumped value on Amsterdam.

Affected categories:

- 35 stCallCodes/stCallDelegateCodes* tests — three inner-CALL gas
  values (`0x3D090` / `0x493E0` / `0x55730`) replaced with
  `inner_call_gas` / `middle_call_gas` / `outer_call_gas` variables
  that flip to the bumped values on EIP-8037. Three outlier files
  (test_callcode_dynamic_code{,2_self_call}, test_callcodecallcode
  callcode_111_suicide_end) use their own original values but the
  same conditional pattern.

- 13 individual gas-bump tests (from the original PR 2796 commit and
  later follow-ups) — each gets fork-conditional `tx_gas_limit`,
  `tx_gas[]`, `inner_call_gas`, or sender funding variables that
  preserve the original literal pre-EIP-8037.

The four gas-measurement tests already committed earlier this branch
(test_storage_costs, test_varied_context, test_precomps_eip2929_
cancun, test_manual_create) and test_codesize_valid use the same
pattern via the `sstore_set_delta` / `new_account_delta` / similar
helpers — those are left unchanged.

Verified full Amsterdam fill on `tests/ported_static/` still produces
18 051 passed / 0 failed / 879 skipped.
…ements

Rebase of branch wt-snobal-4-amsterdam-state-gas-fixes onto bal/7
HEAD. Two upstream changes drive the new revision:

  - `bcc2a876d` raises `COST_PER_STATE_BYTE` from 1 174 to 1 530, so
    per-storage state-gas is now `32 * 1530 = 48 960` and per-new-
    account state-gas is `112 * 1530 = 171 360`.
  - `2e707c22c` etc. add fresh entries to `amsterdam_skip_list.txt`
    covering more tests broken by EIP-8037 on Amsterdam.

The 11 original commits on this branch collapsed to a single
revision because:

  - test_sstore_change_from_external_call_in_init_code.py — bal/7's
    upstream version (`tx_gas = [intrinsic + tx_data[d].gas_cost
    (fork)]` with `inner_call_cost` annotations) supersedes the gas
    bump this branch had. Keep bal/7's version, drop the bump.
  - test_storage_costs, test_varied_context, test_manual_create,
    test_precomps_eip2929_cancun — replace the hardcoded SSTORE-set
    and NEW_ACCOUNT spillover deltas (20 468 / 106 488 / 126 956,
    derived for CPSB = 1 174) with fork-helper expressions
    (`fork.sstore_state_gas() - 17 100`, `fork.create_state_gas() -
    25 000`, and their sum) so the deltas auto-adapt to the new
    1 530 CPSB and any future change.
  - All other gas-bump tests — keep their fork-conditional structure
    from the prior `refactor(ported_static): make EIP-8037 gas bumps
    fork-conditional` commit, but raise the EIP-8037 budgets where
    1 530 CPSB pushes the previous bump under the new spill (test_
    storage_costs, test_manual_create, test_codesize_valid,
    test_callcode_dynamic_code, test_wallet_construction, test_
    callcodecallcodecallcode_111_suicide_end). Pre-EIP-8037 values
    are still preserved.

Skip list: start from bal/7's 1 062-entry list (which already
covered the new failures the CPSB bump introduced), then drop the
165 entries that point at files this branch fixes. New total: 732.

Verified across Cancun/Prague/Osaka/Amsterdam: 60 476 passed,
0 failed. Amsterdam alone: 16 482 passed, 0 failed, 2 448 skipped.
@leolara leolara force-pushed the wt-snobal-4-amsterdam-state-gas-fixes branch from d9b6b5f to e010aef Compare May 11, 2026 15:23
Apply `just fix` formatting to the 4 gas-measurement tests this branch
touches (test_storage_costs, test_varied_context, test_manual_create,
test_precomps_eip2929_cancun) plus an upstream-drift reformat picked
up in test_state_gas_call.py. Shorten the E501-flagged docstring line
in test_manual_create by dropping the inline assignment from the
explanation.

`just static` passes (exit 0).
@leolara
Copy link
Copy Markdown
Member Author

leolara commented May 11, 2026

@marioevz @spencer-tb rebased, added more tests fixes and did as Mario said with the conditional gas

@marioevz marioevz merged commit 3a951c7 into ethereum:devnets/bal/7 May 11, 2026
18 checks passed
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.

3 participants