@@ -13,6 +13,7 @@ use crate::{
13
13
self , ExpectedCallData , ExpectedCallTracker , ExpectedCallType , ExpectedEmit ,
14
14
ExpectedRevert , ExpectedRevertKind ,
15
15
} ,
16
+ utils:: IgnoredTraces ,
16
17
CheatsConfig , CheatsCtxt , DynCheatcode , Error , Result , Vm ,
17
18
Vm :: AccountAccess ,
18
19
} ;
@@ -28,14 +29,15 @@ use foundry_evm_core::{
28
29
utils:: new_evm_with_existing_context,
29
30
InspectorExt ,
30
31
} ;
32
+ use foundry_evm_traces:: TracingInspector ;
31
33
use itertools:: Itertools ;
32
34
use rand:: { rngs:: StdRng , Rng , SeedableRng } ;
33
35
use revm:: {
34
36
interpreter:: {
35
37
opcode, CallInputs , CallOutcome , CallScheme , CreateInputs , CreateOutcome , EOFCreateInputs ,
36
- Gas , InstructionResult , Interpreter , InterpreterAction , InterpreterResult ,
38
+ EOFCreateKind , Gas , InstructionResult , Interpreter , InterpreterAction , InterpreterResult ,
37
39
} ,
38
- primitives:: { BlockEnv , CreateScheme , EVMError } ,
40
+ primitives:: { BlockEnv , CreateScheme , EVMError , SpecId , EOF_MAGIC_BYTES } ,
39
41
EvmContext , InnerEvmContext , Inspector ,
40
42
} ;
41
43
use rustc_hash:: FxHashMap ;
@@ -115,8 +117,19 @@ pub trait CheatcodesExecutor {
115
117
self . with_evm ( ccx, |evm| {
116
118
evm. context . evm . inner . journaled_state . depth += 1 ;
117
119
118
- let first_frame_or_result =
119
- evm. handler . execution ( ) . create ( & mut evm. context , Box :: new ( inputs) ) ?;
120
+ // Handle EOF bytecode
121
+ let first_frame_or_result = if evm. handler . cfg . spec_id . is_enabled_in ( SpecId :: PRAGUE_EOF )
122
+ && inputs. scheme == CreateScheme :: Create && inputs. init_code . starts_with ( & EOF_MAGIC_BYTES )
123
+ {
124
+ evm. handler . execution ( ) . eofcreate (
125
+ & mut evm. context ,
126
+ Box :: new ( EOFCreateInputs :: new ( inputs. caller , inputs. value , inputs. gas_limit , EOFCreateKind :: Tx {
127
+ initdata : inputs. init_code ,
128
+ } ) ) ,
129
+ ) ?
130
+ } else {
131
+ evm. handler . execution ( ) . create ( & mut evm. context , Box :: new ( inputs) ) ?
132
+ } ;
120
133
121
134
let mut result = match first_frame_or_result {
122
135
revm:: FrameOrResult :: Frame ( first_frame) => evm. run_the_loop ( first_frame) ?,
@@ -126,8 +139,8 @@ pub trait CheatcodesExecutor {
126
139
evm. handler . execution ( ) . last_frame_return ( & mut evm. context , & mut result) ?;
127
140
128
141
let outcome = match result {
129
- revm:: FrameResult :: Call ( _) | revm :: FrameResult :: EOFCreate ( _ ) => unreachable ! ( ) ,
130
- revm:: FrameResult :: Create ( create) => create,
142
+ revm:: FrameResult :: Call ( _) => unreachable ! ( ) ,
143
+ revm:: FrameResult :: Create ( create) | revm :: FrameResult :: EOFCreate ( create ) => create,
131
144
} ;
132
145
133
146
evm. context . evm . inner . journaled_state . depth -= 1 ;
@@ -139,6 +152,11 @@ pub trait CheatcodesExecutor {
139
152
fn console_log < DB : DatabaseExt > ( & mut self , ccx : & mut CheatsCtxt < DB > , message : String ) {
140
153
self . get_inspector :: < DB > ( ccx. state ) . console_log ( message) ;
141
154
}
155
+
156
+ /// Returns a mutable reference to the tracing inspector if it is available.
157
+ fn tracing_inspector ( & mut self ) -> Option < & mut Option < TracingInspector > > {
158
+ None
159
+ }
142
160
}
143
161
144
162
/// Basic implementation of [CheatcodesExecutor] that simply returns the [Cheatcodes] instance as an
@@ -310,6 +328,9 @@ pub struct Cheatcodes {
310
328
311
329
/// Optional RNG algorithm.
312
330
rng : Option < StdRng > ,
331
+
332
+ /// Ignored traces.
333
+ pub ignored_traces : IgnoredTraces ,
313
334
}
314
335
315
336
// This is not derived because calling this in `fn new` with `..Default::default()` creates a second
@@ -352,6 +373,7 @@ impl Cheatcodes {
352
373
pc : Default :: default ( ) ,
353
374
breakpoints : Default :: default ( ) ,
354
375
rng : Default :: default ( ) ,
376
+ ignored_traces : Default :: default ( ) ,
355
377
}
356
378
}
357
379
0 commit comments