From 3dcc76e2b0aba962dd130934f698231250ef5ae6 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 30 Jun 2023 02:44:11 +0200 Subject: [PATCH] fix: use correct address for log (#3481) --- .../revm/revm-inspectors/src/tracing/types.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/revm/revm-inspectors/src/tracing/types.rs b/crates/revm/revm-inspectors/src/tracing/types.rs index feb3524e41..8809de6085 100644 --- a/crates/revm/revm-inspectors/src/tracing/types.rs +++ b/crates/revm/revm-inspectors/src/tracing/types.rs @@ -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 { @@ -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>( @@ -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()), })