Skip to content

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

Merged
fselmo merged 19 commits intoethereum: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 intoethereum:eips/amsterdam/eip-7954from
raxhvl:eips/amsterdam/eip-7954-v1

Conversation

@raxhvl
Copy link
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).

@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
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
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
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

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

fselmo commented Feb 25, 2026

@raxhvl I added a minor simplification refactor here. Tests look good to me but I will take one more pass at them tomorrow as I ran out of time today 😅

@fselmo fselmo force-pushed the eips/amsterdam/eip-7954-v1 branch from 5c82a52 to a23b9e1 Compare February 25, 2026 01:41
@fselmo
Copy link
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
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?

@fselmo
Copy link
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
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
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
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
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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: fselmo <[email protected]>
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