Conversation
EIP-7979 adds explicit call and return instructions to the EVM: a per-frame return stack and three opcodes, CALLSUB (0xB0), CALLDEST (0xB1) and RETURNSUB (0xB2), using the EIP's placeholder values. Spec (src/ethereum/forks/amsterdam): - Evm gains `return_stack` and `valid_call_destinations`; RETURN_STACK_LIMIT = 1024. - The JUMPDEST scan becomes a single pass, `get_valid_destinations`, returning both the jump and the call destination sets. A CALLDEST is both, so JUMP and JUMPI need no change. The EIP-8024 immediate handling is preserved. - callsub/calldest/returnsub in control_flow.py; ReturnStackOverflowError and ReturnStackUnderflowError; gas costs mid (8), jumpdest (1) and low (5). Framework (packages/testing): - Opcode table entries and the EIP7979 fork mixin, picked up by Amsterdam automatically. Tests (tests/amsterdam/eip7979_callsub, 44 tests, 130 fixtures): - The EIP's five vectors byte-for-byte; invalid destinations (JUMPDEST, PUSH data, DUPN immediate, out of range, uint64 overflow, self, stack underflow); return-stack underflow; the 1024 limit by counted recursion; per-frame isolation across all four call opcodes; call elimination via JUMP/JUMPI, tail call and mutual recursion at constant depth; exact gas by measurement; initcode, CREATE, CREATE2 and 7702 contexts; fork transition. - tests/frontier/opcodes/test_all_opcodes.py: CALLSUB and RETURNSUB get the same special-casing as JUMP in the generic harness.
ethereum-spec-lint's UintLenHygiene rule requires ulen(...) rather than Uint(len(...)).
EIP-8337 validates code prefixed with MAGIC bytes at CREATE time, proving fully static control flow and no data-stack underflow, and begins execution of such code immediately after its header. Requires EIP-7979. Placeholders, each in one place (vm/validation.py, vm/gas.py), pending the EIP: MAGIC = 0xEF 0x79, a one-byte version 0x01 naming this fork's validation rules, VALIDATION_BYTE_COST = 64. Spec (src/ethereum/forks/amsterdam): - vm/validation.py: the EIP's reference validator, ported with the opcode table extended to this fork (CLZ, SLOTNUM, and EIP-8024 DUPN/SWAPN/EXCHANGE with their immediate rules). Traversal begins at the entry point; header bytes are unreachable data. - CREATE (all three paths): code beginning with MAGIC is charged VALIDATION_BYTE_COST per byte before validation runs, then validated; failure is an exceptional halt (InvalidValidatedCode), as EIP-3541's rejection is. Other 0xEF prefixes are rejected as before. - Execution of created MAGIC code starts after the header; positions remain absolute. Initcode is neither validated nor given an entry point. The runtime JUMPDEST scan also starts at the entry point. Framework: an EIP8337 mixin (no opcode changes). Tests (tests/amsterdam/eip8337_validated_code, 66 tests, 200 fixtures): - The EIP's 43 validation vectors deployed behind the header (PUSH1 destinations relocated by the header length), each created iff valid. - Header and prefix cases: header only, wrong version, bare MAGIC, the EIP-3541/EOF/7702 0xEF prefixes, plain code. - CREATE and CREATE2 paths, factory keeps its gas on failure; MAGIC initcode gets no entry point; the validation charge measured as exactly VALIDATION_BYTE_COST per byte against equal-length plain code. - Execution: entry point, CODESIZE and CODECOPY see the header, absolute JUMP/CALLSUB positions, MAGIC callee under every call opcode, invalid MAGIC code placed directly in state halts at runtime. - Fork transition.
This was referenced Sep 12, 2026
Draft
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.
Draft. Reference implementation and tests for EIP-8337, which adds opt-in validation on top of EIP-7979 (#3575, which this branch includes). Not proposed for Hegotá; posted to show that 7979 can be validated in about 450 lines when the time comes. MAGIC bytes, header layout, and the validation charge are placeholders, each defined in one place. All 200 fixtures fill against the spec; just static is clean.
Description
Related Issues or PRs
N/A.
Checklist
just static<type>(<area>): <title>, where<type>and<area>come from an appropriateC-<type>, respectivelyA-<area>, label. The title should match the target squash commit message.Cute Animal Picture