Skip to content

✨ feat(specs,tests): Implement EIP-7954#2276

Merged
fselmo merged 19 commits into
ethereum:eips/amsterdam/eip-7954from
raxhvl:eips/amsterdam/eip-7954-v1
Feb 25, 2026
Merged

✨ feat(specs,tests): Implement EIP-7954#2276
fselmo merged 19 commits into
ethereum:eips/amsterdam/eip-7954from
raxhvl:eips/amsterdam/eip-7954-v1

Conversation

@raxhvl
Copy link
Copy Markdown
Member

@raxhvl raxhvl commented Feb 23, 2026

🗒️ Description

Adds specs and tests for EIP-7954, see test_casee.md for human readable test cases.

test_max_code_size.py:

  • test_deploy_size — Code size boundary enforced at old max, new max, and over
  • test_create_opcode_deploy_size — Same via CREATE/CREATE2 opcodes
  • test_deploy_gas_usage — Code deposit gas charged correctly at new max
  • test_opcodes — EXTCODESIZE/EXTCODEHASH/EXTCODECOPY/CODESIZE/CODECOPY correct on max-size contract

test_max_initcode_size.py:

  • test_initcode_size — Initcode size boundary enforced at old max, new max, and over
  • test_create_opcode_initcode_size — Same via CREATE/CREATE2 opcodes
  • test_initcode_gas_metering_tx — Initcode gas metering at new max (tx level)
  • test_initcode_gas_metering_create_opcodes — Initcode gas metering at new max (opcode level)

test_fork_transition.py:

  • test_deploy_size_fork_transition — Code size limit enforced pre-fork, relaxed post-fork
  • test_create_opcode_deploy_size_fork_transition — Same via CREATE/CREATE2 opcodes
  • test_initcode_size_fork_transition — Initcode size limit enforced pre-fork, relaxed post-fork
  • test_create_opcode_initcode_size_fork_transition — Same via CREATE/CREATE2 opcodes
  • test_deploy_at_parent_max_across_fork — Old max still valid on both sides

test_eip_mainnet.py:

  • test_deploy_max_code_size_mainnet — Deploy at new max succeeds
  • test_deploy_over_max_code_size_mainnet — Deploy over new max fails
  • test_max_initcode_tx_mainnet — Creation with max initcode succeeds
  • test_over_max_initcode_tx_mainnet — Creation over max initcode rejected
  • test_opcodes_on_max_size_contract_mainnet — EXTCODESIZE/EXTCODEHASH/EXTCODECOPY correct on max-size contract

🔗 Related Issues or PRs

closes #2275

✅ 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).

Comment thread tests/amsterdam/eip7954_increase_max_contract_size/test_max_initcode_size.py Outdated
Comment thread tests/amsterdam/eip7954_increase_max_contract_size/test_max_code_size.py Outdated
@raxhvl raxhvl added A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) C-test Category: test labels Feb 23, 2026
@raxhvl raxhvl force-pushed the eips/amsterdam/eip-7954-v1 branch from 28db343 to 596239c Compare February 23, 2026 15:46
@raxhvl raxhvl marked this pull request as ready for review February 23, 2026 15:48
@raxhvl
Copy link
Copy Markdown
Member Author

raxhvl commented Feb 23, 2026

The mainnet tests that verify EVM opcodes for new sizes need not deploy their own contract and pollute state. I think we should reuse one of the contract deployed in the same suite.

@spencer-tb spencer-tb self-assigned this Feb 23, 2026
@marioevz marioevz self-assigned this Feb 24, 2026
@marioevz marioevz self-requested a review February 24, 2026 13:54
@marioevz marioevz requested review from fselmo and removed request for marioevz February 24, 2026 16:41
@marioevz marioevz removed their assignment Feb 24, 2026
@fselmo fselmo force-pushed the eips/amsterdam/eip-7954-v1 branch from 95ff84c to 1ddd772 Compare February 24, 2026 17:34
@fselmo
Copy link
Copy Markdown
Contributor

fselmo commented Feb 24, 2026

@raxhvl had to rebase here to get CI working. Added some minor tweaks as well but going to review more thoroughly now 👀

