Crate edb_engine

Crate edb_engine 

Source
Expand description

EDB Engine - Advanced Ethereum smart contract debugging and analysis engine.

This crate provides the core debugging engine for EDB (Ethereum Debugger), enabling detailed analysis and debugging of smart contract execution at both opcode and source levels. The engine supports real-time expression evaluation, comprehensive snapshot management, and advanced debugging features for Ethereum smart contracts.

ยงKey Features

ยง๐Ÿ” Multi-Level Debugging

  • Opcode-level debugging: Step through EVM bytecode execution
  • Source-level debugging: Debug using original Solidity source code
  • Hybrid debugging: Switch seamlessly between opcode and source views

ยง๐Ÿ“ธ Snapshot System

  • Capture execution state at any point during contract execution
  • Navigate forward/backward through execution history
  • Support for both hook-based and opcode-based snapshots

ยงโšก Real-time Expression Evaluation

  • Evaluate Solidity-like expressions against any execution snapshot
  • Access variables, function calls, storage, and blockchain context
  • Support for complex expressions with type casting and operations

ยง๐Ÿ”— JSON-RPC API

  • Complete debugging API for frontend integration
  • WebSocket and HTTP support for real-time debugging
  • Comprehensive error handling and protocol compliance

ยง๐Ÿ›  Advanced Analysis

  • Contract instrumentation for debugging hooks
  • Source code analysis and mapping
  • ABI resolution and type inference
  • Storage layout analysis

ยงCore Modules

  • analysis - Source code analysis and contract instrumentation
  • core - Core engine types and execution management
  • context - Engine context and state management
  • eval - Expression evaluation system
  • inspector - EVM execution inspectors for data collection
  • instrumentation - Contract instrumentation and code generation
  • rpc - JSON-RPC debugging API
  • snapshot - Snapshot management and analysis
  • tweak - Runtime contract modification for debugging
  • utils - Utility functions and helpers

ยงQuick Start

โ“˜
use edb_engine::{EngineContext, DebugRpcServer};
use revm::primitives::Address;

// Create engine context with debugging data
let context = EngineContext::new(db, snapshots, trace, artifacts);

// Start RPC server for debugging API
let server = DebugRpcServer::new(context);
let handle = server.start().await?;

println!("Debug server running on port {}", handle.port());

ยงArchitecture

The EDB engine follows a modular architecture:

  1. Data Collection: Inspectors collect execution data during EVM execution
  2. Snapshot Management: Captured data is organized into navigable snapshots
  3. Expression Evaluation: Real-time evaluation against snapshot data
  4. API Layer: JSON-RPC interface exposes all debugging functionality
  5. Analysis: Deep contract analysis for enhanced debugging experience

Re-exportsยง

pub use core::*;
pub use context::*;
pub use eval::*;
pub use inspector::*;
pub use instrumentation::*;
pub use rpc::*;
pub use snapshot::*;
pub use tweak::*;
pub use utils::*;

Modulesยง

analysis
Source code analysis and contract instrumentation (internal module).
context
Engine context management and EVM instantiation for debugging.
core
Core engine functionality for transaction analysis and debugging.
eval
Expression evaluation system for EDB.
inspector
EVM execution inspectors for debugging and analysis.
instrumentation
Contract instrumentation and code generation (internal module).
rpc
JSON-RPC server for EDB debugging control and inspection.
snapshot
Unified snapshot management for time travel debugging
tweak
Contract bytecode modification for debugging through creation transaction replay.
utils
Utility functions and helpers for the EDB engine.

Macrosยง

etherscan_rate_limit_guard
Automaticall pause the request if the rate limit is reached and resume it after the rate limit is reset.