From 3e74c77766cce5988b36b4902fbf3aa13da64c69 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Tue, 12 Mar 2024 05:13:25 +0100 Subject: [PATCH 1/3] feat: `trace_call` and `trace_callMany` --- crates/provider/src/new.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/crates/provider/src/new.rs b/crates/provider/src/new.rs index 15331370dd5..9b4d4d68ea6 100644 --- a/crates/provider/src/new.rs +++ b/crates/provider/src/new.rs @@ -11,7 +11,7 @@ use alloy_primitives::{ use alloy_rpc_client::{ClientRef, RpcClient, WeakClient}; use alloy_rpc_trace_types::{ geth::{GethDebugTracingOptions, GethTrace}, - parity::LocalizedTransactionTrace, + parity::{LocalizedTransactionTrace, TraceResults, TraceType}, }; use alloy_rpc_types::{ state::StateOverride, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag, @@ -399,6 +399,35 @@ pub trait Provider: Send + Sync self.client().prepare("eth_createAccessList", (request, block.unwrap_or_default())).await } + /// Executes the given transaction and returns a number of possible traces. + /// + /// # Note + /// + /// Not all nodes support this call. + async fn trace_call( + &self, + request: &N::TransactionRequest, + trace_type: Vec, + block: Option, + ) -> TransportResult { + self.client().prepare("trace_call", (request, trace_type, block)).await + } + + /// Traces multiple transactions on top of the same block, i.e. transaction `n` will be executed on top of the given block with all `n - 1` transaction applied first. + /// + /// Allows tracing dependent transactions. + /// + /// # Note + /// + /// Not all nodes support this call. + async fn trace_call_many( + &self, + request: &[(N::TransactionRequest, Vec)], + block: Option, + ) -> TransportResult { + self.client().prepare("trace_callMany", (request, block)).await + } + // todo: move to extension trait /// Parity trace transaction. async fn trace_transaction( From 554e14d99c39580969ce12957c47f4dea9e0d8b5 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Tue, 12 Mar 2024 05:15:30 +0100 Subject: [PATCH 2/3] chore: fmt --- crates/provider/src/new.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/provider/src/new.rs b/crates/provider/src/new.rs index 9b4d4d68ea6..f962a6ddc73 100644 --- a/crates/provider/src/new.rs +++ b/crates/provider/src/new.rs @@ -413,7 +413,8 @@ pub trait Provider: Send + Sync self.client().prepare("trace_call", (request, trace_type, block)).await } - /// Traces multiple transactions on top of the same block, i.e. transaction `n` will be executed on top of the given block with all `n - 1` transaction applied first. + /// Traces multiple transactions on top of the same block, i.e. transaction `n` will be executed + /// on top of the given block with all `n - 1` transaction applied first. /// /// Allows tracing dependent transactions. /// From 1ecf22d4c5502f3f34f97d586892958a8aaa9f5b Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Tue, 12 Mar 2024 15:02:10 +0100 Subject: [PATCH 3/3] chore: use slices --- crates/provider/src/new.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/provider/src/new.rs b/crates/provider/src/new.rs index f962a6ddc73..9f392d51bcc 100644 --- a/crates/provider/src/new.rs +++ b/crates/provider/src/new.rs @@ -407,7 +407,7 @@ pub trait Provider: Send + Sync async fn trace_call( &self, request: &N::TransactionRequest, - trace_type: Vec, + trace_type: &[TraceType], block: Option, ) -> TransportResult { self.client().prepare("trace_call", (request, trace_type, block)).await