EIP-1803 · Stagnant · Interface · 2017-07-28
EIP-1803: Rename opcodes for clarity
Proposed renaming six EVM opcode mnemonics (such as SHA3 to KECCAK256 and GAS to GASLEFT) so their names match what they actually do; bytecode is unaffected.
What problem does it solve?
Some EVM opcode names are misleading, a leftover from early design:
SHA3actually computes Keccak-256, which differs from the final NIST SHA-3 standard.GASreturns the gas remaining, not gas used or a gas limit.GASLIMITis the block gas limit, easily confused with a transaction's gas limit.INVALID(0xfe) is a specific designated opcode (EIP-141), but the name sounds like "any undefined opcode".
Confusing names lead to bugs in assemblers, disassemblers, documentation and people's mental models. This EIP only changes the human-readable names.
How it works
The proposed renames:
| Opcode | Old name | New name | Why |
|---|---|---|---|
0x31 |
BALANCE |
EXTBALANCE |
Consistent with EXTCODESIZE, EXTCODECOPY, EXTCODEHASH |
0x20 |
SHA3 |
KECCAK256 |
It is Keccak-256, not standard SHA-3 |
0x43 |
NUMBER |
BLOCKNUMBER |
Clear that it is the block number |
0x45 |
GASLIMIT |
BLOCKGASLIMIT |
Not the transaction gas limit |
0x5a |
GAS |
GASLEFT |
It returns remaining gas |
0xfe |
INVALID |
ABORT |
The designated invalid instruction, not any unknown opcode |
Byte values and behaviour do not change, so no hard fork is needed. Only tools that print or parse mnemonics are affected.
There is precedent: EIP-6 renamed SUICIDE (0xff) to SELFDESTRUCT.
Sample code
Solidity and Yul already use the clearer names at the language level, even where the opcode is still often listed under its old name:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract Names {
function demo(bytes calldata data) external view returns (bytes32 h, uint256 left, uint256 blk) {
h = keccak256(data); // opcode 0x20, a.k.a. SHA3
left = gasleft(); // opcode 0x5a, a.k.a. GAS
blk = block.number; // opcode 0x43, a.k.a. NUMBER
assembly {
let lim := gaslimit() // opcode 0x45, block gas limit
pop(lim)
}
}
}
Things to know
- Status is Stagnant. It was never formally adopted, so tools disagree: you will see both
SHA3andKECCAK256in disassemblers, docs and opcode tables. - Because nothing on-chain changes, the impact is purely on tooling and documentation.
- Solidity and Yul independently converged on
keccak256andgasleft(), which covers the two renames people trip over most.