A modular, high-performance Ethereum Virtual Machine (EVM) interpreter built from the ground up in Rust. This project implements the core logic of the Ethereum execution layer, following the specifications laid out in the Ethereum Yellow Paper.
- Full Instruction Set: Support for arithmetic, comparison, bitwise, stack, memory, and storage operations.
- Control Flow: Robust implementation of
JUMP,JUMPI, andJUMPDESTwith mandatory bytecode pre-scanning to prevent invalid jumps into data. - Gas Metering: Precise static and dynamic gas calculation for all opcodes.
- Security: Panic-proof 256-bit arithmetic using
wrappingandoverflowingoperations.
- Hashing:
SHA3(Keccak256) support for memory ranges using thetiny-keccaklibrary. - Environmental Context: Access to transaction and block data via
ADDRESS,CALLER,CALLVALUE, andGAS. - Logging: Implementation of
LOG0throughLOG4for event emission and off-chain indexing.
bin/cli: A command-line interface for running EVM bytecode with support for hex strings, file inputs, and real-time execution tracing.crates/core: The heartbeat of the interpreter, containing theEvmengine,Stack,Memory, andStorageimplementations.crates/shared: Shared types, opcode constants, and error definitions used across the workspace.
- Rust (latest stable version)
git clone <repository-url>
cd evm-rs
cargo buildRun bytecode directly from the terminal:
cargo run -p evm-cli -- run --code 0x6001600201Run bytecode from a .hex file:
cargo run -p evm-cli -- run --file path/to/program.hexEnable execution tracing to see the stack state per opcode:
cargo run -p evm-cli -- run --code 0x6001600201 --traceThe project includes an extensive suite of integration tests covering math, data flow, loops, and security boundaries.
cargo test --workspace- Arithmetic: 256-bit wide words (via
primitive-types). - Memory: Linear, byte-addressable volatile memory.
- Storage: Key-value mapping for persistent contract state.
- Environment: Support for caller identity and execution context.