@@ -106,6 +106,20 @@ impl DeducedOperands {
106106 }
107107}
108108
109+ pub struct VirtualMachineConfig {
110+ pub trace_enabled : bool ,
111+ pub disable_trace_padding : bool ,
112+ }
113+
114+ impl Default for VirtualMachineConfig {
115+ fn default ( ) -> Self {
116+ Self {
117+ trace_enabled : false ,
118+ disable_trace_padding : false ,
119+ }
120+ }
121+ }
122+
109123pub struct VirtualMachine {
110124 pub ( crate ) run_context : RunContext ,
111125 pub builtin_runners : Vec < BuiltinRunner > ,
@@ -135,15 +149,21 @@ pub struct VirtualMachine {
135149 pub ( crate ) relocation_table : Option < Vec < usize > > ,
136150}
137151
152+ impl Default for VirtualMachine {
153+ fn default ( ) -> Self {
154+ Self :: new ( & VirtualMachineConfig :: default ( ) )
155+ }
156+ }
157+
138158impl VirtualMachine {
139- pub fn new ( trace_enabled : bool , disable_trace_padding : bool ) -> VirtualMachine {
159+ pub fn new ( config : & VirtualMachineConfig ) -> VirtualMachine {
140160 let run_context = RunContext {
141161 pc : Relocatable :: from ( ( 0 , 0 ) ) ,
142162 ap : 0 ,
143163 fp : 0 ,
144164 } ;
145165
146- let trace = if trace_enabled {
166+ let trace = if config . trace_enabled {
147167 Some ( Vec :: < TraceEntry > :: new ( ) )
148168 } else {
149169 None
@@ -160,7 +180,7 @@ impl VirtualMachine {
160180 segments : MemorySegmentManager :: new ( ) ,
161181 rc_limits : None ,
162182 run_finished : false ,
163- disable_trace_padding,
183+ disable_trace_padding : config . disable_trace_padding ,
164184 instruction_cache : Vec :: new ( ) ,
165185 #[ cfg( feature = "test_utils" ) ]
166186 hooks : None ,
@@ -1660,7 +1680,7 @@ mod tests {
16601680 op1 : MaybeRelocatable :: Int ( Felt252 :: from ( 10 ) ) ,
16611681 } ;
16621682
1663- let mut vm = VirtualMachine :: new ( false , false ) ;
1683+ let mut vm = VirtualMachine :: default ( ) ;
16641684 vm. run_context . pc = Relocatable :: from ( ( 0 , 4 ) ) ;
16651685 vm. run_context . ap = 5 ;
16661686 vm. run_context . fp = 6 ;
0 commit comments