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: Geth trace inconsistence with self-destruct #173

Merged
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions src/tracing/builder/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,16 @@ impl GethTraceBuilder {
call_frames.push((0, root_call_frame));

for (idx, trace) in self.nodes.iter().enumerate().skip(1) {
// include logs only if call and all its parents were successful
let include_logs = include_logs && !self.call_or_parent_failed(trace);
call_frames.push((idx, trace.geth_empty_call_frame(include_logs)));

// selfdestructs are not recorded as individual call traces but are derived from
// the call trace and are added as additional `CallFrame` objects to the parent call
// the call trace and are added as additional `CallFrame` objects
// becoming the first child of the derived call
Comment on lines +150 to +151
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see, this adds the call frame first and then adds the sefldestruct to that callframe that we just added as a child call

if let Some(selfdestruct) = trace.geth_selfdestruct_call_trace() {
call_frames.last_mut().expect("not empty").1.calls.push(selfdestruct);
}

// include logs only if call and all its parents were successful
let include_logs = include_logs && !self.call_or_parent_failed(trace);
call_frames.push((idx, trace.geth_empty_call_frame(include_logs)));
}

// pop the _children_ calls frame and move it to the parent
Expand Down
2 changes: 1 addition & 1 deletion src/tracing/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl CallTraceNode {
if self.is_selfdestruct() {
Some(CallFrame {
typ: "SELFDESTRUCT".to_string(),
from: self.trace.caller,
from: self.trace.address,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah this makes sense

to: self.trace.selfdestruct_refund_target,
value: self.trace.selfdestruct_transferred_value,
..Default::default()
Expand Down
Loading