1
1
//! In-memory blockchain backend.
2
2
3
3
use self :: state:: trie_storage;
4
+ use super :: executor:: new_evm_with_inspector_ref;
4
5
use crate :: {
5
6
ForkChoice , NodeConfig , PrecompileFactory ,
6
7
config:: PruneStateHistoryConfig ,
@@ -40,7 +41,9 @@ use alloy_consensus::{
40
41
transaction:: Recovered ,
41
42
} ;
42
43
use alloy_eips:: { eip1559:: BaseFeeParams , eip4844:: kzg_to_versioned_hash, eip7840:: BlobParams } ;
43
- use alloy_evm:: { Database , Evm , eth:: EthEvmContext , precompiles:: PrecompilesMap } ;
44
+ use alloy_evm:: {
45
+ Database , Evm , eth:: EthEvmContext , overrides:: OverrideBlockHashes , precompiles:: PrecompilesMap ,
46
+ } ;
44
47
use alloy_network:: {
45
48
AnyHeader , AnyRpcBlock , AnyRpcHeader , AnyRpcTransaction , AnyTxEnvelope , AnyTxType ,
46
49
EthereumWallet , UnknownTxEnvelope , UnknownTypedTransaction ,
@@ -89,7 +92,7 @@ use foundry_evm::{
89
92
constants:: DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE ,
90
93
decode:: RevertDecoder ,
91
94
inspectors:: AccessListInspector ,
92
- traces:: TracingInspectorConfig ,
95
+ traces:: { CallTraceDecoder , TracingInspectorConfig } ,
93
96
utils:: { get_blob_base_fee_update_fraction, get_blob_base_fee_update_fraction_by_spec_id} ,
94
97
} ;
95
98
use foundry_evm_core:: either_evm:: EitherEvm ;
@@ -125,8 +128,6 @@ use std::{
125
128
use storage:: { Blockchain , DEFAULT_HISTORY_LIMIT , MinedTransaction } ;
126
129
use tokio:: sync:: RwLock as AsyncRwLock ;
127
130
128
- use super :: executor:: new_evm_with_inspector_ref;
129
-
130
131
pub mod cache;
131
132
pub mod fork_db;
132
133
pub mod in_memory_db;
@@ -226,6 +227,8 @@ pub struct Backend {
226
227
enable_steps_tracing : bool ,
227
228
print_logs : bool ,
228
229
print_traces : bool ,
230
+ /// Recorder used for decoding traces, used together with print_traces
231
+ call_trace_decoder : Arc < CallTraceDecoder > ,
229
232
odyssey : bool ,
230
233
/// How to keep history state
231
234
prune_state_history_config : PruneStateHistoryConfig ,
@@ -255,6 +258,7 @@ impl Backend {
255
258
enable_steps_tracing : bool ,
256
259
print_logs : bool ,
257
260
print_traces : bool ,
261
+ call_trace_decoder : Arc < CallTraceDecoder > ,
258
262
odyssey : bool ,
259
263
prune_state_history_config : PruneStateHistoryConfig ,
260
264
max_persisted_states : Option < usize > ,
@@ -360,6 +364,7 @@ impl Backend {
360
364
enable_steps_tracing,
361
365
print_logs,
362
366
print_traces,
367
+ call_trace_decoder,
363
368
odyssey,
364
369
prune_state_history_config,
365
370
transaction_block_keeper,
@@ -1211,7 +1216,7 @@ impl Backend {
1211
1216
inspector. print_logs ( ) ;
1212
1217
1213
1218
if self . print_traces {
1214
- inspector. print_traces ( ) ;
1219
+ inspector. print_traces ( self . call_trace_decoder . clone ( ) ) ;
1215
1220
}
1216
1221
1217
1222
Ok ( ( exit_reason, out, gas_used, state, logs. unwrap_or_default ( ) ) )
@@ -1254,6 +1259,7 @@ impl Backend {
1254
1259
enable_steps_tracing : self . enable_steps_tracing ,
1255
1260
print_logs : self . print_logs ,
1256
1261
print_traces : self . print_traces ,
1262
+ call_trace_decoder : self . call_trace_decoder . clone ( ) ,
1257
1263
precompile_factory : self . precompile_factory . clone ( ) ,
1258
1264
odyssey : self . odyssey ,
1259
1265
optimism : self . is_optimism ( ) ,
@@ -1340,6 +1346,7 @@ impl Backend {
1340
1346
enable_steps_tracing : self . enable_steps_tracing ,
1341
1347
print_logs : self . print_logs ,
1342
1348
print_traces : self . print_traces ,
1349
+ call_trace_decoder : self . call_trace_decoder . clone ( ) ,
1343
1350
odyssey : self . odyssey ,
1344
1351
precompile_factory : self . precompile_factory . clone ( ) ,
1345
1352
optimism : self . is_optimism ( ) ,
@@ -1477,7 +1484,7 @@ impl Backend {
1477
1484
state:: apply_state_overrides ( state_overrides. into_iter ( ) . collect ( ) , & mut cache_db) ?;
1478
1485
}
1479
1486
if let Some ( block_overrides) = overrides. block {
1480
- state :: apply_block_overrides ( * block_overrides, & mut cache_db , & mut block) ;
1487
+ cache_db . apply_block_overrides ( * block_overrides, & mut block) ;
1481
1488
}
1482
1489
self . call_with_state ( & cache_db as & dyn DatabaseRef , request, fee_details, block)
1483
1490
} ?;
@@ -1656,7 +1663,7 @@ impl Backend {
1656
1663
state:: apply_state_overrides ( state_overrides, & mut cache_db) ?;
1657
1664
}
1658
1665
if let Some ( block_overrides) = block_overrides {
1659
- state :: apply_block_overrides ( block_overrides, & mut cache_db , & mut block_env) ;
1666
+ cache_db . apply_block_overrides ( block_overrides, & mut block_env) ;
1660
1667
}
1661
1668
1662
1669
// execute all calls in that block
@@ -1862,7 +1869,7 @@ impl Backend {
1862
1869
inspector. print_logs ( ) ;
1863
1870
1864
1871
if self . print_traces {
1865
- inspector. into_print_traces ( ) ;
1872
+ inspector. into_print_traces ( self . call_trace_decoder . clone ( ) ) ;
1866
1873
}
1867
1874
1868
1875
Ok ( ( exit_reason, out, gas_used as u128 , state) )
@@ -1887,7 +1894,7 @@ impl Backend {
1887
1894
state:: apply_state_overrides ( state_overrides, & mut cache_db) ?;
1888
1895
}
1889
1896
if let Some ( block_overrides) = block_overrides {
1890
- state :: apply_block_overrides ( block_overrides, & mut cache_db , & mut block) ;
1897
+ cache_db . apply_block_overrides ( block_overrides, & mut block) ;
1891
1898
}
1892
1899
1893
1900
if let Some ( tracer) = tracer {
0 commit comments