Expand description
§LEVM - Lambda EVM
A pure Rust implementation of the Ethereum Virtual Machine.
§Overview
LEVM (Lambda EVM) is ethrex’s native EVM implementation, designed for:
- Correctness: Full compatibility with Ethereum consensus tests
- Performance: Optimized opcode execution and memory management
- Readability: Clean, well-documented Rust code
- Extensibility: Modular design for easy feature additions
§Architecture
┌─────────────────────────────────────────────────────────────┐
│ VM │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ CallFrame │ │ Memory │ │ Stack │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Substate │ │ Precompiles │ │ Environment │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ GeneralizedDatabase │
│ (Account state, storage, code) │
└─────────────────────────────────────────────────────────────┘§Key Components
vm::VM: Main EVM execution enginecall_frame::CallFrame: Execution context for each callmemory::Memory: EVM memory with expansion trackingenvironment::Environment: Block and transaction contextprecompiles: Native implementations of precompiled contractshooks: Execution hooks for pre/post-execution logic and L2-specific behavior
§Supported Forks
LEVM supports post-merge Ethereum forks:
- Paris (The Merge), Shanghai, Cancun, Prague, Osaka
Note: ethrex is a post-merge client and does not support pre-merge forks.
§Usage
ⓘ
use levm::{VM, Environment};
// Create VM with database and environment
let mut vm = VM::new(env, db, &tx, tracer, vm_type, &NativeCrypto);
// Execute the transaction
let report = vm.execute()?;
// Check execution result
if report.is_success() {
println!("Gas used: {}", report.gas_used);
}Re-exports§
pub use environment::*;