mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor: engine interceptors (#8048)
This commit is contained in:
@ -47,6 +47,7 @@ tokio = { workspace = true, features = [
|
||||
"time",
|
||||
"rt-multi-thread",
|
||||
] }
|
||||
tokio-stream.workspace = true
|
||||
|
||||
## misc
|
||||
aquamarine.workspace = true
|
||||
|
||||
@ -14,7 +14,8 @@ use reth_beacon_consensus::{
|
||||
BeaconConsensus, BeaconConsensusEngine,
|
||||
};
|
||||
use reth_blockchain_tree::{
|
||||
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
|
||||
noop::NoopBlockchainTree, BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree,
|
||||
TreeExternals,
|
||||
};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_exex::{ExExContext, ExExHandle, ExExManager, ExExManagerHandle};
|
||||
@ -23,8 +24,7 @@ use reth_network::NetworkEvents;
|
||||
use reth_node_api::{FullNodeComponents, FullNodeTypes};
|
||||
use reth_node_core::{
|
||||
dirs::{ChainPath, DataDirPath},
|
||||
engine_api_store::EngineApiStore,
|
||||
engine_skip_fcu::EngineApiSkipFcu,
|
||||
engine::EngineMessageStreamExt,
|
||||
exit::NodeExitFuture,
|
||||
};
|
||||
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
|
||||
@ -37,10 +37,10 @@ use reth_tracing::tracing::{debug, info};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use std::{future::Future, sync::Arc};
|
||||
use tokio::sync::{mpsc::unbounded_channel, oneshot};
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
|
||||
pub mod common;
|
||||
pub use common::LaunchContext;
|
||||
use reth_blockchain_tree::noop::NoopBlockchainTree;
|
||||
|
||||
/// A general purpose trait that launches a new node of any kind.
|
||||
///
|
||||
@ -261,29 +261,15 @@ where
|
||||
|
||||
// create pipeline
|
||||
let network_client = node_adapter.network().fetch_client().await?;
|
||||
let (consensus_engine_tx, mut consensus_engine_rx) = unbounded_channel();
|
||||
let (consensus_engine_tx, consensus_engine_rx) = unbounded_channel();
|
||||
|
||||
if let Some(skip_fcu_threshold) = ctx.node_config().debug.skip_fcu {
|
||||
debug!(target: "reth::cli", "spawning skip FCU task");
|
||||
let (skip_fcu_tx, skip_fcu_rx) = unbounded_channel();
|
||||
let engine_skip_fcu = EngineApiSkipFcu::new(skip_fcu_threshold);
|
||||
ctx.task_executor().spawn_critical(
|
||||
"skip FCU interceptor",
|
||||
engine_skip_fcu.intercept(consensus_engine_rx, skip_fcu_tx),
|
||||
);
|
||||
consensus_engine_rx = skip_fcu_rx;
|
||||
}
|
||||
|
||||
if let Some(store_path) = ctx.node_config().debug.engine_api_store.clone() {
|
||||
debug!(target: "reth::cli", "spawning engine API store");
|
||||
let (engine_intercept_tx, engine_intercept_rx) = unbounded_channel();
|
||||
let engine_api_store = EngineApiStore::new(store_path);
|
||||
ctx.task_executor().spawn_critical(
|
||||
"engine api interceptor",
|
||||
engine_api_store.intercept(consensus_engine_rx, engine_intercept_tx),
|
||||
);
|
||||
consensus_engine_rx = engine_intercept_rx;
|
||||
};
|
||||
let node_config = ctx.node_config();
|
||||
let consensus_engine_stream = UnboundedReceiverStream::from(consensus_engine_rx)
|
||||
.maybe_skip_fcu(node_config.debug.skip_fcu)
|
||||
// Store messages _after_ skipping messages so that `replay-engine` command
|
||||
// would replay the exact same messages that were observed by the engine
|
||||
// during this run.
|
||||
.maybe_store_messages(node_config.debug.engine_api_store.clone());
|
||||
|
||||
let max_block = ctx.max_block(network_client.clone()).await?;
|
||||
let mut hooks = EngineHooks::new();
|
||||
@ -303,8 +289,7 @@ where
|
||||
info!(target: "reth::cli", "Starting Reth in dev mode");
|
||||
|
||||
for (idx, (address, alloc)) in ctx.chain_spec().genesis.alloc.iter().enumerate() {
|
||||
info!(target: "reth::cli", "Allocated Genesis Account: {:02}. {} ({} ETH)", idx,
|
||||
address.to_string(), format_ether(alloc.balance));
|
||||
info!(target: "reth::cli", "Allocated Genesis Account: {:02}. {} ({} ETH)", idx, address.to_string(), format_ether(alloc.balance));
|
||||
}
|
||||
|
||||
// install auto-seal
|
||||
@ -395,7 +380,7 @@ address.to_string(), format_ether(alloc.balance));
|
||||
initial_target,
|
||||
reth_beacon_consensus::MIN_BLOCKS_FOR_PIPELINE_RUN,
|
||||
consensus_engine_tx,
|
||||
consensus_engine_rx,
|
||||
Box::pin(consensus_engine_stream),
|
||||
hooks,
|
||||
)?;
|
||||
info!(target: "reth::cli", "Consensus engine initialized");
|
||||
|
||||
Reference in New Issue
Block a user