Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add FlatCallTracer #11114

Merged
merged 22 commits into from
Sep 24, 2024
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ use reth_rpc_types::{
debug::ExecutionWitness,
state::EvmOverrides,
trace::geth::{
BlockTraceResult, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType,
GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, NoopFrame, TraceResult,
call::FlatCallFrame, BlockTraceResult, FlatCallConfig, FourByteFrame,
GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingCallOptions,
GethDebugTracingOptions, GethTrace, NoopFrame, TraceResult
},
Block as RpcBlock, BlockError, Bundle, StateContext, TransactionRequest,
};
Expand Down Expand Up @@ -390,9 +391,21 @@ where
return Ok(frame)
}
GethDebugBuiltInTracerType::FlatCallTracer => {
return Err(
EthApiError::Unsupported("Flatcall tracer is not supported yet").into()
)
let flat_call_config = tracer_config
.into_flat_call_config()
.map_err(|_| EthApiError::InvalidTracerConfig)?;

let mut inspector = TracingInspector::new(
TracingInspectorConfig::from_flat_call_config(&flat_call_config)
);

// Now `res` is the unwrapped value, not an Option
let res = None;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good start, we need to replicate what we do here:

/// Returns all traces for the given transaction hash
pub async fn trace_transaction(
&self,
hash: B256,
) -> Result<Option<Vec<LocalizedTransactionTrace>>, Eth::Error> {
self.inner
.eth_api
.spawn_trace_transaction_in_block(
hash,
TracingInspectorConfig::default_parity(),
move |tx_info, inspector, _, _| {
let traces =
inspector.into_parity_builder().into_localized_transaction_traces(tx_info);
Ok(traces)
},
)
.await

and

let traces = self.inner.eth_api.trace_block_with(
block_id,
TracingInspectorConfig::default_parity(),
|tx_info, inspector, _, _, _| {
let traces =
inspector.into_parity_builder().into_localized_transaction_traces(tx_info);
Ok(traces)
},
);

I think here we can ignore the block reward stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tx_info should just be default here right since it isn't actually tx and is just a call?

(quickly update code to use default, lmk if there is something else i should be fetching)

// Transform the collected data into a FlatCallFrame
let frame = FlatCallFrame::from(res);

return Ok(frame)
}
},
#[cfg(not(feature = "js-tracer"))]
Expand Down