@fselmo fselmo force-pushed the eips/amsterdam/eip-7954-v1 branch from 1ddd772 to 95ff84c Compare February 24, 2026 17:37
@fselmo fselmo force-pushed the eips/amsterdam/eip-7954-v1 branch from 95ff84c to be62700 Compare February 24, 2026 17:39
@fselmo fselmo force-pushed the eips/amsterdam/eip-7954-v1 branch from be62700 to fbb0c0f Compare February 24, 2026 18:05
@fselmo
Copy link
Copy Markdown
Contributor

fselmo commented Feb 24, 2026

note: json_infra is expected to fail here since we're changing the spec and consuming an older version of it for tests

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.00%. Comparing base (7329095) to head (83d8240).
⚠️ Report is 1 commits behind head on eips/amsterdam/eip-7954.

Additional details and impacted files
@@                     Coverage Diff                     @@
##           eips/amsterdam/eip-7954    #2276      +/-   ##
===========================================================
- Coverage                    85.85%   84.00%   -1.85%     
===========================================================
  Files                          599      642      +43     
  Lines                        39428    42191    +2763     
  Branches                      3776     4055     +279     
===========================================================
+ Hits                         33851    35444    +1593     
- Misses                        4946     6027    +1081     
- Partials                       631      720      +89     
Flag Coverage Δ
unittests 84.00% <100.00%> (-1.85%) ⬇️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fselmo fselmo force-pushed the eips/amsterdam/eip-7954-v1 branch from 5c82a52 to a23b9e1 Compare February 25, 2026 01:41
@fselmo
Copy link
Copy Markdown
Contributor

fselmo commented Feb 25, 2026

Tests look good to me but I will take one more pass at them tomorrow as I ran out of time today 😅

I lied, I was able to get to it today! 😄

I added a test case for testing max code WITH max init code together. I'd love your thoughts on it. I also added some simplifications on what you already had and double checked gas, etc. Anything I wasn't sure we wanted I left as comments. Please feel free to push back on any of what I added, comment, etc... and also please lmk if you think the new test case is overkill across all 3 of mainnet, transition, and as a "regular" test.

I'm ready to approve here once you mark these resolved 👀. Nicely done and ty for this! 🚀

@raxhvl raxhvl force-pushed the eips/amsterdam/eip-7954-v1 branch from 92b1d44 to 173c9da Compare February 25, 2026 10:52
@raxhvl
Copy link
Copy Markdown
Member Author

raxhvl commented Feb 25, 2026

@fselmo thanks for this thorough review. responded to all your points.

re overkill: i hoped my initial implementation wouldn't be considered overkill for literally changing a single line in the specification. the new test is a valuable addition, but we could a second opinion on whether it's needed for the transition; the other two are definitely required.

Lastly, for the mainnet opcode test, can we reuse the deployed contract instead of creating a new one?

raxhvl and others added 2 commits February 25, 2026 17:31
@fselmo
Copy link
Copy Markdown
Contributor

fselmo commented Feb 25, 2026

Lastly, for the mainnet opcode test, can we reuse the deployed contract instead of creating a new one?

Great thought. I used the deterministic_deploy_contract() where we can... oracle contracts and some others require changes in their state to be validated so I don't think we can realistically re-use these. Is this what you meant? I have the commit here. Let me know if you meant something else.

Copy link
Copy Markdown
Contributor

@fselmo fselmo left a comment

Choose a reason for hiding this comment

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

lgtm, barring any added thoughts from your side @raxhvl. Feel free to merge 👍🏼

@raxhvl
Copy link
Copy Markdown
Member Author

raxhvl commented Feb 25, 2026

The mainnet test file deploys 4 contract.

I think for mainnet test lets only keep test_max_code_size_with_max_initcode_mainnet which is a super set of test_max_initcode_size_mainnet and test_max_code_size_mainnet. I cant think of a case where the former passes and either of the later ones fail. So we are down to two tests.

My question was can we get test_max_code_size_opcodes_mainnet to use the contract deployed by test_max_code_size_with_max_initcode_mainnet to verify the opcodes so we the test suite only deploys a single contract and keep the impact on mainnet state for testing minimal.

@fselmo
Copy link
Copy Markdown
Contributor

fselmo commented Feb 25, 2026

My question was can we get test_max_code_size_opcodes_mainnet to use the contract deployed by test_max_code_size_with_max_initcode_mainnet to verify the opcodes so we the test suite only deploys a single contract and keep the impact on mainnet state for testing minimal.

