mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: simplify PayloadBuilder setup (#14276)
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -3029,6 +3029,7 @@ dependencies = [
|
|||||||
"eyre",
|
"eyre",
|
||||||
"reth",
|
"reth",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
|
"reth-ethereum-payload-builder",
|
||||||
"reth-evm",
|
"reth-evm",
|
||||||
"reth-evm-ethereum",
|
"reth-evm-ethereum",
|
||||||
"reth-node-api",
|
"reth-node-api",
|
||||||
@ -7205,7 +7206,6 @@ dependencies = [
|
|||||||
"reth-node-types",
|
"reth-node-types",
|
||||||
"reth-optimism-chainspec",
|
"reth-optimism-chainspec",
|
||||||
"reth-payload-builder",
|
"reth-payload-builder",
|
||||||
"reth-payload-builder-primitives",
|
|
||||||
"reth-payload-primitives",
|
"reth-payload-primitives",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
"reth-prune",
|
"reth-prune",
|
||||||
@ -7300,7 +7300,6 @@ dependencies = [
|
|||||||
"reth-metrics",
|
"reth-metrics",
|
||||||
"reth-network-p2p",
|
"reth-network-p2p",
|
||||||
"reth-payload-builder",
|
"reth-payload-builder",
|
||||||
"reth-payload-builder-primitives",
|
|
||||||
"reth-payload-primitives",
|
"reth-payload-primitives",
|
||||||
"reth-primitives-traits",
|
"reth-primitives-traits",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
@ -7696,6 +7695,7 @@ dependencies = [
|
|||||||
"reth-consensus",
|
"reth-consensus",
|
||||||
"reth-db",
|
"reth-db",
|
||||||
"reth-db-common",
|
"reth-db-common",
|
||||||
|
"reth-ethereum-payload-builder",
|
||||||
"reth-evm",
|
"reth-evm",
|
||||||
"reth-execution-types",
|
"reth-execution-types",
|
||||||
"reth-exex",
|
"reth-exex",
|
||||||
@ -8011,6 +8011,7 @@ version = "1.1.5"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-rpc-types-engine",
|
"alloy-rpc-types-engine",
|
||||||
"eyre",
|
"eyre",
|
||||||
|
"reth-basic-payload-builder",
|
||||||
"reth-consensus",
|
"reth-consensus",
|
||||||
"reth-db-api",
|
"reth-db-api",
|
||||||
"reth-engine-primitives",
|
"reth-engine-primitives",
|
||||||
@ -8018,6 +8019,7 @@ dependencies = [
|
|||||||
"reth-network-api",
|
"reth-network-api",
|
||||||
"reth-node-core",
|
"reth-node-core",
|
||||||
"reth-node-types",
|
"reth-node-types",
|
||||||
|
"reth-payload-builder",
|
||||||
"reth-payload-builder-primitives",
|
"reth-payload-builder-primitives",
|
||||||
"reth-payload-primitives",
|
"reth-payload-primitives",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
@ -8039,6 +8041,7 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"jsonrpsee",
|
"jsonrpsee",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
"reth-basic-payload-builder",
|
||||||
"reth-chain-state",
|
"reth-chain-state",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
"reth-cli-util",
|
"reth-cli-util",
|
||||||
@ -8155,7 +8158,6 @@ dependencies = [
|
|||||||
"eyre",
|
"eyre",
|
||||||
"futures",
|
"futures",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"reth-basic-payload-builder",
|
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
"reth-consensus",
|
"reth-consensus",
|
||||||
"reth-db",
|
"reth-db",
|
||||||
@ -8171,7 +8173,6 @@ dependencies = [
|
|||||||
"reth-node-api",
|
"reth-node-api",
|
||||||
"reth-node-builder",
|
"reth-node-builder",
|
||||||
"reth-node-core",
|
"reth-node-core",
|
||||||
"reth-payload-builder",
|
|
||||||
"reth-payload-primitives",
|
"reth-payload-primitives",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
"reth-revm",
|
"reth-revm",
|
||||||
@ -8588,7 +8589,6 @@ dependencies = [
|
|||||||
"alloy-consensus",
|
"alloy-consensus",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rpc-types",
|
"alloy-rpc-types",
|
||||||
"async-trait",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"metrics",
|
"metrics",
|
||||||
"reth-chain-state",
|
"reth-chain-state",
|
||||||
@ -8608,8 +8608,6 @@ dependencies = [
|
|||||||
name = "reth-payload-builder-primitives"
|
name = "reth-payload-builder-primitives"
|
||||||
version = "1.1.5"
|
version = "1.1.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-rpc-types-engine",
|
|
||||||
"async-trait",
|
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"reth-payload-primitives",
|
"reth-payload-primitives",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|||||||
@ -60,11 +60,13 @@ where
|
|||||||
node: FullNode<Node, AddOns>,
|
node: FullNode<Node, AddOns>,
|
||||||
attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes + 'static,
|
attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes + 'static,
|
||||||
) -> eyre::Result<Self> {
|
) -> eyre::Result<Self> {
|
||||||
let builder = node.payload_builder.clone();
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
inner: node.clone(),
|
inner: node.clone(),
|
||||||
payload: PayloadTestContext::new(builder, attributes_generator).await?,
|
payload: PayloadTestContext::new(
|
||||||
|
node.payload_builder_handle.clone(),
|
||||||
|
attributes_generator,
|
||||||
|
)
|
||||||
|
.await?,
|
||||||
network: NetworkTestContext::new(node.network.clone()),
|
network: NetworkTestContext::new(node.network.clone()),
|
||||||
engine_api: EngineApiTestContext {
|
engine_api: EngineApiTestContext {
|
||||||
chain_spec: node.chain_spec(),
|
chain_spec: node.chain_spec(),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use reth_node_api::BlockBody;
|
use reth_node_api::BlockBody;
|
||||||
use reth_payload_builder::{PayloadBuilderHandle, PayloadId};
|
use reth_payload_builder::{PayloadBuilderHandle, PayloadId};
|
||||||
use reth_payload_builder_primitives::{Events, PayloadBuilder};
|
use reth_payload_builder_primitives::Events;
|
||||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadTypes};
|
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadTypes};
|
||||||
use tokio_stream::wrappers::BroadcastStream;
|
use tokio_stream::wrappers::BroadcastStream;
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,6 @@ reth-node-types.workspace = true
|
|||||||
reth-evm.workspace = true
|
reth-evm.workspace = true
|
||||||
reth-ethereum-engine-primitives.workspace = true
|
reth-ethereum-engine-primitives.workspace = true
|
||||||
reth-payload-builder.workspace = true
|
reth-payload-builder.workspace = true
|
||||||
reth-payload-builder-primitives.workspace = true
|
|
||||||
reth-payload-primitives.workspace = true
|
reth-payload-primitives.workspace = true
|
||||||
reth-provider.workspace = true
|
reth-provider.workspace = true
|
||||||
reth-prune.workspace = true
|
reth-prune.workspace = true
|
||||||
|
|||||||
@ -7,7 +7,6 @@ use eyre::OptionExt;
|
|||||||
use futures_util::{stream::Fuse, StreamExt};
|
use futures_util::{stream::Fuse, StreamExt};
|
||||||
use reth_engine_primitives::{BeaconEngineMessage, EngineTypes};
|
use reth_engine_primitives::{BeaconEngineMessage, EngineTypes};
|
||||||
use reth_payload_builder::PayloadBuilderHandle;
|
use reth_payload_builder::PayloadBuilderHandle;
|
||||||
use reth_payload_builder_primitives::PayloadBuilder;
|
|
||||||
use reth_payload_primitives::{
|
use reth_payload_primitives::{
|
||||||
BuiltPayload, EngineApiMessageVersion, PayloadAttributesBuilder, PayloadKind, PayloadTypes,
|
BuiltPayload, EngineApiMessageVersion, PayloadAttributesBuilder, PayloadKind, PayloadTypes,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -20,7 +20,6 @@ reth-engine-primitives.workspace = true
|
|||||||
reth-errors.workspace = true
|
reth-errors.workspace = true
|
||||||
reth-evm.workspace = true
|
reth-evm.workspace = true
|
||||||
reth-network-p2p.workspace = true
|
reth-network-p2p.workspace = true
|
||||||
reth-payload-builder-primitives.workspace = true
|
|
||||||
reth-payload-builder.workspace = true
|
reth-payload-builder.workspace = true
|
||||||
reth-payload-primitives.workspace = true
|
reth-payload-primitives.workspace = true
|
||||||
reth-primitives-traits.workspace = true
|
reth-primitives-traits.workspace = true
|
||||||
|
|||||||
@ -40,7 +40,6 @@ use reth_evm::{
|
|||||||
ConfigureEvm, Evm, TransactionEnv,
|
ConfigureEvm, Evm, TransactionEnv,
|
||||||
};
|
};
|
||||||
use reth_payload_builder::PayloadBuilderHandle;
|
use reth_payload_builder::PayloadBuilderHandle;
|
||||||
use reth_payload_builder_primitives::PayloadBuilder;
|
|
||||||
use reth_payload_primitives::{EngineApiMessageVersion, PayloadBuilderAttributes};
|
use reth_payload_primitives::{EngineApiMessageVersion, PayloadBuilderAttributes};
|
||||||
use reth_primitives_traits::{
|
use reth_primitives_traits::{
|
||||||
Block, GotExpected, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader,
|
Block, GotExpected, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader,
|
||||||
|
|||||||
@ -12,9 +12,7 @@ workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# reth
|
# reth
|
||||||
reth-payload-builder.workspace = true
|
|
||||||
reth-ethereum-engine-primitives.workspace = true
|
reth-ethereum-engine-primitives.workspace = true
|
||||||
reth-basic-payload-builder.workspace = true
|
|
||||||
reth-ethereum-payload-builder.workspace = true
|
reth-ethereum-payload-builder.workspace = true
|
||||||
reth-ethereum-consensus.workspace = true
|
reth-ethereum-consensus.workspace = true
|
||||||
reth-ethereum-primitives.workspace = true
|
reth-ethereum-primitives.workspace = true
|
||||||
@ -75,7 +73,6 @@ test-utils = [
|
|||||||
"reth-chainspec/test-utils",
|
"reth-chainspec/test-utils",
|
||||||
"reth-consensus/test-utils",
|
"reth-consensus/test-utils",
|
||||||
"reth-network/test-utils",
|
"reth-network/test-utils",
|
||||||
"reth-payload-builder/test-utils",
|
|
||||||
"reth-ethereum-primitives/test-utils",
|
"reth-ethereum-primitives/test-utils",
|
||||||
"reth-revm/test-utils",
|
"reth-revm/test-utils",
|
||||||
"reth-db/test-utils",
|
"reth-db/test-utils",
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
//! Payload component configuration for the Ethereum node.
|
//! Payload component configuration for the Ethereum node.
|
||||||
|
|
||||||
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
|
|
||||||
use reth_chainspec::ChainSpec;
|
use reth_chainspec::ChainSpec;
|
||||||
use reth_ethereum_engine_primitives::{
|
use reth_ethereum_engine_primitives::{
|
||||||
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
|
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
|
||||||
@ -13,8 +12,6 @@ use reth_node_api::{FullNodeTypes, NodeTypesWithEngine, PrimitivesTy, TxTy};
|
|||||||
use reth_node_builder::{
|
use reth_node_builder::{
|
||||||
components::PayloadServiceBuilder, BuilderContext, PayloadBuilderConfig, PayloadTypes,
|
components::PayloadServiceBuilder, BuilderContext, PayloadBuilderConfig, PayloadTypes,
|
||||||
};
|
};
|
||||||
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
|
||||||
use reth_provider::CanonStateSubscriptions;
|
|
||||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||||
|
|
||||||
/// A basic ethereum payload service.
|
/// A basic ethereum payload service.
|
||||||
@ -23,13 +20,16 @@ use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
|||||||
pub struct EthereumPayloadBuilder;
|
pub struct EthereumPayloadBuilder;
|
||||||
|
|
||||||
impl EthereumPayloadBuilder {
|
impl EthereumPayloadBuilder {
|
||||||
/// A helper method initializing [`PayloadBuilderService`] with the given EVM config.
|
/// A helper method initializing [`reth_ethereum_payload_builder::EthereumPayloadBuilder`] with
|
||||||
pub fn spawn<Types, Node, Evm, Pool>(
|
/// the given EVM config.
|
||||||
self,
|
pub fn build<Types, Node, Evm, Pool>(
|
||||||
|
&self,
|
||||||
evm_config: Evm,
|
evm_config: Evm,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> eyre::Result<PayloadBuilderHandle<Types::Engine>>
|
) -> eyre::Result<
|
||||||
|
reth_ethereum_payload_builder::EthereumPayloadBuilder<Pool, Node::Provider, Evm>,
|
||||||
|
>
|
||||||
where
|
where
|
||||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
|
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
|
||||||
Node: FullNodeTypes<Types = Types>,
|
Node: FullNodeTypes<Types = Types>,
|
||||||
@ -44,30 +44,12 @@ impl EthereumPayloadBuilder {
|
|||||||
>,
|
>,
|
||||||
{
|
{
|
||||||
let conf = ctx.payload_builder_config();
|
let conf = ctx.payload_builder_config();
|
||||||
let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
|
Ok(reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
|
||||||
ctx.provider().clone(),
|
ctx.provider().clone(),
|
||||||
pool,
|
pool,
|
||||||
evm_config,
|
evm_config,
|
||||||
EthereumBuilderConfig::new(conf.extra_data_bytes()).with_gas_limit(conf.gas_limit()),
|
EthereumBuilderConfig::new(conf.extra_data_bytes()).with_gas_limit(conf.gas_limit()),
|
||||||
);
|
))
|
||||||
|
|
||||||
let payload_job_config = BasicPayloadJobGeneratorConfig::default()
|
|
||||||
.interval(conf.interval())
|
|
||||||
.deadline(conf.deadline())
|
|
||||||
.max_payload_tasks(conf.max_payload_tasks());
|
|
||||||
|
|
||||||
let payload_generator = BasicPayloadJobGenerator::with_builder(
|
|
||||||
ctx.provider().clone(),
|
|
||||||
ctx.task_executor().clone(),
|
|
||||||
payload_job_config,
|
|
||||||
payload_builder,
|
|
||||||
);
|
|
||||||
let (payload_service, payload_builder) =
|
|
||||||
PayloadBuilderService::new(payload_generator, ctx.provider().canonical_state_stream());
|
|
||||||
|
|
||||||
ctx.task_executor().spawn_critical("payload builder service", Box::pin(payload_service));
|
|
||||||
|
|
||||||
Ok(payload_builder)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,11 +66,14 @@ where
|
|||||||
PayloadBuilderAttributes = EthPayloadBuilderAttributes,
|
PayloadBuilderAttributes = EthPayloadBuilderAttributes,
|
||||||
>,
|
>,
|
||||||
{
|
{
|
||||||
async fn spawn_payload_service(
|
type PayloadBuilder =
|
||||||
self,
|
reth_ethereum_payload_builder::EthereumPayloadBuilder<Pool, Node::Provider, EthEvmConfig>;
|
||||||
|
|
||||||
|
async fn build_payload_builder(
|
||||||
|
&self,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> eyre::Result<PayloadBuilderHandle<Types::Engine>> {
|
) -> eyre::Result<Self::PayloadBuilder> {
|
||||||
self.spawn(EthEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
self.build(EthEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,10 +11,10 @@ use alloy_rpc_types_eth::TransactionRequest;
|
|||||||
use alloy_signer::SignerSync;
|
use alloy_signer::SignerSync;
|
||||||
use rand::{seq::SliceRandom, Rng};
|
use rand::{seq::SliceRandom, Rng};
|
||||||
use reth_e2e_test_utils::{wallet::Wallet, NodeHelperType, TmpDB};
|
use reth_e2e_test_utils::{wallet::Wallet, NodeHelperType, TmpDB};
|
||||||
|
use reth_ethereum_engine_primitives::EthPayloadBuilderAttributes;
|
||||||
use reth_ethereum_primitives::TxType;
|
use reth_ethereum_primitives::TxType;
|
||||||
use reth_node_api::NodeTypesWithDBAdapter;
|
use reth_node_api::NodeTypesWithDBAdapter;
|
||||||
use reth_node_ethereum::EthereumNode;
|
use reth_node_ethereum::EthereumNode;
|
||||||
use reth_payload_builder::EthPayloadBuilderAttributes;
|
|
||||||
use reth_provider::FullProvider;
|
use reth_provider::FullProvider;
|
||||||
use revm::primitives::{AccessListItem, Authorization};
|
use revm::primitives::{AccessListItem, Authorization};
|
||||||
|
|
||||||
|
|||||||
@ -20,18 +20,19 @@ reth-db-common.workspace = true
|
|||||||
reth-evm = { workspace = true, features = ["test-utils"] }
|
reth-evm = { workspace = true, features = ["test-utils"] }
|
||||||
reth-execution-types.workspace = true
|
reth-execution-types.workspace = true
|
||||||
reth-exex.workspace = true
|
reth-exex.workspace = true
|
||||||
|
reth-payload-builder.workspace = true
|
||||||
reth-network.workspace = true
|
reth-network.workspace = true
|
||||||
reth-node-api.workspace = true
|
reth-node-api.workspace = true
|
||||||
reth-node-core.workspace = true
|
reth-node-core.workspace = true
|
||||||
reth-node-builder = { workspace = true, features = ["test-utils"] }
|
reth-node-builder = { workspace = true, features = ["test-utils"] }
|
||||||
reth-node-ethereum.workspace = true
|
reth-node-ethereum.workspace = true
|
||||||
reth-payload-builder.workspace = true
|
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
reth-primitives-traits.workspace = true
|
reth-primitives-traits.workspace = true
|
||||||
reth-provider = { workspace = true, features = ["test-utils"] }
|
reth-provider = { workspace = true, features = ["test-utils"] }
|
||||||
reth-tasks.workspace = true
|
reth-tasks.workspace = true
|
||||||
reth-transaction-pool = { workspace = true, features = ["test-utils"] }
|
reth-transaction-pool = { workspace = true, features = ["test-utils"] }
|
||||||
reth-trie-db.workspace = true
|
reth-trie-db.workspace = true
|
||||||
|
reth-ethereum-payload-builder.workspace = true
|
||||||
|
|
||||||
## alloy
|
## alloy
|
||||||
alloy-eips.workspace = true
|
alloy-eips.workspace = true
|
||||||
|
|||||||
@ -24,6 +24,7 @@ use reth_db::{
|
|||||||
DatabaseEnv,
|
DatabaseEnv,
|
||||||
};
|
};
|
||||||
use reth_db_common::init::init_genesis;
|
use reth_db_common::init::init_genesis;
|
||||||
|
use reth_ethereum_payload_builder::EthereumBuilderConfig;
|
||||||
use reth_evm::test_utils::MockExecutorProvider;
|
use reth_evm::test_utils::MockExecutorProvider;
|
||||||
use reth_execution_types::Chain;
|
use reth_execution_types::Chain;
|
||||||
use reth_exex::{ExExContext, ExExEvent, ExExNotification, ExExNotifications, Wal};
|
use reth_exex::{ExExContext, ExExEvent, ExExNotification, ExExNotifications, Wal};
|
||||||
@ -287,7 +288,14 @@ pub async fn test_exex_context_with_chain_spec(
|
|||||||
let task_executor = tasks.executor();
|
let task_executor = tasks.executor();
|
||||||
tasks.executor().spawn(network_manager);
|
tasks.executor().spawn(network_manager);
|
||||||
|
|
||||||
let (_, payload_builder) = NoopPayloadBuilderService::<EthEngineTypes>::new();
|
let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
|
||||||
|
provider.clone(),
|
||||||
|
transaction_pool.clone(),
|
||||||
|
evm_config.clone(),
|
||||||
|
EthereumBuilderConfig::new(Default::default()),
|
||||||
|
);
|
||||||
|
|
||||||
|
let (_, payload_builder_handle) = NoopPayloadBuilderService::<EthEngineTypes>::new();
|
||||||
|
|
||||||
let components = NodeAdapter::<FullNodeTypesAdapter<_, _, _>, _> {
|
let components = NodeAdapter::<FullNodeTypesAdapter<_, _, _>, _> {
|
||||||
components: Components {
|
components: Components {
|
||||||
@ -297,6 +305,7 @@ pub async fn test_exex_context_with_chain_spec(
|
|||||||
consensus,
|
consensus,
|
||||||
network,
|
network,
|
||||||
payload_builder,
|
payload_builder,
|
||||||
|
payload_builder_handle,
|
||||||
},
|
},
|
||||||
task_executor,
|
task_executor,
|
||||||
provider,
|
provider,
|
||||||
|
|||||||
@ -12,12 +12,14 @@ workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# reth
|
# reth
|
||||||
|
reth-basic-payload-builder.workspace = true
|
||||||
reth-db-api.workspace = true
|
reth-db-api.workspace = true
|
||||||
reth-consensus.workspace = true
|
reth-consensus.workspace = true
|
||||||
reth-evm.workspace = true
|
reth-evm.workspace = true
|
||||||
reth-provider.workspace = true
|
reth-provider.workspace = true
|
||||||
reth-engine-primitives.workspace = true
|
reth-engine-primitives.workspace = true
|
||||||
reth-transaction-pool.workspace = true
|
reth-transaction-pool.workspace = true
|
||||||
|
reth-payload-builder.workspace = true
|
||||||
reth-payload-builder-primitives.workspace = true
|
reth-payload-builder-primitives.workspace = true
|
||||||
reth-payload-primitives.workspace = true
|
reth-payload-primitives.workspace = true
|
||||||
reth-tasks.workspace = true
|
reth-tasks.workspace = true
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
//! Traits for configuring a node.
|
//! Traits for configuring a node.
|
||||||
|
|
||||||
|
use crate::PayloadTypes;
|
||||||
use alloy_rpc_types_engine::JwtSecret;
|
use alloy_rpc_types_engine::JwtSecret;
|
||||||
|
use reth_basic_payload_builder::PayloadBuilder;
|
||||||
use reth_consensus::{ConsensusError, FullConsensus};
|
use reth_consensus::{ConsensusError, FullConsensus};
|
||||||
use reth_db_api::{database_metrics::DatabaseMetrics, Database};
|
use reth_db_api::{database_metrics::DatabaseMetrics, Database};
|
||||||
use reth_engine_primitives::BeaconConsensusEngineHandle;
|
use reth_engine_primitives::BeaconConsensusEngineHandle;
|
||||||
@ -8,7 +10,7 @@ use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
|||||||
use reth_network_api::FullNetwork;
|
use reth_network_api::FullNetwork;
|
||||||
use reth_node_core::node_config::NodeConfig;
|
use reth_node_core::node_config::NodeConfig;
|
||||||
use reth_node_types::{NodeTypes, NodeTypesWithDBAdapter, NodeTypesWithEngine, TxTy};
|
use reth_node_types::{NodeTypes, NodeTypesWithDBAdapter, NodeTypesWithEngine, TxTy};
|
||||||
use reth_payload_builder_primitives::PayloadBuilder;
|
use reth_payload_builder::PayloadBuilderHandle;
|
||||||
use reth_provider::FullProvider;
|
use reth_provider::FullProvider;
|
||||||
use reth_tasks::TaskExecutor;
|
use reth_tasks::TaskExecutor;
|
||||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||||
@ -42,6 +44,23 @@ where
|
|||||||
type Provider = Provider;
|
type Provider = Provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper trait to bound [`PayloadBuilder`] to the node's engine types.
|
||||||
|
pub trait PayloadBuilderFor<N: NodeTypesWithEngine>:
|
||||||
|
PayloadBuilder<
|
||||||
|
Attributes = <N::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
||||||
|
BuiltPayload = <N::Engine as PayloadTypes>::BuiltPayload,
|
||||||
|
>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T, N: NodeTypesWithEngine> PayloadBuilderFor<N> for T where
|
||||||
|
T: PayloadBuilder<
|
||||||
|
Attributes = <N::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
||||||
|
BuiltPayload = <N::Engine as PayloadTypes>::BuiltPayload,
|
||||||
|
>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// Encapsulates all types and components of the node.
|
/// Encapsulates all types and components of the node.
|
||||||
pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
|
pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
|
||||||
/// The transaction pool of the node.
|
/// The transaction pool of the node.
|
||||||
@ -63,8 +82,7 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
|
|||||||
type Network: FullNetwork;
|
type Network: FullNetwork;
|
||||||
|
|
||||||
/// Builds new blocks.
|
/// Builds new blocks.
|
||||||
type PayloadBuilder: PayloadBuilder<PayloadType = <Self::Types as NodeTypesWithEngine>::Engine>
|
type PayloadBuilder: PayloadBuilderFor<Self::Types>;
|
||||||
+ Clone;
|
|
||||||
|
|
||||||
/// Returns the transaction pool of the node.
|
/// Returns the transaction pool of the node.
|
||||||
fn pool(&self) -> &Self::Pool;
|
fn pool(&self) -> &Self::Pool;
|
||||||
@ -81,9 +99,15 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
|
|||||||
/// Returns the handle to the network
|
/// Returns the handle to the network
|
||||||
fn network(&self) -> &Self::Network;
|
fn network(&self) -> &Self::Network;
|
||||||
|
|
||||||
/// Returns the handle to the payload builder service.
|
/// Returns the configured payload builder.
|
||||||
fn payload_builder(&self) -> &Self::PayloadBuilder;
|
fn payload_builder(&self) -> &Self::PayloadBuilder;
|
||||||
|
|
||||||
|
/// Returns the handle to the payload builder service handling payload building requests from
|
||||||
|
/// the engine.
|
||||||
|
fn payload_builder_handle(
|
||||||
|
&self,
|
||||||
|
) -> &PayloadBuilderHandle<<Self::Types as NodeTypesWithEngine>::Engine>;
|
||||||
|
|
||||||
/// Returns the provider of the node.
|
/// Returns the provider of the node.
|
||||||
fn provider(&self) -> &Self::Provider;
|
fn provider(&self) -> &Self::Provider;
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,7 @@ reth-tasks.workspace = true
|
|||||||
reth-tokio-util.workspace = true
|
reth-tokio-util.workspace = true
|
||||||
reth-tracing.workspace = true
|
reth-tracing.workspace = true
|
||||||
reth-transaction-pool.workspace = true
|
reth-transaction-pool.workspace = true
|
||||||
|
reth-basic-payload-builder.workspace = true
|
||||||
|
|
||||||
## ethereum
|
## ethereum
|
||||||
alloy-consensus.workspace = true
|
alloy-consensus.workspace = true
|
||||||
|
|||||||
@ -119,6 +119,14 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
|
|||||||
self.components.payload_builder()
|
self.components.payload_builder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn payload_builder_handle(
|
||||||
|
&self,
|
||||||
|
) -> &reth_payload_builder::PayloadBuilderHandle<
|
||||||
|
<Self::Types as reth_node_api::NodeTypesWithEngine>::Engine,
|
||||||
|
> {
|
||||||
|
self.components.payload_builder_handle()
|
||||||
|
}
|
||||||
|
|
||||||
fn provider(&self) -> &Self::Provider {
|
fn provider(&self) -> &Self::Provider {
|
||||||
&self.provider
|
&self.provider
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,11 +10,12 @@ use crate::{
|
|||||||
use reth_consensus::{ConsensusError, FullConsensus};
|
use reth_consensus::{ConsensusError, FullConsensus};
|
||||||
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
||||||
use reth_network::NetworkPrimitives;
|
use reth_network::NetworkPrimitives;
|
||||||
use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypesWithEngine, PrimitivesTy, TxTy};
|
use reth_node_api::{BlockTy, BodyTy, HeaderTy, PrimitivesTy, TxTy};
|
||||||
use reth_payload_builder::PayloadBuilderHandle;
|
|
||||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||||
use std::{future::Future, marker::PhantomData};
|
use std::{future::Future, marker::PhantomData};
|
||||||
|
|
||||||
|
use super::PayloadBuilderFor;
|
||||||
|
|
||||||
/// A generic, general purpose and customizable [`NodeComponentsBuilder`] implementation.
|
/// A generic, general purpose and customizable [`NodeComponentsBuilder`] implementation.
|
||||||
///
|
///
|
||||||
/// This type is stateful and captures the configuration of the node's components.
|
/// This type is stateful and captures the configuration of the node's components.
|
||||||
@ -324,6 +325,7 @@ where
|
|||||||
ExecB::EVM,
|
ExecB::EVM,
|
||||||
ExecB::Executor,
|
ExecB::Executor,
|
||||||
ConsB::Consensus,
|
ConsB::Consensus,
|
||||||
|
PayloadB::PayloadBuilder,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
async fn build_components(
|
async fn build_components(
|
||||||
@ -332,7 +334,7 @@ where
|
|||||||
) -> eyre::Result<Self::Components> {
|
) -> eyre::Result<Self::Components> {
|
||||||
let Self {
|
let Self {
|
||||||
pool_builder,
|
pool_builder,
|
||||||
payload_builder,
|
payload_builder: payload_builder_builder,
|
||||||
network_builder,
|
network_builder,
|
||||||
executor_builder: evm_builder,
|
executor_builder: evm_builder,
|
||||||
consensus_builder,
|
consensus_builder,
|
||||||
@ -342,7 +344,10 @@ where
|
|||||||
let (evm_config, executor) = evm_builder.build_evm(context).await?;
|
let (evm_config, executor) = evm_builder.build_evm(context).await?;
|
||||||
let pool = pool_builder.build_pool(context).await?;
|
let pool = pool_builder.build_pool(context).await?;
|
||||||
let network = network_builder.build_network(context, pool.clone()).await?;
|
let network = network_builder.build_network(context, pool.clone()).await?;
|
||||||
let payload_builder = payload_builder.spawn_payload_service(context, pool.clone()).await?;
|
let payload_builder =
|
||||||
|
payload_builder_builder.build_payload_builder(context, pool.clone()).await?;
|
||||||
|
let payload_builder_handle =
|
||||||
|
payload_builder_builder.spawn_payload_builder_service(context, payload_builder.clone());
|
||||||
let consensus = consensus_builder.build_consensus(context).await?;
|
let consensus = consensus_builder.build_consensus(context).await?;
|
||||||
|
|
||||||
Ok(Components {
|
Ok(Components {
|
||||||
@ -350,6 +355,7 @@ where
|
|||||||
evm_config,
|
evm_config,
|
||||||
network,
|
network,
|
||||||
payload_builder,
|
payload_builder,
|
||||||
|
payload_builder_handle,
|
||||||
executor,
|
executor,
|
||||||
consensus,
|
consensus,
|
||||||
})
|
})
|
||||||
@ -380,10 +386,7 @@ impl Default for ComponentsBuilder<(), (), (), (), (), ()> {
|
|||||||
/// A type that's responsible for building the components of the node.
|
/// A type that's responsible for building the components of the node.
|
||||||
pub trait NodeComponentsBuilder<Node: FullNodeTypes>: Send {
|
pub trait NodeComponentsBuilder<Node: FullNodeTypes>: Send {
|
||||||
/// The components for the node with the given types
|
/// The components for the node with the given types
|
||||||
type Components: NodeComponents<
|
type Components: NodeComponents<Node>;
|
||||||
Node,
|
|
||||||
PayloadBuilder = PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
|
|
||||||
>;
|
|
||||||
|
|
||||||
/// Consumes the type and returns the created components.
|
/// Consumes the type and returns the created components.
|
||||||
fn build_components(
|
fn build_components(
|
||||||
@ -392,7 +395,7 @@ pub trait NodeComponentsBuilder<Node: FullNodeTypes>: Send {
|
|||||||
) -> impl Future<Output = eyre::Result<Self::Components>> + Send;
|
) -> impl Future<Output = eyre::Result<Self::Components>> + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Node, N, F, Fut, Pool, EVM, Executor, Cons> NodeComponentsBuilder<Node> for F
|
impl<Node, N, F, Fut, Pool, EVM, Executor, Cons, Payload> NodeComponentsBuilder<Node> for F
|
||||||
where
|
where
|
||||||
N: NetworkPrimitives<
|
N: NetworkPrimitives<
|
||||||
BlockHeader = HeaderTy<Node::Types>,
|
BlockHeader = HeaderTy<Node::Types>,
|
||||||
@ -401,7 +404,8 @@ where
|
|||||||
>,
|
>,
|
||||||
Node: FullNodeTypes,
|
Node: FullNodeTypes,
|
||||||
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
|
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
|
||||||
Fut: Future<Output = eyre::Result<Components<Node, N, Pool, EVM, Executor, Cons>>> + Send,
|
Fut: Future<Output = eyre::Result<Components<Node, N, Pool, EVM, Executor, Cons, Payload>>>
|
||||||
|
+ Send,
|
||||||
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
||||||
+ Unpin
|
+ Unpin
|
||||||
+ 'static,
|
+ 'static,
|
||||||
@ -409,8 +413,9 @@ where
|
|||||||
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
|
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
|
||||||
Cons:
|
Cons:
|
||||||
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
|
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
|
||||||
|
Payload: PayloadBuilderFor<Node::Types> + Unpin + 'static,
|
||||||
{
|
{
|
||||||
type Components = Components<Node, N, Pool, EVM, Executor, Cons>;
|
type Components = Components<Node, N, Pool, EVM, Executor, Cons, Payload>;
|
||||||
|
|
||||||
fn build_components(
|
fn build_components(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -21,6 +21,7 @@ pub use network::*;
|
|||||||
pub use payload::*;
|
pub use payload::*;
|
||||||
pub use pool::*;
|
pub use pool::*;
|
||||||
use reth_network_p2p::BlockClient;
|
use reth_network_p2p::BlockClient;
|
||||||
|
use reth_payload_builder::PayloadBuilderHandle;
|
||||||
|
|
||||||
use crate::{ConfigureEvm, FullNodeTypes};
|
use crate::{ConfigureEvm, FullNodeTypes};
|
||||||
use reth_consensus::{ConsensusError, FullConsensus};
|
use reth_consensus::{ConsensusError, FullConsensus};
|
||||||
@ -28,9 +29,9 @@ use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
|||||||
use reth_network::{NetworkHandle, NetworkPrimitives};
|
use reth_network::{NetworkHandle, NetworkPrimitives};
|
||||||
use reth_network_api::FullNetwork;
|
use reth_network_api::FullNetwork;
|
||||||
use reth_node_api::{
|
use reth_node_api::{
|
||||||
BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, PayloadBuilder, PrimitivesTy, TxTy,
|
BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, PayloadBuilderFor, PrimitivesTy,
|
||||||
|
TxTy,
|
||||||
};
|
};
|
||||||
use reth_payload_builder::PayloadBuilderHandle;
|
|
||||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||||
|
|
||||||
/// An abstraction over the components of a node, consisting of:
|
/// An abstraction over the components of a node, consisting of:
|
||||||
@ -58,8 +59,7 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
|
|||||||
type Network: FullNetwork<Client: BlockClient<Block = BlockTy<T::Types>>>;
|
type Network: FullNetwork<Client: BlockClient<Block = BlockTy<T::Types>>>;
|
||||||
|
|
||||||
/// Builds new blocks.
|
/// Builds new blocks.
|
||||||
type PayloadBuilder: PayloadBuilder<PayloadType = <T::Types as NodeTypesWithEngine>::Engine>
|
type PayloadBuilder: PayloadBuilderFor<T::Types> + Clone + Unpin + 'static;
|
||||||
+ Clone;
|
|
||||||
|
|
||||||
/// Returns the transaction pool of the node.
|
/// Returns the transaction pool of the node.
|
||||||
fn pool(&self) -> &Self::Pool;
|
fn pool(&self) -> &Self::Pool;
|
||||||
@ -76,15 +76,29 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
|
|||||||
/// Returns the handle to the network
|
/// Returns the handle to the network
|
||||||
fn network(&self) -> &Self::Network;
|
fn network(&self) -> &Self::Network;
|
||||||
|
|
||||||
/// Returns the handle to the payload builder service.
|
/// Returns the payload builder that knows how to build blocks.
|
||||||
fn payload_builder(&self) -> &Self::PayloadBuilder;
|
fn payload_builder(&self) -> &Self::PayloadBuilder;
|
||||||
|
|
||||||
|
/// Returns the handle to the payload builder service handling payload building requests from
|
||||||
|
/// the engine.
|
||||||
|
fn payload_builder_handle(
|
||||||
|
&self,
|
||||||
|
) -> &PayloadBuilderHandle<<T::Types as NodeTypesWithEngine>::Engine>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All the components of the node.
|
/// All the components of the node.
|
||||||
///
|
///
|
||||||
/// This provides access to all the components of the node.
|
/// This provides access to all the components of the node.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Executor, Consensus> {
|
pub struct Components<
|
||||||
|
Node: FullNodeTypes,
|
||||||
|
N: NetworkPrimitives,
|
||||||
|
Pool,
|
||||||
|
EVM,
|
||||||
|
Executor,
|
||||||
|
Consensus,
|
||||||
|
Payload,
|
||||||
|
> {
|
||||||
/// The transaction pool of the node.
|
/// The transaction pool of the node.
|
||||||
pub transaction_pool: Pool,
|
pub transaction_pool: Pool,
|
||||||
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
|
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
|
||||||
@ -95,19 +109,21 @@ pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Exec
|
|||||||
pub consensus: Consensus,
|
pub consensus: Consensus,
|
||||||
/// The network implementation of the node.
|
/// The network implementation of the node.
|
||||||
pub network: NetworkHandle<N>,
|
pub network: NetworkHandle<N>,
|
||||||
|
/// The payload builder.
|
||||||
|
pub payload_builder: Payload,
|
||||||
/// The handle to the payload builder service.
|
/// The handle to the payload builder service.
|
||||||
pub payload_builder: PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
|
pub payload_builder_handle: PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Node, Pool, EVM, Executor, Cons, N> NodeComponents<Node>
|
impl<Node, Pool, EVM, Executor, Cons, N, Payload> NodeComponents<Node>
|
||||||
for Components<Node, N, Pool, EVM, Executor, Cons>
|
for Components<Node, N, Pool, EVM, Executor, Cons, Payload>
|
||||||
where
|
where
|
||||||
|
Node: FullNodeTypes,
|
||||||
N: NetworkPrimitives<
|
N: NetworkPrimitives<
|
||||||
BlockHeader = HeaderTy<Node::Types>,
|
BlockHeader = HeaderTy<Node::Types>,
|
||||||
BlockBody = BodyTy<Node::Types>,
|
BlockBody = BodyTy<Node::Types>,
|
||||||
Block = BlockTy<Node::Types>,
|
Block = BlockTy<Node::Types>,
|
||||||
>,
|
>,
|
||||||
Node: FullNodeTypes,
|
|
||||||
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
|
||||||
+ Unpin
|
+ Unpin
|
||||||
+ 'static,
|
+ 'static,
|
||||||
@ -115,13 +131,14 @@ where
|
|||||||
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
|
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
|
||||||
Cons:
|
Cons:
|
||||||
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
|
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
|
||||||
|
Payload: PayloadBuilderFor<Node::Types> + Clone + Unpin + 'static,
|
||||||
{
|
{
|
||||||
type Pool = Pool;
|
type Pool = Pool;
|
||||||
type Evm = EVM;
|
type Evm = EVM;
|
||||||
type Executor = Executor;
|
type Executor = Executor;
|
||||||
type Consensus = Cons;
|
type Consensus = Cons;
|
||||||
type Network = NetworkHandle<N>;
|
type Network = NetworkHandle<N>;
|
||||||
type PayloadBuilder = PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>;
|
type PayloadBuilder = Payload;
|
||||||
|
|
||||||
fn pool(&self) -> &Self::Pool {
|
fn pool(&self) -> &Self::Pool {
|
||||||
&self.transaction_pool
|
&self.transaction_pool
|
||||||
@ -146,16 +163,24 @@ where
|
|||||||
fn payload_builder(&self) -> &Self::PayloadBuilder {
|
fn payload_builder(&self) -> &Self::PayloadBuilder {
|
||||||
&self.payload_builder
|
&self.payload_builder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn payload_builder_handle(
|
||||||
|
&self,
|
||||||
|
) -> &PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine> {
|
||||||
|
&self.payload_builder_handle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Node, N, Pool, EVM, Executor, Cons> Clone for Components<Node, N, Pool, EVM, Executor, Cons>
|
impl<Node, N, Pool, EVM, Executor, Cons, Payload> Clone
|
||||||
|
for Components<Node, N, Pool, EVM, Executor, Cons, Payload>
|
||||||
where
|
where
|
||||||
N: NetworkPrimitives,
|
N: NetworkPrimitives,
|
||||||
Node: FullNodeTypes,
|
Node: FullNodeTypes,
|
||||||
Pool: TransactionPool,
|
Pool: TransactionPool,
|
||||||
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>,
|
EVM: ConfigureEvm,
|
||||||
Executor: BlockExecutorProvider,
|
Executor: BlockExecutorProvider,
|
||||||
Cons: Clone,
|
Cons: Clone,
|
||||||
|
Payload: Clone,
|
||||||
{
|
{
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -165,6 +190,7 @@ where
|
|||||||
consensus: self.consensus.clone(),
|
consensus: self.consensus.clone(),
|
||||||
network: self.network.clone(),
|
network: self.network.clone(),
|
||||||
payload_builder: self.payload_builder.clone(),
|
payload_builder: self.payload_builder.clone(),
|
||||||
|
payload_builder_handle: self.payload_builder_handle.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,45 +1,73 @@
|
|||||||
//! Payload service component for the node builder.
|
//! Payload service component for the node builder.
|
||||||
|
|
||||||
|
use crate::{BuilderContext, FullNodeTypes, NodeTypesWithEngine};
|
||||||
|
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
|
||||||
|
use reth_chain_state::CanonStateSubscriptions;
|
||||||
|
use reth_node_api::PayloadBuilderFor;
|
||||||
|
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
||||||
|
use reth_transaction_pool::TransactionPool;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
use reth_node_api::NodeTypesWithEngine;
|
|
||||||
use reth_payload_builder::PayloadBuilderHandle;
|
|
||||||
use reth_transaction_pool::TransactionPool;
|
|
||||||
|
|
||||||
use crate::{BuilderContext, FullNodeTypes};
|
|
||||||
|
|
||||||
/// A type that knows how to spawn the payload service.
|
/// A type that knows how to spawn the payload service.
|
||||||
pub trait PayloadServiceBuilder<Node: FullNodeTypes, Pool: TransactionPool>: Send {
|
pub trait PayloadServiceBuilder<Node: FullNodeTypes, Pool: TransactionPool>: Send + Sized {
|
||||||
|
/// Payload builder implementation.
|
||||||
|
type PayloadBuilder: PayloadBuilderFor<Node::Types> + Unpin + 'static;
|
||||||
|
|
||||||
/// Spawns the payload service and returns the handle to it.
|
/// Spawns the payload service and returns the handle to it.
|
||||||
///
|
///
|
||||||
/// The [`BuilderContext`] is provided to allow access to the node's configuration.
|
/// The [`BuilderContext`] is provided to allow access to the node's configuration.
|
||||||
fn spawn_payload_service(
|
fn build_payload_builder(
|
||||||
self,
|
&self,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> impl Future<
|
) -> impl Future<Output = eyre::Result<Self::PayloadBuilder>> + Send;
|
||||||
Output = eyre::Result<PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>>,
|
|
||||||
> + Send;
|
/// Spawns the [`PayloadBuilderService`] and returns the handle to it for use by the engine.
|
||||||
|
///
|
||||||
|
/// We provide default implementation via [`BasicPayloadJobGenerator`] but it can be overridden
|
||||||
|
/// for custom job orchestration logic,
|
||||||
|
fn spawn_payload_builder_service(
|
||||||
|
self,
|
||||||
|
ctx: &BuilderContext<Node>,
|
||||||
|
payload_builder: Self::PayloadBuilder,
|
||||||
|
) -> PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine> {
|
||||||
|
let conf = ctx.config().builder.clone();
|
||||||
|
|
||||||
|
let payload_job_config = BasicPayloadJobGeneratorConfig::default()
|
||||||
|
.interval(conf.interval)
|
||||||
|
.deadline(conf.deadline)
|
||||||
|
.max_payload_tasks(conf.max_payload_tasks);
|
||||||
|
|
||||||
|
let payload_generator = BasicPayloadJobGenerator::with_builder(
|
||||||
|
ctx.provider().clone(),
|
||||||
|
ctx.task_executor().clone(),
|
||||||
|
payload_job_config,
|
||||||
|
payload_builder,
|
||||||
|
);
|
||||||
|
let (payload_service, payload_service_handle) =
|
||||||
|
PayloadBuilderService::new(payload_generator, ctx.provider().canonical_state_stream());
|
||||||
|
|
||||||
|
ctx.task_executor().spawn_critical("payload builder service", Box::pin(payload_service));
|
||||||
|
|
||||||
|
payload_service_handle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Node, F, Fut, Pool> PayloadServiceBuilder<Node, Pool> for F
|
impl<Node, F, Fut, Pool, Builder> PayloadServiceBuilder<Node, Pool> for F
|
||||||
where
|
where
|
||||||
Node: FullNodeTypes,
|
Node: FullNodeTypes,
|
||||||
Pool: TransactionPool,
|
Pool: TransactionPool,
|
||||||
F: Fn(&BuilderContext<Node>, Pool) -> Fut + Send,
|
F: Fn(&BuilderContext<Node>, Pool) -> Fut + Send,
|
||||||
Fut: Future<
|
Fut: Future<Output = eyre::Result<Builder>> + Send,
|
||||||
Output = eyre::Result<
|
Builder: PayloadBuilderFor<Node::Types> + Unpin + 'static,
|
||||||
PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
|
|
||||||
>,
|
|
||||||
> + Send,
|
|
||||||
{
|
{
|
||||||
fn spawn_payload_service(
|
type PayloadBuilder = Builder;
|
||||||
self,
|
|
||||||
|
fn build_payload_builder(
|
||||||
|
&self,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> impl Future<
|
) -> impl Future<Output = eyre::Result<Self::PayloadBuilder>> + Send {
|
||||||
Output = eyre::Result<PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>>,
|
|
||||||
> + Send {
|
|
||||||
self(ctx, pool)
|
self(ctx, pool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ use reth_network::{NetworkSyncUpdater, SyncState};
|
|||||||
use reth_network_api::BlockDownloaderProvider;
|
use reth_network_api::BlockDownloaderProvider;
|
||||||
use reth_node_api::{
|
use reth_node_api::{
|
||||||
BeaconConsensusEngineHandle, BuiltPayload, FullNodeTypes, NodeTypesWithDBAdapter,
|
BeaconConsensusEngineHandle, BuiltPayload, FullNodeTypes, NodeTypesWithDBAdapter,
|
||||||
NodeTypesWithEngine, PayloadAttributesBuilder, PayloadBuilder, PayloadTypes,
|
NodeTypesWithEngine, PayloadAttributesBuilder, PayloadTypes,
|
||||||
};
|
};
|
||||||
use reth_node_core::{
|
use reth_node_core::{
|
||||||
dirs::{ChainPath, DataDirPath},
|
dirs::{ChainPath, DataDirPath},
|
||||||
@ -218,7 +218,7 @@ where
|
|||||||
ctx.provider_factory().clone(),
|
ctx.provider_factory().clone(),
|
||||||
ctx.blockchain_db().clone(),
|
ctx.blockchain_db().clone(),
|
||||||
pruner,
|
pruner,
|
||||||
ctx.components().payload_builder().clone(),
|
ctx.components().payload_builder_handle().clone(),
|
||||||
engine_payload_validator,
|
engine_payload_validator,
|
||||||
engine_tree_config,
|
engine_tree_config,
|
||||||
ctx.invalid_block_hook()?,
|
ctx.invalid_block_hook()?,
|
||||||
@ -243,7 +243,7 @@ where
|
|||||||
ctx.provider_factory().clone(),
|
ctx.provider_factory().clone(),
|
||||||
ctx.blockchain_db().clone(),
|
ctx.blockchain_db().clone(),
|
||||||
pruner,
|
pruner,
|
||||||
ctx.components().payload_builder().clone(),
|
ctx.components().payload_builder_handle().clone(),
|
||||||
engine_payload_validator,
|
engine_payload_validator,
|
||||||
engine_tree_config,
|
engine_tree_config,
|
||||||
ctx.invalid_block_hook()?,
|
ctx.invalid_block_hook()?,
|
||||||
@ -317,7 +317,7 @@ where
|
|||||||
let network_handle = ctx.components().network().clone();
|
let network_handle = ctx.components().network().clone();
|
||||||
let mut built_payloads = ctx
|
let mut built_payloads = ctx
|
||||||
.components()
|
.components()
|
||||||
.payload_builder()
|
.payload_builder_handle()
|
||||||
.subscribe()
|
.subscribe()
|
||||||
.await
|
.await
|
||||||
.map_err(|e| eyre::eyre!("Failed to subscribe to payload builder events: {:?}", e))?
|
.map_err(|e| eyre::eyre!("Failed to subscribe to payload builder events: {:?}", e))?
|
||||||
@ -399,6 +399,7 @@ where
|
|||||||
network: ctx.components().network().clone(),
|
network: ctx.components().network().clone(),
|
||||||
provider: ctx.node_adapter().provider.clone(),
|
provider: ctx.node_adapter().provider.clone(),
|
||||||
payload_builder: ctx.components().payload_builder().clone(),
|
payload_builder: ctx.components().payload_builder().clone(),
|
||||||
|
payload_builder_handle: ctx.components().payload_builder_handle().clone(),
|
||||||
task_executor: ctx.task_executor().clone(),
|
task_executor: ctx.task_executor().clone(),
|
||||||
config: ctx.node_config().clone(),
|
config: ctx.node_config().clone(),
|
||||||
data_dir: ctx.data_dir().clone(),
|
data_dir: ctx.data_dir().clone(),
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
// re-export the node api types
|
// re-export the node api types
|
||||||
pub use reth_node_api::{FullNodeTypes, NodeTypes, NodeTypesWithEngine};
|
pub use reth_node_api::{FullNodeTypes, NodeTypes, NodeTypesWithEngine};
|
||||||
|
use reth_payload_builder::PayloadBuilderHandle;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
@ -12,7 +13,6 @@ use reth_node_core::{
|
|||||||
dirs::{ChainPath, DataDirPath},
|
dirs::{ChainPath, DataDirPath},
|
||||||
node_config::NodeConfig,
|
node_config::NodeConfig,
|
||||||
};
|
};
|
||||||
use reth_payload_builder::PayloadBuilderHandle;
|
|
||||||
use reth_provider::ChainSpecProvider;
|
use reth_provider::ChainSpecProvider;
|
||||||
use reth_rpc_api::EngineApiClient;
|
use reth_rpc_api::EngineApiClient;
|
||||||
use reth_rpc_builder::{auth::AuthServerHandle, RpcServerHandle};
|
use reth_rpc_builder::{auth::AuthServerHandle, RpcServerHandle};
|
||||||
@ -117,8 +117,10 @@ pub struct FullNode<Node: FullNodeComponents, AddOns: NodeAddOns<Node>> {
|
|||||||
pub network: Node::Network,
|
pub network: Node::Network,
|
||||||
/// Provider to interact with the node's database
|
/// Provider to interact with the node's database
|
||||||
pub provider: Node::Provider,
|
pub provider: Node::Provider,
|
||||||
|
/// Node's configured payload builder.
|
||||||
|
pub payload_builder: Node::PayloadBuilder,
|
||||||
/// Handle to the node's payload builder service.
|
/// Handle to the node's payload builder service.
|
||||||
pub payload_builder: PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
|
pub payload_builder_handle: PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
|
||||||
/// Task executor for the node.
|
/// Task executor for the node.
|
||||||
pub task_executor: TaskExecutor,
|
pub task_executor: TaskExecutor,
|
||||||
/// The initial node config.
|
/// The initial node config.
|
||||||
@ -138,6 +140,7 @@ impl<Node: FullNodeComponents, AddOns: NodeAddOns<Node>> Clone for FullNode<Node
|
|||||||
network: self.network.clone(),
|
network: self.network.clone(),
|
||||||
provider: self.provider.clone(),
|
provider: self.provider.clone(),
|
||||||
payload_builder: self.payload_builder.clone(),
|
payload_builder: self.payload_builder.clone(),
|
||||||
|
payload_builder_handle: self.payload_builder_handle.clone(),
|
||||||
task_executor: self.task_executor.clone(),
|
task_executor: self.task_executor.clone(),
|
||||||
config: self.config.clone(),
|
config: self.config.clone(),
|
||||||
data_dir: self.data_dir.clone(),
|
data_dir: self.data_dir.clone(),
|
||||||
|
|||||||
@ -437,7 +437,7 @@ where
|
|||||||
node.provider().clone(),
|
node.provider().clone(),
|
||||||
config.chain.clone(),
|
config.chain.clone(),
|
||||||
beacon_engine_handle,
|
beacon_engine_handle,
|
||||||
PayloadStore::new(node.payload_builder().clone()),
|
PayloadStore::new(node.payload_builder_handle().clone()),
|
||||||
node.pool().clone(),
|
node.pool().clone(),
|
||||||
Box::new(node.task_executor().clone()),
|
Box::new(node.task_executor().clone()),
|
||||||
client,
|
client,
|
||||||
|
|||||||
@ -7,7 +7,6 @@ use crate::{
|
|||||||
OpEngineTypes,
|
OpEngineTypes,
|
||||||
};
|
};
|
||||||
use op_alloy_consensus::OpPooledTransaction;
|
use op_alloy_consensus::OpPooledTransaction;
|
||||||
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
|
|
||||||
use reth_chainspec::{EthChainSpec, Hardforks};
|
use reth_chainspec::{EthChainSpec, Hardforks};
|
||||||
use reth_evm::{
|
use reth_evm::{
|
||||||
execute::BasicBlockExecutorProvider, ConfigureEvm, ConfigureEvmEnv, ConfigureEvmFor,
|
execute::BasicBlockExecutorProvider, ConfigureEvm, ConfigureEvmEnv, ConfigureEvmFor,
|
||||||
@ -23,7 +22,7 @@ use reth_node_builder::{
|
|||||||
},
|
},
|
||||||
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
|
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
|
||||||
rpc::{EngineValidatorAddOn, EngineValidatorBuilder, RethRpcAddOns, RpcAddOns, RpcHandle},
|
rpc::{EngineValidatorAddOn, EngineValidatorBuilder, RethRpcAddOns, RpcAddOns, RpcHandle},
|
||||||
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig,
|
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder,
|
||||||
};
|
};
|
||||||
use reth_optimism_chainspec::OpChainSpec;
|
use reth_optimism_chainspec::OpChainSpec;
|
||||||
use reth_optimism_consensus::OpBeaconConsensus;
|
use reth_optimism_consensus::OpBeaconConsensus;
|
||||||
@ -39,7 +38,6 @@ use reth_optimism_rpc::{
|
|||||||
witness::{DebugExecutionWitnessApiServer, OpDebugWitnessApi},
|
witness::{DebugExecutionWitnessApiServer, OpDebugWitnessApi},
|
||||||
OpEthApi, OpEthApiError, SequencerClient,
|
OpEthApi, OpEthApiError, SequencerClient,
|
||||||
};
|
};
|
||||||
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
|
||||||
use reth_provider::{CanonStateSubscriptions, EthStorage};
|
use reth_provider::{CanonStateSubscriptions, EthStorage};
|
||||||
use reth_rpc_eth_types::error::FromEvmError;
|
use reth_rpc_eth_types::error::FromEvmError;
|
||||||
use reth_rpc_server_types::RethRpcModule;
|
use reth_rpc_server_types::RethRpcModule;
|
||||||
@ -485,13 +483,23 @@ impl<Txs> OpPayloadBuilder<Txs> {
|
|||||||
OpPayloadBuilder { compute_pending_block, best_transactions, da_config }
|
OpPayloadBuilder { compute_pending_block, best_transactions, da_config }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A helper method to initialize [`PayloadBuilderService`] with the given EVM config.
|
/// A helper method to initialize [`reth_optimism_payload_builder::OpPayloadBuilder`] with the
|
||||||
pub fn spawn<Node, Evm, Pool>(
|
/// given EVM config.
|
||||||
self,
|
#[expect(clippy::type_complexity)]
|
||||||
|
pub fn build<Node, Evm, Pool>(
|
||||||
|
&self,
|
||||||
evm_config: Evm,
|
evm_config: Evm,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> eyre::Result<PayloadBuilderHandle<OpEngineTypes>>
|
) -> eyre::Result<
|
||||||
|
reth_optimism_payload_builder::OpPayloadBuilder<
|
||||||
|
Pool,
|
||||||
|
Node::Provider,
|
||||||
|
Evm,
|
||||||
|
PrimitivesTy<Node::Types>,
|
||||||
|
Txs,
|
||||||
|
>,
|
||||||
|
>
|
||||||
where
|
where
|
||||||
Node: FullNodeTypes<
|
Node: FullNodeTypes<
|
||||||
Types: NodeTypesWithEngine<
|
Types: NodeTypesWithEngine<
|
||||||
@ -511,28 +519,10 @@ impl<Txs> OpPayloadBuilder<Txs> {
|
|||||||
ctx.provider().clone(),
|
ctx.provider().clone(),
|
||||||
evm_config,
|
evm_config,
|
||||||
BasicOpReceiptBuilder::default(),
|
BasicOpReceiptBuilder::default(),
|
||||||
OpBuilderConfig { da_config: self.da_config },
|
OpBuilderConfig { da_config: self.da_config.clone() },
|
||||||
)
|
)
|
||||||
.with_transactions(self.best_transactions)
|
.with_transactions(self.best_transactions.clone())
|
||||||
.set_compute_pending_block(self.compute_pending_block);
|
.set_compute_pending_block(self.compute_pending_block);
|
||||||
let conf = ctx.payload_builder_config();
|
|
||||||
|
|
||||||
let payload_job_config = BasicPayloadJobGeneratorConfig::default()
|
|
||||||
.interval(conf.interval())
|
|
||||||
.deadline(conf.deadline())
|
|
||||||
.max_payload_tasks(conf.max_payload_tasks());
|
|
||||||
|
|
||||||
let payload_generator = BasicPayloadJobGenerator::with_builder(
|
|
||||||
ctx.provider().clone(),
|
|
||||||
ctx.task_executor().clone(),
|
|
||||||
payload_job_config,
|
|
||||||
payload_builder,
|
|
||||||
);
|
|
||||||
let (payload_service, payload_builder) =
|
|
||||||
PayloadBuilderService::new(payload_generator, ctx.provider().canonical_state_stream());
|
|
||||||
|
|
||||||
ctx.task_executor().spawn_critical("payload builder service", Box::pin(payload_service));
|
|
||||||
|
|
||||||
Ok(payload_builder)
|
Ok(payload_builder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,12 +541,20 @@ where
|
|||||||
+ 'static,
|
+ 'static,
|
||||||
Txs: OpPayloadTransactions<Pool::Transaction>,
|
Txs: OpPayloadTransactions<Pool::Transaction>,
|
||||||
{
|
{
|
||||||
async fn spawn_payload_service(
|
type PayloadBuilder = reth_optimism_payload_builder::OpPayloadBuilder<
|
||||||
self,
|
Pool,
|
||||||
|
Node::Provider,
|
||||||
|
OpEvmConfig,
|
||||||
|
PrimitivesTy<Node::Types>,
|
||||||
|
Txs,
|
||||||
|
>;
|
||||||
|
|
||||||
|
async fn build_payload_builder(
|
||||||
|
&self,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> eyre::Result<PayloadBuilderHandle<OpEngineTypes>> {
|
) -> eyre::Result<Self::PayloadBuilder> {
|
||||||
self.spawn(OpEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
self.build(OpEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,11 +15,7 @@ workspace = true
|
|||||||
# reth
|
# reth
|
||||||
reth-payload-primitives.workspace = true
|
reth-payload-primitives.workspace = true
|
||||||
|
|
||||||
# alloy
|
|
||||||
alloy-rpc-types-engine = { workspace = true, features = ["serde"] }
|
|
||||||
|
|
||||||
# async
|
# async
|
||||||
async-trait.workspace = true
|
|
||||||
pin-project.workspace = true
|
pin-project.workspace = true
|
||||||
tokio = { workspace = true, features = ["sync"] }
|
tokio = { workspace = true, features = ["sync"] }
|
||||||
tokio-stream.workspace = true
|
tokio-stream.workspace = true
|
||||||
|
|||||||
@ -11,8 +11,4 @@
|
|||||||
mod events;
|
mod events;
|
||||||
pub use crate::events::{Events, PayloadEvents};
|
pub use crate::events::{Events, PayloadEvents};
|
||||||
|
|
||||||
/// Contains the payload builder trait to abstract over payload attributes.
|
|
||||||
mod traits;
|
|
||||||
pub use traits::{PayloadBuilder, PayloadStoreExt};
|
|
||||||
|
|
||||||
pub use reth_payload_primitives::PayloadBuilderError;
|
pub use reth_payload_primitives::PayloadBuilderError;
|
||||||
|
|||||||
@ -1,111 +0,0 @@
|
|||||||
use crate::{PayloadBuilderError, PayloadEvents};
|
|
||||||
use alloy_rpc_types_engine::PayloadId;
|
|
||||||
use reth_payload_primitives::{PayloadKind, PayloadTypes};
|
|
||||||
use std::fmt::Debug;
|
|
||||||
use tokio::sync::oneshot;
|
|
||||||
|
|
||||||
/// A helper trait for internal usage to retrieve and resolve payloads.
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
pub trait PayloadStoreExt<T: PayloadTypes>: Debug + Send + Sync + Unpin {
|
|
||||||
/// Resolves the payload job and returns the best payload that has been built so far.
|
|
||||||
async fn resolve_kind(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
kind: PayloadKind,
|
|
||||||
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>>;
|
|
||||||
|
|
||||||
/// Resolves the payload job as fast and possible and returns the best payload that has been
|
|
||||||
/// built so far.
|
|
||||||
async fn resolve(&self, id: PayloadId) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
|
|
||||||
self.resolve_kind(id, PayloadKind::Earliest).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the best payload for the given identifier.
|
|
||||||
async fn best_payload(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>>;
|
|
||||||
|
|
||||||
/// Returns the payload attributes associated with the given identifier.
|
|
||||||
async fn payload_attributes(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
) -> Option<Result<T::PayloadBuilderAttributes, PayloadBuilderError>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl<T: PayloadTypes, P> PayloadStoreExt<T> for P
|
|
||||||
where
|
|
||||||
P: PayloadBuilder<PayloadType = T>,
|
|
||||||
{
|
|
||||||
async fn resolve_kind(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
kind: PayloadKind,
|
|
||||||
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
|
|
||||||
Some(PayloadBuilder::resolve_kind(self, id, kind).await?.map_err(Into::into))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn best_payload(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
|
|
||||||
Some(PayloadBuilder::best_payload(self, id).await?.map_err(Into::into))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn payload_attributes(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
) -> Option<Result<T::PayloadBuilderAttributes, PayloadBuilderError>> {
|
|
||||||
Some(PayloadBuilder::payload_attributes(self, id).await?.map_err(Into::into))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A type that can request, subscribe to and resolve payloads.
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
pub trait PayloadBuilder: Debug + Send + Sync + Unpin {
|
|
||||||
/// The Payload type for the builder.
|
|
||||||
type PayloadType: PayloadTypes;
|
|
||||||
/// The error type returned by the builder.
|
|
||||||
type Error: Into<PayloadBuilderError>;
|
|
||||||
|
|
||||||
/// Sends a message to the service to start building a new payload for the given payload.
|
|
||||||
///
|
|
||||||
/// Returns a receiver that will receive the payload id.
|
|
||||||
fn send_new_payload(
|
|
||||||
&self,
|
|
||||||
attr: <Self::PayloadType as PayloadTypes>::PayloadBuilderAttributes,
|
|
||||||
) -> oneshot::Receiver<Result<PayloadId, Self::Error>>;
|
|
||||||
|
|
||||||
/// Returns the best payload for the given identifier.
|
|
||||||
async fn best_payload(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>>;
|
|
||||||
|
|
||||||
/// Resolves the payload job and returns the best payload that has been built so far.
|
|
||||||
async fn resolve_kind(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
kind: PayloadKind,
|
|
||||||
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>>;
|
|
||||||
|
|
||||||
/// Resolves the payload job as fast and possible and returns the best payload that has been
|
|
||||||
/// built so far.
|
|
||||||
async fn resolve(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>> {
|
|
||||||
self.resolve_kind(id, PayloadKind::Earliest).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sends a message to the service to subscribe to payload events.
|
|
||||||
/// Returns a receiver that will receive them.
|
|
||||||
async fn subscribe(&self) -> Result<PayloadEvents<Self::PayloadType>, Self::Error>;
|
|
||||||
|
|
||||||
/// Returns the payload attributes associated with the given identifier.
|
|
||||||
async fn payload_attributes(
|
|
||||||
&self,
|
|
||||||
id: PayloadId,
|
|
||||||
) -> Option<Result<<Self::PayloadType as PayloadTypes>::PayloadBuilderAttributes, Self::Error>>;
|
|
||||||
}
|
|
||||||
@ -26,7 +26,6 @@ alloy-primitives = { workspace = true, optional = true }
|
|||||||
alloy-rpc-types = { workspace = true, features = ["engine"] }
|
alloy-rpc-types = { workspace = true, features = ["engine"] }
|
||||||
|
|
||||||
# async
|
# async
|
||||||
async-trait.workspace = true
|
|
||||||
tokio = { workspace = true, features = ["sync"] }
|
tokio = { workspace = true, features = ["sync"] }
|
||||||
tokio-stream.workspace = true
|
tokio-stream.workspace = true
|
||||||
futures-util.workspace = true
|
futures-util.workspace = true
|
||||||
|
|||||||
@ -11,9 +11,7 @@ use alloy_consensus::BlockHeader;
|
|||||||
use alloy_rpc_types::engine::PayloadId;
|
use alloy_rpc_types::engine::PayloadId;
|
||||||
use futures_util::{future::FutureExt, Stream, StreamExt};
|
use futures_util::{future::FutureExt, Stream, StreamExt};
|
||||||
use reth_chain_state::CanonStateNotification;
|
use reth_chain_state::CanonStateNotification;
|
||||||
use reth_payload_builder_primitives::{
|
use reth_payload_builder_primitives::{Events, PayloadBuilderError, PayloadEvents};
|
||||||
Events, PayloadBuilder, PayloadBuilderError, PayloadEvents, PayloadStoreExt,
|
|
||||||
};
|
|
||||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind, PayloadTypes};
|
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind, PayloadTypes};
|
||||||
use reth_primitives_traits::NodePrimitives;
|
use reth_primitives_traits::NodePrimitives;
|
||||||
use std::{
|
use std::{
|
||||||
@ -38,7 +36,7 @@ type PayloadFuture<P> = Pin<Box<dyn Future<Output = Result<P, PayloadBuilderErro
|
|||||||
/// API).
|
/// API).
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PayloadStore<T: PayloadTypes> {
|
pub struct PayloadStore<T: PayloadTypes> {
|
||||||
inner: Arc<dyn PayloadStoreExt<T>>,
|
inner: Arc<PayloadBuilderHandle<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> PayloadStore<T>
|
impl<T> PayloadStore<T>
|
||||||
@ -91,10 +89,7 @@ where
|
|||||||
T: PayloadTypes,
|
T: PayloadTypes,
|
||||||
{
|
{
|
||||||
/// Create a new instance
|
/// Create a new instance
|
||||||
pub fn new<P>(inner: P) -> Self
|
pub fn new(inner: PayloadBuilderHandle<T>) -> Self {
|
||||||
where
|
|
||||||
P: PayloadStoreExt<T> + 'static,
|
|
||||||
{
|
|
||||||
Self { inner: Arc::new(inner) }
|
Self { inner: Arc::new(inner) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,36 +112,40 @@ pub struct PayloadBuilderHandle<T: PayloadTypes> {
|
|||||||
to_service: mpsc::UnboundedSender<PayloadServiceCommand<T>>,
|
to_service: mpsc::UnboundedSender<PayloadServiceCommand<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// === impl PayloadBuilderHandle ===
|
impl<T: PayloadTypes> PayloadBuilderHandle<T> {
|
||||||
|
/// Creates a new payload builder handle for the given channel.
|
||||||
|
///
|
||||||
|
/// Note: this is only used internally by the [`PayloadBuilderService`] to manage the payload
|
||||||
|
/// building flow See [`PayloadBuilderService::poll`] for implementation details.
|
||||||
|
pub const fn new(to_service: mpsc::UnboundedSender<PayloadServiceCommand<T>>) -> Self {
|
||||||
|
Self { to_service }
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
/// Sends a message to the service to start building a new payload for the given payload.
|
||||||
impl<T> PayloadBuilder for PayloadBuilderHandle<T>
|
///
|
||||||
where
|
/// Returns a receiver that will receive the payload id.
|
||||||
T: PayloadTypes,
|
pub fn send_new_payload(
|
||||||
{
|
|
||||||
type PayloadType = T;
|
|
||||||
type Error = PayloadBuilderError;
|
|
||||||
|
|
||||||
fn send_new_payload(
|
|
||||||
&self,
|
&self,
|
||||||
attr: <Self::PayloadType as PayloadTypes>::PayloadBuilderAttributes,
|
attr: T::PayloadBuilderAttributes,
|
||||||
) -> Receiver<Result<PayloadId, Self::Error>> {
|
) -> Receiver<Result<PayloadId, PayloadBuilderError>> {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
let _ = self.to_service.send(PayloadServiceCommand::BuildNewPayload(attr, tx));
|
let _ = self.to_service.send(PayloadServiceCommand::BuildNewPayload(attr, tx));
|
||||||
rx
|
rx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the best payload for the given identifier.
|
||||||
/// Note: this does not resolve the job if it's still in progress.
|
/// Note: this does not resolve the job if it's still in progress.
|
||||||
async fn best_payload(
|
pub async fn best_payload(
|
||||||
&self,
|
&self,
|
||||||
id: PayloadId,
|
id: PayloadId,
|
||||||
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>> {
|
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
self.to_service.send(PayloadServiceCommand::BestPayload(id, tx)).ok()?;
|
self.to_service.send(PayloadServiceCommand::BestPayload(id, tx)).ok()?;
|
||||||
rx.await.ok()?
|
rx.await.ok()?
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn resolve_kind(
|
/// Resolves the payload job and returns the best payload that has been built so far.
|
||||||
|
pub async fn resolve_kind(
|
||||||
&self,
|
&self,
|
||||||
id: PayloadId,
|
id: PayloadId,
|
||||||
kind: PayloadKind,
|
kind: PayloadKind,
|
||||||
@ -159,7 +158,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn subscribe(&self) -> Result<PayloadEvents<Self::PayloadType>, Self::Error> {
|
/// Sends a message to the service to subscribe to payload events.
|
||||||
|
/// Returns a receiver that will receive them.
|
||||||
|
pub async fn subscribe(&self) -> Result<PayloadEvents<T>, PayloadBuilderError> {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
let _ = self.to_service.send(PayloadServiceCommand::Subscribe(tx));
|
let _ = self.to_service.send(PayloadServiceCommand::Subscribe(tx));
|
||||||
Ok(PayloadEvents { receiver: rx.await? })
|
Ok(PayloadEvents { receiver: rx.await? })
|
||||||
@ -168,7 +169,7 @@ where
|
|||||||
/// Returns the payload attributes associated with the given identifier.
|
/// Returns the payload attributes associated with the given identifier.
|
||||||
///
|
///
|
||||||
/// Note: this returns the attributes of the payload and does not resolve the job.
|
/// Note: this returns the attributes of the payload and does not resolve the job.
|
||||||
async fn payload_attributes(
|
pub async fn payload_attributes(
|
||||||
&self,
|
&self,
|
||||||
id: PayloadId,
|
id: PayloadId,
|
||||||
) -> Option<Result<T::PayloadBuilderAttributes, PayloadBuilderError>> {
|
) -> Option<Result<T::PayloadBuilderAttributes, PayloadBuilderError>> {
|
||||||
@ -178,19 +179,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> PayloadBuilderHandle<T>
|
|
||||||
where
|
|
||||||
T: PayloadTypes,
|
|
||||||
{
|
|
||||||
/// Creates a new payload builder handle for the given channel.
|
|
||||||
///
|
|
||||||
/// Note: this is only used internally by the [`PayloadBuilderService`] to manage the payload
|
|
||||||
/// building flow See [`PayloadBuilderService::poll`] for implementation details.
|
|
||||||
pub const fn new(to_service: mpsc::UnboundedSender<PayloadServiceCommand<T>>) -> Self {
|
|
||||||
Self { to_service }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Clone for PayloadBuilderHandle<T>
|
impl<T> Clone for PayloadBuilderHandle<T>
|
||||||
where
|
where
|
||||||
T: PayloadTypes,
|
T: PayloadTypes,
|
||||||
|
|||||||
@ -34,12 +34,11 @@ use reth::{
|
|||||||
node::{NodeTypes, NodeTypesWithEngine},
|
node::{NodeTypes, NodeTypesWithEngine},
|
||||||
rpc::{EngineValidatorBuilder, RpcAddOns},
|
rpc::{EngineValidatorBuilder, RpcAddOns},
|
||||||
BuilderContext, FullNodeTypes, Node, NodeAdapter, NodeBuilder, NodeComponentsBuilder,
|
BuilderContext, FullNodeTypes, Node, NodeAdapter, NodeBuilder, NodeComponentsBuilder,
|
||||||
PayloadBuilderConfig,
|
|
||||||
},
|
},
|
||||||
network::NetworkHandle,
|
network::NetworkHandle,
|
||||||
payload::ExecutionPayloadValidator,
|
payload::ExecutionPayloadValidator,
|
||||||
primitives::{Block, EthPrimitives, SealedBlock, TransactionSigned},
|
primitives::{Block, EthPrimitives, SealedBlock, TransactionSigned},
|
||||||
providers::{CanonStateSubscriptions, EthStorage, StateProviderFactory},
|
providers::{EthStorage, StateProviderFactory},
|
||||||
rpc::{
|
rpc::{
|
||||||
eth::EthApi,
|
eth::EthApi,
|
||||||
types::engine::{ExecutionPayload, PayloadError},
|
types::engine::{ExecutionPayload, PayloadError},
|
||||||
@ -48,10 +47,7 @@ use reth::{
|
|||||||
transaction_pool::{PoolTransaction, TransactionPool},
|
transaction_pool::{PoolTransaction, TransactionPool},
|
||||||
version::default_extra_data_bytes,
|
version::default_extra_data_bytes,
|
||||||
};
|
};
|
||||||
use reth_basic_payload_builder::{
|
use reth_basic_payload_builder::{BuildArguments, BuildOutcome, PayloadBuilder, PayloadConfig};
|
||||||
BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig, BuildArguments, BuildOutcome,
|
|
||||||
PayloadBuilder, PayloadConfig,
|
|
||||||
};
|
|
||||||
use reth_chainspec::{Chain, ChainSpec, ChainSpecProvider};
|
use reth_chainspec::{Chain, ChainSpec, ChainSpecProvider};
|
||||||
use reth_engine_local::payload::UnsupportedLocalAttributes;
|
use reth_engine_local::payload::UnsupportedLocalAttributes;
|
||||||
use reth_ethereum_payload_builder::EthereumBuilderConfig;
|
use reth_ethereum_payload_builder::EthereumBuilderConfig;
|
||||||
@ -68,10 +64,7 @@ use reth_node_ethereum::{
|
|||||||
},
|
},
|
||||||
EthEvmConfig,
|
EthEvmConfig,
|
||||||
};
|
};
|
||||||
use reth_payload_builder::{
|
use reth_payload_builder::{EthBuiltPayload, EthPayloadBuilderAttributes, PayloadBuilderError};
|
||||||
EthBuiltPayload, EthPayloadBuilderAttributes, PayloadBuilderError, PayloadBuilderHandle,
|
|
||||||
PayloadBuilderService,
|
|
||||||
};
|
|
||||||
use reth_tracing::{RethTracer, Tracer};
|
use reth_tracing::{RethTracer, Tracer};
|
||||||
use reth_trie_db::MerklePatriciaTrie;
|
use reth_trie_db::MerklePatriciaTrie;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -367,11 +360,13 @@ where
|
|||||||
+ Unpin
|
+ Unpin
|
||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
async fn spawn_payload_service(
|
type PayloadBuilder = CustomPayloadBuilder<Pool, Node::Provider>;
|
||||||
self,
|
|
||||||
|
async fn build_payload_builder(
|
||||||
|
&self,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> eyre::Result<PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>> {
|
) -> eyre::Result<Self::PayloadBuilder> {
|
||||||
let payload_builder = CustomPayloadBuilder {
|
let payload_builder = CustomPayloadBuilder {
|
||||||
inner: reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
|
inner: reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
|
||||||
ctx.provider().clone(),
|
ctx.provider().clone(),
|
||||||
@ -380,24 +375,6 @@ where
|
|||||||
EthereumBuilderConfig::new(default_extra_data_bytes()),
|
EthereumBuilderConfig::new(default_extra_data_bytes()),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
let conf = ctx.payload_builder_config();
|
|
||||||
|
|
||||||
let payload_job_config = BasicPayloadJobGeneratorConfig::default()
|
|
||||||
.interval(conf.interval())
|
|
||||||
.deadline(conf.deadline())
|
|
||||||
.max_payload_tasks(conf.max_payload_tasks());
|
|
||||||
|
|
||||||
let payload_generator = BasicPayloadJobGenerator::with_builder(
|
|
||||||
ctx.provider().clone(),
|
|
||||||
ctx.task_executor().clone(),
|
|
||||||
payload_job_config,
|
|
||||||
payload_builder,
|
|
||||||
);
|
|
||||||
let (payload_service, payload_builder) =
|
|
||||||
PayloadBuilderService::new(payload_generator, ctx.provider().canonical_state_stream());
|
|
||||||
|
|
||||||
ctx.task_executor().spawn_critical("payload builder service", Box::pin(payload_service));
|
|
||||||
|
|
||||||
Ok(payload_builder)
|
Ok(payload_builder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ reth-evm-ethereum.workspace = true
|
|||||||
reth-node-api.workspace = true
|
reth-node-api.workspace = true
|
||||||
reth-node-core.workspace = true
|
reth-node-core.workspace = true
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
|
reth-ethereum-payload-builder.workspace = true
|
||||||
reth-node-ethereum = { workspace = true, features = ["test-utils"] }
|
reth-node-ethereum = { workspace = true, features = ["test-utils"] }
|
||||||
reth-tracing.workspace = true
|
reth-tracing.workspace = true
|
||||||
reth-evm.workspace = true
|
reth-evm.workspace = true
|
||||||
|
|||||||
@ -204,12 +204,15 @@ where
|
|||||||
PayloadBuilderAttributes = EthPayloadBuilderAttributes,
|
PayloadBuilderAttributes = EthPayloadBuilderAttributes,
|
||||||
>,
|
>,
|
||||||
{
|
{
|
||||||
async fn spawn_payload_service(
|
type PayloadBuilder =
|
||||||
self,
|
reth_ethereum_payload_builder::EthereumPayloadBuilder<Pool, Node::Provider, MyEvmConfig>;
|
||||||
|
|
||||||
|
async fn build_payload_builder(
|
||||||
|
&self,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> eyre::Result<reth::payload::PayloadBuilderHandle<Types::Engine>> {
|
) -> eyre::Result<Self::PayloadBuilder> {
|
||||||
self.inner.spawn(MyEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
self.inner.build(MyEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|||||||
@ -11,20 +11,15 @@
|
|||||||
|
|
||||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||||
|
|
||||||
use generator::EmptyBlockPayloadJobGenerator;
|
|
||||||
use reth::{
|
use reth::{
|
||||||
builder::{components::PayloadServiceBuilder, node::FullNodeTypes, BuilderContext},
|
builder::{components::PayloadServiceBuilder, node::FullNodeTypes, BuilderContext},
|
||||||
cli::{config::PayloadBuilderConfig, Cli},
|
cli::{config::PayloadBuilderConfig, Cli},
|
||||||
payload::PayloadBuilderHandle,
|
|
||||||
providers::CanonStateSubscriptions,
|
|
||||||
transaction_pool::{PoolTransaction, TransactionPool},
|
transaction_pool::{PoolTransaction, TransactionPool},
|
||||||
};
|
};
|
||||||
use reth_basic_payload_builder::BasicPayloadJobGeneratorConfig;
|
|
||||||
use reth_chainspec::ChainSpec;
|
use reth_chainspec::ChainSpec;
|
||||||
use reth_ethereum_payload_builder::EthereumBuilderConfig;
|
use reth_ethereum_payload_builder::{EthereumBuilderConfig, EthereumPayloadBuilder};
|
||||||
use reth_node_api::NodeTypesWithEngine;
|
use reth_node_api::NodeTypesWithEngine;
|
||||||
use reth_node_ethereum::{node::EthereumAddOns, EthEngineTypes, EthEvmConfig, EthereumNode};
|
use reth_node_ethereum::{node::EthereumAddOns, EthEngineTypes, EthEvmConfig, EthereumNode};
|
||||||
use reth_payload_builder::PayloadBuilderService;
|
|
||||||
use reth_primitives::{EthPrimitives, TransactionSigned};
|
use reth_primitives::{EthPrimitives, TransactionSigned};
|
||||||
|
|
||||||
pub mod generator;
|
pub mod generator;
|
||||||
@ -47,38 +42,22 @@ where
|
|||||||
+ Unpin
|
+ Unpin
|
||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
async fn spawn_payload_service(
|
type PayloadBuilder = EthereumPayloadBuilder<Pool, Node::Provider, EthEvmConfig>;
|
||||||
self,
|
|
||||||
|
async fn build_payload_builder(
|
||||||
|
&self,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> eyre::Result<PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>> {
|
) -> eyre::Result<Self::PayloadBuilder> {
|
||||||
tracing::info!("Spawning a custom payload builder");
|
tracing::info!("Spawning a custom payload builder");
|
||||||
let conf = ctx.payload_builder_config();
|
let conf = ctx.payload_builder_config();
|
||||||
|
|
||||||
let payload_job_config = BasicPayloadJobGeneratorConfig::default()
|
Ok(reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
|
||||||
.interval(conf.interval())
|
|
||||||
.deadline(conf.deadline())
|
|
||||||
.max_payload_tasks(conf.max_payload_tasks());
|
|
||||||
|
|
||||||
let payload_generator = EmptyBlockPayloadJobGenerator::with_builder(
|
|
||||||
ctx.provider().clone(),
|
ctx.provider().clone(),
|
||||||
ctx.task_executor().clone(),
|
pool,
|
||||||
payload_job_config,
|
EthEvmConfig::new(ctx.chain_spec()),
|
||||||
reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
|
EthereumBuilderConfig::new(conf.extra_data_bytes()),
|
||||||
ctx.provider().clone(),
|
))
|
||||||
pool,
|
|
||||||
EthEvmConfig::new(ctx.chain_spec()),
|
|
||||||
EthereumBuilderConfig::new(conf.extra_data_bytes()),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let (payload_service, payload_builder) =
|
|
||||||
PayloadBuilderService::new(payload_generator, ctx.provider().canonical_state_stream());
|
|
||||||
|
|
||||||
ctx.task_executor()
|
|
||||||
.spawn_critical("custom payload builder service", Box::pin(payload_service));
|
|
||||||
|
|
||||||
Ok(payload_builder)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user