Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sdk): payload builder AT on NodeComponents and FullNodeComponents #11529

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/exex/exex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ reth-fs-util.workspace = true
reth-metrics.workspace = true
reth-node-api.workspace = true
reth-node-core.workspace = true
reth-payload-builder.workspace = true
reth-primitives = { workspace = true, features = ["secp256k1"] }
reth-primitives-traits.workspace = true
reth-provider.workspace = true
Expand Down
7 changes: 2 additions & 5 deletions crates/exex/exex/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Debug;

use reth_node_api::{FullNodeComponents, NodeTypes, NodeTypesWithEngine};
use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_node_core::node_config::NodeConfig;
use reth_primitives::Head;
use reth_tasks::TaskExecutor;
Expand Down Expand Up @@ -81,10 +81,7 @@ impl<Node: FullNodeComponents> ExExContext<Node> {
}

/// Returns the handle to the payload builder service.
pub fn payload_builder(
&self,
) -> &reth_payload_builder::PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>
{
pub fn payload_builder(&self) -> &Node::PayloadBuilder {
self.components.payload_builder()
}

Expand Down
1 change: 0 additions & 1 deletion crates/node/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ reth-evm.workspace = true
reth-provider.workspace = true
reth-engine-primitives.workspace = true
reth-transaction-pool.workspace = true
reth-payload-builder.workspace = true
reth-payload-primitives.workspace = true
reth-tasks.workspace = true
reth-rpc-eth-api.workspace = true
Expand Down
9 changes: 5 additions & 4 deletions crates/node/api/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::marker::PhantomData;
use reth_evm::execute::BlockExecutorProvider;
use reth_network_api::FullNetwork;
use reth_node_types::{NodeTypesWithDB, NodeTypesWithEngine};
use reth_payload_builder::PayloadBuilderHandle;
use reth_payload_primitives::PayloadBuilder;
use reth_primitives::Header;
use reth_provider::FullProvider;
use reth_rpc_eth_api::EthApiTypes;
Expand Down Expand Up @@ -57,6 +57,9 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
/// Network API.
type Network: FullNetwork;

/// Builds new blocks.
type PayloadBuilder: PayloadBuilder;

/// Returns the transaction pool of the node.
fn pool(&self) -> &Self::Pool;

Expand All @@ -73,9 +76,7 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
fn network(&self) -> &Self::Network;

/// Returns the handle to the payload builder service.
fn payload_builder(
&self,
) -> &PayloadBuilderHandle<<Self::Types as NodeTypesWithEngine>::Engine>;
fn payload_builder(&self) -> &Self::PayloadBuilder;

/// Returns handle to runtime.
fn task_executor(&self) -> &TaskExecutor;
Expand Down
11 changes: 7 additions & 4 deletions crates/node/builder/src/builder/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ use std::{fmt, future::Future};

use reth_exex::ExExContext;
use reth_node_api::{
FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes, NodeTypesWithDB, NodeTypesWithEngine,
FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes, NodeTypesWithDB, PayloadBuilder,
};
use reth_node_core::{
node_config::NodeConfig,
rpc::eth::{helpers::AddDevSigners, FullEthApiServer},
};
use reth_payload_builder::PayloadBuilderHandle;
use reth_tasks::TaskExecutor;

use crate::{
Expand Down Expand Up @@ -99,11 +98,15 @@ 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 Network = C::Network;
type PayloadBuilder = C::PayloadBuilder;

fn pool(&self) -> &Self::Pool {
self.components.pool()
Expand All @@ -125,7 +128,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()
}

Expand Down
6 changes: 5 additions & 1 deletion crates/node/builder/src/components/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{future::Future, marker::PhantomData};
use reth_consensus::Consensus;
use reth_evm::execute::BlockExecutorProvider;
use reth_node_api::{EngineValidator, NodeTypesWithEngine};
use reth_payload_builder::PayloadBuilderHandle;
use reth_primitives::Header;
use reth_transaction_pool::TransactionPool;

Expand Down Expand Up @@ -421,7 +422,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>,
>;
mattsse marked this conversation as resolved.
Show resolved Hide resolved

/// Consumes the type and returns the created components.
fn build_components(
Expand Down
10 changes: 6 additions & 4 deletions crates/node/builder/src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
/// Network API.
type Network: FullNetwork;

/// Builds new blocks.
type PayloadBuilder;

/// Validator for the engine API.
type EngineValidator: EngineValidator<<T::Types as NodeTypesWithEngine>::Engine>;

Expand All @@ -74,7 +77,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;

/// Returns the engine validator.
fn engine_validator(&self) -> &Self::EngineValidator;
Expand Down Expand Up @@ -117,6 +120,7 @@ where
type Consensus = Cons;
type Network = NetworkHandle;
type EngineValidator = Val;
type PayloadBuilder = PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>;

fn pool(&self) -> &Self::Pool {
&self.transaction_pool
Expand All @@ -138,9 +142,7 @@ where
&self.network
}

fn payload_builder(
&self,
) -> &PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine> {
fn payload_builder(&self) -> &Self::PayloadBuilder {
&self.payload_builder
}

Expand Down
5 changes: 1 addition & 4 deletions crates/node/builder/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use reth_node_core::{
eth::{EthApiTypes, FullEthApiServer},
},
};
use reth_payload_builder::PayloadBuilderHandle;
use reth_provider::providers::ProviderNodeTypes;
use reth_rpc_builder::{
auth::{AuthRpcModule, AuthServerHandle},
Expand Down Expand Up @@ -285,9 +284,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()
}
}
Expand Down
Loading