Skip to content

feat(spec, spec-specs): EIP-7997#2802

Open
kclowes wants to merge 4 commits into
ethereum:forks/amsterdamfrom
kclowes:eips/amsterdam/eip-7997
Open

feat(spec, spec-specs): EIP-7997#2802
kclowes wants to merge 4 commits into
ethereum:forks/amsterdamfrom
kclowes:eips/amsterdam/eip-7997

Conversation

@kclowes
Copy link
Copy Markdown
Contributor

@kclowes kclowes commented May 4, 2026

🗒️ Description

EIP-7997 implementation and tests

🔗 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).
  • 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

Put a link to a cute animal picture inside the parenthesis-->

@kclowes kclowes changed the title Eips/amsterdam/eip 7997 feat(spec, spec-specs): EIP-7997 May 4, 2026
@kclowes kclowes added A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) C-feat Category: an improvement or new feature A-test-specs Area: execution_testing.specs labels May 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.48%. Comparing base (9d18733) to head (97a92d1).
⚠️ Report is 11 commits behind head on forks/amsterdam.

Files with missing lines Patch % Lines
src/ethereum/forks/amsterdam/fork.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           forks/amsterdam    #2802      +/-   ##
===================================================
- Coverage            88.17%   85.48%   -2.69%     
===================================================
  Files                  577      630      +53     
  Lines                35659    39383    +3724     
  Branches              3490     3909     +419     
===================================================
+ Hits                 31442    33668    +2226     
- Misses                3654     5055    +1401     
- Partials               563      660      +97     
Flag Coverage Δ
unittests 85.48% <50.00%> (-2.69%) ⬇️

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.

@kclowes kclowes force-pushed the eips/amsterdam/eip-7997 branch from 4eb98bd to 2daf7a9 Compare May 6, 2026 20:22
@LouisTsai-Csie LouisTsai-Csie self-requested a review May 7, 2026 06:10
@petertdavies
Copy link
Copy Markdown
Contributor

Deploying a system contract in the precompile range has the potential to cause weird bugs in clients that have longstanding hardcoded assumptions that the 0x01-0xff range is only precompiles. This isn't a precompile, it's just a regular contract. The level of testing required is higher than might superficially appear from the EIP.

The included tests look pretty good, but I could think of few more:

  • Test the interaction between 0x12 and access list prewarming. The EIP is silent on prewarming, as written this PR does not prewarm.
  • Try CALLCODEing it.
  • Give it a balance using SELFDESTRUCT.

@kclowes
Copy link
Copy Markdown
Contributor Author

kclowes commented May 7, 2026

Thanks @petertdavies! I will add those! It is very strange that this is in the precompile range, but is not a precompile.

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.

Looks great so far, a few comments. Thanks!

ref:ethereum.forks.amsterdam.fork.DETERMINISTIC_FACTORY_ADDRESS

"""
code_hash = store_code(old.state, DETERMINISTIC_FACTORY_CODE)
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.

Interesting, I did not know we had this functionality!

I'm not sure though how do we signal from the tests that a block is the first block in the fork?

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.

@marioevz I'm not sure what you mean by:

I'm not sure though how do we signal from the tests that a block is the first block in the fork?

Can you clarify? AFAIK, the tests don't call apply_fork, and AIUI, we'd have to test with a pre_alloc mutable as discussed below, for inherently not a great test. This is also highlighted in the codecov report since there is not a great way to test this method. Let me know if you see another way though! I'm happy to update.

REFERENCE_SPEC_GIT_PATH = ref_spec_7997.git_path
REFERENCE_SPEC_VERSION = ref_spec_7997.version

pytestmark = pytest.mark.valid_from("Amsterdam")
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.

Suggested change
pytestmark = pytest.mark.valid_from("Amsterdam")
pytestmark = pytest.mark.valid_from("EIP7997")

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.

We should test the transition to the fork where this EIP is enabled, but that circles back to my question on the first comment since I'm not really sure how we signal this in the t8n. Maybe @gurukamath has more insight.

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.

I think that the best we can do is do a pre_alloc_mutable and do something like: pre[0x12] - Account(code=b"", nonce=0, balance=0, and assert that you can call the contract, and it returns success for the call, but it doesn't return anything else. It looks like we do a similar thing here. I'm not sure how much value that test really adds though.

…warming, CALLCODE, and giving it a balance via SELFDESTRUCT
@kclowes kclowes marked this pull request as ready for review May 11, 2026 17:40
@kclowes
Copy link
Copy Markdown
Contributor Author

kclowes commented May 11, 2026

@marioevz @petertdavies @LouisTsai-Csie - this is ready for another look when you get a chance. I added the tests @petertdavies suggested.

I'm not sure how to raise the question of whether this contract should be prewarmed - is that something that we'd generally put into the tests and see which clients fail or is it something we'd bring up in a sync call or comment on the EIP?

Edit to add: I don't think there is a way around the apply_fork coverage fail, but very happy to hear suggestions!

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/*`) A-test-specs Area: execution_testing.specs C-feat Category: an improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants