feat(tests): cover EXTCODESIZE/EXTCODECOPY surcharge on empty accounts#8
Merged
marioevz merged 2 commits intoJun 23, 2026
Conversation
The EIP-8038 code-read surcharge (`+WARM_ACCESS`) is added before the account is read, with no emptiness guard, so an empty or non-existent target still costs cold `3100` / warm `200`. The suite previously measured these two opcodes only against code-bearing targets, leaving the empty-account path unverified: A client that skipped the second read for code-less accounts would have gone uncaught. Add three tests against a non-existent `0xDEAD` target: The cold/warm surcharge for both opcodes, `EXTCODESIZE` returning `0` while still charged, and `EXTCODECOPY` composing the surcharge additively with the per-word copy and memory-expansion costs.
marioevz
reviewed
Jun 23, 2026
marioevz
left a comment
There was a problem hiding this comment.
Some comments just to simplify and make the tests more maintainable. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add tests pinning that the EIP-8038
EXTCODESIZE/EXTCODECOPYcode-read surcharge (+WARM_ACCESS) is charged unconditionally, including against an empty or non-existent account, whereEXTCODESIZEreturns0andEXTCODECOPYcopies zeros.In the spec the surcharge is added after the warm/cold branch and before the account is read, with no emptiness guard (
amsterdam/vm/instructions/environment.py,extcodesizeandextcodecopy), so an empty target still costs cold3100/ warm200, exactly like a code-bearing target. The suite previously measured these two opcodes only against code-bearing targets: The sole empty-accountEXT*test coveredEXTCODEHASH, which carries no surcharge, so a client that skipped the second read for code-less accounts would have gone uncaught.New tests (
tests/amsterdam/eip8038_state_access_gas_cost_increase/test_ext_code_opcodes_gas.py):test_ext_code_double_read_empty_account: ChargesEXTCODESIZE/EXTCODECOPYagainst0xDEAD, cold and warm, asserting3100/200and cross-checking the opcode model.test_extcodesize_empty_account_returns_zero: Asserts the surcharge alongside a returned size of0, usingstop=Falseso the size check is not dead code after the auto-appendedSTOP.test_extcodecopy_empty_account_composes_additively: Copies 32 and 96 bytes from the empty source, asserting the surcharge composes additively with the per-word copy and memory-expansion costs.Verified on Amsterdam: All parametrizations fill, and the execution traces show the measured opcode charging
3100(cold) /200(warm) against0xDEADwithEXTCODESIZEreturning0. Coverage addition only: No spec or fixture behavior changes.🔗 Related Issues or PRs