Skip to content

Commit

Permalink
fix: remove steps after steps tracing cheatcodes are done (foundry-rs…
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored and rplusq committed Nov 29, 2024
1 parent 9041c64 commit 1fd762c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/cheatcodes/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,16 +761,23 @@ impl Cheatcode for stopAndReturnDebugTraceRecordingCall {
return Err(Error::from("nothing recorded"))
};

// Revert the tracer config to the one before recording
tracer.update_config(|_config| record_info.original_tracer_config);

// Use the trace nodes to flatten the call trace
let root = tracer.traces();
let steps = flatten_call_trace(0, root, record_info.start_node_idx);

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

// Free up memory by clearing the steps if they are not recorded outside of cheatcode usage.
if !record_info.original_tracer_config.record_steps {
tracer.traces_mut().nodes_mut().iter_mut().for_each(|node| {
node.trace.steps = Vec::new();
});
}

// Revert the tracer config to the one before recording
tracer.update_config(|_config| record_info.original_tracer_config);

// Clean up the recording info
ccx.state.record_debug_steps_info = None;

Expand Down

0 comments on commit 1fd762c

Please sign in to comment.