Skip to content

Commit

Permalink
fix: dont include empty revert reason (#5736)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 12, 2023
1 parent 829d3ed commit 701e378
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crates/revm/revm-inspectors/src/tracing/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ impl CallTraceNode {

// we need to populate error and revert reason
if !self.trace.success {
call_frame.revert_reason = decode_revert_reason(self.trace.output.as_ref());
// decode the revert reason, but don't include it if it's empty
call_frame.revert_reason = decode_revert_reason(self.trace.output.as_ref())
.filter(|reason| !reason.is_empty());

// Note: the call tracer mimics parity's trace transaction and geth maps errors to parity style error messages, <https://github.com/ethereum/go-ethereum/blob/34d507215951fb3f4a5983b65e127577989a6db8/eth/tracers/native/call_flat.go#L39-L55>
call_frame.error = self.trace.as_error_msg(TraceStyle::Parity);
}
Expand Down Expand Up @@ -676,3 +679,14 @@ impl AsRef<[u8]> for RecordedMemory {
self.as_bytes()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn decode_empty_revert() {
let reason = decode_revert_reason("".as_bytes());
assert_eq!(reason, Some("".to_string()));
}
}

0 comments on commit 701e378

Please sign in to comment.