mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: remove consensus setup from node-core (#7793)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -6920,7 +6920,6 @@ dependencies = [
|
||||
"procfs",
|
||||
"proptest",
|
||||
"rand 0.8.5",
|
||||
"reth-auto-seal-consensus",
|
||||
"reth-beacon-consensus",
|
||||
"reth-config",
|
||||
"reth-consensus-common",
|
||||
|
||||
@ -13,9 +13,10 @@ use crate::{
|
||||
use eyre::Context;
|
||||
use futures::{future, future::Either, stream, stream_select, Future, StreamExt};
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use reth_auto_seal_consensus::{AutoSealConsensus, MiningMode};
|
||||
use reth_beacon_consensus::{
|
||||
hooks::{EngineHooks, PruneHook, StaticFileHook},
|
||||
BeaconConsensusEngine,
|
||||
BeaconConsensus, BeaconConsensusEngine,
|
||||
};
|
||||
use reth_blockchain_tree::{
|
||||
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
|
||||
@ -28,7 +29,7 @@ use reth_db::{
|
||||
DatabaseEnv,
|
||||
};
|
||||
use reth_exex::{ExExContext, ExExHandle, ExExManager, ExExManagerHandle};
|
||||
use reth_interfaces::p2p::either::EitherDownloader;
|
||||
use reth_interfaces::{consensus::Consensus, p2p::either::EitherDownloader};
|
||||
use reth_network::{NetworkBuilder, NetworkConfig, NetworkEvents, NetworkHandle};
|
||||
use reth_node_api::{
|
||||
FullNodeComponents, FullNodeComponentsAdapter, FullNodeTypes, FullNodeTypesAdapter, NodeTypes,
|
||||
@ -524,7 +525,12 @@ where
|
||||
|
||||
info!(target: "reth::cli", "\n{}", config.chain.display_hardforks());
|
||||
|
||||
let consensus = config.consensus();
|
||||
// setup the consensus instance
|
||||
let consensus: Arc<dyn Consensus> = if config.dev.dev {
|
||||
Arc::new(AutoSealConsensus::new(Arc::clone(&config.chain)))
|
||||
} else {
|
||||
Arc::new(BeaconConsensus::new(Arc::clone(&config.chain)))
|
||||
};
|
||||
|
||||
debug!(target: "reth::cli", "Spawning stages metrics listener task");
|
||||
let (sync_metrics_tx, sync_metrics_rx) = unbounded_channel();
|
||||
@ -721,7 +727,17 @@ where
|
||||
info!(target: "reth::cli", "Allocated Genesis Account: {:02}. {} ({} ETH)", idx, address.to_string(), format_ether(alloc.balance));
|
||||
}
|
||||
|
||||
let mining_mode = config.mining_mode(transaction_pool.pending_transactions_listener());
|
||||
// install auto-seal
|
||||
let pending_transactions_listener = transaction_pool.pending_transactions_listener();
|
||||
|
||||
let mining_mode = if let Some(interval) = config.dev.block_time {
|
||||
MiningMode::interval(interval)
|
||||
} else if let Some(max_transactions) = config.dev.block_max_transactions {
|
||||
MiningMode::instant(max_transactions, pending_transactions_listener)
|
||||
} else {
|
||||
info!(target: "reth::cli", "No mining mode specified, defaulting to ReadyTransaction");
|
||||
MiningMode::instant(1, pending_transactions_listener)
|
||||
};
|
||||
|
||||
let (_, client, mut task) = reth_auto_seal_consensus::AutoSealBuilder::new(
|
||||
Arc::clone(&config.chain),
|
||||
|
||||
@ -33,7 +33,6 @@ reth-evm.workspace = true
|
||||
reth-engine-primitives.workspace = true
|
||||
reth-tasks.workspace = true
|
||||
reth-consensus-common.workspace = true
|
||||
reth-auto-seal-consensus.workspace = true
|
||||
reth-beacon-consensus.workspace = true
|
||||
|
||||
# ethereum
|
||||
@ -98,7 +97,6 @@ optimism = [
|
||||
"reth-rpc-engine-api/optimism",
|
||||
"reth-provider/optimism",
|
||||
"reth-rpc-types-compat/optimism",
|
||||
"reth-auto-seal-consensus/optimism",
|
||||
"reth-consensus-common/optimism",
|
||||
"reth-beacon-consensus/optimism",
|
||||
]
|
||||
|
||||
@ -235,10 +235,7 @@ pub fn insert_genesis_header<DB: Database>(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::*;
|
||||
|
||||
use reth_db::{
|
||||
cursor::DbCursorRO,
|
||||
models::{storage_sharded_key::StorageShardedKey, ShardedKey},
|
||||
@ -246,8 +243,8 @@ mod tests {
|
||||
DatabaseEnv,
|
||||
};
|
||||
use reth_primitives::{
|
||||
Address, Chain, ChainSpec, ForkTimestamps, Genesis, GenesisAccount, IntegerList, GOERLI,
|
||||
GOERLI_GENESIS_HASH, MAINNET, MAINNET_GENESIS_HASH, SEPOLIA, SEPOLIA_GENESIS_HASH,
|
||||
Chain, ForkTimestamps, Genesis, IntegerList, GOERLI, GOERLI_GENESIS_HASH, MAINNET,
|
||||
MAINNET_GENESIS_HASH, SEPOLIA, SEPOLIA_GENESIS_HASH,
|
||||
};
|
||||
use reth_provider::test_utils::create_test_provider_factory_with_chain_spec;
|
||||
|
||||
|
||||
@ -12,15 +12,13 @@ use crate::{
|
||||
use discv5::ListenConfig;
|
||||
use metrics_exporter_prometheus::PrometheusHandle;
|
||||
use once_cell::sync::Lazy;
|
||||
use reth_auto_seal_consensus::{AutoSealConsensus, MiningMode};
|
||||
use reth_beacon_consensus::BeaconConsensus;
|
||||
use reth_config::{config::PruneConfig, Config};
|
||||
use reth_db::{database::Database, database_metrics::DatabaseMetrics};
|
||||
use reth_interfaces::{consensus::Consensus, p2p::headers::client::HeadersClient, RethResult};
|
||||
use reth_interfaces::{p2p::headers::client::HeadersClient, RethResult};
|
||||
use reth_network::{NetworkBuilder, NetworkConfig, NetworkManager};
|
||||
use reth_primitives::{
|
||||
constants::eip4844::MAINNET_KZG_TRUSTED_SETUP, kzg::KzgSettings, stage::StageId,
|
||||
BlockHashOrNumber, BlockNumber, ChainSpec, Head, SealedHeader, TxHash, B256, MAINNET,
|
||||
BlockHashOrNumber, BlockNumber, ChainSpec, Head, SealedHeader, B256, MAINNET,
|
||||
};
|
||||
use reth_provider::{
|
||||
providers::StaticFileProvider, BlockHashReader, BlockNumReader, HeaderProvider,
|
||||
@ -29,7 +27,6 @@ use reth_provider::{
|
||||
use reth_tasks::TaskExecutor;
|
||||
use secp256k1::SecretKey;
|
||||
use std::{net::SocketAddr, path::PathBuf, sync::Arc};
|
||||
use tokio::sync::mpsc::Receiver;
|
||||
use tracing::*;
|
||||
|
||||
/// The default prometheus recorder handle. We use a global static to ensure that it is only
|
||||
@ -291,18 +288,6 @@ impl NodeConfig {
|
||||
Ok(max_block)
|
||||
}
|
||||
|
||||
/// Get the [MiningMode] from the given dev args
|
||||
pub fn mining_mode(&self, pending_transactions_listener: Receiver<TxHash>) -> MiningMode {
|
||||
if let Some(interval) = self.dev.block_time {
|
||||
MiningMode::interval(interval)
|
||||
} else if let Some(max_transactions) = self.dev.block_max_transactions {
|
||||
MiningMode::instant(max_transactions, pending_transactions_listener)
|
||||
} else {
|
||||
info!(target: "reth::cli", "No mining mode specified, defaulting to ReadyTransaction");
|
||||
MiningMode::instant(1, pending_transactions_listener)
|
||||
}
|
||||
}
|
||||
|
||||
/// Create the [NetworkConfig] for the node
|
||||
pub fn network_config<C>(
|
||||
&self,
|
||||
@ -337,18 +322,6 @@ impl NodeConfig {
|
||||
Ok(builder)
|
||||
}
|
||||
|
||||
/// Returns the [Consensus] instance to use.
|
||||
///
|
||||
/// By default this will be a [BeaconConsensus] instance, but if the `--dev` flag is set, it
|
||||
/// will be an [AutoSealConsensus] instance.
|
||||
pub fn consensus(&self) -> Arc<dyn Consensus> {
|
||||
if self.dev.dev {
|
||||
Arc::new(AutoSealConsensus::new(Arc::clone(&self.chain)))
|
||||
} else {
|
||||
Arc::new(BeaconConsensus::new(Arc::clone(&self.chain)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Loads 'MAINNET_KZG_TRUSTED_SETUP'
|
||||
pub fn kzg_settings(&self) -> eyre::Result<Arc<KzgSettings>> {
|
||||
Ok(Arc::clone(&MAINNET_KZG_TRUSTED_SETUP))
|
||||
|
||||
Reference in New Issue
Block a user