This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
REVM is a highly efficient Rust implementation of the Ethereum Virtual Machine (EVM). It serves both as:
- A standard EVM for executing Ethereum transactions
- A framework for building custom EVM variants (like Optimism's op-revm)
The project is used by major Ethereum infrastructure including Reth, Foundry, Hardhat, Optimism, Scroll, and many zkVMs.
# Build the project
cargo build
cargo build --release
# Run all tests
cargo nextest run --workspace
# Lint and format
cargo clippy --workspace --all-targets --all-features
cargo fmt --all
# Check no_std compatibility
cargo check --target riscv32imac-unknown-none-elf --no-default-features
cargo check --target riscv64imac-unknown-none-elf --no-default-features
# Run Ethereum state tests
cargo run -p revme statetest legacytests/Cancun/GeneralStateTests# Download and run ethereum tests
./scripts/run-tests.sh
# Clean test fixtures and re-run
./scripts/run-tests.sh clean
# Run with specific profile
./scripts/run-tests.sh releaseThe workspace consists of these core crates:
- revm: Main crate that re-exports all others
- revm-primitives: Constants, primitive types, and core data structures
- revm-interpreter: EVM opcode implementations and execution engine
- revm-context: Execution context, environment, and journaled state
- revm-handler: Execution flow control and call frame management
- revm-database: State database traits and implementations
- revm-precompile: Ethereum precompiled contracts
- revm-inspector: Tracing and debugging framework
- op-revm: Example of custom EVM variant (Optimism)
- Trait-based Architecture: Core functionality is defined through traits, allowing custom implementations
- Handler Pattern: Execution flow is controlled through customizable handlers
- no_std Support: All core crates support no_std environments
- Feature Flags: Extensive use of feature flags for optional functionality
- Database Trait (
revm-database): Defines how state is accessed - Inspector Trait (
revm-inspector): Hooks for transaction tracing - Handler Interface (
revm-handler): Customizable execution logic - Context (
revm-context): Manages execution state and environment
When working on the frame_stack branch, note that significant refactoring is happening around:
- Frame and FrameData structures (moved from handler to context)
- Execution loop simplification
- Inspector trait cleanup
- Unit tests in each crate
- Integration tests using Ethereum official test suite
- Example projects demonstrating features
- Benchmarking with CodSpeed
When adding new features:
- Ensure no_std compatibility
- Add appropriate feature flags
- Include tests for new functionality
- Update relevant examples if needed