Skip to content

feat(spec-specs, tests): EIP-8038: move SSTORE access-cost check before read - #3064

Merged
marioevz merged 3 commits into
ethereum:forks/amsterdamfrom
gurukamath:eip-7928/frontload-access-check-sstore
Jul 8, 2026
Merged

marioevz merged 3 commits into
ethereum:forks/amsterdamfrom
gurukamath:eip-7928/frontload-access-check-sstore

Conversation

@gurukamath

@gurukamath gurukamath commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

🗒️ Description

Post EIP-8038, the cold storage access cost (COLD_STORAGE_ACCESS = 3000)
exceeds the EIP-2200 call stipend (2300). SSTORE's EIP-2200 stipend sentry
(gas_left > CALL_STIPEND) therefore no longer guarantees that the access
cost is affordable before SSTORE performs its implicit storage read.

This PR moves up the access check. More context here on discord

🔗 Related Issues or PRs

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

@codecov

codecov Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.30%. Comparing base (b15a08b) to head (cb43ea2).
⚠️ Report is 5 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #3064   +/-   ##
================================================
  Coverage            93.30%   93.30%           
================================================
  Files                  624      624           
  Lines                36986    36988    +2     
  Branches              3383     3384    +1     
================================================
+ Hits                 34508    34510    +2     
  Misses                1695     1695           
  Partials               783      783           
Flag Coverage Δ
unittests 93.30% <100.00%> (+<0.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.

@gurukamath

Copy link
Copy Markdown
Contributor Author

@nerolation For review

@danceratopz
danceratopz force-pushed the eips/amsterdam/eip-2780-8038 branch 2 times, most recently from 35a757b to b270a21 Compare July 2, 2026 12:26
@spencer-tb
spencer-tb force-pushed the eips/amsterdam/eip-2780-8038 branch from bd52730 to ada583d Compare July 2, 2026 20:16
@spencer-tb spencer-tb added A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) C-feat Category: an improvement or new feature labels Jul 2, 2026
@spencer-tb spencer-tb added this to the Glamsterdam Devnet 7 Finalize milestone Jul 2, 2026
@gurukamath

Copy link
Copy Markdown
Contributor Author

Related to the spec update ethereum/EIPs#11854

@gurukamath
gurukamath force-pushed the eip-7928/frontload-access-check-sstore branch from bd2244f to 1768ac2 Compare July 6, 2026 14:49
… read

Post EIP-8038 the cold storage access cost (3000) exceeds the EIP-2200 call stipend (2300), so clearing the stipend sentry no longer guarantees the access cost is affordable. The implicit storage read in SSTORE records the slot into the EIP-7928 Block Access List, and that record survives frame rollback. With gas_left in (stipend, access_cost), the old ordering recorded a phantom read for an SSTORE that then ran out of gas on the access cost itself.

Compute the access cost first and check it (alongside the stipend sentry) before the read, warming the slot only once the access is affordable -- mirroring the CALL opcode and matching SLOAD, which already charges access before reading.

Pivot test_bal_sstore_and_oog OOG boundaries on the access cost instead of the stipend, and refresh the test_sstore_stipend_check_excludes_reservoir docstring.
@gurukamath
gurukamath force-pushed the eip-7928/frontload-access-check-sstore branch from 1768ac2 to 4d0bec2 Compare July 6, 2026 15:01
@gurukamath
gurukamath changed the base branch from eips/amsterdam/eip-2780-8038 to forks/amsterdam July 6, 2026 15:05
@gurukamath
gurukamath marked this pull request as ready for review July 6, 2026 15:08
@gurukamath
gurukamath force-pushed the eip-7928/frontload-access-check-sstore branch from 4d0bec2 to 41dfeb4 Compare July 6, 2026 15:18
@gurukamath
gurukamath requested a review from marioevz July 6, 2026 15:26

@jochem-brouwer jochem-brouwer left a comment

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.

Hi @gurukamath, this looks correct 😄 👍 , could you as sanity check verify if the changes rolled back in instructions/storage.py fail the newly introduced tests (the new tx gas limits) and if you re-add them they now pass? (Should fail at most 2 tests, I think it fails only one test, fail ABOVE_STIPEND_BELOW_ACCESS, pass AT_ACCESS_COST, if you roll back the instructions.py changes?)

OutOfGasAt.EIP_2200_STIPEND,
OutOfGasAt.EIP_2200_STIPEND_PLUS_1,
OutOfGasAt.ABOVE_STIPEND_BELOW_ACCESS,
OutOfGasAt.AT_ACCESS_COST,

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
OutOfGasAt.AT_ACCESS_COST,
OutOfGasAt.ABOVE_STIPEND_AT_ACCESS,

Nit: better name, more descriptive?

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.

Good point. Don't think the name fully described the scenario. Went with ACCESS_COVERED_OOG_ON_WRITE to be more explicit about it.

@gurukamath

Copy link
Copy Markdown
Contributor Author

Hi @gurukamath, this looks correct 😄 👍 , could you as sanity check verify if the changes rolled back in instructions/storage.py fail the newly introduced tests (the new tx gas limits) and if you re-add them they now pass? (Should fail at most 2 tests, I think it fails only one test, fail ABOVE_STIPEND_BELOW_ACCESS, pass AT_ACCESS_COST, if you roll back the instructions.py changes?)

I see there are two failure cases as expected EIP_2200_STIPEND_PLUS_1 and ABOVE_STIPEND_BELOW_ACCESS. These are the only two that behave differently between the previous implementation and the updated one

Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>

@spencer-tb spencer-tb left a comment

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.

LGTM! @jochem-brouwer for final approve here :)

@jochem-brouwer jochem-brouwer left a comment

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.

Thanks for the clarification, LGTM!

@marioevz marioevz changed the title feat(spec-specs, tests): move SSTORE access-cost check before read feat(spec-specs, tests): EIP-8038: move SSTORE access-cost check before read Jul 8, 2026
@marioevz
marioevz merged commit 76b7f70 into ethereum:forks/amsterdam Jul 8, 2026
27 checks passed
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-feat Category: an improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants