@@ -27,7 +27,10 @@ pub struct CairoRunConfig<'a> {
2727 #[ cfg_attr( feature = "test_utils" , arbitrary( value = "main" ) ) ]
2828 pub entrypoint : & ' a str ,
2929 pub trace_enabled : bool ,
30+ /// Relocate memory if `true`, otherwise memory is not relocated.
3031 pub relocate_mem : bool ,
32+ // When `relocate_trace` is set to `false`, the trace will not be relocated even if `trace_enabled` is `true`.
33+ pub relocate_trace : bool ,
3134 pub layout : LayoutName ,
3235 /// The `dynamic_layout_params` argument should only be used with dynamic layout.
3336 /// It is ignored otherwise.
@@ -51,6 +54,7 @@ impl Default for CairoRunConfig<'_> {
5154 entrypoint : "main" ,
5255 trace_enabled : false ,
5356 relocate_mem : false ,
57+ relocate_trace : false ,
5458 layout : LayoutName :: plain,
5559 proof_mode : false ,
5660 secure_run : None ,
@@ -113,7 +117,10 @@ pub fn cairo_run_program_with_initial_scope(
113117 if secure_run {
114118 verify_secure_runner ( & cairo_runner, true , None ) ?;
115119 }
116- cairo_runner. relocate ( cairo_run_config. relocate_mem ) ?;
120+ cairo_runner. relocate (
121+ cairo_run_config. relocate_mem ,
122+ cairo_run_config. relocate_trace ,
123+ ) ?;
117124
118125 Ok ( cairo_runner)
119126}
@@ -218,7 +225,10 @@ pub fn cairo_run_pie(
218225 // Check that the Cairo PIE produced by this run is compatible with the Cairo PIE received
219226 cairo_runner. get_cairo_pie ( ) ?. check_pie_compatibility ( pie) ?;
220227 }
221- cairo_runner. relocate ( cairo_run_config. relocate_mem ) ?;
228+ cairo_runner. relocate (
229+ cairo_run_config. relocate_mem ,
230+ cairo_run_config. relocate_trace ,
231+ ) ?;
222232
223233 Ok ( cairo_runner)
224234}
@@ -267,7 +277,10 @@ pub fn cairo_run_fuzzed_program(
267277 if secure_run {
268278 verify_secure_runner ( & cairo_runner, true , None ) ?;
269279 }
270- cairo_runner. relocate ( cairo_run_config. relocate_mem ) ?;
280+ cairo_runner. relocate (
281+ cairo_run_config. relocate_mem ,
282+ cairo_run_config. relocate_trace ,
283+ ) ?;
271284
272285 Ok ( cairo_runner)
273286}
@@ -367,7 +380,7 @@ mod tests {
367380
368381 let end = cairo_runner. initialize ( false ) . unwrap ( ) ;
369382 assert ! ( cairo_runner. run_until_pc( end, & mut hint_processor) . is_ok( ) ) ;
370- assert ! ( cairo_runner. relocate( true ) . is_ok( ) ) ;
383+ assert ! ( cairo_runner. relocate( true , true ) . is_ok( ) ) ;
371384 // `main` returns without doing nothing, but `not_main` sets `[ap]` to `1`
372385 // Memory location was found empirically and simply hardcoded
373386 assert_eq ! ( cairo_runner. relocated_memory[ 2 ] , Some ( Felt252 :: from( 123 ) ) ) ;
@@ -433,7 +446,7 @@ mod tests {
433446 let mut hint_processor = BuiltinHintProcessor :: new_empty ( ) ;
434447 let mut cairo_runner = run_test_program ( program_content, & mut hint_processor) . unwrap ( ) ;
435448
436- assert ! ( cairo_runner. relocate( false ) . is_ok( ) ) ;
449+ assert ! ( cairo_runner. relocate( false , true ) . is_ok( ) ) ;
437450
438451 let trace_entries = cairo_runner. relocated_trace . unwrap ( ) ;
439452 let mut buffer = [ 0 ; 24 ] ;
@@ -457,7 +470,7 @@ mod tests {
457470 let mut cairo_runner = run_test_program ( program_content, & mut hint_processor) . unwrap ( ) ;
458471
459472 // relocate memory so we can dump it to file
460- assert ! ( cairo_runner. relocate( true ) . is_ok( ) ) ;
473+ assert ! ( cairo_runner. relocate( true , true ) . is_ok( ) ) ;
461474
462475 let mut buffer = [ 0 ; 120 ] ;
463476 let mut buff_writer = SliceWriter :: new ( & mut buffer) ;
@@ -481,7 +494,7 @@ mod tests {
481494 let mut cairo_runner = cairo_runner ! ( program) ;
482495 let end = cairo_runner. initialize ( false ) . unwrap ( ) ;
483496 assert ! ( cairo_runner. run_until_pc( end, & mut hint_processor) . is_ok( ) ) ;
484- assert ! ( cairo_runner. relocate( false ) . is_ok( ) ) ;
497+ assert ! ( cairo_runner. relocate( false , false ) . is_ok( ) ) ;
485498 assert ! ( cairo_runner. relocated_trace. is_none( ) ) ;
486499 }
487500
0 commit comments