EIP-4520 EB/EC-prefixed multi-byte opcodes (Multi-byte opcodes prefixed by EB and EC.)

No call decision · EVM & execution · EIP status Stagnant · created 2021-12-01

To solve the problem that EVM opcodes are limited to one byte, capping the total at 256, this reserves the two unused bytes 0xEB and 0xEC as extension prefixes, enabling 2-byte and, if needed, 3-byte opcodes.

Why it is needed

EVM opcodes are represented by a single byte (0x00 to 0xFF), so at most 256 can exist. Most values are already allocated, leaving almost no room to add new features. At the same time, making even rarely used opcodes take up a full byte wastes this precious address space. This EIP sets aside two currently unallocated values, 0xEB and 0xEC, and reserves them as extension prefixes signaling that more bytes follow. This keeps frequently used opcodes small and fast at one byte, while rarely used opcodes can grow to 2 bytes and experimental opcodes to 3 bytes, resolving the overall opcode count limit.

What changes

Today

After EIP-4520

Who is affected

In depth

Why 0xEB and 0xEC were chosen as prefix bytes

With a single prefix, only 255 2-byte opcodes could follow it, so this EIP uses two prefixes (0xEB and 0xEC) to accommodate up to 510 2-byte opcodes. Both values were chosen from the series starting with E, in which the same series value 0xEF is already reserved for contracts following the Ethereum Object Format (EOF) specification. Using values not yet allocated to any opcode as prefixes carries lower risk of breaking deployed contracts than reusing opcodes already in use, which is why these values were chosen.

The structure of the 2-byte opcode space

When one more byte follows 0xEB or 0xEC, the entire combination becomes a single opcode. The source gives as examples 0xEC 01 as a new ADD and 0xEB F4 as a new DELEGATECALL. 0xEB and 0xEC themselves have no effect on the stack or memory; only the specific opcode designated by the following byte defines the stack and memory behavior.

Extension to 3-byte opcodes

Only the four combinations 0xEB 0xEB, 0xEC 0xEC, 0xEB 0xEC, and 0xEC 0xEB can be interpreted as further extensions, and if one more byte follows, it becomes a 3-byte opcode. The source proposes using this 3-byte space to place experimental opcodes first. If they are verified to be safe and useful, they can later be moved and reallocated to the 2-byte or 1-byte space.

Handling undefined multi-byte opcodes

When an as-yet-undefined multi-byte opcode combination is encountered, it is not treated as a NOP that does nothing, but as INVALID, which halts execution, just as with existing undefined single-byte opcodes. This rule keeps undefined behavior consistent.

Compatibility risk with existing code

If a previously deployed contract included the bytes 0xEB or 0xEC for other purposes (for example, in an executed code section rather than a data section), after this EIP is introduced that portion may be interpreted as an extension prefix, potentially causing unintended behavior or broken code.

No security considerations specified

The source states in its security considerations section that there are no known security issues. However, this assessment applies only to the prefix reservation itself; the security of individual opcodes actually allocated in this space later must be reviewed separately at the time each opcode is proposed.

Current status

This EIP was written on 2021-12-01 and is currently in Stagnant status. That is, discussion is no longer progressing and inclusion in any fork has not been decided. It should be noted that the content covered here is a proposed design, not a rule actually applied to Ethereum.

Original EIP · ← EIPs