mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Put ChainsSpecs in Arc<> (#3075)
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
@ -19,7 +19,7 @@ pub fn parse_duration_from_secs(arg: &str) -> eyre::Result<Duration, std::num::P
|
||||
/// Clap value parser for [ChainSpec]s that takes either a built-in chainspec or the path
|
||||
/// to a custom one.
|
||||
pub fn chain_spec_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Error> {
|
||||
Ok(Arc::new(match s {
|
||||
Ok(match s {
|
||||
"mainnet" => MAINNET.clone(),
|
||||
"goerli" => GOERLI.clone(),
|
||||
"sepolia" => SEPOLIA.clone(),
|
||||
@ -27,22 +27,25 @@ pub fn chain_spec_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Er
|
||||
let raw = std::fs::read_to_string(PathBuf::from(shellexpand::full(s)?.into_owned()))?;
|
||||
serde_json::from_str(&raw)?
|
||||
}
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
/// Clap value parser for [ChainSpec]s that takes either a built-in genesis format or the path
|
||||
/// to a custom one.
|
||||
pub fn genesis_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Error> {
|
||||
Ok(Arc::new(match s {
|
||||
Ok(match s {
|
||||
"mainnet" => MAINNET.clone(),
|
||||
"goerli" => GOERLI.clone(),
|
||||
"sepolia" => SEPOLIA.clone(),
|
||||
_ => {
|
||||
let raw = std::fs::read_to_string(PathBuf::from(shellexpand::full(s)?.into_owned()))?;
|
||||
let genesis: AllGenesisFormats = serde_json::from_str(&raw)?;
|
||||
genesis.into()
|
||||
match genesis {
|
||||
AllGenesisFormats::Reth(chain_spec) => Arc::new(chain_spec),
|
||||
_ => return Err(eyre::eyre!("Unexpected genesis format")),
|
||||
}
|
||||
}
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
/// Parse [BlockHashOrNumber]
|
||||
|
||||
@ -7,7 +7,7 @@ use reth_db::{
|
||||
use reth_primitives::{stage::StageCheckpoint, MAINNET};
|
||||
use reth_provider::Transaction;
|
||||
use reth_stages::{stages::ExecutionStage, Stage, UnwindInput};
|
||||
use std::{ops::DerefMut, path::PathBuf, sync::Arc};
|
||||
use std::{ops::DerefMut, path::PathBuf};
|
||||
use tracing::info;
|
||||
|
||||
pub(crate) async fn dump_execution_stage<DB: Database>(
|
||||
@ -95,8 +95,7 @@ async fn unwind_and_copy<DB: Database>(
|
||||
) -> eyre::Result<()> {
|
||||
let mut unwind_tx = Transaction::new(db_tool.db)?;
|
||||
|
||||
let mut exec_stage =
|
||||
ExecutionStage::new_with_factory(reth_revm::Factory::new(Arc::new(MAINNET.clone())));
|
||||
let mut exec_stage = ExecutionStage::new_with_factory(reth_revm::Factory::new(MAINNET.clone()));
|
||||
|
||||
exec_stage
|
||||
.unwind(
|
||||
@ -129,8 +128,7 @@ async fn dry_run(
|
||||
info!(target: "reth::cli", "Executing stage. [dry-run]");
|
||||
|
||||
let mut tx = Transaction::new(&output_db)?;
|
||||
let mut exec_stage =
|
||||
ExecutionStage::new_with_factory(reth_revm::Factory::new(Arc::new(MAINNET.clone())));
|
||||
let mut exec_stage = ExecutionStage::new_with_factory(reth_revm::Factory::new(MAINNET.clone()));
|
||||
|
||||
exec_stage
|
||||
.execute(
|
||||
|
||||
@ -11,7 +11,7 @@ use reth_stages::{
|
||||
},
|
||||
Stage, UnwindInput,
|
||||
};
|
||||
use std::{ops::DerefMut, path::PathBuf, sync::Arc};
|
||||
use std::{ops::DerefMut, path::PathBuf};
|
||||
use tracing::info;
|
||||
|
||||
pub(crate) async fn dump_merkle_stage<DB: Database>(
|
||||
@ -65,7 +65,7 @@ async fn unwind_and_copy<DB: Database>(
|
||||
|
||||
// Bring Plainstate to TO (hashing stage execution requires it)
|
||||
let mut exec_stage = ExecutionStage::new(
|
||||
reth_revm::Factory::new(Arc::new(MAINNET.clone())),
|
||||
reth_revm::Factory::new(MAINNET.clone()),
|
||||
ExecutionStageThresholds { max_blocks: Some(u64::MAX), max_changes: None },
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user