diff --git a/crates/revm/revm-inspectors/src/tracing/mod.rs b/crates/revm/revm-inspectors/src/tracing/mod.rs index f5b1794c93..e1ff439b52 100644 --- a/crates/revm/revm-inspectors/src/tracing/mod.rs +++ b/crates/revm/revm-inspectors/src/tracing/mod.rs @@ -241,8 +241,9 @@ impl TracingInspector { created_address: Option
, ) { let trace_idx = self.pop_trace_idx(); - let trace = &mut self.traces.arena[trace_idx].trace; + let trace = &mut self.traces.arena[trace_idx].trace; + // check if this is the root call if trace_idx == 0 { // this is the root call which should get the gas used of the transaction // refunds are applied after execution, which is when the root call ends @@ -261,6 +262,15 @@ impl TracingInspector { // A new contract was created via CREATE trace.address = address; } + + if self.config.record_state_diff { + // check if the `address` account of a call was created + if !trace.kind.is_any_create() && trace.success { + if let Some(acc) = data.journaled_state.state.get(&trace.address) { + trace.is_callee_account_created = Some(acc.is_created()); + } + } + } } /// Starts tracking a step diff --git a/crates/revm/revm-inspectors/src/tracing/types.rs b/crates/revm/revm-inspectors/src/tracing/types.rs index b5a607f434..519e50c0d9 100644 --- a/crates/revm/revm-inspectors/src/tracing/types.rs +++ b/crates/revm/revm-inspectors/src/tracing/types.rs @@ -126,6 +126,13 @@ pub(crate) struct CallTrace { /// In other words, this is the callee if the [CallKind::Call] or the address of the created /// contract if [CallKind::Create]. pub(crate) address: Address, + /// If this is a Call, this tracks whether the callee address was created in this transaction. + /// + /// This is only required for state diff related tracing, such as parity tracing with + /// `stateDiff`. + /// + /// Note: this will always be None for [CallKind::Create] [CallKind::Create2] calls. + pub(crate) is_callee_account_created: Option, /// Whether this is a call to a precompile /// /// Note: This is an Option because not all tracers make use of this @@ -198,6 +205,7 @@ impl Default for CallTrace { success: Default::default(), caller: Default::default(), address: Default::default(), + is_callee_account_created: None, selfdestruct_refund_target: None, kind: Default::default(), value: Default::default(),