feat(builder): ethereum builder config (#13315)

This commit is contained in:
Roman Krasiuk
2024-12-11 22:26:25 +01:00
committed by GitHub
parent 3d12a4eafa
commit c553b1e86d
14 changed files with 120 additions and 69 deletions

View File

@ -22,6 +22,7 @@ use reth_cli_commands::common::{AccessRights, CliNodeTypes, Environment, Environ
use reth_cli_runner::CliContext; use reth_cli_runner::CliContext;
use reth_consensus::{Consensus, FullConsensus}; use reth_consensus::{Consensus, FullConsensus};
use reth_errors::RethResult; use reth_errors::RethResult;
use reth_ethereum_payload_builder::EthereumBuilderConfig;
use reth_evm::execute::{BlockExecutorProvider, Executor}; use reth_evm::execute::{BlockExecutorProvider, Executor};
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_fs_util as fs; use reth_fs_util as fs;
@ -228,7 +229,6 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
}; };
let payload_config = PayloadConfig::new( let payload_config = PayloadConfig::new(
Arc::new(SealedHeader::new(best_block.header().clone(), best_block.hash())), Arc::new(SealedHeader::new(best_block.header().clone(), best_block.hash())),
Bytes::default(),
reth_payload_builder::EthPayloadBuilderAttributes::try_new( reth_payload_builder::EthPayloadBuilderAttributes::try_new(
best_block.hash(), best_block.hash(),
payload_attrs, payload_attrs,
@ -247,6 +247,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::new( let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
EthEvmConfig::new(provider_factory.chain_spec()), EthEvmConfig::new(provider_factory.chain_spec()),
EthereumBuilderConfig::new(Default::default()),
); );
match payload_builder.try_build(args)? { match payload_builder.try_build(args)? {

View File

@ -15,6 +15,7 @@ use reth_config::Config;
use reth_consensus::FullConsensus; use reth_consensus::FullConsensus;
use reth_db::DatabaseEnv; use reth_db::DatabaseEnv;
use reth_engine_util::engine_store::{EngineMessageStore, StoredEngineApiMessage}; use reth_engine_util::engine_store::{EngineMessageStore, StoredEngineApiMessage};
use reth_ethereum_payload_builder::EthereumBuilderConfig;
use reth_fs_util as fs; use reth_fs_util as fs;
use reth_network::{BlockDownloaderProvider, NetworkHandle}; use reth_network::{BlockDownloaderProvider, NetworkHandle};
use reth_network_api::NetworkInfo; use reth_network_api::NetworkInfo;
@ -123,6 +124,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
// Set up payload builder // Set up payload builder
let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::new( let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
EthEvmConfig::new(provider_factory.chain_spec()), EthEvmConfig::new(provider_factory.chain_spec()),
EthereumBuilderConfig::new(Default::default()),
); );
let payload_generator = BasicPayloadJobGenerator::with_builder( let payload_generator = BasicPayloadJobGenerator::with_builder(

View File

@ -27,6 +27,7 @@ reth-consensus.workspace = true
reth-beacon-consensus.workspace = true reth-beacon-consensus.workspace = true
reth-rpc.workspace = true reth-rpc.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-node-core.workspace = true
reth-chainspec.workspace = true reth-chainspec.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-revm = { workspace = true, features = ["std"] } reth-revm = { workspace = true, features = ["std"] }
@ -43,7 +44,6 @@ reth-chainspec.workspace = true
reth-db.workspace = true reth-db.workspace = true
reth-exex.workspace = true reth-exex.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-node-core.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-e2e-test-utils.workspace = true reth-e2e-test-utils.workspace = true
reth-rpc-eth-api.workspace = true reth-rpc-eth-api.workspace = true

View File

@ -8,6 +8,7 @@ use reth_chainspec::ChainSpec;
use reth_ethereum_engine_primitives::{ use reth_ethereum_engine_primitives::{
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes, EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
}; };
use reth_ethereum_payload_builder::EthereumBuilderConfig;
use reth_evm::execute::BasicBlockExecutorProvider; use reth_evm::execute::BasicBlockExecutorProvider;
use reth_evm_ethereum::execute::EthExecutionStrategyFactory; use reth_evm_ethereum::execute::EthExecutionStrategyFactory;
use reth_network::{EthNetworkPrimitives, NetworkHandle, PeersInfo}; use reth_network::{EthNetworkPrimitives, NetworkHandle, PeersInfo};
@ -23,6 +24,7 @@ use reth_node_builder::{
rpc::{EngineValidatorBuilder, RpcAddOns}, rpc::{EngineValidatorBuilder, RpcAddOns},
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig, PayloadTypes, BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig, PayloadTypes,
}; };
use reth_node_core::version::default_extra_data_bytes;
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService}; use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{EthPrimitives, PooledTransactionsElement}; use reth_primitives::{EthPrimitives, PooledTransactionsElement};
use reth_provider::{CanonStateSubscriptions, EthStorage}; use reth_provider::{CanonStateSubscriptions, EthStorage};
@ -228,9 +230,24 @@ where
} }
/// A basic ethereum payload service. /// A basic ethereum payload service.
#[derive(Debug, Default, Clone)] #[derive(Clone, Debug)]
#[non_exhaustive] pub struct EthereumPayloadBuilder {
pub struct EthereumPayloadBuilder; /// Payload builder configuration.
config: EthereumBuilderConfig,
}
impl Default for EthereumPayloadBuilder {
fn default() -> Self {
Self { config: EthereumBuilderConfig::new(default_extra_data_bytes()) }
}
}
impl EthereumPayloadBuilder {
/// Create new ethereum payload builder.
pub const fn new(config: EthereumBuilderConfig) -> Self {
Self { config }
}
}
impl EthereumPayloadBuilder { impl EthereumPayloadBuilder {
/// A helper method initializing [`PayloadBuilderService`] with the given EVM config. /// A helper method initializing [`PayloadBuilderService`] with the given EVM config.
@ -254,7 +271,7 @@ impl EthereumPayloadBuilder {
>, >,
{ {
let payload_builder = let payload_builder =
reth_ethereum_payload_builder::EthereumPayloadBuilder::new(evm_config); reth_ethereum_payload_builder::EthereumPayloadBuilder::new(evm_config, self.config);
let conf = ctx.payload_builder_config(); let conf = ctx.payload_builder_config();
let payload_job_config = BasicPayloadJobGeneratorConfig::default() let payload_job_config = BasicPayloadJobGeneratorConfig::default()

View File

@ -0,0 +1,22 @@
use alloy_primitives::Bytes;
/// Settings for the Ethereum builder.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct EthereumBuilderConfig {
/// Block extra data.
pub extra_data: Bytes,
}
impl EthereumBuilderConfig {
/// Create new payload builder config.
pub const fn new(extra_data: Bytes) -> Self {
Self { extra_data }
}
}
impl EthereumBuilderConfig {
/// Returns owned extra data bytes for the block.
pub fn extra_data(&self) -> Bytes {
self.extra_data.clone()
}
}

View File

@ -50,21 +50,26 @@ use revm::{
use std::sync::Arc; use std::sync::Arc;
use tracing::{debug, trace, warn}; use tracing::{debug, trace, warn};
mod config;
pub use config::*;
type BestTransactionsIter<Pool> = Box< type BestTransactionsIter<Pool> = Box<
dyn BestTransactions<Item = Arc<ValidPoolTransaction<<Pool as TransactionPool>::Transaction>>>, dyn BestTransactions<Item = Arc<ValidPoolTransaction<<Pool as TransactionPool>::Transaction>>>,
>; >;
/// Ethereum payload builder /// Ethereum payload builder
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct EthereumPayloadBuilder<EvmConfig = EthEvmConfig> { pub struct EthereumPayloadBuilder<EvmConfig = EthEvmConfig> {
/// The type responsible for creating the evm. /// The type responsible for creating the evm.
evm_config: EvmConfig, evm_config: EvmConfig,
/// Payload builder configuration.
builder_config: EthereumBuilderConfig,
} }
impl<EvmConfig> EthereumPayloadBuilder<EvmConfig> { impl<EvmConfig> EthereumPayloadBuilder<EvmConfig> {
/// `EthereumPayloadBuilder` constructor. /// `EthereumPayloadBuilder` constructor.
pub const fn new(evm_config: EvmConfig) -> Self { pub const fn new(evm_config: EvmConfig, builder_config: EthereumBuilderConfig) -> Self {
Self { evm_config } Self { evm_config, builder_config }
} }
} }
@ -107,9 +112,14 @@ where
.map_err(PayloadBuilderError::other)?; .map_err(PayloadBuilderError::other)?;
let pool = args.pool.clone(); let pool = args.pool.clone();
default_ethereum_payload(self.evm_config.clone(), args, cfg_env, block_env, |attributes| { default_ethereum_payload(
pool.best_transactions_with_attributes(attributes) self.evm_config.clone(),
}) self.builder_config.clone(),
args,
cfg_env,
block_env,
|attributes| pool.best_transactions_with_attributes(attributes),
)
} }
fn build_empty_payload( fn build_empty_payload(
@ -133,9 +143,14 @@ where
let pool = args.pool.clone(); let pool = args.pool.clone();
default_ethereum_payload(self.evm_config.clone(), args, cfg_env, block_env, |attributes| { default_ethereum_payload(
pool.best_transactions_with_attributes(attributes) self.evm_config.clone(),
})? self.builder_config.clone(),
args,
cfg_env,
block_env,
|attributes| pool.best_transactions_with_attributes(attributes),
)?
.into_payload() .into_payload()
.ok_or_else(|| PayloadBuilderError::MissingPayload) .ok_or_else(|| PayloadBuilderError::MissingPayload)
} }
@ -149,6 +164,7 @@ where
#[inline] #[inline]
pub fn default_ethereum_payload<EvmConfig, Pool, Client, F>( pub fn default_ethereum_payload<EvmConfig, Pool, Client, F>(
evm_config: EvmConfig, evm_config: EvmConfig,
builder_config: EthereumBuilderConfig,
args: BuildArguments<Pool, Client, EthPayloadBuilderAttributes, EthBuiltPayload>, args: BuildArguments<Pool, Client, EthPayloadBuilderAttributes, EthBuiltPayload>,
initialized_cfg: CfgEnvWithHandlerCfg, initialized_cfg: CfgEnvWithHandlerCfg,
initialized_block_env: BlockEnv, initialized_block_env: BlockEnv,
@ -167,7 +183,7 @@ where
let state = StateProviderDatabase::new(state_provider); let state = StateProviderDatabase::new(state_provider);
let mut db = let mut db =
State::builder().with_database(cached_reads.as_db_mut(state)).with_bundle_update().build(); State::builder().with_database(cached_reads.as_db_mut(state)).with_bundle_update().build();
let PayloadConfig { parent_header, extra_data, attributes } = config; let PayloadConfig { parent_header, attributes } = config;
debug!(target: "payload_builder", id=%attributes.id, parent_header = ?parent_header.hash(), parent_number = parent_header.number, "building new payload"); debug!(target: "payload_builder", id=%attributes.id, parent_header = ?parent_header.hash(), parent_number = parent_header.number, "building new payload");
let mut cumulative_gas_used = 0; let mut cumulative_gas_used = 0;
@ -470,7 +486,7 @@ where
gas_limit: block_gas_limit, gas_limit: block_gas_limit,
difficulty: U256::ZERO, difficulty: U256::ZERO,
gas_used: cumulative_gas_used, gas_used: cumulative_gas_used,
extra_data, extra_data: builder_config.extra_data,
parent_beacon_block_root: attributes.parent_beacon_block_root, parent_beacon_block_root: attributes.parent_beacon_block_root,
blob_gas_used: blob_gas_used.map(Into::into), blob_gas_used: blob_gas_used.map(Into::into),
excess_blob_gas: excess_blob_gas.map(Into::into), excess_blob_gas: excess_blob_gas.map(Into::into),

View File

@ -1,4 +1,4 @@
use crate::{cli::config::PayloadBuilderConfig, version::default_extradata}; use crate::{cli::config::PayloadBuilderConfig, version::default_extra_data};
use alloy_consensus::constants::MAXIMUM_EXTRA_DATA_SIZE; use alloy_consensus::constants::MAXIMUM_EXTRA_DATA_SIZE;
use alloy_eips::{eip1559::ETHEREUM_BLOCK_GAS_LIMIT, merge::SLOT_DURATION}; use alloy_eips::{eip1559::ETHEREUM_BLOCK_GAS_LIMIT, merge::SLOT_DURATION};
use clap::{ use clap::{
@ -13,7 +13,7 @@ use std::{borrow::Cow, ffi::OsStr, time::Duration};
#[command(next_help_heading = "Builder")] #[command(next_help_heading = "Builder")]
pub struct PayloadBuilderArgs { pub struct PayloadBuilderArgs {
/// Block extra data set by the payload builder. /// Block extra data set by the payload builder.
#[arg(long = "builder.extradata", value_parser = ExtradataValueParser::default(), default_value_t = default_extradata())] #[arg(long = "builder.extradata", value_parser = ExtradataValueParser::default(), default_value_t = default_extra_data())]
pub extradata: String, pub extradata: String,
/// Target gas ceiling for built blocks. /// Target gas ceiling for built blocks.
@ -40,7 +40,7 @@ pub struct PayloadBuilderArgs {
impl Default for PayloadBuilderArgs { impl Default for PayloadBuilderArgs {
fn default() -> Self { fn default() -> Self {
Self { Self {
extradata: default_extradata(), extradata: default_extra_data(),
max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT, max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
interval: Duration::from_secs(1), interval: Duration::from_secs(1),
deadline: SLOT_DURATION, deadline: SLOT_DURATION,
@ -130,7 +130,7 @@ mod tests {
#[test] #[test]
fn test_default_extradata() { fn test_default_extradata() {
let extradata = default_extradata(); let extradata = default_extra_data();
let args = CommandParser::<PayloadBuilderArgs>::parse_from([ let args = CommandParser::<PayloadBuilderArgs>::parse_from([
"reth", "reth",
"--builder.extradata", "--builder.extradata",

View File

@ -1,4 +1,5 @@
//! Version information for reth. //! Version information for reth.
use alloy_primitives::Bytes;
use alloy_rpc_types_engine::ClientCode; use alloy_rpc_types_engine::ClientCode;
use reth_db::ClientVersion; use reth_db::ClientVersion;
@ -114,7 +115,7 @@ pub(crate) const P2P_CLIENT_VERSION: &str = const_format::concatcp!(
env!("VERGEN_CARGO_TARGET_TRIPLE") env!("VERGEN_CARGO_TARGET_TRIPLE")
); );
/// The default extradata used for payload building. /// The default extra data used for payload building.
/// ///
/// - The latest version from Cargo.toml /// - The latest version from Cargo.toml
/// - The OS identifier /// - The OS identifier
@ -124,10 +125,16 @@ pub(crate) const P2P_CLIENT_VERSION: &str = const_format::concatcp!(
/// ```text /// ```text
/// reth/v{major}.{minor}.{patch}/{OS} /// reth/v{major}.{minor}.{patch}/{OS}
/// ``` /// ```
pub fn default_extradata() -> String { pub fn default_extra_data() -> String {
format!("reth/v{}/{}", env!("CARGO_PKG_VERSION"), std::env::consts::OS) format!("reth/v{}/{}", env!("CARGO_PKG_VERSION"), std::env::consts::OS)
} }
/// The default extra data in bytes.
/// See [`default_extra_data`].
pub fn default_extra_data_bytes() -> Bytes {
Bytes::from(default_extra_data().as_bytes().to_vec())
}
/// The default client version accessing the database. /// The default client version accessing the database.
pub fn default_client_version() -> ClientVersion { pub fn default_client_version() -> ClientVersion {
ClientVersion { ClientVersion {
@ -143,7 +150,7 @@ mod tests {
#[test] #[test]
fn assert_extradata_less_32bytes() { fn assert_extradata_less_32bytes() {
let extradata = default_extradata(); let extradata = default_extra_data();
assert!(extradata.len() <= 32, "extradata must be less than 32 bytes: {extradata}") assert!(extradata.len() <= 32, "extradata must be less than 32 bytes: {extradata}")
} }
} }

View File

@ -195,11 +195,7 @@ where
let (initialized_cfg, initialized_block_env) = let (initialized_cfg, initialized_block_env) =
self.cfg_and_block_env(&attributes, &parent).map_err(PayloadBuilderError::other)?; self.cfg_and_block_env(&attributes, &parent).map_err(PayloadBuilderError::other)?;
let config = PayloadConfig { let config = PayloadConfig { parent_header: Arc::new(parent), attributes };
parent_header: Arc::new(parent),
attributes,
extra_data: Default::default(),
};
let ctx = OpPayloadBuilderCtx { let ctx = OpPayloadBuilderCtx {
evm_config: self.evm_config.clone(), evm_config: self.evm_config.clone(),
chain_spec: client.chain_spec(), chain_spec: client.chain_spec(),
@ -621,7 +617,7 @@ impl<EvmConfig> OpPayloadBuilderCtx<EvmConfig> {
/// Returns the extra data for the block. /// Returns the extra data for the block.
/// ///
/// After holocene this extracts the extradata from the paylpad /// After holocene this extracts the extra data from the payload
pub fn extra_data(&self) -> Result<Bytes, PayloadBuilderError> { pub fn extra_data(&self) -> Result<Bytes, PayloadBuilderError> {
if self.is_holocene_active() { if self.is_holocene_active() {
self.attributes() self.attributes()
@ -632,7 +628,7 @@ impl<EvmConfig> OpPayloadBuilderCtx<EvmConfig> {
) )
.map_err(PayloadBuilderError::other) .map_err(PayloadBuilderError::other)
} else { } else {
Ok(self.config.extra_data.clone()) Ok(Default::default())
} }
} }

View File

@ -163,11 +163,7 @@ where
.ok_or_else(|| PayloadBuilderError::MissingParentHeader(attributes.parent()))? .ok_or_else(|| PayloadBuilderError::MissingParentHeader(attributes.parent()))?
}; };
let config = PayloadConfig::new( let config = PayloadConfig::new(Arc::new(parent_header.clone()), attributes);
Arc::new(parent_header.clone()),
self.config.extradata.clone(),
attributes,
);
let until = self.job_deadline(config.attributes.timestamp()); let until = self.job_deadline(config.attributes.timestamp());
let deadline = Box::pin(tokio::time::sleep_until(until)); let deadline = Box::pin(tokio::time::sleep_until(until));
@ -713,30 +709,17 @@ impl Drop for Cancelled {
pub struct PayloadConfig<Attributes> { pub struct PayloadConfig<Attributes> {
/// The parent header. /// The parent header.
pub parent_header: Arc<SealedHeader>, pub parent_header: Arc<SealedHeader>,
/// Block extra data.
pub extra_data: Bytes,
/// Requested attributes for the payload. /// Requested attributes for the payload.
pub attributes: Attributes, pub attributes: Attributes,
} }
impl<Attributes> PayloadConfig<Attributes> {
/// Returns an owned instance of the [`PayloadConfig`]'s `extra_data` bytes.
pub fn extra_data(&self) -> Bytes {
self.extra_data.clone()
}
}
impl<Attributes> PayloadConfig<Attributes> impl<Attributes> PayloadConfig<Attributes>
where where
Attributes: PayloadBuilderAttributes, Attributes: PayloadBuilderAttributes,
{ {
/// Create new payload config. /// Create new payload config.
pub const fn new( pub const fn new(parent_header: Arc<SealedHeader>, attributes: Attributes) -> Self {
parent_header: Arc<SealedHeader>, Self { parent_header, attributes }
extra_data: Bytes,
attributes: Attributes,
) -> Self {
Self { parent_header, extra_data, attributes }
} }
/// Returns the payload id. /// Returns the payload id.

View File

@ -204,7 +204,6 @@ where
cached_reads: args.cached_reads.clone(), cached_reads: args.cached_reads.clone(),
config: PayloadConfig { config: PayloadConfig {
parent_header: args.config.parent_header.clone(), parent_header: args.config.parent_header.clone(),
extra_data: args.config.extra_data.clone(),
attributes: left_attr.clone(), attributes: left_attr.clone(),
}, },
cancel: args.cancel.clone(), cancel: args.cancel.clone(),
@ -226,7 +225,6 @@ where
cached_reads: args.cached_reads.clone(), cached_reads: args.cached_reads.clone(),
config: PayloadConfig { config: PayloadConfig {
parent_header: args.config.parent_header.clone(), parent_header: args.config.parent_header.clone(),
extra_data: args.config.extra_data.clone(),
attributes: right_attr.clone(), attributes: right_attr.clone(),
}, },
cancel: args.cancel.clone(), cancel: args.cancel.clone(),
@ -252,16 +250,14 @@ where
match config.attributes { match config.attributes {
Either::Left(left_attr) => { Either::Left(left_attr) => {
let left_config = PayloadConfig { let left_config = PayloadConfig {
attributes: left_attr,
parent_header: config.parent_header.clone(), parent_header: config.parent_header.clone(),
extra_data: config.extra_data.clone(), attributes: left_attr,
}; };
self.left.build_empty_payload(client, left_config).map(Either::Left) self.left.build_empty_payload(client, left_config).map(Either::Left)
} }
Either::Right(right_attr) => { Either::Right(right_attr) => {
let right_config = PayloadConfig { let right_config = PayloadConfig {
parent_header: config.parent_header.clone(), parent_header: config.parent_header.clone(),
extra_data: config.extra_data.clone(),
attributes: right_attr, attributes: right_attr,
}; };
self.right.build_empty_payload(client, right_config).map(Either::Right) self.right.build_empty_payload(client, right_config).map(Either::Right)

View File

@ -46,12 +46,14 @@ use reth::{
}, },
tasks::TaskManager, tasks::TaskManager,
transaction_pool::{PoolTransaction, TransactionPool}, transaction_pool::{PoolTransaction, TransactionPool},
version::default_extra_data_bytes,
}; };
use reth_basic_payload_builder::{ use reth_basic_payload_builder::{
BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig, BuildArguments, BuildOutcome, BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig, BuildArguments, BuildOutcome,
PayloadBuilder, PayloadConfig, PayloadBuilder, PayloadConfig,
}; };
use reth_chainspec::{Chain, ChainSpec, ChainSpecProvider}; use reth_chainspec::{Chain, ChainSpec, ChainSpecProvider};
use reth_ethereum_payload_builder::EthereumBuilderConfig;
use reth_node_api::{ use reth_node_api::{
payload::{EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes}, payload::{EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes},
validate_version_specific_fields, AddOnsContext, EngineTypes, EngineValidator, validate_version_specific_fields, AddOnsContext, EngineTypes, EngineValidator,
@ -398,20 +400,21 @@ where
args: BuildArguments<Pool, Client, Self::Attributes, Self::BuiltPayload>, args: BuildArguments<Pool, Client, Self::Attributes, Self::BuiltPayload>,
) -> Result<BuildOutcome<Self::BuiltPayload>, PayloadBuilderError> { ) -> Result<BuildOutcome<Self::BuiltPayload>, PayloadBuilderError> {
let BuildArguments { client, pool, cached_reads, config, cancel, best_payload } = args; let BuildArguments { client, pool, cached_reads, config, cancel, best_payload } = args;
let PayloadConfig { parent_header, extra_data, attributes } = config; let PayloadConfig { parent_header, attributes } = config;
let chain_spec = client.chain_spec(); let chain_spec = client.chain_spec();
// This reuses the default EthereumPayloadBuilder to build the payload // This reuses the default EthereumPayloadBuilder to build the payload
// but any custom logic can be implemented here // but any custom logic can be implemented here
reth_ethereum_payload_builder::EthereumPayloadBuilder::new(EthEvmConfig::new( reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
chain_spec.clone(), EthEvmConfig::new(chain_spec.clone()),
)) EthereumBuilderConfig::new(default_extra_data_bytes()),
)
.try_build(BuildArguments { .try_build(BuildArguments {
client, client,
pool, pool,
cached_reads, cached_reads,
config: PayloadConfig { parent_header, extra_data, attributes: attributes.0 }, config: PayloadConfig { parent_header, attributes: attributes.0 },
cancel, cancel,
best_payload, best_payload,
}) })
@ -422,10 +425,16 @@ where
client: &Client, client: &Client,
config: PayloadConfig<Self::Attributes>, config: PayloadConfig<Self::Attributes>,
) -> Result<Self::BuiltPayload, PayloadBuilderError> { ) -> Result<Self::BuiltPayload, PayloadBuilderError> {
let PayloadConfig { parent_header, extra_data, attributes } = config; let PayloadConfig { parent_header, attributes } = config;
let chain_spec = client.chain_spec(); let chain_spec = client.chain_spec();
<reth_ethereum_payload_builder::EthereumPayloadBuilder as PayloadBuilder<Pool, Client>>::build_empty_payload(&reth_ethereum_payload_builder::EthereumPayloadBuilder::new(EthEvmConfig::new(chain_spec.clone())),client, <reth_ethereum_payload_builder::EthereumPayloadBuilder as PayloadBuilder<Pool, Client>>::build_empty_payload(
PayloadConfig { parent_header, extra_data, attributes: attributes.0}) &reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
EthEvmConfig::new(chain_spec.clone()),
EthereumBuilderConfig::new(default_extra_data_bytes())
),
client,
PayloadConfig { parent_header, attributes: attributes.0}
)
} }
} }

View File

@ -1,6 +1,5 @@
use crate::job::EmptyBlockPayloadJob; use crate::job::EmptyBlockPayloadJob;
use alloy_eips::BlockNumberOrTag; use alloy_eips::BlockNumberOrTag;
use alloy_primitives::Bytes;
use reth::{ use reth::{
providers::{BlockReaderIdExt, BlockSource, StateProviderFactory}, providers::{BlockReaderIdExt, BlockSource, StateProviderFactory},
tasks::TaskSpawner, tasks::TaskSpawner,
@ -85,7 +84,7 @@ where
let hash = parent_block.hash(); let hash = parent_block.hash();
let header = SealedHeader::new(parent_block.header().clone(), hash); let header = SealedHeader::new(parent_block.header().clone(), hash);
let config = PayloadConfig::new(Arc::new(header), Bytes::default(), attributes); let config = PayloadConfig::new(Arc::new(header), attributes);
Ok(EmptyBlockPayloadJob { Ok(EmptyBlockPayloadJob {
client: self.client.clone(), client: self.client.clone(),
_pool: self.pool.clone(), _pool: self.pool.clone(),

View File

@ -18,9 +18,11 @@ use reth::{
payload::PayloadBuilderHandle, payload::PayloadBuilderHandle,
providers::CanonStateSubscriptions, providers::CanonStateSubscriptions,
transaction_pool::{PoolTransaction, TransactionPool}, transaction_pool::{PoolTransaction, TransactionPool},
version::default_extra_data_bytes,
}; };
use reth_basic_payload_builder::BasicPayloadJobGeneratorConfig; use reth_basic_payload_builder::BasicPayloadJobGeneratorConfig;
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_ethereum_payload_builder::EthereumBuilderConfig;
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_payload_builder::PayloadBuilderService;
@ -65,9 +67,10 @@ where
pool, pool,
ctx.task_executor().clone(), ctx.task_executor().clone(),
payload_job_config, payload_job_config,
reth_ethereum_payload_builder::EthereumPayloadBuilder::new(EthEvmConfig::new( reth_ethereum_payload_builder::EthereumPayloadBuilder::new(
ctx.chain_spec(), EthEvmConfig::new(ctx.chain_spec()),
)), EthereumBuilderConfig::new(default_extra_data_bytes()),
),
); );
let (payload_service, payload_builder) = let (payload_service, payload_builder) =