diff --git a/crates/node-interaction/src/lib.rs b/crates/node-interaction/src/lib.rs index bcdf308..8e17a26 100644 --- a/crates/node-interaction/src/lib.rs +++ b/crates/node-interaction/src/lib.rs @@ -1,6 +1,6 @@ //! This crate implements all node interactions. -use alloy::rpc::types::trace::geth::GethTrace; +use alloy::rpc::types::trace::geth::{DiffMode, GethTrace}; use alloy::rpc::types::{TransactionReceipt, TransactionRequest}; use tokio_runtime::TO_TOKIO; @@ -18,4 +18,7 @@ pub trait EthereumNode { /// Trace the transaction in the [TransactionReceipt] and return a [GethTrace]. fn trace_transaction(&self, transaction: TransactionReceipt) -> anyhow::Result; + + /// Returns the state diff of the transaction hash in the [TransactionReceipt]. + fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result; } diff --git a/crates/node/src/geth.rs b/crates/node/src/geth.rs index e3de017..bb94544 100644 --- a/crates/node/src/geth.rs +++ b/crates/node/src/geth.rs @@ -185,6 +185,19 @@ impl EthereumNode for Instance { .await?) })) } + + fn state_diff( + &self, + transaction: alloy::rpc::types::TransactionReceipt, + ) -> anyhow::Result { + match self + .trace_transaction(transaction)? + .try_into_pre_state_frame()? + { + PreStateFrame::Diff(diff) => Ok(diff), + _ => anyhow::bail!("expected a diff mode trace"), + } + } } impl Node for Instance { @@ -219,19 +232,6 @@ impl Node for Instance { Ok(()) } - fn state_diff( - &self, - transaction: alloy::rpc::types::TransactionReceipt, - ) -> anyhow::Result { - match self - .trace_transaction(transaction)? - .try_into_pre_state_frame()? - { - PreStateFrame::Diff(diff) => Ok(diff), - _ => anyhow::bail!("expected a diff mode trace"), - } - } - fn version(&self) -> anyhow::Result { let output = Command::new(&self.geth) .arg("--version") diff --git a/crates/node/src/kitchensink.rs b/crates/node/src/kitchensink.rs index 4f06160..b6007f4 100644 --- a/crates/node/src/kitchensink.rs +++ b/crates/node/src/kitchensink.rs @@ -279,6 +279,16 @@ impl EthereumNode for KitchensinkNode { .await?) })) } + + fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result { + match self + .trace_transaction(transaction)? + .try_into_pre_state_frame()? + { + PreStateFrame::Diff(diff) => Ok(diff), + _ => anyhow::bail!("expected a diff mode trace"), + } + } } impl Node for KitchensinkNode { @@ -317,16 +327,6 @@ impl Node for KitchensinkNode { self.init(&genesis)?.spawn_process() } - fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result { - match self - .trace_transaction(transaction)? - .try_into_pre_state_frame()? - { - PreStateFrame::Diff(diff) => Ok(diff), - _ => anyhow::bail!("expected a diff mode trace"), - } - } - fn version(&self) -> anyhow::Result { let output = Command::new(&self.substrate_binary) .arg("--version") diff --git a/crates/node/src/lib.rs b/crates/node/src/lib.rs index 690d836..a293c8a 100644 --- a/crates/node/src/lib.rs +++ b/crates/node/src/lib.rs @@ -1,6 +1,5 @@ //! This crate implements the testing nodes. -use alloy::rpc::types::{TransactionReceipt, trace::geth::DiffMode}; use revive_dt_config::Arguments; use revive_dt_node_interaction::EthereumNode; @@ -29,9 +28,6 @@ pub trait Node: EthereumNode { /// Returns the nodes connection string. fn connection_string(&self) -> String; - /// Returns the state diff of the transaction hash in the [TransactionReceipt]. - fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result; - /// Returns the node version. fn version(&self) -> anyhow::Result; }