1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
//! Core EVM wrapper and execution engine
//!
//! This module provides the `TraceEvm` wrapper around revm's `MainnetEvm` with enhanced
//! tracing capabilities and convenient type aliases for different database configurations.
//!
//! ## Key Components
//!
//! - **`TraceEvm`**: Main wrapper struct that adds tracing capabilities to revm's EVM
//! - **Database Reset**: Utilities for clearing cache state between executions
//! - **Inspector Integration**: Support for transaction tracing and analysis
//!
//! ## Usage Examples
//!
//! ```no_run
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use revm_trace::create_evm;
//!
//! // Create a default EVM instance (no tracing)
//! let evm = create_evm("https://eth-mainnet.g.alchemy.com/v2/your-key").await?;
//!
//! // Create an EVM with custom tracer
//! use revm_trace::{create_evm_with_tracer, TxInspector};
//! let tracer = TxInspector::new();
//! let evm_with_tracer = create_evm_with_tracer(
//! "https://eth-mainnet.g.alchemy.com/v2/your-key",
//! tracer
//! ).await?;
//! # Ok(())
//! # }
//! ```
pub use ;
use ;
// Sub-modules for EVM functionality
/// Enhanced EVM wrapper with tracing capabilities
///
/// `TraceEvm` is a wrapper around revm's `MainnetEvm` that provides:
/// - Transparent access to all EVM functionality via `Deref`/`DerefMut`
/// - Enhanced tracing and inspection capabilities
/// - Database state management utilities
/// - Type-safe database and inspector configuration
///
/// # Type Parameters
/// - `DB`: Database backend implementing the `Database` trait
/// - `INSP`: Inspector for transaction tracing and analysis
///
/// # Usage Patterns
///
/// `TraceEvm` supports two main usage patterns:
///
/// ## 1. Convenience Functions (Recommended for most users)
/// ```no_run
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// use revm_trace::{create_evm_with_tracer, TxInspector, types::SimulationBatch, traits::TransactionTrace};
///
/// let tracer = TxInspector::new();
/// let mut evm = create_evm_with_tracer("https://eth.llamarpc.com", tracer).await?;
///
/// // Create a sample batch (empty for demo)
/// let batch = SimulationBatch {
/// transactions: vec![],
/// is_stateful: false,
/// };
///
/// // High-level batch processing with automatic state management
/// let results = evm.trace_transactions(batch);
/// # Ok(())
/// # }
/// ```
///
/// ## 2. Manual Control (Advanced users)
/// ```no_run
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// use revm_trace::{create_evm_with_tracer, TxInspector};
/// use revm::context::TxEnv;
/// use revm::{ExecuteEvm, InspectCommitEvm};
/// use alloy::primitives::{address, U256, TxKind};
///
/// let tracer = TxInspector::new();
/// let mut evm = create_evm_with_tracer("https://eth.llamarpc.com", tracer).await?;
///
/// // Create a sample transaction
/// let tx = TxEnv::builder()
/// .caller(address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045"))
/// .kind(TxKind::Call(address!("A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")))
/// .chain_id(Some(evm.cfg.chain_id))
/// .value(U256::ZERO)
/// .build_fill();
///
/// // Manual transaction execution with fine-grained control
/// evm.set_tx(tx);
/// let result = evm.inspect_replay_commit()?; // Explicit Inspector activation
///
/// // Access Inspector data at any time
/// let transfers = evm.get_inspector().get_transfers();
/// let traces = evm.get_inspector().get_traces();
///
/// // Manual state management
/// evm.reset_inspector(); // Clear state for next transaction
/// # Ok(())
/// # }
/// ```
///
/// **Important**: Modern REVM requires explicit `inspect_replay_commit()` calls to activate
/// Inspector hooks. The convenience functions like `trace_transactions()` automate this process.
///
/// # Examples
///
/// ```no_run
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// use revm_trace::create_evm;
///
/// // Create a basic EVM instance
/// let evm = create_evm("https://eth-mainnet.g.alchemy.com/v2/your-key").await?;
///
/// // Create an EVM with custom tracer
/// use revm_trace::{create_evm_with_tracer, TxInspector};
/// let tracer = TxInspector::new();
/// let evm_with_tracer = create_evm_with_tracer(
/// "https://eth-mainnet.g.alchemy.com/v2/your-key",
/// tracer
/// ).await?;
/// # Ok(())
/// # }
/// ```
;
/// Transparent access to the underlying MainnetEvm
///
/// This implementation allows `TraceEvm` to be used as a drop-in replacement
/// for `MainnetEvm` by providing direct access to all its methods and fields.
/// Mutable access to the underlying MainnetEvm
///
/// This implementation allows modification of the underlying EVM state
/// and configuration through the `TraceEvm` wrapper.