Skip to content

Commit

Permalink
NDEV-2620: Move Tracer trait to neon-lib crate
Browse files Browse the repository at this point in the history
  • Loading branch information
andreisilviudragnea committed Feb 16, 2024
1 parent 875b8fe commit 550f606
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion evm_loader/lib/src/commands/emulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use solana_sdk::pubkey::Pubkey;
use crate::commands::get_config::BuildConfigSimulator;
use crate::rpc::Rpc;
use crate::syscall_stubs::setup_emulator_syscall_stubs;
use crate::tracing::tracers::Tracer;
use crate::types::{EmulateRequest, TxParams};
use crate::{
account_storage::{EmulatorAccountStorage, SolanaAccount},
errors::NeonError,
NeonResult,
};
use evm_loader::evm::tracing::Tracer;
use evm_loader::{
config::{EVM_STEPS_MIN, PAYMENT_TO_TREASURE},
evm::{ExitStatus, Machine},
Expand Down
6 changes: 5 additions & 1 deletion evm_loader/lib/src/tracing/tracers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::tracing::tracers::struct_logger::StructLogger;
use crate::tracing::TraceConfig;
use evm_loader::evm::database::Database;
use evm_loader::evm::tracing::{Event, EventListener, Tracer};
use evm_loader::evm::tracing::{Event, EventListener};
use serde_json::Value;

pub mod struct_logger;
Expand All @@ -20,6 +20,10 @@ impl EventListener for TracerTypeEnum {
}
}

pub trait Tracer: EventListener {
fn into_traces(self) -> Value;
}

impl Tracer for TracerTypeEnum {
fn into_traces(self) -> Value {
match self {
Expand Down
3 changes: 2 additions & 1 deletion evm_loader/lib/src/tracing/tracers/struct_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use serde::Serialize;
use serde_json::Value;
use web3::types::Bytes;

use crate::tracing::tracers::Tracer;
use crate::tracing::TraceConfig;
use evm_loader::evm::opcode_table::OPNAMES;
use evm_loader::evm::tracing::{Event, EventListener, Tracer};
use evm_loader::evm::tracing::{Event, EventListener};

/// `StructLoggerResult` groups all structured logs emitted by the EVM
/// while replaying a transaction in debug mode as well as transaction
Expand Down
2 changes: 1 addition & 1 deletion evm_loader/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ borsh = "0.9"
bincode = "1"
serde_bytes = "0.11.12"
serde = { version = "1.0.186", default-features = false, features = ["derive", "rc"] }
serde_json = { version = "1.0.107", features = ["preserve_order"] }
ethnum = { version = "1.4", default-features = false, features = ["serde"] }
cfg-if = { version = "1.0" }
log = { version = "0.4", default-features = false, optional = true }
Expand All @@ -64,6 +63,7 @@ features = ["is_sync"]

[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
serde_json = { version = "1.0.107", features = ["preserve_order"] }

[lib]
crate-type = ["cdylib", "lib"]
Expand Down
14 changes: 1 addition & 13 deletions evm_loader/program/src/evm/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
use super::{Context, ExitStatus};
use crate::evm::database::Database;
use ethnum::U256;
use serde_json::Value;

use super::{Context, ExitStatus};

pub struct NoopEventListener;

pub trait EventListener {
fn event(&mut self, executor_state: &impl Database, event: Event);
}

pub trait Tracer: EventListener {
fn into_traces(self) -> Value;
}

impl EventListener for NoopEventListener {
fn event(&mut self, _executor_state: &impl Database, _event: Event) {}
}

impl Tracer for NoopEventListener {
fn into_traces(self) -> Value {
Value::Null
}
}

/// Trace event
pub enum Event {
BeginVM {
Expand Down

0 comments on commit 550f606

Please sign in to comment.