Skip to content

feat(tests): cover EXTCODESIZE/EXTCODECOPY surcharge on empty accounts#8

Merged
marioevz merged 2 commits into
CPerezz:eip-8038-testsfrom
danceratopz:8038-extcodehash-extcodecopy-suggestions
Jun 23, 2026
Merged

feat(tests): cover EXTCODESIZE/EXTCODECOPY surcharge on empty accounts#8
marioevz merged 2 commits into
CPerezz:eip-8038-testsfrom
danceratopz:8038-extcodehash-extcodecopy-suggestions

Conversation

@danceratopz

Copy link
Copy Markdown

Add tests pinning that the EIP-8038 EXTCODESIZE/EXTCODECOPY code-read surcharge (+WARM_ACCESS) is charged unconditionally, including against an empty or non-existent account, where EXTCODESIZE returns 0 and EXTCODECOPY copies 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, extcodesize and extcodecopy), so an empty target still costs cold 3100 / warm 200, exactly like a code-bearing target. The suite previously measured these two opcodes only against code-bearing targets: The sole empty-account EXT* test covered EXTCODEHASH, 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: Charges EXTCODESIZE/EXTCODECOPY against 0xDEAD, cold and warm, asserting 3100 / 200 and cross-checking the opcode model.
  • test_extcodesize_empty_account_returns_zero: Asserts the surcharge alongside a returned size of 0, using stop=False so the size check is not dead code after the auto-appended STOP.
  • 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) against 0xDEAD with EXTCODESIZE returning 0. Coverage addition only: No spec or fixture behavior changes.

🔗 Related Issues or PRs

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 marioevz left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments just to simplify and make the tests more maintainable. Thanks!

@marioevz
marioevz merged commit c6111fd into CPerezz:eip-8038-tests Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants