Skip to content

Commit 1e14cd7

Browse files
committed
the state diff method belongs to node interactions
Signed-off-by: Cyrill Leutwiler <[email protected]>
1 parent 3b26e1e commit 1e14cd7

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

crates/node-interaction/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! This crate implements all node interactions.
22
3-
use alloy::rpc::types::trace::geth::GethTrace;
3+
use alloy::rpc::types::trace::geth::{DiffMode, GethTrace};
44
use alloy::rpc::types::{TransactionReceipt, TransactionRequest};
55
use tokio_runtime::TO_TOKIO;
66

@@ -18,4 +18,7 @@ pub trait EthereumNode {
1818

1919
/// Trace the transaction in the [TransactionReceipt] and return a [GethTrace].
2020
fn trace_transaction(&self, transaction: TransactionReceipt) -> anyhow::Result<GethTrace>;
21+
22+
/// Returns the state diff of the transaction hash in the [TransactionReceipt].
23+
fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result<DiffMode>;
2124
}

crates/node/src/geth.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ impl EthereumNode for Instance {
185185
.await?)
186186
}))
187187
}
188+
189+
fn state_diff(
190+
&self,
191+
transaction: alloy::rpc::types::TransactionReceipt,
192+
) -> anyhow::Result<DiffMode> {
193+
match self
194+
.trace_transaction(transaction)?
195+
.try_into_pre_state_frame()?
196+
{
197+
PreStateFrame::Diff(diff) => Ok(diff),
198+
_ => anyhow::bail!("expected a diff mode trace"),
199+
}
200+
}
188201
}
189202

190203
impl Node for Instance {
@@ -219,19 +232,6 @@ impl Node for Instance {
219232
Ok(())
220233
}
221234

222-
fn state_diff(
223-
&self,
224-
transaction: alloy::rpc::types::TransactionReceipt,
225-
) -> anyhow::Result<DiffMode> {
226-
match self
227-
.trace_transaction(transaction)?
228-
.try_into_pre_state_frame()?
229-
{
230-
PreStateFrame::Diff(diff) => Ok(diff),
231-
_ => anyhow::bail!("expected a diff mode trace"),
232-
}
233-
}
234-
235235
fn version(&self) -> anyhow::Result<String> {
236236
let output = Command::new(&self.geth)
237237
.arg("--version")

crates/node/src/kitchensink.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,16 @@ impl EthereumNode for KitchensinkNode {
279279
.await?)
280280
}))
281281
}
282+
283+
fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result<DiffMode> {
284+
match self
285+
.trace_transaction(transaction)?
286+
.try_into_pre_state_frame()?
287+
{
288+
PreStateFrame::Diff(diff) => Ok(diff),
289+
_ => anyhow::bail!("expected a diff mode trace"),
290+
}
291+
}
282292
}
283293

284294
impl Node for KitchensinkNode {
@@ -317,16 +327,6 @@ impl Node for KitchensinkNode {
317327
self.init(&genesis)?.spawn_process()
318328
}
319329

320-
fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result<DiffMode> {
321-
match self
322-
.trace_transaction(transaction)?
323-
.try_into_pre_state_frame()?
324-
{
325-
PreStateFrame::Diff(diff) => Ok(diff),
326-
_ => anyhow::bail!("expected a diff mode trace"),
327-
}
328-
}
329-
330330
fn version(&self) -> anyhow::Result<String> {
331331
let output = Command::new(&self.substrate_binary)
332332
.arg("--version")

crates/node/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! This crate implements the testing nodes.
22
3-
use alloy::rpc::types::{TransactionReceipt, trace::geth::DiffMode};
43
use revive_dt_config::Arguments;
54
use revive_dt_node_interaction::EthereumNode;
65

@@ -29,9 +28,6 @@ pub trait Node: EthereumNode {
2928
/// Returns the nodes connection string.
3029
fn connection_string(&self) -> String;
3130

32-
/// Returns the state diff of the transaction hash in the [TransactionReceipt].
33-
fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result<DiffMode>;
34-
3531
/// Returns the node version.
3632
fn version(&self) -> anyhow::Result<String>;
3733
}

0 commit comments

Comments
 (0)