EIP-8337 Verified EVM code (Validated EVM Code)
No call decision · EVM & execution · EIP status Draft · created 2026-07-09
Prefixing code with the MAGIC bytes (0xEF 0x79) proves at deployment time (CREATE) that the code's control flow is fully static and that the data stack never underflows. Verification is optional, so existing code continues to work unchanged.
Why it is needed
In the EVM today, a jump instruction's destination is a value computed at runtime. This forces code-analysis tools to assume that any jump could go to any jump destination (JUMPDEST) in the code, so the number of possible paths grows as the number of jumps times the number of destinations, i.e., quadratically with code size. For tools that run at deployment or execution time (verifiers, native-code compilers), this becomes grounds for denial-of-service attacks, and offline formal analysis or gas estimation can become practically infeasible as the state space grows exponentially or worse. Today, compilers emulate calls and returns with dynamic jumps, and analysis tools then have to reconstruct that structure, creating unwanted work on both sides. This EIP has code that forgoes dynamic control flow prove its safety once, at CREATE time, so that every tool afterward can trust and use that proof.
What changes
Today
- Because jump destinations are determined at runtime, analysis tools must assume that any jump could go to any destination
- Every time the code runs, JUMPDEST analysis, jump destination checks, and stack underflow checks are repeated
- The cost of safety analysis grows quadratically or worse with code size
After EIP-8337
- For MAGIC code, every jump and call destination is fixed by the code alone and proven once at deployment
- Code that has been proven can skip JUMPDEST analysis, jump destination checks, and underflow checks at execution time
- The entire control flow can be scanned in time proportional to code size, enabling AOT/JIT compilation and automated correctness proofs
Who is affected
- Contract Developers and Compiler Teams: Static EVM code can be written directly, eliminating the need for the workaround of emulating calls and returns with dynamic jumps.
- Client teams: Verification must be implemented. The validate() function in the reference implementation is about 170 lines long.
- Analysis, auditing, and zk tools: The control flow graph of verified code can be reconstructed with a single linear scan, without inspection.
- Contract deployer: An additional VALIDATION_BYTE_COST (tentatively 64) gas per byte is charged at CREATE. If verification fails, gas is consumed and deployment is aborted.
In depth
MAGIC header and version
MAGIC is the two bytes 0xEF 0x79, followed by a version byte. This EIP defines version 0x01. 0xEF was reserved by EIP-3541, so code starting with this byte could not be deployed after the London fork. The second byte, 0x79, was chosen to avoid two values it could otherwise collide with: 0x00, the magic of the EOF container format, and 0xF0, the second byte of a contract deployed before London. There is a single version byte because validation rules are expected to change only a few times per decade. Execution starts right after the header, but PC values and destinations are counted from the first MAGIC byte. The version byte is also an extension point for the header, so an EIP that needs to add more to the header can simply define the rules for a new version that includes it.
What is proven
Of the six exceptional halting conditions defined by the Yellow Paper, three, namely invalid instruction, invalid jump destination, and insufficient stack items, are proven at CREATE time before the code ever executes. The other three (state modification during a static call, out of gas, and exceeding 1024 stack items) cannot be known from the code alone, so they are still checked at execution time as today. Verification looks only at the code's control flow and stack offsets, not at data or operations. Because it follows both branches of every JUMPI, it also scans paths that can never be taken given the actual data, and it rejects code that contains an invalid path even if that path is never actually taken at runtime. As the test cases show, recursion with no base case is valid, and code that causes an overflow is also valid, since overflow is the responsibility of runtime checks.
The five constraints
Constraint 1: Every reachable instruction must be a defined, non-deprecated opcode. The INVALID opcode is valid. Constraint 2: Every reachable JUMP and JUMPI must be immediately preceded by a PUSH whose immediate value is the destination, and the destination must be a JUMPDEST or CALLDEST instruction. A jump to a CALLDEST enters that subroutine. Constraint 3: A CALLSUB must likewise have an immediately preceding PUSH whose immediate value is the destination, and the destination must be a CALLDEST. Constraint 4: Stack offsets must be path-independent. Whatever path reaches an instruction, the offset must be the same, every frame opened from one entry point must close with the same net stack effect, and a reachable instruction must belong to exactly one subroutine. Constraint 5: On every path, each instruction must find as many items on the data stack as it removes, and every RETURNSUB must find a return address on the return stack. A subroutine is validated once, by offset, no matter how many call sites it has or at what absolute depth it is called.
Validation at CREATE time, and its cost
Validation must run on the output of the init code, before that output executes, in time and space linear in code size. A validation failure is an exceptional-halt condition for CREATE, and a failed creation consumes gas the same way reverting init code would. CREATE charges VALIDATION_BYTE_COST gas per byte, tentatively set to 64. Native cost measured on a single 2.6GHz Intel core runs typically 12-14 nanoseconds per byte of code, with a worst case (invalid code that drives up demand through recursive cycles) of 587 nanoseconds; 64 covers that worst case with comfortable margin and is about 30% of today's roughly 216 gas/byte deployment cost. The final value is left to the adopting fork's gas schedule. A fork that changes the instruction set must define validation rules and a new version for that fork's full instruction set, and code created afterward must carry the creating fork's version and pass those rules. Contracts made under an earlier fork remain as they are; if they reach an opcode a later fork has deprecated, they halt exceptionally, the same way an undefined opcode would today.
Why underflow is proven but overflow is not
Underflow is a property of the code alone. For each subroutine, demand counts how far below the entry depth it reaches, and every way in (call site, jump, fallthrough) is checked to see whether that demand is satisfied. If what the incoming path has stacked up falls short, the shortfall becomes that path's own demand and propagates upward. Demand is a non-decreasing integer bounded by 1024, so this iteration always terminates even in the presence of recursion. Execution starts from an empty stack, so top-level code is valid only if its demand is 0. Overflow, by contrast, generally cannot be statically proven when recursion is present, since stack depth then depends on data. Without recursion it can be proven (the enclosed overflow_validator.py does so), but that would attach a caveat to every safety claim, so this proposal leaves overflow as a runtime check, as it is today. Still, the growth of each subroutine can be computed offline in linear time, so clients can reduce the per-push check they do today to one check per call, with no change to consensus.
What validation unlocks: linear analysis and translation benchmarks
Because every destination is proven and every instruction has a single static stack offset, valid code can be translated, once at deployment, into a form that runs cheaper in linear time. Measuring five kernels (a multiplication chain, a call tree, a shift-XOR mixer, the Euclidean algorithm, and memory store-and-sum) with EIP-7979's demo compiler and translator shows that interpreting a register intermediate code runs with 1.4-2.1x fewer machine instructions than interpreting bytecode, 2.8-3.3x fewer combined with 64-bit arithmetic, 4.2-7x fewer (19-51x combined) for RISC-V machine code produced by a deliberately simple translator, and 33-971x fewer once run through an optimizing compiler. Running the first two kernels on a 64-bit RISC-V zkVM gives a proving cost equal to the measured instruction count plus a constant startup cost. All measurements include gas metering and the runtime checks this proposal does not eliminate (stack overflow, return depth). The enclosed extract_cfg.py recovers the full control-flow graph of validated code in a single linear pass, without self-checking.
Compatibility, security, and current status
Validation is opt-in and does not change semantics. EIP-3541 has rejected every deployment starting with 0xEF since London, and the three deployed before that are two standalone 0xEF and one 0xEF 0xF0..., so no existing code starts with MAGIC. A chain where MAGIC code has already been deployed must not activate this EIP. Opcode behavior is the same with or without the prefix, and an interpreter never sees invalid MAGIC code, so clients do not need to maintain two interpreters. Because validation is part of consensus, the residual risk is disagreement between implementations and flaws in the specification itself, and the defenses are an executable specification, shared test vectors, and differential testing. A remediation mechanism for flawed code is left for future work. This EIP requires EIP-3541 and EIP-7979, and is currently in Draft status, so its contents may still change.