From bec9b44dd7efc9ef60421d8e84c51d08dfa7eaa2 Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Thu, 2 May 2024 00:22:25 +0200 Subject: [PATCH 1/2] Derive default for TracingInspector --- src/tracing/config.rs | 14 ++++---------- src/tracing/mod.rs | 12 ++---------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/tracing/config.rs b/src/tracing/config.rs index 2832f9d..28bfeae 100644 --- a/src/tracing/config.rs +++ b/src/tracing/config.rs @@ -8,7 +8,7 @@ use std::collections::HashSet; /// /// Use [TracingInspectorConfig::default_parity] or [TracingInspectorConfig::default_geth] to get /// the default configs for specific styles of traces. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] pub struct TracingInspectorConfig { /// Whether to record every individual opcode level step. pub record_steps: bool, @@ -39,14 +39,7 @@ impl TracingInspectorConfig { /// Returns a config with everything is disabled. pub const fn none() -> Self { - Self { - record_steps: false, - record_memory_snapshots: false, - record_stack_snapshots: StackSnapshotType::None, - record_state_diff: false, - exclude_precompile_calls: false, - record_logs: false, - } + Self::default() } /// Returns a config for parity style traces. @@ -236,9 +229,10 @@ impl TracingInspectorConfig { } /// How much of the stack to record. Nothing, just the items pushed, or the full stack -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] pub enum StackSnapshotType { /// Don't record stack snapshots + #[default] None, /// Record only the items pushed to the stack Pushes, diff --git a/src/tracing/mod.rs b/src/tracing/mod.rs index 92da8d8..f0faea8 100644 --- a/src/tracing/mod.rs +++ b/src/tracing/mod.rs @@ -57,7 +57,7 @@ pub use mux::{Error as MuxError, MuxInspector}; /// The [TracingInspector] keeps track of everything by: /// 1. start tracking steps/calls on [Inspector::step] and [Inspector::call] /// 2. complete steps/calls on [Inspector::step_end] and [Inspector::call_end] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct TracingInspector { /// Configures what and how the inspector records traces. config: TracingInspectorConfig, @@ -82,15 +82,7 @@ pub struct TracingInspector { impl TracingInspector { /// Returns a new instance for the given config pub fn new(config: TracingInspectorConfig) -> Self { - Self { - config, - traces: Default::default(), - trace_stack: vec![], - step_stack: vec![], - last_call_return_data: None, - gas_inspector: Default::default(), - spec_id: None, - } + Self { config, ..Default::default() } } /// Resets the inspector to its initial state of [Self::new]. From 2bce0439653a5c890b5043456193e94aab889909 Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Thu, 2 May 2024 00:33:05 +0200 Subject: [PATCH 2/2] fix ci --- src/tracing/config.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tracing/config.rs b/src/tracing/config.rs index 28bfeae..dc5204c 100644 --- a/src/tracing/config.rs +++ b/src/tracing/config.rs @@ -39,7 +39,14 @@ impl TracingInspectorConfig { /// Returns a config with everything is disabled. pub const fn none() -> Self { - Self::default() + Self { + record_steps: false, + record_memory_snapshots: false, + record_stack_snapshots: StackSnapshotType::None, + record_state_diff: false, + exclude_precompile_calls: false, + record_logs: false, + } } /// Returns a config for parity style traces.