Skip to content

Commit

Permalink
feat: trace position field + bump deps (#186)
Browse files Browse the repository at this point in the history
ref #180

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: jsvisa <delweng@gmail.com>
  • Loading branch information
klkvr and jsvisa authored Aug 29, 2024
1 parent 0de6442 commit 392c298
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ clippy.lint_groups_priority = "allow"

[dependencies]
# eth
alloy-sol-types = "0.7"
alloy-primitives = "0.7"
alloy-rpc-types = { version = "0.2", features = ["eth", "trace"] }
revm = { version = "13", default-features = false, features = ["std"] }
alloy-sol-types = "0.8"
alloy-primitives = "0.8"
alloy-rpc-types = { version = "0.3", features = ["eth", "trace"] }
revm = { version = "14", default-features = false, features = ["std"] }

anstyle = "1.0"
colorchoice = "1.0"
Expand Down
2 changes: 2 additions & 0 deletions src/tracing/builder/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ where
Ok(())
}

/// Populates [StateDiff] given iterator over [Account]s and a [DatabaseRef].
///
/// Loops over all state accounts in the accounts diff that contains all accounts that are included
/// in the [ExecutionResult] state map and compares the balance and nonce against what's in the
/// `db`, which should point to the beginning of the transaction.
Expand Down
2 changes: 1 addition & 1 deletion src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ where
if self.config.record_logs {
let trace = self.last_trace();
trace.ordering.push(TraceMemberOrder::Log(trace.logs.len()));
trace.logs.push(CallLog::from(log.clone()));
trace.logs.push(CallLog::from(log.clone()).with_position(trace.children.len() as u64));
}
}

Expand Down
18 changes: 17 additions & 1 deletion src/tracing/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,27 @@ pub struct CallLog {
pub raw_log: LogData,
/// Optional complementary decoded log data.
pub decoded: DecodedCallLog,
/// The position of the log relative to subcalls within the same trace.
pub position: u64,
}

impl From<Log> for CallLog {
/// Converts a [`Log`] into a [`CallLog`].
fn from(log: Log) -> Self {
Self { raw_log: log.data, decoded: DecodedCallLog { name: None, params: None } }
Self {
position: Default::default(),
raw_log: log.data,
decoded: DecodedCallLog { name: None, params: None },
}
}
}

impl CallLog {
/// Sets the position of the log.
#[inline]
pub fn with_position(mut self, position: u64) -> Self {
self.position = position;
self
}
}

Expand Down Expand Up @@ -411,6 +426,7 @@ impl CallTraceNode {
address: Some(self.execution_address()),
topics: Some(log.raw_log.topics().to_vec()),
data: Some(log.raw_log.data.clone()),
position: Some(log.position),
})
.collect();
}
Expand Down

0 comments on commit 392c298

Please sign in to comment.