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

Derive default for TracingInspector #104

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions src/tracing/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -236,9 +236,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,
Expand Down
12 changes: 2 additions & 10 deletions src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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].
Expand Down
Loading