Skip to main content

Crate ethrex_levm

Crate ethrex_levm 

Source
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

§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::*;

Modules§

account
call_frame
constants
db
debug
environment
errors
execution_handlers
gas_cost
hooks
memory
opcode_handlers
opcode_tracer
opcodes
precompiles
tracing
utils
vm