Expand description
§REVM Transaction Simulator and Analyzer
A high-performance, multi-threaded Rust library for EVM transaction simulation and analysis, built on REVM.
§Usage Patterns
- Quick Start: Use
create_evm
orcreate_evm_with_tracer
for fast EVM instantiation at the latest block. - Custom Block Height: Use
EvmBuilder
for full control, including custom block height and inspector. - Change Block Context: After creation, use
set_db_block
to update block context (this also resets the database cache for consistency). - Multi-Threaded Simulation: Enable the
foundry-fork
feature for high-performance, thread-safe simulation with Foundry-fork-db backend.
§Key Features
- Flexible EVM Construction: Unified builder pattern for AlloyDB and Foundry-fork-db backends.
- Customizable Inspector System: Use built-in
TxInspector
or your own inspector for tracing and analysis. - Multi-Threaded & High-Performance: Foundry-fork-db backend enables safe, concurrent simulation with shared cache.
- Batch Processing & Asset Analysis: Simulate and analyze multiple transactions, including asset transfers and call traces.
- Safe Simulation: All simulations are isolated—no real blockchain state is modified.
- EVM-Compatible Chain Support: Works with any EVM-compatible blockchain, not just Ethereum mainnet.
- Rich Utility Functions: Includes tools for batch querying token balances, simulating Multicall deployment and batch execution, and more.
- Flexible Connection: Supports both HTTP and WebSocket (ws/wss) endpoints for EVM construction.
§TxInspector Highlights
- Comprehensive Asset Transfer Tracking: Automatically tracks ETH and ERC20 transfers with full context.
- Advanced Call Tree Analysis: Builds hierarchical call traces and pinpoints error locations.
- Event Log Collection: Captures and parses all emitted events during simulation.
- Error Investigation Tools: Locates exact failure points in complex call chains, decodes revert reasons, and provides contract-specific error context.
- Performance: Optimized for both single transaction and batch processing scenarios.
§Module Structure
evm
: Core EVM implementation with tracing capabilitiesinspectors
: EVM execution inspectors for different analysis needstypes
: Core data structures and type definitionstraits
: Trait definitions for extensibilityerrors
: Error types and handlingutils
: Helper functions and utilities
§Installation
[dependencies]
revm-trace = "4.0.0"
# TLS Backend Selection (choose one):
# Default: native-tls (OpenSSL) for maximum compatibility
# Alternative: Pure Rust TLS for system-dependency-free builds
# revm-trace = { version = "4.0.0", default-features = false, features = ["rustls-tls"] }
Re-exports§
pub use inspectors::tx_inspector::TxInspector;
pub use evm::TraceEvm;
pub use evm::builder::create_evm;
pub use evm::builder::create_evm_with_tracer;
pub use evm::builder::EvmBuilder;
pub use types::SimulationTx;
pub use types::SimulationBatch;
pub use revm;
pub use alloy;
pub use traits::*;
Modules§
- errors
- Error types for EVM tracing and simulation
- evm
- Core EVM wrapper and execution engine
- inspectors
- Inspector implementations for transaction tracing
- traits
- types
- utils
- Utility modules for EVM operations and blockchain interactions
Structs§
- Block
Env - The block environment
- MyWrap
Database Async - Wraps a DatabaseAsync or DatabaseAsyncRef to provide a
Database
implementation.