From b2cf71dab359f464fa42c7ebdb44645e327ae57d Mon Sep 17 00:00:00 2001 From: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Mon, 13 Nov 2023 10:08:34 -0800 Subject: [PATCH 1/3] Update debug.rs --- crates/rpc/rpc-testing-util/src/debug.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/rpc/rpc-testing-util/src/debug.rs b/crates/rpc/rpc-testing-util/src/debug.rs index cc9111821657..7f59bcf077ee 100644 --- a/crates/rpc/rpc-testing-util/src/debug.rs +++ b/crates/rpc/rpc-testing-util/src/debug.rs @@ -5,11 +5,11 @@ use jsonrpsee::core::Error as RpcError; use reth_primitives::{BlockId, TxHash, B256}; use reth_rpc_api::{clients::DebugApiClient, EthApiClient}; use reth_rpc_types::trace::geth::{GethDebugTracerType, GethDebugTracingOptions}; +use reth_rpc_types::CallRequest; use std::{ pin::Pin, task::{Context, Poll}, }; - const NOOP_TRACER: &str = include_str!("../assets/noop-tracer.js"); const JS_TRACER_TEMPLATE: &str = include_str!("../assets/tracer-template.js"); @@ -37,6 +37,13 @@ pub trait DebugApiExt { ) -> Result, jsonrpsee::core::Error> where B: Into + Send; + + /// method for tracing a call + async fn debug_trace_call_json( + &self, + request: CallRequest, + opts: GethDebugTracingOptions, + ) -> Result; } #[async_trait::async_trait] @@ -81,6 +88,17 @@ where Ok(DebugTraceTransactionsStream { stream: Box::pin(stream) }) } + + async fn debug_trace_call_json( + &self, + request: CallRequest, + opts: GethDebugTracingOptions, + ) -> Result { + let mut params = jsonrpsee::core::params::ArrayParams::new(); + params.insert(request).unwrap(); + params.insert(opts).unwrap(); + self.request("debug_traceCall", params).await + } } /// A helper type that can be used to build a javascript tracer. From 41da9fa9429e3112ae138ca9759a346271bb67fa Mon Sep 17 00:00:00 2001 From: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Mon, 13 Nov 2023 10:11:41 -0800 Subject: [PATCH 2/3] fmt --- crates/rpc/rpc-testing-util/src/debug.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/rpc/rpc-testing-util/src/debug.rs b/crates/rpc/rpc-testing-util/src/debug.rs index 7f59bcf077ee..9f6b588b497e 100644 --- a/crates/rpc/rpc-testing-util/src/debug.rs +++ b/crates/rpc/rpc-testing-util/src/debug.rs @@ -4,8 +4,10 @@ use futures::{Stream, StreamExt}; use jsonrpsee::core::Error as RpcError; use reth_primitives::{BlockId, TxHash, B256}; use reth_rpc_api::{clients::DebugApiClient, EthApiClient}; -use reth_rpc_types::trace::geth::{GethDebugTracerType, GethDebugTracingOptions}; -use reth_rpc_types::CallRequest; +use reth_rpc_types::{ + trace::geth::{GethDebugTracerType, GethDebugTracingOptions}, + CallRequest, +}; use std::{ pin::Pin, task::{Context, Poll}, From 1af7f84b1fc18756338c4b9f090dfafe826c122c Mon Sep 17 00:00:00 2001 From: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:10:22 -0800 Subject: [PATCH 3/3] Update debug.rs --- crates/rpc/rpc-testing-util/src/debug.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/rpc/rpc-testing-util/src/debug.rs b/crates/rpc/rpc-testing-util/src/debug.rs index 9f6b588b497e..14a6b86908b9 100644 --- a/crates/rpc/rpc-testing-util/src/debug.rs +++ b/crates/rpc/rpc-testing-util/src/debug.rs @@ -39,13 +39,19 @@ pub trait DebugApiExt { ) -> Result, jsonrpsee::core::Error> where B: Into + Send; - - /// method for tracing a call + /// method for debug_traceCall async fn debug_trace_call_json( &self, request: CallRequest, opts: GethDebugTracingOptions, ) -> Result; + + /// method for debug_traceCall using raw JSON strings for the request and options. + async fn debug_trace_call_raw_json( + &self, + request_json: String, + opts_json: String, + ) -> Result; } #[async_trait::async_trait] @@ -90,7 +96,6 @@ where Ok(DebugTraceTransactionsStream { stream: Box::pin(stream) }) } - async fn debug_trace_call_json( &self, request: CallRequest, @@ -101,6 +106,19 @@ where params.insert(opts).unwrap(); self.request("debug_traceCall", params).await } + + async fn debug_trace_call_raw_json( + &self, + request_json: String, + opts_json: String, + ) -> Result { + let request = serde_json::from_str::(&request_json) + .map_err(|e| RpcError::Custom(e.to_string()))?; + let opts = serde_json::from_str::(&opts_json) + .map_err(|e| RpcError::Custom(e.to_string()))?; + + self.debug_trace_call_json(request, opts).await + } } /// A helper type that can be used to build a javascript tracer.