Repository navigation
fix(jit): decouple JUMPDEST analysis from instruction decoding - #358
Merged
Merged
Conversation
EIP-8024 leaves JUMPDEST analysis unchanged: only PUSH data is skipped, DUPN/SWAPN/EXCHANGE immediates are analyzed as if they were opcodes. The bytecode parser instead marked every decoded JUMPDEST instruction as a valid jump target, and the decoder does consume EIP-8024 immediates, so the two disagreed once such an immediate entered the stream. In e6605b ([DUPN, PUSH1 0x5b]) the analysis masks the 0x5b behind the PUSH1, but decoding yielded it as a JUMPDEST and the JIT accepted the jump the interpreter rejects (caught by the devnet-8 eip8024 test_vector_push_in_immediate_masks_jumpdest fixtures). Compute the valid-target bitmap with the legacy scan over the raw bytes, generalize the existing DUPN-immediate rewind to re-yield any analysis-valid target swallowed by a consumed immediate (including targets inside desynchronized PUSH data), and exclude analysis-masked decoded JUMPDESTs from the dynamic jump dispatch table. Execution cannot fall through into rewound bytes: every immediate that desynchronizes decoding from the analysis is an invalid DUPN/SWAPN/EXCHANGE encoding, so the opcode preceding them halts.
DaniPopes
approved these changes
Aug 13, 2026
This branch was previously deployed
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.
Summary
Fixes the JIT failure surfaced by the devnet-8
[email protected]fixtures on #357 (eip8024_dupn_swapn_exchange/eip_vectors/vector_push_in_immediate_masks_jumpdest). The bug predates the fixture bump; the v8.1.0eip_vectorsare just the first fixtures to exercise it.EIP-8024 leaves JUMPDEST analysis unchanged: only PUSH data is skipped, DUPN/SWAPN/EXCHANGE immediates are analyzed as if they were opcodes. The bytecode parser instead marked every decoded JUMPDEST instruction as a valid jump target, and the decoder does consume EIP-8024 immediates, so the two disagreed once such an immediate entered the stream. In
e6605b([DUPN, PUSH1 0x5b]) the analysis masks the0x5bbehind the PUSH1, but decoding yielded it as a JUMPDEST instruction and the JIT accepted the jump the interpreter rejects.Fix
0x5binside desynchronized PUSH data) is re-yielded so jumps have an instruction to land on. Analysis-aligned PUSH data never contains valid targets, so pre-EIP-8024 bytecode never rewinds.Execution cannot fall through into rewound bytes: every immediate that desynchronizes decoding from the analysis is an invalid DUPN/SWAPN/EXCHANGE encoding (
decode_single/decode_pairreject 91..=127, which covers0x5band all PUSH opcodes), so the opcode preceding them halts at runtime.Validation
0x5bafter DUPN (must be invalid), and a jump to an analysis-valid0x5binside desynchronized PUSH data (must land).evm2-jit-codegentests and the 30.evmsnapshot tests pass; workspace suite passes.for_amsterdamdevnet state-test corpus (2,737 files,EVM2_COMPILED_EEST_SUBSET=all) passes through the JIT — the configuration thejit ubuntu jitCI job runs.Note: #357's JIT job needs this fix to go green (rebase or merge-order either way).