EOT - EVM Opcode Table
A Rust implementation of EVM opcodes for all Ethereum forks, with complete fork inheritance, validation, and metadata.
Quick start
Add this to your Cargo.toml:
[]
= "0.1"
Basic usage:
use ;
// Use the latest fork (Cancun)
let tload = TLOAD;
println!; // 100
println!; // Fork::Cancun
println!; // Some(1153)
// Check if an opcode exists in a fork
if has_opcode
// Get all opcodes for a fork
let all_opcodes = all_opcodes;
println!;
// Convert between opcode and byte value
let byte_val: u8 = tload.into; // 0x5c
let back_to_opcode = from;
assert_eq!;
Architecture
Smart Fork System
Instead of manually copying opcodes between forks, we use automatic inheritance:
Frontier (Base) → Homestead → Byzantium → Constantinople → Istanbul → Berlin → London → Shanghai → Cancun
Each fork automatically includes all opcodes from previous forks plus its own additions.
Rich Metadata
Every opcode includes complete information:
use ;
let tload = TLOAD;
let metadata = tload.metadata;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Other Features
use ;
// State modification analysis
let sstore = SSTORE;
println!; // true
println!; // false
// Push opcode analysis
let push1 = PUSH1;
println!; // true
println!; // Some(1)
// Stack depth requirements
let dup5 = DUP5;
println!; // 5
// Opcode groups
let add = ADD;
println!; // Group::StopArithmetic
Supported Forks
| Fork | Block | Date | New Opcodes | Status |
|---|---|---|---|---|
| Frontier | 0 | Jul 2015 | Base set (140+ opcodes) | ✅ |
| Homestead | 1,150,000 | Mar 2016 | DELEGATECALL |
✅ |
| Byzantium | 4,370,000 | Oct 2017 | REVERT, RETURNDATASIZE, RETURNDATACOPY, STATICCALL |
✅ |
| Constantinople | 7,280,000 | Feb 2019 | SHL, SHR, SAR, CREATE2, EXTCODEHASH |
✅ |
| Istanbul | 9,069,000 | Dec 2019 | CHAINID, SELFBALANCE |
✅ |
| Berlin | 12,244,000 | Apr 2021 | Gas cost changes | ✅ |
| London | 12,965,000 | Aug 2021 | BASEFEE |
✅ |
| Shanghai | 17,034,870 | Apr 2023 | PUSH0 |
✅ |
| Cancun | 19,426,587 | Mar 2024 | TLOAD, TSTORE, MCOPY, BLOBHASH, BLOBBASEFEE |
✅ |
Building the Project
Prerequisites
- Rust 1.70+ (for proper trait support)
- Python 3.8+ (for code generation, optional)
Building
&&
Regenerating Fork Files (Optional)
If you need to modify opcode data:
# Run the Python generator
# Then rebuild
Contributing
-
Adding a new fork:
- Update the CSV data in the generator script
- Add the fork to the
Forkenum inlib.rs - Regenerate files with
python3 generate_forks.py
-
Fixing opcode data:
- Update the relevant data in
generate_forks.py - Regenerate and test
- Update the relevant data in
-
Adding features:
- Extend the trait system in
traits.rs - Add comprehensive tests
- Extend the trait system in
Example: Adding a New Fork
# In generate_forks.py, add to get_historical_additions():
:
Then:
License
MIT License - see LICENSE file for details.
Acknowledgments
- clearloop for evm-opcodes
- Ethereum Foundation for EVM specification
- EIP authors for comprehensive opcode documentation