diff --git a/crates/rpc/rpc-api/src/debug.rs b/crates/rpc/rpc-api/src/debug.rs index dc594e0275..ab9b80f424 100644 --- a/crates/rpc/rpc-api/src/debug.rs +++ b/crates/rpc/rpc-api/src/debug.rs @@ -1,7 +1,10 @@ use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc}; use reth_primitives::{BlockId, BlockNumberOrTag, Bytes, H256}; use reth_rpc_types::{ - trace::geth::{BlockTraceResult, GethDebugTracingOptions, GethTraceFrame, TraceResult}, + trace::geth::{ + BlockTraceResult, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTraceFrame, + TraceResult, + }, CallRequest, RichBlock, }; @@ -97,6 +100,6 @@ pub trait DebugApi { &self, request: CallRequest, block_number: Option, - opts: GethDebugTracingOptions, + opts: GethDebugTracingCallOptions, ) -> Result; } diff --git a/crates/rpc/rpc-types/src/eth/block.rs b/crates/rpc/rpc-types/src/eth/block.rs index 5c9de8ab4f..f75075eb8d 100644 --- a/crates/rpc/rpc-types/src/eth/block.rs +++ b/crates/rpc/rpc-types/src/eth/block.rs @@ -2,7 +2,7 @@ use crate::Transaction; use reth_primitives::{ Address, Block as PrimitiveBlock, Bloom, Bytes, Header as PrimitiveHeader, SealedHeader, - Withdrawal, H256, H64, U256, + Withdrawal, H256, H64, U256, U64, }; use reth_rlp::Encodable; use serde::{ser::Error, Deserialize, Serialize, Serializer}; @@ -351,6 +351,27 @@ impl Serialize for Rich { } } +/// BlockOverrides is a set of header fields to override. +#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] +#[serde(default, rename_all = "camelCase", deny_unknown_fields)] +#[allow(missing_docs)] +pub struct BlockOverrides { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub number: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub difficulty: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub time: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gas_limit: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub coinbase: Option
, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub random: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub base_fee: Option, +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs b/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs index 71d6c9077d..0400c34d29 100644 --- a/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs +++ b/crates/rpc/rpc-types/src/eth/trace/geth/mod.rs @@ -1,5 +1,6 @@ #![allow(missing_docs)] +use crate::{state::StateOverride, BlockOverrides}; /// Geth tracing types use reth_primitives::{Bytes, JsonU256, H256, U256}; use serde::{Deserialize, Serialize}; @@ -308,9 +309,6 @@ pub struct GethDefaultTracingOptions { /// maximum length of output, but zero means unlimited #[serde(default, skip_serializing_if = "Option::is_none")] pub limit: Option, - /// Chain overrides, can be used to execute a trace using future fork rules - #[serde(default, skip_serializing_if = "Option::is_none")] - pub overrides: Option, } /// Bindings for additional `debug_traceCall` options @@ -321,5 +319,10 @@ pub struct GethDefaultTracingOptions { pub struct GethDebugTracingCallOptions { #[serde(flatten)] pub tracing_options: GethDebugTracingOptions, - // TODO: Add stateoverrides and blockoverrides options + /// The state overrides to apply + #[serde(default, skip_serializing_if = "Option::is_none")] + pub state_overrides: Option, + /// The block overrides to apply + #[serde(default, skip_serializing_if = "Option::is_none")] + pub block_overrides: Option, } diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index 8b6876fc5d..350133e73e 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -21,7 +21,8 @@ use reth_rpc_api::DebugApiServer; use reth_rpc_types::{ trace::geth::{ BlockTraceResult, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType, - GethDebugTracingOptions, GethTraceFrame, NoopFrame, TraceResult, + GethDebugTracingCallOptions, GethDebugTracingOptions, GethTraceFrame, NoopFrame, + TraceResult, }, BlockError, CallRequest, RichBlock, }; @@ -141,11 +142,13 @@ where &self, call: CallRequest, block_id: Option, - opts: GethDebugTracingOptions, + opts: GethDebugTracingCallOptions, ) -> EthResult { let at = block_id.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest)); - - let GethDebugTracingOptions { config, .. } = opts; + // TODO(mattsse) apply block overrides + let GethDebugTracingCallOptions { tracing_options, state_overrides, block_overrides: _ } = + opts; + let GethDebugTracingOptions { config, .. } = tracing_options; // TODO(mattsse) support non default tracers // default structlog tracer @@ -153,7 +156,8 @@ where let mut inspector = TracingInspector::new(inspector_config); - let (res, _) = self.eth_api.inspect_call_at(call, at, None, &mut inspector).await?; + let (res, _) = + self.eth_api.inspect_call_at(call, at, state_overrides, &mut inspector).await?; let gas_used = res.result.gas_used(); let frame = inspector.into_geth_builder().geth_traces(U256::from(gas_used), config); @@ -288,7 +292,7 @@ where &self, request: CallRequest, block_number: Option, - opts: GethDebugTracingOptions, + opts: GethDebugTracingCallOptions, ) -> RpcResult { Ok(DebugApi::debug_trace_call(self, request, block_number, opts).await?) }