diff --git a/src/tracing/config.rs b/src/tracing/config.rs index e306c46f..a9abea65 100644 --- a/src/tracing/config.rs +++ b/src/tracing/config.rs @@ -1,6 +1,6 @@ use alloy_primitives::U256; use alloy_rpc_types_trace::{ - geth::{CallConfig, GethDefaultTracingOptions, PreStateConfig}, + geth::{CallConfig, FlatCallConfig, GethDefaultTracingOptions, PreStateConfig}, parity::TraceType, }; use revm::interpreter::OpCode; @@ -188,6 +188,19 @@ impl TracingInspectorConfig { .set_record_logs(config.with_log.unwrap_or_default()) } + /// Returns a config for geth's + /// [FlatCallTracer](alloy_rpc_types_trace::geth::call::FlatCallFrame). + /// + /// This returns [Self::default_parity] and sets + /// [TracingInspectorConfig::exclude_precompile_calls] if configured in the given + /// [FlatCallConfig] + #[inline] + pub fn from_flat_call_config(config: &FlatCallConfig) -> Self { + Self::default_parity() + // call tracer is similar parity tracer with optional support for logs + .set_exclude_precompile_calls(!config.include_precompiles.unwrap_or_default()) + } + /// Returns a config for geth's [PrestateTracer](alloy_rpc_types_trace::geth::PreStateFrame). /// /// Note: This currently returns [Self::none] because the prestate tracer result currently @@ -389,4 +402,15 @@ mod tests { // not required for StateDiff assert!(!config.record_state_diff); } + + #[test] + fn test_flat_call_config() { + let config = FlatCallConfig { include_precompiles: Some(true), ..Default::default() }; + let config = TracingInspectorConfig::from_flat_call_config(&config); + assert!(!config.exclude_precompile_calls); + + let config = FlatCallConfig { include_precompiles: Some(false), ..Default::default() }; + let config = TracingInspectorConfig::from_flat_call_config(&config); + assert!(config.exclude_precompile_calls); + } }