Skip to content

feat(spec-specs, tests): alt to merge 8037 to forks/amsterdam#2901

Open
spencer-tb wants to merge 110 commits into
ethereum:forks/amsterdamfrom
spencer-tb:eips/amsterdam/eip-8037
Open

feat(spec-specs, tests): alt to merge 8037 to forks/amsterdam#2901
spencer-tb wants to merge 110 commits into
ethereum:forks/amsterdamfrom
spencer-tb:eips/amsterdam/eip-8037

Conversation

@spencer-tb
Copy link
Copy Markdown
Contributor

@spencer-tb spencer-tb commented May 22, 2026

🗒️ Description

This PR merges EIP-8037 into forks/amsterdam including framework, specs and all test changes.

Please assign yourself below for reviewing!

Review Plan

The test batch 2/3 reviewers should aim to check that the changes don't break what the tests are intending to do in the first place.

🔗 Related Issues or PRs

N/A.

✅ 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 and others added 30 commits May 21, 2026 12:59
…se (ethereum#2363)

* feat(spec-specs): update EIP-8037 to match latest spec revision

* feat(tests): add EIP-8037 state creation gas cost increase tests
Co-authored-by: Ben Adams <thundercat@illyriad.co.uk>
Add sstore_state_gas(), code_deposit_state_gas(), and create_state_gas()
calculator methods to Fork. Replace Spec constants and manual gas
arithmetic across all EIP-8037 tests with dynamic fork method calls.
Remove redundant Op.STOP, hardcoded numbers from docstrings, and add
fork: Fork parameter to all test functions that use fork methods.
Test CREATE with max initcode size using proper regular/state gas
split via the reservoir. Verifies gas boundary behavior with EIP-8037
two-dimensional metering.
Align EIP-8037 gas constant references with upstream renames:
- GAS_STORAGE_UPDATE → GAS_COLD_STORAGE_WRITE
- GAS_COLD_SLOAD → GAS_COLD_STORAGE_ACCESS
- GAS_WARM_ACCOUNT_ACCESS → GAS_WARM_ACCESS

Bump gas_limit on tests added to upstream after EIP-8037 branched,
which now need extra gas for EIP-8037 state gas costs.
… format runs in withdrawal request contract tests (ethereum#2532)

* fix(tests): prevent tx_gas_limit double-accumulation across fixture format runs in withdrawal request contract tests

* fix: mypy

* fix: ruff

* fix: ruff

* chore(tests): refactor fix to fork-aware transactions to prevent mutation

* chore(test): add a warning to all tests that could mutate vars; address in later PR

Add a lightweight repr-based snapshot hook to the filler plugin that warns whenever
any ``pytest.param`` value is mutated during a test run.

A subsequent PR could address this by returning values instead of mutating, then
flipping the hook to a hard failure.

---------

Co-authored-by: fselmo <fselmo2@gmail.com>
… gas validity test (ethereum#2583)

Co-authored-by: Stefan <22667037+qu0b@users.noreply.github.com>
Conditionally increase tx gas_limit (and env gas_limit where needed)
when fork >= Amsterdam to account for EIP-8037 state creation gas costs.

137 files, 9 with env gas_limit bumps. Headroom: 2,000,000.
Move MAX_CODE_SIZE check before gas charges, charge keccak hash
cost (regular gas) before code deposit state gas, and add tests
for over-max code size and reservoir preservation after OOG.
On CREATE/CREATE2 address collision the 63/64 gas allocation is
burned but was not added to regular_gas_used, leaving it invisible
to 2D block gas accounting. Per EIP-684 collision behaves as an
immediate exceptional halt, so the burned gas belongs in the regular
dimension.
…and subcall pattern

Co-authored-by: Mario Vega <marioevz@gmail.com>
The static test skip list and conftest were a temporary workaround for
EIP-8037 gas failures. The ported static tests in tests/ported_static/
replace this approach; failures are tracked in ethereum#2601.
…thereum#2603)

* fix(execute): use --sender-fund-refund-gas-limit for all funding txs

On EIP-8037 networks, simple value transfers to new accounts require
more than 21000 gas due to GAS_NEW_ACCOUNT state gas (112 * cpsb).
The default Transaction gas_limit of 21000 causes 'intrinsic gas too
low' errors during test setup.

Changes:
- contracts.py: Use 200000 gas for deterministic factory deployer funding
- pre_alloc.py: Pass sender_fund_refund_gas_limit to Alloc and use it
  for simple EOA funding transactions

Usage: --sender-fund-refund-gas-limit 200000

* chore: additional fixes for execute remote funds w/ higher gas limits

* fix: bump all gas limits to 200k for EIP-8037 state creation costs

- sender.py: bump --sender-fund-refund-gas-limit default 21000 → 200000
- pre_alloc.py: bump funding_gas_limit default 21000 → 200000
- pre_alloc.py: use configurable gas limit for per-test refund txs
- execute_recover.py: bump recovery refund gas limit 21000 → 200000

EIP-8037 charges GAS_NEW_ACCOUNT (112 × cost_per_state_byte = 131488)
for transfers to new accounts, making 21000 gas insufficient for all
funding, refund, and recovery transactions.

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

---------

Co-authored-by: Felipe Selmo <fselmo2@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… gas (ethereum#2595)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
…ode size validation (ethereum#2608)

* fix(spec): charge CREATE state gas after initcode size validation

Move charge_state_gas(STATE_BYTES_PER_NEW_ACCOUNT) from create()/create2()
into generic_create(), after the MAX_INIT_CODE_SIZE check.

Previously, state gas was charged before the initcode size check, so a
CREATE with oversized initcode would persist state_gas_used equal to the
account creation state gas cost (STATE_BYTES_PER_NEW_ACCOUNT *
cost_per_state_byte) even though no account was ever created and no state
was touched.

Reported by @AskDragan (reth): ethereum#2578 (comment)

* fix(spec): check static context before gas in CREATE/CREATE2

Move the is_static check from generic_create() into create() and
create2(), before stack pops and charge_gas(). This is consistent
with SSTORE, CALL, and SELFDESTRUCT which all check static context
before any gas charging.
…evel failure (ethereum#2689)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 21.95122% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.91%. Comparing base (1de389b) to head (2a765ab).
⚠️ Report is 4 commits behind head on forks/amsterdam.

Files with missing lines Patch % Lines
src/ethereum/forks/amsterdam/transactions.py 15.38% 22 Missing ⚠️
src/ethereum/forks/amsterdam/vm/__init__.py 41.66% 7 Missing ⚠️
src/ethereum/trace.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           forks/amsterdam    #2901      +/-   ##
===================================================
- Coverage            90.44%   88.91%   -1.53%     
===================================================
  Files                  535      496      -39     
  Lines                32439    29758    -2681     
  Branches              3012     2723     -289     
===================================================
- Hits                 29338    26459    -2879     
- Misses                2573     2814     +241     
+ Partials               528      485      -43     
Flag Coverage Δ
unittests 88.91% <21.95%> (-1.53%) ⬇️

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
Copy link
Copy Markdown
Contributor Author

@marioevz - removed the sstore_state_gas function here: 0bfb5f2

@spencer-tb spencer-tb marked this pull request as ready for review May 27, 2026 16:01
@marioevz marioevz requested a review from SamWilsn May 27, 2026 16:12
Comment thread src/ethereum/forks/amsterdam/vm/__init__.py Outdated
Comment thread src/ethereum/forks/amsterdam/vm/__init__.py
Comment thread src/ethereum/forks/amsterdam/vm/__init__.py
Comment thread src/ethereum/forks/amsterdam/vm/__init__.py
Comment thread src/ethereum/forks/amsterdam/vm/instructions/storage.py Outdated
Comment thread src/ethereum/forks/amsterdam/fork.py Outdated
Comment thread src/ethereum/forks/amsterdam/fork.py Outdated
Comment on lines +31 to +46
@dataclass
class IntrinsicGasCost:
"""
Intrinsic gas costs for a transaction, split by gas type.

`regular`: `ethereum.base_types.Uint`
Regular execution gas (calldata, base cost, access list, etc.)
`state`: `ethereum.base_types.Uint`
State growth gas (account creation, storage set, authorization).
`calldata_floor`: `ethereum.base_types.Uint`
Minimum gas cost based on calldata size per [EIP-7623].
"""

regular: Uint
state: Uint
calldata_floor: Uint
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.

This will need to be backported.

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.

Agreed, will add to back meta item in EIP tracker, as a follow up: #2040 (comment)

Comment thread src/ethereum/forks/amsterdam/transactions.py Outdated
Comment thread src/ethereum/forks/amsterdam/transactions.py Outdated
Copy link
Copy Markdown
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

I've reviewed packages/testing and tests/amsterdam in this review round, and left a couple of comments, thanks!

Comment thread tests/amsterdam/eip7708_eth_transfer_logs/test_burn_logs.py Outdated
Comment thread tests/amsterdam/eip7708_eth_transfer_logs/test_burn_logs.py Outdated
Comment thread tests/amsterdam/eip7708_eth_transfer_logs/test_burn_logs.py Outdated
Comment thread tests/amsterdam/eip7708_eth_transfer_logs/test_burn_logs.py Outdated
@leolara
Copy link
Copy Markdown
Member

leolara commented May 28, 2026

I would like to say that many of my fixes for ported_static in amsterdam should be in snobal-6 and bal-7 branches.

#2783
#2790
#2796
#2839

Not merged yet: #2843

@leolara leolara self-requested a review May 28, 2026 10:16
leolara
leolara previously approved these changes May 28, 2026
@leolara
Copy link
Copy Markdown
Member

leolara commented May 28, 2026

ported_static 👍🏼

Copy link
Copy Markdown
Contributor

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

Got through Osaka, Berlin, and Byzantium today. I saw a few things that need to be updated, but nothing major!

@@ -642,6 +648,13 @@ def intrinsic_cost_for_num_accounts(account_count: int) -> int:
],
)
@pytest.mark.valid_from("Osaka")
# TODO[EIP-8037]: cap math here uses the combined intrinsic (regular + state)
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.

Added an issue for this case here

# Ensures that the precompile call is not starved by the 63/64 rule.
precompile_gas_with_margin = precompile_gas * 64 // 63
gas_costs = fork.gas_costs()
sstore_gas = gas_costs.STORAGE_SET * (len(modexp_expected) // 32)
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.

I'm curious about this change. It looks like len(modexp_expected) // 32 = 38 // 32 = 1, so it only budgets for 1 SSTORE, when the contract actually does
2-4. I believe the test passes because extra_gas covers the shortfall, but may be missing something, or maybe that's ok, just wanted to flag :)

Alloc,
Bytes,
Environment,
Fork,
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.

Looks like this can be removed. Not used anywhere.

Copy link
Copy Markdown
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

A couple more comments.

Comment thread tests/shanghai/eip3860_initcode/test_initcode.py
Comment thread tests/frontier/opcodes/test_dup.py
SYSTEM_MAX_SSTORES_PER_CALL = 16


class EIP8037(BaseFork):
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.

Shouldn't this class also update transaction_gas_limit_cap to return None again? It feels to me that the cap is effectively removed by this EIP. Not entirely sure about the repercussions though.

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.

The cap still exists it just relocates to regular gas only!

Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com>
spencer-tb and others added 5 commits June 1, 2026 16:40
…e pattern

Co-authored-by: marioevz <11726710+marioevz@users.noreply.github.com>
Co-authored-by: marioevz <11726710+marioevz@users.noreply.github.com>
…r 8037

Co-authored-by: marioevz <11726710+marioevz@users.noreply.github.com>
… 8037

Co-authored-by: marioevz <11726710+marioevz@users.noreply.github.com>
Co-authored-by: marioevz <11726710+marioevz@users.noreply.github.com>
@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037 branch from 9a978a8 to b95369f Compare June 1, 2026 15:41
Co-authored-by: marioevz <11726710+marioevz@users.noreply.github.com>
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.

10 participants