Skip to content

feat(tests): add max-code-size jumpdest test for immediate bytes - #2998

Merged
danceratopz merged 1 commit into
ethereum:forks/amsterdamfrom
danceratopz:7954-immediate-jumpdest
Jun 18, 2026
Merged

feat(tests): add max-code-size jumpdest test for immediate bytes#2998
danceratopz merged 1 commit into
ethereum:forks/amsterdamfrom
danceratopz:7954-immediate-jumpdest

Conversation

@danceratopz

@danceratopz danceratopz commented Jun 17, 2026

Copy link
Copy Markdown
Member

🗒️ Description

Follow-up to #2993, from a review idea by @LouisTsai-Csie: extend the max-code-size jumpdest coverage to a 0x5B that lands in an instruction's immediate bytes: #2993 (review)

test_max_code_size_jumpdest_in_immediate puts a 0x5B as the last byte of a MAX_CODE_SIZE contract, right after an immediate-carrying opcode, and jumps to it:

  • PUSH1: the 0x5B is push data, always skipped, so it is not a JUMPDEST and the jump is rejected.
  • DUPN/SWAPN/EXCHANGE: per EIP-8024 the 0x5B is an invalid immediate that is not skipped, so it stays a valid JUMPDEST and the jump is accepted.

HTML explainer of test cases with visualization

The additional benefit is marginal. EIP-8024 already tests this immediate classification (on small contracts), and #2993 already proves the jumpdest scan survives to 64 KiB. The only thing this uniquely catches is a client whose immediate-skipping logic is size-bounded independently of the main jumpdest pass: it would pass both existing suites yet break on an EIP-8024 immediate near the new max. Obscure and unlikely, since real clients run one linear pass over the whole code.

Cost is negligible (sub-second t8n per case), so I'm not precious about it: happy to merge or close as people see fit.

🔗 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).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.

Cute Animal Picture

cute animal

Add `test_max_code_size_jumpdest_in_immediate`, which places a `0x5B`
as the last byte of a `MAX_CODE_SIZE` contract, right after an
immediate-carrying opcode, and jumps to it:

- `PUSH1`: The `0x5B` is push data, always skipped, so the jump is
  rejected.
- `DUPN`/`SWAPN`/`EXCHANGE`: Per EIP-8024 the `0x5B` is an invalid
  immediate, kept at an instruction boundary, so it stays a valid
  `JUMPDEST` and the jump is accepted.

Exercises the immediate-skipping branches of jumpdest analysis well
past the old 24 KiB code and 48 KiB initcode limits.
@danceratopz danceratopz added C-feat Category: an improvement or new feature A-tests Area: Consensus tests. labels Jun 17, 2026
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.20%. Comparing base (c00006f) to head (0c646cc).
⚠️ Report is 1 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #2998   +/-   ##
================================================
  Coverage            93.20%   93.20%           
================================================
  Files                  620      620           
  Lines                38759    38759           
  Branches              3341     3341           
================================================
  Hits                 36127    36127           
  Misses                1773     1773           
  Partials               859      859           
Flag Coverage Δ
unittests 93.20% <ø> (ø)

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.

@LouisTsai-Csie LouisTsai-Csie 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.

Thanks! This is what i want.

@danceratopz
danceratopz merged commit 5f8c109 into ethereum:forks/amsterdam Jun 18, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants