Compare commits

..

1 Commits

Author SHA1 Message Date
Omar Abdulla 6d8906ebe9 Upload code when initializing the driver 2025-11-12 12:54:19 +03:00
2 changed files with 12 additions and 29 deletions
@@ -4,7 +4,7 @@ use std::{
pin::Pin, pin::Pin,
process::{Command, Stdio}, process::{Command, Stdio},
sync::{ sync::{
Arc, Mutex, Arc,
atomic::{AtomicU32, Ordering}, atomic::{AtomicU32, Ordering},
}, },
time::Duration, time::Duration,
@@ -32,7 +32,7 @@ use futures::{FutureExt, Stream, StreamExt};
use revive_common::EVMVersion; use revive_common::EVMVersion;
use revive_dt_common::fs::clear_directory; use revive_dt_common::fs::clear_directory;
use revive_dt_format::traits::ResolverApi; use revive_dt_format::traits::ResolverApi;
use serde_json::{Value, json}; use serde_json::json;
use sp_core::crypto::Ss58Codec; use sp_core::crypto::Ss58Codec;
use sp_runtime::AccountId32; use sp_runtime::AccountId32;
@@ -57,9 +57,6 @@ use crate::{
static NODE_COUNT: AtomicU32 = AtomicU32::new(0); static NODE_COUNT: AtomicU32 = AtomicU32::new(0);
/// The number of blocks that should be cached by the revive-dev-node and the eth-rpc.
const NUMBER_OF_CACHED_BLOCKS: u32 = 100_000;
/// A node implementation for Substrate based chains. Currently, this supports either substrate /// A node implementation for Substrate based chains. Currently, this supports either substrate
/// or the revive-dev-node which is done by changing the path and some of the other arguments passed /// or the revive-dev-node which is done by changing the path and some of the other arguments passed
/// to the command. /// to the command.
@@ -141,8 +138,6 @@ impl SubstrateNode {
} }
fn init(&mut self, _: Genesis) -> anyhow::Result<&mut Self> { fn init(&mut self, _: Genesis) -> anyhow::Result<&mut Self> {
static CHAINSPEC_MUTEX: Mutex<Option<Value>> = Mutex::new(None);
if !self.rpc_url.is_empty() { if !self.rpc_url.is_empty() {
return Ok(self); return Ok(self);
} }
@@ -161,22 +156,12 @@ impl SubstrateNode {
let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE); let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE);
trace!("Creating the node genesis"); trace!("Creating the node genesis");
let chainspec_json = {
let mut chainspec_mutex = CHAINSPEC_MUTEX.lock().expect("Poisoned");
match chainspec_mutex.as_ref() {
Some(chainspec_json) => chainspec_json.clone(),
None => {
let chainspec_json = Self::node_genesis( let chainspec_json = Self::node_genesis(
&self.node_binary, &self.node_binary,
&self.export_chainspec_command, &self.export_chainspec_command,
&self.wallet, &self.wallet,
) )
.context("Failed to prepare the chainspec command")?; .context("Failed to prepare the chainspec command")?;
*chainspec_mutex = Some(chainspec_json.clone());
chainspec_json
}
}
};
trace!("Writing the node genesis"); trace!("Writing the node genesis");
serde_json::to_writer_pretty( serde_json::to_writer_pretty(
@@ -227,8 +212,6 @@ impl SubstrateNode {
.arg(u32::MAX.to_string()) .arg(u32::MAX.to_string())
.arg("--pool-kbytes") .arg("--pool-kbytes")
.arg(u32::MAX.to_string()) .arg(u32::MAX.to_string())
.arg("--state-pruning")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
.env("RUST_LOG", Self::SUBSTRATE_LOG_ENV) .env("RUST_LOG", Self::SUBSTRATE_LOG_ENV)
.stdout(stdout_file) .stdout(stdout_file)
.stderr(stderr_file); .stderr(stderr_file);
@@ -269,9 +252,9 @@ impl SubstrateNode {
.arg("--rpc-max-connections") .arg("--rpc-max-connections")
.arg(u32::MAX.to_string()) .arg(u32::MAX.to_string())
.arg("--index-last-n-blocks") .arg("--index-last-n-blocks")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string()) .arg(1_000u32.to_string())
.arg("--cache-size") .arg("--cache-size")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string()) .arg(1_000u32.to_string())
.env("RUST_LOG", Self::PROXY_LOG_ENV) .env("RUST_LOG", Self::PROXY_LOG_ENV)
.stdout(stdout_file) .stdout(stdout_file)
.stderr(stderr_file); .stderr(stderr_file);
@@ -324,7 +307,7 @@ impl SubstrateNode {
.get_or_try_init(|| async move { .get_or_try_init(|| async move {
construct_concurrency_limited_provider::<Ethereum, _>( construct_concurrency_limited_provider::<Ethereum, _>(
self.rpc_url.as_str(), self.rpc_url.as_str(),
FallbackGasFiller::new(u64::MAX, 50_000_000_000, 1_000_000_000), FallbackGasFiller::new(u64::MAX, 5_000_000_000, 1_000_000_000),
ChainIdFiller::new(Some(CHAIN_ID)), ChainIdFiller::new(Some(CHAIN_ID)),
NonceFiller::new(self.nonce_manager.clone()), NonceFiller::new(self.nonce_manager.clone()),
self.wallet.clone(), self.wallet.clone(),