@@ -15,7 +15,10 @@ use trevm::{
1515 helpers:: Ctx ,
1616 inspectors:: { Layered , TimeLimit } ,
1717 revm:: {
18- context:: result:: { EVMError , ExecutionResult } ,
18+ context:: {
19+ result:: { EVMError , ExecutionResult } ,
20+ BlockEnv , CfgEnv ,
21+ } ,
1922 database:: { Cache , CacheDB } ,
2023 inspector:: NoOpInspector ,
2124 DatabaseRef , Inspector ,
@@ -63,15 +66,19 @@ where
6366 Insp : Inspector < Ctx < SimDb < Db > > > + Default + Sync + ' static ,
6467{
6568 /// Creates a new `SimEnv` instance.
66- pub fn new (
69+ pub fn new < C , B > (
6770 db : Db ,
6871 constants : SignetSystemConstants ,
69- cfg : Box < dyn Cfg > ,
70- block : Box < dyn Block > ,
72+ cfg : C ,
73+ block : B ,
7174 finish_by : std:: time:: Instant ,
7275 concurrency_limit : usize ,
7376 sim_items : SimCache ,
74- ) -> Self {
77+ ) -> Self
78+ where
79+ C : Cfg ,
80+ B : Block ,
81+ {
7582 SimEnv :: new ( db, constants, cfg, block, finish_by, concurrency_limit, sim_items) . into ( )
7683 }
7784
@@ -125,10 +132,10 @@ pub struct SimEnv<Db, Insp = NoOpInspector> {
125132 constants : SignetSystemConstants ,
126133
127134 /// Chain cfg to use for the simulation.
128- cfg : Box < dyn Cfg > ,
135+ cfg : CfgEnv ,
129136
130137 /// Block to use for the simulation.
131- block : Box < dyn Block > ,
138+ block : BlockEnv ,
132139
133140 /// The instant by which the simulation should finish.
134141 finish_by : std:: time:: Instant ,
@@ -151,15 +158,24 @@ impl<Db, Insp> fmt::Debug for SimEnv<Db, Insp> {
151158
152159impl < Db , Insp > SimEnv < Db , Insp > {
153160 /// Creates a new `SimFactory` instance.
154- pub fn new (
161+ pub fn new < C , B > (
155162 db : Db ,
156163 constants : SignetSystemConstants ,
157- cfg : Box < dyn Cfg > ,
158- block : Box < dyn Block > ,
164+ cfg_ref : C ,
165+ block_ref : B ,
159166 finish_by : std:: time:: Instant ,
160167 concurrency_limit : usize ,
161168 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+
163179 Self {
164180 db : Arc :: new ( CacheDB :: new ( db) ) ,
165181 constants,
@@ -188,12 +204,12 @@ impl<Db, Insp> SimEnv<Db, Insp> {
188204 }
189205
190206 /// Get a reference to the chain cfg.
191- pub fn cfg ( & self ) -> & dyn Cfg {
207+ pub const fn cfg ( & self ) -> & CfgEnv {
192208 & self . cfg
193209 }
194210
195211 /// Get a reference to the block.
196- pub fn block ( & self ) -> & dyn Block {
212+ pub const fn block ( & self ) -> & BlockEnv {
197213 & self . block
198214 }
199215
0 commit comments