mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-12 17:01:06 +00:00
Added fetch_add_nonce method for NodeInteraction trait. Added extra logging. (#25)
* added logging * added fetch_add_nonce method * Added nonce for legacy transaction also * Addressed PR comments
This commit is contained in:
@@ -3,13 +3,17 @@ use std::{
|
||||
io::BufRead,
|
||||
path::PathBuf,
|
||||
process::{Child, Command, Stdio},
|
||||
sync::atomic::{AtomicU32, Ordering},
|
||||
sync::{
|
||||
Mutex,
|
||||
atomic::{AtomicU32, Ordering},
|
||||
},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use alloy::{
|
||||
hex,
|
||||
network::EthereumWallet,
|
||||
primitives::{Address, map::HashMap},
|
||||
providers::{Provider, ProviderBuilder, ext::DebugApi},
|
||||
rpc::types::{
|
||||
TransactionReceipt,
|
||||
@@ -22,7 +26,8 @@ use sp_runtime::AccountId32;
|
||||
|
||||
use revive_dt_config::Arguments;
|
||||
use revive_dt_node_interaction::{
|
||||
EthereumNode, trace::trace_transaction, transaction::execute_transaction,
|
||||
EthereumNode, nonce::fetch_onchain_nonce, trace::trace_transaction,
|
||||
transaction::execute_transaction,
|
||||
};
|
||||
|
||||
use crate::Node;
|
||||
@@ -39,6 +44,7 @@ pub struct KitchensinkNode {
|
||||
base_directory: PathBuf,
|
||||
process_substrate: Option<Child>,
|
||||
process_proxy: Option<Child>,
|
||||
nonces: Mutex<HashMap<Address, u64>>,
|
||||
}
|
||||
|
||||
impl KitchensinkNode {
|
||||
@@ -289,6 +295,19 @@ impl EthereumNode for KitchensinkNode {
|
||||
_ => anyhow::bail!("expected a diff mode trace"),
|
||||
}
|
||||
}
|
||||
|
||||
fn fetch_add_nonce(&self, address: Address) -> anyhow::Result<u64> {
|
||||
let url = self.rpc_url.clone();
|
||||
let wallet = self.wallet.clone();
|
||||
|
||||
let onchain_nonce = fetch_onchain_nonce(url, wallet, address)?;
|
||||
|
||||
let mut nonces = self.nonces.lock().unwrap();
|
||||
let current = nonces.entry(address).or_insert(onchain_nonce);
|
||||
let value = *current;
|
||||
*current += 1;
|
||||
Ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for KitchensinkNode {
|
||||
@@ -306,6 +325,7 @@ impl Node for KitchensinkNode {
|
||||
base_directory,
|
||||
process_substrate: None,
|
||||
process_proxy: None,
|
||||
nonces: Mutex::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user