Yes! I like that. I extracted this to a fixture and used the deterministic deploy so we can reduce it to just this contract when possible, which can also be used in the non-mainnet file to DRY some of the same code over there 👌🏼

@fselmo
Copy link
Copy Markdown
Contributor

fselmo commented Feb 25, 2026

I think for mainnet test lets only keep test_max_code_size_with_max_initcode_mainnet which is a super set of test_max_initcode_size_mainnet and test_max_code_size_mainnet. I cant think of a case where the former passes and either of the later ones fail. So we are down to two tests.

Done 👍🏼

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests
@fselmo fselmo force-pushed the eips/amsterdam/eip-7954-v1 branch from 8b4cef6 to 83d8240 Compare February 25, 2026 19:07
@fselmo fselmo merged commit 93352e4 into ethereum:eips/amsterdam/eip-7954 Feb 25, 2026
14 of 15 checks passed
github-actions Bot pushed a commit that referenced this pull request Feb 27, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
spencer-tb pushed a commit to spencer-tb/execution-specs that referenced this pull request Mar 3, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
spencer-tb pushed a commit to spencer-tb/execution-specs that referenced this pull request Mar 6, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
spencer-tb pushed a commit to spencer-tb/execution-specs that referenced this pull request Mar 10, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
marioevz pushed a commit that referenced this pull request Mar 24, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
marioevz pushed a commit that referenced this pull request Apr 8, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
flcl42 pushed a commit to flcl42/execution-specs that referenced this pull request Apr 10, 2026
github-actions Bot pushed a commit that referenced this pull request Apr 10, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
spencer-tb pushed a commit to spencer-tb/execution-specs that referenced this pull request Apr 20, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
Carsons-Eels pushed a commit that referenced this pull request Apr 27, 2026
* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
marioevz added a commit that referenced this pull request May 15, 2026
…2850)

* ✨ feat(specs,tests): Implement EIP-7954 (#2276)

* ✨ feat: Tests for new contract size

* ✨ feat: Gas metering of initcode

* ✨ feat: Transition, Mainnet tests

* 🧹 chore: Names

* fix: use gas constant instead of hard-coded number

* fix: remove references to old_max that are not in tests

* fix: align with other forks; use 2*code_size for initcode size

* chore: fix lint

* refactor: simplify gas calculation with gas cost API; add post check

* refactor: use opcode metadata for gas calc

* feat(test): add max_code with max_init_code in same test

* refactor: simplify calls to compute_create_address; no conditional necessary

* 🧹 chore: Simplify docstring

* 🧹 chore: Simplify opcode based testing

* 🧹 chore: Better names

* 🧹 chore: types

* version

Co-authored-by: felipe <fselmo2@gmail.com>

* feat(test): use deterministic deploy for similar contracts

* refactor: use same max-size self-checking contract for tests

- DRY max size contract for mainnet by including the superset in one
  and removing subset tests

---------

Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>

* fix(tests): Failing initcode test (#2355)

* refactor(tests): remove gas metering test moved to EIP-8037

The 2D gas metering test for max initcode size via CREATE is an
EIP-8037 concern and now lives in the 8037 test suite. The 7954 max
initcode enforcement is covered by test_max_initcode_size_via_create.

* fix(tests): Merge issues

* refactor(tests): Condition EIP-7954 to EIP Inclusion

* refactor(tests): gate pre-EIP-7954 code size tests before EIP7954

These ported_static tests hardcode sizes around the pre-EIP-7954
24 KiB MAX_CODE_SIZE / 48 KiB MAX_INITCODE_SIZE limits, so paths
that previously failed now succeed on Amsterdam and break their
Account.NONEXISTENT expectations. I marked them valid_before(EIP7954).
The remaining 22 params still cover EIP-2929 warming on Amsterdam.
Equivalent Amsterdam-side coverage is provided by
eip7954_increase_max_contract_size/test_max_code_size.py and
test_max_initcode_size.py, which size against fork.max_code_size() /
fork.max_initcode_size() and follow the same creation-tx, CREATE,
and CREATE2 paths with the new limits.

* fix(tests): cover warm-after-failed-create over max code size

---------

Co-authored-by: raxhvl <10168946+raxhvl@users.noreply.github.com>
Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: fselmo <fselmo2@gmail.com>
Co-authored-by: Mario Vega <marioevz@gmail.com>
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

A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) C-test Category: test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants