Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
chore: set trace result to null if non revert or selfdestruct (paradi…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jul 18, 2023
1 parent 0e05085 commit b8587a2
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions crates/revm/revm-inspectors/src/tracing/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ impl CallTrace {
self.status as u8 >= InstructionResult::Revert as u8
}

// Returns true if the status code is a revert
pub(crate) fn is_revert(&self) -> bool {
self.status == InstructionResult::Revert
}

/// Returns the error message if it is an erroneous result.
pub(crate) fn as_error(&self, kind: TraceStyle) -> Option<String> {
// See also <https://github.com/ethereum/go-ethereum/blob/34d507215951fb3f4a5983b65e127577989a6db8/eth/tracers/native/call_flat.go#L39-L55>
Expand Down Expand Up @@ -340,15 +345,16 @@ impl CallTraceNode {
/// Converts this node into a parity `TransactionTrace`
pub(crate) fn parity_transaction_trace(&self, trace_address: Vec<usize>) -> TransactionTrace {
let action = self.parity_action();
let output = self.parity_trace_output();
let result = if action.is_selfdestruct() ||
(self.trace.is_error() && !self.trace.is_revert())
{
// if the trace is a selfdestruct or an error that is not a revert, the result is None
None
} else {
Some(self.parity_trace_output())
};
let error = self.trace.as_error(TraceStyle::Parity);
TransactionTrace {
action,
error,
result: Some(output),
trace_address,
subtraces: self.children.len(),
}
TransactionTrace { action, error, result, trace_address, subtraces: self.children.len() }
}

/// Returns the `Output` for a parity trace
Expand Down

0 comments on commit b8587a2

Please sign in to comment.