Skip to content

Commit

Permalink
migrate builder
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jan 10, 2025
1 parent 12f2f39 commit 4588326
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 830 deletions.
9 changes: 7 additions & 2 deletions crates/node/builder/src/components/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
use reth_consensus::{ConsensusError, FullConsensus};
use reth_evm::execute::BlockExecutorProvider;
use reth_network::NetworkPrimitives;
use reth_node_api::{BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy};
use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy};
use reth_payload_builder::PayloadBuilderHandle;
use reth_transaction_pool::{PoolTransaction, TransactionPool};
use std::{future::Future, marker::PhantomData};
Expand Down Expand Up @@ -310,6 +310,7 @@ where
Primitives: NetworkPrimitives<
BlockHeader = HeaderTy<Node::Types>,
BlockBody = BodyTy<Node::Types>,
Block = BlockTy<Node::Types>,
>,
>,
PayloadB: PayloadServiceBuilder<Node, PoolB::Pool>,
Expand Down Expand Up @@ -393,7 +394,11 @@ pub trait NodeComponentsBuilder<Node: FullNodeTypes>: Send {

impl<Node, N, F, Fut, Pool, EVM, Executor, Cons> NodeComponentsBuilder<Node> for F
where
N: NetworkPrimitives<BlockHeader = HeaderTy<Node::Types>, BlockBody = BodyTy<Node::Types>>,
N: NetworkPrimitives<
BlockHeader = HeaderTy<Node::Types>,
BlockBody = BodyTy<Node::Types>,
Block = BlockTy<Node::Types>,
>,
Node: FullNodeTypes,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<Components<Node, N, Pool, EVM, Executor, Cons>>> + Send,
Expand Down
14 changes: 9 additions & 5 deletions crates/node/builder/src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use reth_consensus::{ConsensusError, FullConsensus};
use reth_evm::execute::BlockExecutorProvider;
use reth_network::{NetworkHandle, NetworkPrimitives};
use reth_network_api::FullNetwork;
use reth_node_api::{BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, PayloadBuilder, TxTy};
use reth_node_api::{
BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, PayloadBuilder, TxTy,
};
use reth_payload_builder::PayloadBuilderHandle;
use reth_transaction_pool::{PoolTransaction, TransactionPool};

Expand All @@ -53,9 +55,7 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
+ 'static;

/// Network API.
type Network: FullNetwork<
Client: BlockClient<Header = HeaderTy<T::Types>, Body = BodyTy<T::Types>>,
>;
type Network: FullNetwork<Client: BlockClient<Block = BlockTy<T::Types>>>;

/// Builds new blocks.
type PayloadBuilder: PayloadBuilder<PayloadType = <T::Types as NodeTypesWithEngine>::Engine>
Expand Down Expand Up @@ -102,7 +102,11 @@ pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Exec
impl<Node, Pool, EVM, Executor, Cons, N> NodeComponents<Node>
for Components<Node, N, Pool, EVM, Executor, Cons>
where
N: NetworkPrimitives<BlockHeader = HeaderTy<Node::Types>, BlockBody = BodyTy<Node::Types>>,
N: NetworkPrimitives<
BlockHeader = HeaderTy<Node::Types>,
BlockBody = BodyTy<Node::Types>,
Block = BlockTy<Node::Types>,
>,
Node: FullNodeTypes,
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin
Expand Down
11 changes: 6 additions & 5 deletions crates/node/builder/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::sync::Arc;

use crate::BlockTy;
use alloy_primitives::{BlockNumber, B256};
use reth_config::{config::StageConfig, PruneConfig};
use reth_consensus::{Consensus, ConsensusError};
Expand All @@ -14,7 +15,7 @@ use reth_exex::ExExManagerHandle;
use reth_network_p2p::{
bodies::downloader::BodyDownloader, headers::downloader::HeaderDownloader, BlockClient,
};
use reth_node_api::{BodyTy, HeaderTy};
use reth_node_api::HeaderTy;
use reth_provider::{providers::ProviderNodeTypes, ProviderFactory};
use reth_stages::{prelude::DefaultStages, stages::ExecutionStage, Pipeline, StageSet};
use reth_static_file::StaticFileProducer;
Expand All @@ -27,7 +28,7 @@ use tokio::sync::watch;
pub fn build_networked_pipeline<N, Client, Executor>(
config: &StageConfig,
client: Client,
consensus: Arc<dyn Consensus<Client::Header, Client::Body, Error = ConsensusError>>,
consensus: Arc<dyn Consensus<BlockTy<N>, Error = ConsensusError>>,
provider_factory: ProviderFactory<N>,
task_executor: &TaskExecutor,
metrics_tx: reth_stages::MetricEventsSender,
Expand All @@ -39,7 +40,7 @@ pub fn build_networked_pipeline<N, Client, Executor>(
) -> eyre::Result<Pipeline<N>>
where
N: ProviderNodeTypes,
Client: BlockClient<Header = HeaderTy<N>, Body = BodyTy<N>> + 'static,
Client: BlockClient<Block = BlockTy<N>> + 'static,
Executor: BlockExecutorProvider<Primitives = N::Primitives>,
{
// building network downloaders using the fetch client
Expand Down Expand Up @@ -75,7 +76,7 @@ pub fn build_pipeline<N, H, B, Executor>(
stage_config: &StageConfig,
header_downloader: H,
body_downloader: B,
consensus: Arc<dyn Consensus<H::Header, B::Body, Error = ConsensusError>>,
consensus: Arc<dyn Consensus<BlockTy<N>, Error = ConsensusError>>,
max_block: Option<u64>,
metrics_tx: reth_stages::MetricEventsSender,
prune_config: Option<PruneConfig>,
Expand All @@ -86,7 +87,7 @@ pub fn build_pipeline<N, H, B, Executor>(
where
N: ProviderNodeTypes,
H: HeaderDownloader<Header = HeaderTy<N>> + 'static,
B: BodyDownloader<Header = HeaderTy<N>, Body = BodyTy<N>> + 'static,
B: BodyDownloader<Block = BlockTy<N>> + 'static,
Executor: BlockExecutorProvider<Primitives = N::Primitives>,
{
let mut builder = Pipeline::<N>::builder();
Expand Down
Loading

0 comments on commit 4588326

Please sign in to comment.