mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
chore(sdk): payload builder AT on NodeComponents and FullNodeComponents (#11529)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -5,16 +5,6 @@
|
||||
//! The node builder process is essentially a state machine that transitions through various states
|
||||
//! before the node can be launched.
|
||||
|
||||
use std::{fmt, future::Future};
|
||||
|
||||
use reth_exex::ExExContext;
|
||||
use reth_node_api::{
|
||||
FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes, NodeTypesWithDB, NodeTypesWithEngine,
|
||||
};
|
||||
use reth_node_core::node_config::NodeConfig;
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_tasks::TaskExecutor;
|
||||
|
||||
use crate::{
|
||||
components::{NodeComponents, NodeComponentsBuilder},
|
||||
hooks::NodeHooks,
|
||||
@@ -22,6 +12,13 @@ use crate::{
|
||||
rpc::{RethRpcAddOns, RethRpcServerHandles, RpcContext},
|
||||
AddOns, FullNode,
|
||||
};
|
||||
use reth_exex::ExExContext;
|
||||
use reth_node_api::{
|
||||
FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes, NodeTypesWithDB, PayloadBuilder,
|
||||
};
|
||||
use reth_node_core::node_config::NodeConfig;
|
||||
use reth_tasks::TaskExecutor;
|
||||
use std::{fmt, future::Future};
|
||||
|
||||
/// A node builder that also has the configured types.
|
||||
pub struct NodeBuilderWithTypes<T: FullNodeTypes> {
|
||||
@@ -91,12 +88,16 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeTypes for NodeAdapter<T, C>
|
||||
type Provider = T::Provider;
|
||||
}
|
||||
|
||||
impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<T, C> {
|
||||
impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<T, C>
|
||||
where
|
||||
C::PayloadBuilder: PayloadBuilder,
|
||||
{
|
||||
type Pool = C::Pool;
|
||||
type Evm = C::Evm;
|
||||
type Executor = C::Executor;
|
||||
type Consensus = C::Consensus;
|
||||
type Network = C::Network;
|
||||
type PayloadBuilder = C::PayloadBuilder;
|
||||
|
||||
fn pool(&self) -> &Self::Pool {
|
||||
self.components.pool()
|
||||
@@ -118,7 +119,7 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
|
||||
self.components.network()
|
||||
}
|
||||
|
||||
fn payload_builder(&self) -> &PayloadBuilderHandle<<T::Types as NodeTypesWithEngine>::Engine> {
|
||||
fn payload_builder(&self) -> &Self::PayloadBuilder {
|
||||
self.components.payload_builder()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
//! A generic [`NodeComponentsBuilder`]
|
||||
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
use reth_consensus::Consensus;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_primitives::Header;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
|
||||
use crate::{
|
||||
components::{
|
||||
Components, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, NodeComponents,
|
||||
@@ -14,6 +7,13 @@ use crate::{
|
||||
},
|
||||
BuilderContext, ConfigureEvm, FullNodeTypes,
|
||||
};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_node_api::NodeTypesWithEngine;
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_primitives::Header;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
/// A generic, general purpose and customizable [`NodeComponentsBuilder`] implementation.
|
||||
///
|
||||
@@ -358,7 +358,10 @@ impl Default for ComponentsBuilder<(), (), (), (), (), ()> {
|
||||
/// A type that's responsible for building the components of the node.
|
||||
pub trait NodeComponentsBuilder<Node: FullNodeTypes>: Send {
|
||||
/// The components for the node with the given types
|
||||
type Components: NodeComponents<Node>;
|
||||
type Components: NodeComponents<
|
||||
Node,
|
||||
PayloadBuilder = PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
|
||||
>;
|
||||
|
||||
/// Consumes the type and returns the created components.
|
||||
fn build_components(
|
||||
|
||||
@@ -21,6 +21,7 @@ pub use network::*;
|
||||
pub use payload::*;
|
||||
pub use pool::*;
|
||||
|
||||
use crate::{ConfigureEvm, FullNodeTypes};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_network::NetworkHandle;
|
||||
@@ -30,8 +31,6 @@ use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_primitives::Header;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
|
||||
use crate::{ConfigureEvm, FullNodeTypes};
|
||||
|
||||
/// An abstraction over the components of a node, consisting of:
|
||||
/// - evm and executor
|
||||
/// - transaction pool
|
||||
@@ -53,6 +52,9 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
|
||||
/// Network API.
|
||||
type Network: FullNetwork;
|
||||
|
||||
/// Builds new blocks.
|
||||
type PayloadBuilder: Clone;
|
||||
|
||||
/// Returns the transaction pool of the node.
|
||||
fn pool(&self) -> &Self::Pool;
|
||||
|
||||
@@ -69,7 +71,7 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
|
||||
fn network(&self) -> &Self::Network;
|
||||
|
||||
/// Returns the handle to the payload builder service.
|
||||
fn payload_builder(&self) -> &PayloadBuilderHandle<<T::Types as NodeTypesWithEngine>::Engine>;
|
||||
fn payload_builder(&self) -> &Self::PayloadBuilder;
|
||||
}
|
||||
|
||||
/// All the components of the node.
|
||||
@@ -105,6 +107,7 @@ where
|
||||
type Executor = Executor;
|
||||
type Consensus = Cons;
|
||||
type Network = NetworkHandle;
|
||||
type PayloadBuilder = PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>;
|
||||
|
||||
fn pool(&self) -> &Self::Pool {
|
||||
&self.transaction_pool
|
||||
@@ -126,9 +129,7 @@ where
|
||||
&self.network
|
||||
}
|
||||
|
||||
fn payload_builder(
|
||||
&self,
|
||||
) -> &PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine> {
|
||||
fn payload_builder(&self) -> &Self::PayloadBuilder {
|
||||
&self.payload_builder
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use reth_node_core::{
|
||||
node_config::NodeConfig,
|
||||
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
|
||||
};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_payload_builder::PayloadStore;
|
||||
use reth_provider::providers::ProviderNodeTypes;
|
||||
use reth_rpc::{
|
||||
eth::{EthApiTypes, FullEthApiServer},
|
||||
@@ -294,9 +294,7 @@ where
|
||||
}
|
||||
|
||||
/// Returns the handle to the payload builder service
|
||||
pub fn payload_builder(
|
||||
&self,
|
||||
) -> &PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine> {
|
||||
pub fn payload_builder(&self) -> &Node::PayloadBuilder {
|
||||
self.node.payload_builder()
|
||||
}
|
||||
}
|
||||
@@ -402,7 +400,10 @@ where
|
||||
|
||||
impl<N, EthApi, EV> NodeAddOns<N> for RpcAddOns<N, EthApi, EV>
|
||||
where
|
||||
N: FullNodeComponents<Types: ProviderNodeTypes>,
|
||||
N: FullNodeComponents<
|
||||
Types: ProviderNodeTypes,
|
||||
PayloadBuilder: Into<PayloadStore<<N::Types as NodeTypesWithEngine>::Engine>>,
|
||||
>,
|
||||
EthApi: EthApiTypes + FullEthApiServer + AddDevSigners + Unpin + 'static,
|
||||
EV: EngineValidatorBuilder<N>,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user