EIP-141 Designated invalid EVM instruction

Final · EVM & execution · EIP status Final · created 2017-02-09

This designates EVM opcode 0xfe as the permanently invalid instruction INVALID. A contract can use this instruction to deliberately halt execution.

Why it is needed

The Ethereum Virtual Machine (EVM) executes smart contract code instruction by instruction. Each instruction is distinguished by a 1-byte value called an opcode, but some slots have not yet been assigned any function. Since empty slots could later gain a different meaning as new features are added, there was no guarantee that any given slot would remain invalid forever. This EIP officially designates the single slot 0xfe as the invalid instruction, pinning it to remain invalid going forward. This gives contracts an instruction to use when they want to deliberately halt execution, providing a clear reason for stopping that is distinct from other kinds of failure.

What changes

Today

After EIP-141

Who is affected

In depth

Designate 0xfe as the INVALID instruction

The specification is one sentence: opcode 0xfe is the INVALID instruction. EVM opcodes are 1-byte values that identify instructions, and this EIP assigns no valid behavior to the 0xfe slot, fixing the very meaning of invalid as the specification itself. This is why the title is 'Designated invalid EVM instruction.' It is not simply currently undefined, but designated to remain an invalid instruction going forward. The Abstract summarizes the same thing in one sentence: it designates one instruction to remain an invalid instruction.

Role as an ABORT instruction

The original text states explicitly that the INVALID instruction can be used to halt execution, and that it duplicates as an ABORT instruction. The Motivation section explains that this invalid instruction can be used as a distinct reason for halting execution. In other words, placing 0xfe at the point in the code where execution should stop causes execution to halt there, giving a clear reason for the halt that is distinguishable from other causes of failure.

Backward compatibility

The original text states that since this instruction has never been used before, it has no effect on existing contracts. This means that among already deployed contracts, none expect a different meaning from 0xfe. Therefore this designation is not a change to existing behavior but a formalization of a previously empty slot, and this single fact is also why no backward compatibility issues arise.

Nature and status of the proposal

This proposal was authored by Alex Beregszaszi and created on February 9, 2017. Its type is Standards Track, its category is Core, and its status is Final. Final means the specification is settled and will no longer change, so the specification designating 0xfe as the INVALID instruction should be read as a settled fact. Copyright has been waived under CC0.

Original EIP · ← EIPs