feat(tests): add EIP-7954 jumpdest test past the old code-size limit - #2993
Conversation
EIP-7954 raises `MAX_CODE_SIZE` to 64 KiB and the initcode limit to 128 KiB. Before this fork, deployed runtime code could never exceed 24 KiB, so no existing test ever executes a contract at a program counter past the old limit. The EIP-7954 max-size contracts are either deploy-only or run a short prefix that `STOP`s before their `JUMPDEST` padding, and `EXTCODECOPY`/`CODECOPY` only read the code rather than run it. A client whose jumpdest analysis or code execution is still bounded by the old limit would pass the existing suite yet break on a real 64 KiB contract. `test_max_code_size_high_jumpdest` deploys a `MAX_CODE_SIZE` contract and jumps near the new limit, far beyond the old 24 KiB code and 48 KiB initcode limits: - Valid `JUMPDEST`: The jump succeeds and the code runs at the high offset, storing a sentinel. - Non-`JUMPDEST` byte: The jump is rejected and nothing is stored. The contract is called through a caller that records the call result, so a correct client is told apart from one that truncated its jumpdest analysis (the valid jump fails) or accepts any high offset (the invalid jump wrongly succeeds).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #2993 +/- ##
====================================================
+ Coverage 81.28% 93.20% +11.92%
====================================================
Files 620 620
Lines 36641 38759 +2118
Branches 3311 3341 +30
====================================================
+ Hits 29784 36127 +6343
+ Misses 6335 1773 -4562
- Partials 522 859 +337
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
marioevz
left a comment
There was a problem hiding this comment.
Looks good, just a couple of suggestions, feel free to apply.
LouisTsai-Csie
left a comment
There was a problem hiding this comment.
Good points from Mario, LGTM once those are addressed. No other comments from my side.
Follow-up PR idea on JUMPDEST analysis: clients run it to ensure a jump target doesn't land on an immediate byte. We could add a scenario where the jump targets a 0x5b immediate byte of a PUSH, SWAPN, DUPN, or EXCHANGE instruction, asserting it's rejected as an invalid jump destination. The contract size should be at the new max code size, so the analysis is done well past the increase.
The high jumpdest test is not gas sensitive, so drop the explicit `gas_limit=fork.transaction_gas_limit_cap()` and let the framework fill the transaction gas limit automatically. Co-authored-by: marioevz <11726710+marioevz@users.noreply.github.com>
Store the sentinel in the prefix, before the `JUMP`, so the jump target is a bare `JUMPDEST` (valid) or `STOP` (invalid) with no trailing code: - Valid: The jump completes, the frame returns, and the store is kept. - Invalid: The jump is rejected, the frame reverts, and the store is discarded. Also fix the stale comment: with a bare `STOP` target, a client that wrongly accepts the jump halts normally and keeps the prefix store, so it stores `1`, not `2`. Co-authored-by: marioevz <11726710+marioevz@users.noreply.github.com>
Thanks for the review @LouisTsai-Csie! About the idea above, I think it has low additional value, but happy to add if you disagree. I think it would only catch a client that had hard-coded the wrong contract sizes in EIP-8024 context?
|
|
@LouisTsai-Csie I added the test case here #2998 |
🗒️ Description
EIP-7954 raises
MAX_CODE_SIZEto 64 KiB and the initcode limit to 128 KiB. Before this fork, deployed runtime code could never exceed 24 KiB, so no existing test ever executes a contract at a program counter past the old limit. The EIP-7954 max-size contracts are either deploy-only or run a short prefix thatSTOPs before theirJUMPDESTpadding, andEXTCODECOPY/CODECOPYonly read the code rather than run it.A client whose jumpdest analysis or code execution is still bounded by the old limit would pass the existing suite yet break on a real 64 KiB contract.
test_max_code_size_high_jumpdestdeploys aMAX_CODE_SIZEcontract and jumps near the new limit, far beyond the old 24 KiB code and 48 KiB initcode limits:JUMPDEST: The jump succeeds and the code runs at the high offset, storing a sentinel.JUMPDESTbyte: The jump is rejected and nothing is stored.The contract is called through a caller that records the call result, so a correct client is told apart from one that truncated its jumpdest analysis (the valid jump fails) or accepts any high offset (the invalid jump wrongly succeeds).
Final version
🔗 Related Issues or PRs
glamsterdam-devnet@v6.0.0#2915 (glamsterdam-devnet@v6.0.0)✅ Checklist
just statictype(scope):.Cute Animal Picture