mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: integrate NodeTypesWithDB (#10698)
Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
This commit is contained in:
@ -13,10 +13,7 @@ workspace = true
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-beacon-consensus.workspace = true
|
||||
reth-chainspec.workspace = true
|
||||
reth-consensus.workspace = true
|
||||
reth-db-api.workspace = true
|
||||
reth-engine-primitives.workspace = true
|
||||
reth-engine-tree.workspace = true
|
||||
reth-evm.workspace = true
|
||||
reth-network-p2p.workspace = true
|
||||
@ -26,6 +23,7 @@ reth-provider.workspace = true
|
||||
reth-prune.workspace = true
|
||||
reth-stages-api.workspace = true
|
||||
reth-tasks.workspace = true
|
||||
reth-node-types.workspace = true
|
||||
|
||||
# async
|
||||
futures.workspace = true
|
||||
@ -43,6 +41,7 @@ reth-evm-ethereum.workspace = true
|
||||
reth-exex-types.workspace = true
|
||||
reth-primitives.workspace = true
|
||||
reth-prune-types.workspace = true
|
||||
reth-chainspec.workspace = true
|
||||
|
||||
tokio = { workspace = true, features = ["sync"] }
|
||||
tokio-stream.workspace = true
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
use futures::{Stream, StreamExt};
|
||||
use pin_project::pin_project;
|
||||
use reth_beacon_consensus::{BeaconConsensusEngineEvent, BeaconEngineMessage};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_consensus::Consensus;
|
||||
use reth_db_api::database::Database;
|
||||
use reth_engine_primitives::EngineTypes;
|
||||
use reth_engine_tree::{
|
||||
backfill::PipelineSync,
|
||||
download::BasicBlockDownloader,
|
||||
@ -18,9 +15,13 @@ pub use reth_engine_tree::{
|
||||
};
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_network_p2p::BlockClient;
|
||||
use reth_node_types::NodeTypesWithEngine;
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_payload_validator::ExecutionPayloadValidator;
|
||||
use reth_provider::{providers::BlockchainProvider2, ProviderFactory};
|
||||
use reth_provider::{
|
||||
providers::{BlockchainProvider2, ProviderNodeTypes},
|
||||
ProviderFactory,
|
||||
};
|
||||
use reth_prune::Pruner;
|
||||
use reth_stages_api::Pipeline;
|
||||
use reth_tasks::TaskSpawner;
|
||||
@ -35,50 +36,48 @@ use std::{
|
||||
type EngineMessageStream<T> = Pin<Box<dyn Stream<Item = BeaconEngineMessage<T>> + Send + Sync>>;
|
||||
|
||||
/// Alias for chain orchestrator.
|
||||
type EngineServiceType<DB, Client, T> = ChainOrchestrator<
|
||||
type EngineServiceType<N, Client> = ChainOrchestrator<
|
||||
EngineHandler<
|
||||
EngineApiRequestHandler<EngineApiRequest<T>>,
|
||||
EngineMessageStream<T>,
|
||||
EngineApiRequestHandler<EngineApiRequest<<N as NodeTypesWithEngine>::Engine>>,
|
||||
EngineMessageStream<<N as NodeTypesWithEngine>::Engine>,
|
||||
BasicBlockDownloader<Client>,
|
||||
>,
|
||||
PipelineSync<DB>,
|
||||
PipelineSync<N>,
|
||||
>;
|
||||
|
||||
/// The type that drives the chain forward and communicates progress.
|
||||
#[pin_project]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct EngineService<DB, Client, E, T>
|
||||
pub struct EngineService<N, Client, E>
|
||||
where
|
||||
DB: Database + 'static,
|
||||
N: ProviderNodeTypes,
|
||||
Client: BlockClient + 'static,
|
||||
E: BlockExecutorProvider + 'static,
|
||||
T: EngineTypes,
|
||||
{
|
||||
orchestrator: EngineServiceType<DB, Client, T>,
|
||||
orchestrator: EngineServiceType<N, Client>,
|
||||
_marker: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<DB, Client, E, T> EngineService<DB, Client, E, T>
|
||||
impl<N, Client, E> EngineService<N, Client, E>
|
||||
where
|
||||
DB: Database + 'static,
|
||||
N: ProviderNodeTypes,
|
||||
Client: BlockClient + 'static,
|
||||
E: BlockExecutorProvider + 'static,
|
||||
T: EngineTypes + 'static,
|
||||
{
|
||||
/// Constructor for `EngineService`.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
consensus: Arc<dyn Consensus>,
|
||||
executor_factory: E,
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<N::ChainSpec>,
|
||||
client: Client,
|
||||
incoming_requests: EngineMessageStream<T>,
|
||||
pipeline: Pipeline<DB>,
|
||||
incoming_requests: EngineMessageStream<N::Engine>,
|
||||
pipeline: Pipeline<N>,
|
||||
pipeline_task_spawner: Box<dyn TaskSpawner>,
|
||||
provider: ProviderFactory<DB>,
|
||||
blockchain_db: BlockchainProvider2<DB>,
|
||||
pruner: Pruner<DB, ProviderFactory<DB>>,
|
||||
payload_builder: PayloadBuilderHandle<T>,
|
||||
provider: ProviderFactory<N>,
|
||||
blockchain_db: BlockchainProvider2<N>,
|
||||
pruner: Pruner<N::DB, ProviderFactory<N>>,
|
||||
payload_builder: PayloadBuilderHandle<N::Engine>,
|
||||
tree_config: TreeConfig,
|
||||
invalid_block_hook: Box<dyn InvalidBlockHook>,
|
||||
) -> Self {
|
||||
@ -113,17 +112,16 @@ where
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the orchestrator.
|
||||
pub fn orchestrator_mut(&mut self) -> &mut EngineServiceType<DB, Client, T> {
|
||||
pub fn orchestrator_mut(&mut self) -> &mut EngineServiceType<N, Client> {
|
||||
&mut self.orchestrator
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB, Client, E, T> Stream for EngineService<DB, Client, E, T>
|
||||
impl<N, Client, E> Stream for EngineService<N, Client, E>
|
||||
where
|
||||
DB: Database + 'static,
|
||||
N: ProviderNodeTypes,
|
||||
Client: BlockClient + 'static,
|
||||
E: BlockExecutorProvider + 'static,
|
||||
T: EngineTypes + 'static,
|
||||
{
|
||||
type Item = ChainEvent<BeaconConsensusEngineEvent>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user