Skip to content

feat(tests,forks): tests BAL early validation; refactor system contracts - #3484

Open
fselmo wants to merge 3 commits into
ethereum:forks/amsterdamfrom
fselmo:feat/eip7928-early-validation-test
Open

feat(tests,forks): tests BAL early validation; refactor system contracts#3484
fselmo wants to merge 3 commits into
ethereum:forks/amsterdamfrom
fselmo:feat/eip7928-early-validation-test

Conversation

@fselmo

@fselmo fselmo commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Reviewed and added tests around the early invalidation of blocks using the BAL against BAL reads w/ ITEM_COST.

def

G_remaining >= R_remaining * 2000

This suggested check can lead to clients invalidating valid blocks if implemented as suggested. This PR aims to add tests around this to show that system contract reads are present in R_remaining, as defined by the EIP, but they don't actually pay any gas... so the G_remaining goes to 0 while there are still reads in R_remaining, leading to an improper check on reads that actually use up the G_remaining. This can lead to early invalidation of near-full to full blocks... The invalidation happens near the end but it happens nonetheless and we should cover this in our tests.

As far as I can tell no client is implementing this except for Nethermind and they seem to remove the system contract addresses from the R_remaining, which circumvents the problem. Something the EIP does not suggest and they seemingly did of their own accord. This means no client would currently fail these tests but this gap should nonetheless be covered.


In order to cover this gap appropriately and future-proof this test, it's important to make sure that any system contracts that get added on to post-execution and contain reads get accounted for. This led to a cleaner redesign for the organization of system contracts in the testing framework that builds them in the style of our EIP mixins that were more recently introduced, and adds these properties to the fork more directly – rather than being hard-coded in the Spec class in specs.py which can be a bit too rigid.

Note: I'm quite happy to move this refactor to another PR but I did separate it into its own commit so the tests could be reviewed separately. I ran hasher compare on all tests affected by this contract refactor and they are identical hashes. I even audited the hasher tool to make sure this isn't a blind check since I've never audited the tool itself I don't think 😅 (all looks good there too).

extra: Added some updates to the test-writing skill that come up often enough

Related Issues or PRs

ethereum/EIPs#12277 created to change the EIP

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <title>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Cute Animal Picture

Screenshot 2026-09-03 at 14 05 21

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.01%. Comparing base (027634b) to head (53acdb1).

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #3484   +/-   ##
================================================
  Coverage            94.01%   94.01%           
================================================
  Files                  624      624           
  Lines                36905    36905           
  Branches              3326     3326           
================================================
  Hits                 34695    34695           
  Misses                1533     1533           
  Partials               677      677           
Flag Coverage Δ
unittests 94.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Comment thread .claude/commands/write-test.md Outdated
@fselmo
fselmo force-pushed the feat/eip7928-early-validation-test branch 9 times, most recently from a2c8602 to 00b4c39 Compare September 3, 2026 20:23
@fselmo
fselmo marked this pull request as ready for review September 3, 2026 21:13
@fselmo
fselmo force-pushed the feat/eip7928-early-validation-test branch from 00b4c39 to 53acdb1 Compare September 3, 2026 21:13
@fselmo fselmo added C-feat Category: an improvement or new feature A-tests Area: Consensus tests. A-test-forks Area: execution_testing.forks labels Sep 3, 2026
@fselmo fselmo changed the title feat(tests): Add more tests for early validation invariant check feat(tests,forks): tests BAL early validation; refactor system contracts Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-test-forks Area: execution_testing.forks A-tests Area: Consensus tests. C-feat Category: an improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant