Skip to content

Commit 213d817

Browse files
authored
fix: remove steps after steps tracing cheatcodes are done (#9234)
1 parent c90ea4d commit 213d817

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

crates/cheatcodes/src/evm.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -761,16 +761,23 @@ impl Cheatcode for stopAndReturnDebugTraceRecordingCall {
761761
return Err(Error::from("nothing recorded"))
762762
};
763763

764-
// Revert the tracer config to the one before recording
765-
tracer.update_config(|_config| record_info.original_tracer_config);
766-
767764
// Use the trace nodes to flatten the call trace
768765
let root = tracer.traces();
769766
let steps = flatten_call_trace(0, root, record_info.start_node_idx);
770767

771768
let debug_steps: Vec<DebugStep> =
772769
steps.iter().map(|&step| convert_call_trace_to_debug_step(step)).collect();
773770

771+
// Free up memory by clearing the steps if they are not recorded outside of cheatcode usage.
772+
if !record_info.original_tracer_config.record_steps {
773+
tracer.traces_mut().nodes_mut().iter_mut().for_each(|node| {
774+
node.trace.steps = Vec::new();
775+
});
776+
}
777+
778+
// Revert the tracer config to the one before recording
779+
tracer.update_config(|_config| record_info.original_tracer_config);
780+
774781
// Clean up the recording info
775782
ccx.state.record_debug_steps_info = None;
776783

0 commit comments

Comments
 (0)