edb_engine/rpc/mod.rs
1// EDB - Ethereum Debugger
2// Copyright (C) 2024 Zhuo Zhang and Wuqi Zhang
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Affero General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Affero General Public License for more details.
13//
14// You should have received a copy of the GNU Affero General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17//! JSON-RPC server for EDB debugging control and inspection.
18//!
19//! This module provides a comprehensive JSON-RPC API that enables front-end applications
20//! and debugging clients to interact with the EDB debugging engine. The RPC interface
21//! exposes all debugging functionality including snapshot navigation, expression evaluation,
22//! storage inspection, and trace analysis.
23//!
24//! # Architecture
25//!
26//! The RPC system consists of several key components:
27//!
28//! - **Server** ([`server`]) - HTTP/WebSocket server handling client connections
29//! - **Methods** ([`methods`]) - RPC method implementations organized by functionality
30//! - **Types** ([`types`]) - Request/response data structures and protocol types
31//! - **Utils** ([`utils`]) - Common utilities for RPC operations
32//!
33//! # API Categories
34//!
35//! ## Snapshot Management
36//! - Navigate through execution snapshots (forward/backward)
37//! - Access snapshot details and execution context
38//! - Jump to specific execution points
39//!
40//! ## Expression Evaluation
41//! - Evaluate Solidity-like expressions against any snapshot
42//! - Access variables, function calls, and blockchain context
43//! - Real-time expression evaluation with full debugging context
44//!
45//! ## Storage and State Inspection
46//! - Read contract storage and state variables
47//! - Inspect memory, stack, and call data
48//! - Access transient storage and EVM state
49//!
50//! ## Trace Analysis
51//! - Navigate the complete execution trace
52//! - Analyze call patterns and execution flow
53//! - Access detailed opcode-level execution information
54//!
55//! ## Artifact Management
56//! - Access compiled contract artifacts and metadata
57//! - Retrieve source code mappings and debugging information
58//! - Manage contract compilation and analysis results
59//!
60//! # Usage
61//!
62//! ```rust,ignore
63//! use edb_engine::rpc::{DebugServer, DebugServerConfig};
64//!
65//! // Start the RPC server
66//! let config = DebugServerConfig::default();
67//! let server = DebugServer::new(engine_context, config).await?;
68//! server.run().await?;
69//! ```
70//!
71//! # Protocol
72//!
73//! The RPC server supports both HTTP POST requests and WebSocket connections
74//! for real-time debugging. All methods follow the JSON-RPC 2.0 specification
75//! with structured request/response formats defined in the [`types`] module.
76
77pub mod methods;
78pub mod server;
79pub mod types;
80pub mod utils;
81
82pub use server::*;
83pub use types::*;