Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove steps after steps tracing cheatcodes are done #9234

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading