EIP-3690 EOF jump destination table (EOF - JUMPDEST Table)

No call decision · EVM & execution · EIP status Stagnant · created 2021-06-23

Pre-stores the list of valid jump destinations in an EOF contract in a separate section called jumpdests, so that it is validated only once at creation time instead of being analyzed on every execution.

Why it is needed

Currently, the Ethereum Virtual Machine re-analyzes the entire code every time a contract is executed to determine which locations are valid jump destinations (JUMPDEST). This analysis is overhead repeated every time, and its cost varies by client implementation. Using the EOF container structure introduced by EIP-3540, instead of scattering jump destinations throughout the code as JUMPDEST opcodes, the list can be pre-stored and delivered in a separate section. This moves some of the complexity and processing time from execution time to contract creation (deployment) time, requiring the list's correctness to be validated only once at creation. In addition, this structure also reduces the problem of initcode analysis scope, which previously had no limit other than memory cost, by bounding it to the maximum size of the jumpdests section (0xffff). Legacy code continues to operate unchanged, unaffected by this change.

What changes

Today

After EIP-3690

Who is affected

In depth

Structure of the jumpdests section

A new jumpdests section with section_kind=3 is added to the EOF container. This section holds n unsigned integers jumploc_i, each encoded as an unsigned LEB128. The values stored are not absolute positions but differences (deltas) from the previous value, so a partial sum must be computed to obtain the actual jump position: jumpdest(n) = sum(jumpdests_table[:n+1]).

Section presence condition and placement order

The jumpdests section must be present if and only if the code section contains a JUMP or JUMPI opcode. When present, it must come immediately before the code section, and the overall order becomes format, magic, version, [jumpdests_section_header], code_section_header, [data_section_header], 0, [jumpdests_section_contents], code_section_contents, [data_section_contents].

LEB128 encoding constraints

The LEB128 encoding must be complete (not truncated) and must not read beyond the bounds of the jumpdests section. Only the shortest LEB128 encoding is valid, so that a given value has exactly one allowed encoding. Jumploc values other than the first cannot be zero, a constraint meant to prevent duplicate jump positions.

Valid jump positions and abolition of the JUMPDEST opcode

Every jumploc must point to a valid opcode and must not point inside PUSH data or outside the code section. After this EIP, the JUMPDEST (0x5b) instruction becomes undefined, so under EIP-3670's validation rules, if code contains a JUMPDEST, deployment itself fails.

Jump check at execution time

When executing JUMP or JUMPI, if the destination is not in the jumpdests table, execution halts with a bad jump destination. For JUMPI, this check is only performed when the jump actually occurs, which does not change existing behavior.

Performance measurement results

In the worst case where every byte is a jumpdest (65535 bytes), loading the jumpdests section is about 2.75% slower than the existing JUMPDEST analysis. However, measured against five popular real mainnet contracts, RoninBridge, UniswapV2ERC20, DepositContract, TetherToken, and UniswapV2Router02, loading the jumpdests section is about 88-91% faster than the existing analysis.

Section size limits and initcode analysis scope

The jumpdests section length is capped at 0xffff, the EOF maximum section size, and for deployed code the additional constraint of the 0x6000 maximum bytecode size means the jumpdests section cannot exceed 0x3000. This also implicitly bounds the scope of initcode analysis. Previously there was no limit beyond the EVM memory cost, so initcode analysis over 1MB was possible, and this vulnerability in legacy code is not resolved by this EIP and remains as is.

Status and prerequisites

This EIP's status is Stagnant, meaning it is not currently actively progressing and its content may change or may never be adopted. It is designed to be introduced at the same block where EIP-3540 (EOF format) takes effect, so it presupposes EIP-3540 and EIP-3670, and legacy (existing) bytecode is unaffected by this change.

Original EIP · ← EIPs