@@ -9,13 +9,16 @@ use tokio::{
9
9
select,
10
10
sync:: { mpsc, watch} ,
11
11
} ;
12
- use tracing:: { instrument, trace, trace_span} ;
12
+ use tracing:: { instrument, error , trace, trace_span} ;
13
13
use trevm:: {
14
14
db:: { cow:: CacheOnWrite , TryCachingDb } ,
15
15
helpers:: Ctx ,
16
16
inspectors:: { Layered , TimeLimit } ,
17
17
revm:: {
18
- context:: result:: { EVMError , ExecutionResult } ,
18
+ context:: {
19
+ result:: { EVMError , ExecutionResult } ,
20
+ BlockEnv , CfgEnv ,
21
+ } ,
19
22
database:: { Cache , CacheDB } ,
20
23
inspector:: NoOpInspector ,
21
24
DatabaseRef , Inspector ,
@@ -63,15 +66,19 @@ where
63
66
Insp : Inspector < Ctx < SimDb < Db > > > + Default + Sync + ' static ,
64
67
{
65
68
/// Creates a new `SimEnv` instance.
66
- pub fn new (
69
+ pub fn new < C , B > (
67
70
db : Db ,
68
71
constants : SignetSystemConstants ,
69
- cfg : Box < dyn Cfg > ,
70
- block : Box < dyn Block > ,
72
+ cfg : C ,
73
+ block : B ,
71
74
finish_by : std:: time:: Instant ,
72
75
concurrency_limit : usize ,
73
76
sim_items : SimCache ,
74
- ) -> Self {
77
+ ) -> Self
78
+ where
79
+ C : Cfg ,
80
+ B : Block ,
81
+ {
75
82
SimEnv :: new ( db, constants, cfg, block, finish_by, concurrency_limit, sim_items) . into ( )
76
83
}
77
84
@@ -125,10 +132,10 @@ pub struct SimEnv<Db, Insp = NoOpInspector> {
125
132
constants : SignetSystemConstants ,
126
133
127
134
/// Chain cfg to use for the simulation.
128
- cfg : Box < dyn Cfg > ,
135
+ cfg : CfgEnv ,
129
136
130
137
/// Block to use for the simulation.
131
- block : Box < dyn Block > ,
138
+ block : BlockEnv ,
132
139
133
140
/// The instant by which the simulation should finish.
134
141
finish_by : std:: time:: Instant ,
@@ -151,15 +158,24 @@ impl<Db, Insp> fmt::Debug for SimEnv<Db, Insp> {
151
158
152
159
impl < Db , Insp > SimEnv < Db , Insp > {
153
160
/// Creates a new `SimFactory` instance.
154
- pub fn new (
161
+ pub fn new < C , B > (
155
162
db : Db ,
156
163
constants : SignetSystemConstants ,
157
- cfg : Box < dyn Cfg > ,
158
- block : Box < dyn Block > ,
164
+ cfg_ref : C ,
165
+ block_ref : B ,
159
166
finish_by : std:: time:: Instant ,
160
167
concurrency_limit : usize ,
161
168
sim_items : SimCache ,
162
- ) -> Self {
169
+ ) -> Self
170
+ where
171
+ C : Cfg ,
172
+ B : Block ,
173
+ {
174
+ let mut cfg = CfgEnv :: default ( ) ;
175
+ cfg_ref. fill_cfg_env ( & mut cfg) ;
176
+ let mut block = BlockEnv :: default ( ) ;
177
+ block_ref. fill_block_env ( & mut block) ;
178
+
163
179
Self {
164
180
db : Arc :: new ( CacheDB :: new ( db) ) ,
165
181
constants,
@@ -188,12 +204,12 @@ impl<Db, Insp> SimEnv<Db, Insp> {
188
204
}
189
205
190
206
/// Get a reference to the chain cfg.
191
- pub fn cfg ( & self ) -> & dyn Cfg {
207
+ pub const fn cfg ( & self ) -> & CfgEnv {
192
208
& self . cfg
193
209
}
194
210
195
211
/// Get a reference to the block.
196
- pub fn block ( & self ) -> & dyn Block {
212
+ pub const fn block ( & self ) -> & BlockEnv {
197
213
& self . block
198
214
}
199
215
@@ -298,7 +314,10 @@ where
298
314
// Create the outcome
299
315
Ok ( SimOutcomeWithCache { identifier, score, cache, gas_used } )
300
316
}
301
- Err ( e) => Err ( SignetEthBundleError :: from ( e. into_error ( ) ) ) ,
317
+ Err ( e) => {
318
+ error ! ( err = ?e. error( ) , "simulation error details" ) ;
319
+ Err ( SignetEthBundleError :: from ( e. into_error ( ) ) )
320
+ }
302
321
}
303
322
}
304
323
0 commit comments