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,9 +12,7 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-payload-builder.workspace = true
|
||||
reth-ethereum-engine-primitives.workspace = true
|
||||
reth-basic-payload-builder.workspace = true
|
||||
reth-ethereum-payload-builder.workspace = true
|
||||
reth-ethereum-consensus.workspace = true
|
||||
reth-ethereum-primitives.workspace = true
|
||||
@ -75,7 +73,6 @@ test-utils = [
|
||||
"reth-chainspec/test-utils",
|
||||
"reth-consensus/test-utils",
|
||||
"reth-network/test-utils",
|
||||
"reth-payload-builder/test-utils",
|
||||
"reth-ethereum-primitives/test-utils",
|
||||
"reth-revm/test-utils",
|
||||
"reth-db/test-utils",
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
//! Payload component configuration for the Ethereum node.
|
||||
|
||||
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_ethereum_engine_primitives::{
|
||||
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
|
||||
@ -13,8 +12,6 @@ use reth_node_api::{FullNodeTypes, NodeTypesWithEngine, PrimitivesTy, TxTy};
|
||||
use reth_node_builder::{
|
||||
components::PayloadServiceBuilder, BuilderContext, PayloadBuilderConfig, PayloadTypes,
|
||||
};
|
||||
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
||||
use reth_provider::CanonStateSubscriptions;
|
||||
use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||
|
||||
/// A basic ethereum payload service.
|
||||
@ -23,13 +20,16 @@ use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||
pub struct EthereumPayloadBuilder;
|
||||
|
||||
impl EthereumPayloadBuilder {
|
||||
/// A helper method initializing [`PayloadBuilderService`] with the given EVM config.
|
||||
pub fn spawn<Types, Node, Evm, Pool>(
|
||||
self,
|
||||
/// A helper method initializing [`reth_ethereum_payload_builder::EthereumPayloadBuilder`] with
|
||||
/// the given EVM config.
|
||||
pub fn build<Types, Node, Evm, Pool>(
|
||||
&self,
|
||||
evm_config: Evm,
|
||||
ctx: &BuilderContext<Node>,
|
||||
pool: Pool,
|
||||
) -> eyre::Result<PayloadBuilderHandle<Types::Engine>>
|
||||
) -> eyre::Result<
|
||||
reth_ethereum_payload_builder::EthereumPayloadBuilder<Pool, Node::Provider, Evm>,
|
||||
>
|
||||
where
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
|
||||
Node: FullNodeTypes<Types = Types>,
|
||||
@ -44,30 +44,12 @@ impl EthereumPayloadBuilder {
|
||||
>,
|
||||
{
|
||||
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(),
|
||||
pool,
|
||||
evm_config,
|
||||
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,
|
||||
>,
|
||||
{
|
||||
async fn spawn_payload_service(
|
||||
self,
|
||||
type PayloadBuilder =
|
||||
reth_ethereum_payload_builder::EthereumPayloadBuilder<Pool, Node::Provider, EthEvmConfig>;
|
||||
|
||||
async fn build_payload_builder(
|
||||
&self,
|
||||
ctx: &BuilderContext<Node>,
|
||||
pool: Pool,
|
||||
) -> eyre::Result<PayloadBuilderHandle<Types::Engine>> {
|
||||
self.spawn(EthEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
||||
) -> eyre::Result<Self::PayloadBuilder> {
|
||||
self.build(EthEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,10 +11,10 @@ use alloy_rpc_types_eth::TransactionRequest;
|
||||
use alloy_signer::SignerSync;
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
use reth_e2e_test_utils::{wallet::Wallet, NodeHelperType, TmpDB};
|
||||
use reth_ethereum_engine_primitives::EthPayloadBuilderAttributes;
|
||||
use reth_ethereum_primitives::TxType;
|
||||
use reth_node_api::NodeTypesWithDBAdapter;
|
||||
use reth_node_ethereum::EthereumNode;
|
||||
use reth_payload_builder::EthPayloadBuilderAttributes;
|
||||
use reth_provider::FullProvider;
|
||||
use revm::primitives::{AccessListItem, Authorization};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user