Skip to content

Commit

Permalink
fix: use correct address for log (paradigmxyz#3481)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jun 30, 2023
1 parent c3ea430 commit 3dcc76e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion crates/revm/revm-inspectors/src/tracing/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ impl CallKind {
pub fn is_any_create(&self) -> bool {
matches!(self, CallKind::Create | CallKind::Create2)
}

/// Returns true if the call is a delegate of some sorts
pub fn is_delegate(&self) -> bool {
matches!(self, CallKind::DelegateCall | CallKind::CallCode)
}
}

impl std::fmt::Display for CallKind {
Expand Down Expand Up @@ -204,6 +209,17 @@ pub(crate) struct CallTraceNode {
}

impl CallTraceNode {
/// Returns the call context's execution address
///
/// See `Inspector::call` impl of [TracingInspector](crate::tracing::TracingInspector)
pub(crate) fn execution_address(&self) -> Address {
if self.trace.kind.is_delegate() {
self.trace.caller
} else {
self.trace.address
}
}

/// Pushes all steps onto the stack in reverse order
/// so that the first step is on top of the stack
pub(crate) fn push_steps_on_stack<'a>(
Expand Down Expand Up @@ -393,7 +409,7 @@ impl CallTraceNode {
.logs
.iter()
.map(|log| CallLogFrame {
address: Some(self.trace.address),
address: Some(self.execution_address()),
topics: Some(log.topics.clone()),
data: Some(log.data.clone().into()),
})
Expand Down

0 comments on commit 3dcc76e

Please sign in to comment.