From 26347161ab525549d5df15866a66dcd4dbaa5b02 Mon Sep 17 00:00:00 2001 From: 0xkrane <0x@krane.wtf> Date: Sun, 22 Sep 2024 15:40:26 +0400 Subject: [PATCH 1/5] chore: add from_flat_call_config --- src/tracing/config.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tracing/config.rs b/src/tracing/config.rs index e306c46f..b337caff 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,17 @@ impl TracingInspectorConfig { .set_record_logs(config.with_log.unwrap_or_default()) } + /// Returns a config for geth's [FlatCallTracer](alloy_rpc_types_trace::geth::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 From 25be1ee0d64ab8fbe0dfc96dd7bfb3a892c597e4 Mon Sep 17 00:00:00 2001 From: 0xkrane <0x@krane.wtf> Date: Sun, 22 Sep 2024 15:56:15 +0400 Subject: [PATCH 2/5] chore: add tests --- src/tracing/config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tracing/config.rs b/src/tracing/config.rs index b337caff..4c1e2e0d 100644 --- a/src/tracing/config.rs +++ b/src/tracing/config.rs @@ -400,4 +400,14 @@ mod tests { // not required for StateDiff assert!(!config.record_state_diff); } + + 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); + } } From dee80d1a54afdbc0ee7544f2341c491ab347ee0c Mon Sep 17 00:00:00 2001 From: 0xkrane <0x@krane.wtf> Date: Sun, 22 Sep 2024 16:00:49 +0400 Subject: [PATCH 3/5] add test flag --- src/tracing/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tracing/config.rs b/src/tracing/config.rs index 4c1e2e0d..c6627f64 100644 --- a/src/tracing/config.rs +++ b/src/tracing/config.rs @@ -401,6 +401,7 @@ mod tests { 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); From 24e92ff0bb0edec7775244c04232ce4aa5062704 Mon Sep 17 00:00:00 2001 From: 0xkrane <0x@krane.wtf> Date: Sun, 22 Sep 2024 18:51:40 +0400 Subject: [PATCH 4/5] fix: update path --- src/tracing/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracing/config.rs b/src/tracing/config.rs index c6627f64..d2be1d24 100644 --- a/src/tracing/config.rs +++ b/src/tracing/config.rs @@ -188,7 +188,7 @@ impl TracingInspectorConfig { .set_record_logs(config.with_log.unwrap_or_default()) } - /// Returns a config for geth's [FlatCallTracer](alloy_rpc_types_trace::geth::FlatCallFrame). + /// 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] From 4f63f49f64f70035ec32f1ae50406b4c0e1bfa7f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 23 Sep 2024 10:55:01 +0200 Subject: [PATCH 5/5] rustfmt --- src/tracing/config.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tracing/config.rs b/src/tracing/config.rs index d2be1d24..a9abea65 100644 --- a/src/tracing/config.rs +++ b/src/tracing/config.rs @@ -188,10 +188,12 @@ 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). + /// 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] + /// 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()