mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: Remove ChainSpec from PayloadConfig (#11103)
Co-authored-by: garwah <garwah@garwah> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -7244,6 +7244,7 @@ dependencies = [
|
||||
"alloy-primitives",
|
||||
"reth-basic-payload-builder",
|
||||
"reth-chain-state",
|
||||
"reth-chainspec",
|
||||
"reth-errors",
|
||||
"reth-evm",
|
||||
"reth-evm-ethereum",
|
||||
|
||||
@ -226,7 +226,6 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
best_block.hash(),
|
||||
payload_attrs,
|
||||
)?,
|
||||
provider_factory.chain_spec(),
|
||||
);
|
||||
|
||||
let args = BuildArguments::new(
|
||||
|
||||
@ -122,7 +122,6 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
NoopTransactionPool::default(),
|
||||
ctx.task_executor.clone(),
|
||||
BasicPayloadJobGeneratorConfig::default(),
|
||||
provider_factory.chain_spec(),
|
||||
payload_builder,
|
||||
);
|
||||
|
||||
|
||||
@ -244,7 +244,6 @@ impl EthereumPayloadBuilder {
|
||||
pool,
|
||||
ctx.task_executor().clone(),
|
||||
payload_job_config,
|
||||
ctx.chain_spec(),
|
||||
payload_builder,
|
||||
);
|
||||
let (payload_service, payload_builder) =
|
||||
|
||||
@ -26,6 +26,7 @@ reth-evm-ethereum.workspace = true
|
||||
reth-errors.workspace = true
|
||||
reth-trie.workspace = true
|
||||
reth-chain-state.workspace = true
|
||||
reth-chainspec.workspace = true
|
||||
|
||||
# ethereum
|
||||
revm.workspace = true
|
||||
|
||||
@ -15,6 +15,7 @@ use reth_basic_payload_builder::{
|
||||
PayloadConfig, WithdrawalsOutcome,
|
||||
};
|
||||
use reth_chain_state::ExecutedBlock;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_errors::RethError;
|
||||
use reth_evm::{
|
||||
system_calls::{
|
||||
@ -36,7 +37,7 @@ use reth_primitives::{
|
||||
Block, BlockBody, EthereumHardforks, Header, IntoRecoveredTransaction, Receipt,
|
||||
EMPTY_OMMER_ROOT_HASH,
|
||||
};
|
||||
use reth_provider::StateProviderFactory;
|
||||
use reth_provider::{ChainSpecProvider, StateProviderFactory};
|
||||
use reth_revm::database::StateProviderDatabase;
|
||||
use reth_transaction_pool::{
|
||||
noop::NoopTransactionPool, BestTransactionsAttributes, TransactionPool,
|
||||
@ -88,7 +89,7 @@ where
|
||||
impl<EvmConfig, Pool, Client> PayloadBuilder<Pool, Client> for EthereumPayloadBuilder<EvmConfig>
|
||||
where
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
Client: StateProviderFactory,
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
|
||||
Pool: TransactionPool,
|
||||
{
|
||||
type Attributes = EthPayloadBuilderAttributes;
|
||||
@ -137,22 +138,22 @@ pub fn default_ethereum_payload<EvmConfig, Pool, Client>(
|
||||
) -> Result<BuildOutcome<EthBuiltPayload>, PayloadBuilderError>
|
||||
where
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
Client: StateProviderFactory,
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
|
||||
Pool: TransactionPool,
|
||||
{
|
||||
let BuildArguments { client, pool, mut cached_reads, config, cancel, best_payload } = args;
|
||||
|
||||
let chain_spec = client.chain_spec();
|
||||
let state_provider = client.state_by_block_hash(config.parent_block.hash())?;
|
||||
let state = StateProviderDatabase::new(state_provider);
|
||||
let mut db =
|
||||
State::builder().with_database_ref(cached_reads.as_db(state)).with_bundle_update().build();
|
||||
let PayloadConfig { parent_block, extra_data, attributes, chain_spec } = config;
|
||||
let PayloadConfig { parent_block, extra_data, attributes } = config;
|
||||
|
||||
debug!(target: "payload_builder", id=%attributes.id, parent_hash = ?parent_block.hash(), parent_number = parent_block.number, "building new payload");
|
||||
let mut cumulative_gas_used = 0;
|
||||
let mut sum_blob_gas_used = 0;
|
||||
let block_gas_limit: u64 =
|
||||
initialized_block_env.gas_limit.try_into().unwrap_or(chain_spec.max_gas_limit);
|
||||
let block_gas_limit: u64 = initialized_block_env.gas_limit.to::<u64>();
|
||||
let base_fee = initialized_block_env.basefee.to::<u64>();
|
||||
|
||||
let mut executed_txs = Vec::new();
|
||||
|
||||
@ -278,7 +278,6 @@ impl OptimismPayloadBuilder {
|
||||
pool,
|
||||
ctx.task_executor().clone(),
|
||||
payload_job_config,
|
||||
ctx.chain_spec(),
|
||||
payload_builder,
|
||||
);
|
||||
let (payload_service, payload_builder) =
|
||||
|
||||
@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||
use alloy_primitives::U256;
|
||||
use reth_basic_payload_builder::*;
|
||||
use reth_chain_state::ExecutedBlock;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_chainspec::{ChainSpec, ChainSpecProvider, EthereumHardforks};
|
||||
use reth_evm::{
|
||||
system_calls::pre_block_beacon_root_contract_call, ConfigureEvm, ConfigureEvmEnv,
|
||||
NextBlockEnvAttributes,
|
||||
@ -93,7 +93,7 @@ where
|
||||
/// Implementation of the [`PayloadBuilder`] trait for [`OptimismPayloadBuilder`].
|
||||
impl<Pool, Client, EvmConfig> PayloadBuilder<Pool, Client> for OptimismPayloadBuilder<EvmConfig>
|
||||
where
|
||||
Client: StateProviderFactory,
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
|
||||
Pool: TransactionPool,
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
{
|
||||
@ -164,16 +164,17 @@ pub(crate) fn optimism_payload<EvmConfig, Pool, Client>(
|
||||
) -> Result<BuildOutcome<OptimismBuiltPayload>, PayloadBuilderError>
|
||||
where
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
Client: StateProviderFactory,
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
|
||||
Pool: TransactionPool,
|
||||
{
|
||||
let BuildArguments { client, pool, mut cached_reads, config, cancel, best_payload } = args;
|
||||
|
||||
let chain_spec = client.chain_spec();
|
||||
let state_provider = client.state_by_block_hash(config.parent_block.hash())?;
|
||||
let state = StateProviderDatabase::new(state_provider);
|
||||
let mut db =
|
||||
State::builder().with_database_ref(cached_reads.as_db(state)).with_bundle_update().build();
|
||||
let PayloadConfig { parent_block, attributes, chain_spec, extra_data } = config;
|
||||
let PayloadConfig { parent_block, attributes, extra_data } = config;
|
||||
|
||||
debug!(target: "payload_builder", id=%attributes.payload_attributes.payload_id(), parent_hash = ?parent_block.hash(), parent_number = parent_block.number, "building new payload");
|
||||
|
||||
|
||||
@ -58,8 +58,6 @@ pub struct BasicPayloadJobGenerator<Client, Pool, Tasks, Builder> {
|
||||
config: BasicPayloadJobGeneratorConfig,
|
||||
/// Restricts how many generator tasks can be executed at once.
|
||||
payload_task_guard: PayloadTaskGuard,
|
||||
/// The chain spec.
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
/// The type responsible for building payloads.
|
||||
///
|
||||
/// See [`PayloadBuilder`]
|
||||
@ -78,7 +76,6 @@ impl<Client, Pool, Tasks, Builder> BasicPayloadJobGenerator<Client, Pool, Tasks,
|
||||
pool: Pool,
|
||||
executor: Tasks,
|
||||
config: BasicPayloadJobGeneratorConfig,
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
builder: Builder,
|
||||
) -> Self {
|
||||
Self {
|
||||
@ -87,7 +84,6 @@ impl<Client, Pool, Tasks, Builder> BasicPayloadJobGenerator<Client, Pool, Tasks,
|
||||
executor,
|
||||
payload_task_guard: PayloadTaskGuard::new(config.max_payload_tasks),
|
||||
config,
|
||||
chain_spec,
|
||||
builder,
|
||||
pre_cached: None,
|
||||
}
|
||||
@ -163,12 +159,8 @@ where
|
||||
block.seal(attributes.parent())
|
||||
};
|
||||
|
||||
let config = PayloadConfig::new(
|
||||
Arc::new(parent_block),
|
||||
self.config.extradata.clone(),
|
||||
attributes,
|
||||
Arc::clone(&self.chain_spec),
|
||||
);
|
||||
let config =
|
||||
PayloadConfig::new(Arc::new(parent_block), self.config.extradata.clone(), attributes);
|
||||
|
||||
let until = self.job_deadline(config.attributes.timestamp());
|
||||
let deadline = Box::pin(tokio::time::sleep_until(until));
|
||||
@ -676,8 +668,6 @@ pub struct PayloadConfig<Attributes> {
|
||||
pub extra_data: Bytes,
|
||||
/// Requested attributes for the payload.
|
||||
pub attributes: Attributes,
|
||||
/// The chain spec.
|
||||
pub chain_spec: Arc<ChainSpec>,
|
||||
}
|
||||
|
||||
impl<Attributes> PayloadConfig<Attributes> {
|
||||
@ -696,9 +686,8 @@ where
|
||||
parent_block: Arc<SealedBlock>,
|
||||
extra_data: Bytes,
|
||||
attributes: Attributes,
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
) -> Self {
|
||||
Self { parent_block, extra_data, attributes, chain_spec }
|
||||
Self { parent_block, extra_data, attributes }
|
||||
}
|
||||
|
||||
/// Returns the payload id.
|
||||
|
||||
@ -45,7 +45,7 @@ use reth_basic_payload_builder::{
|
||||
BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig, BuildArguments, BuildOutcome,
|
||||
PayloadBuilder, PayloadConfig,
|
||||
};
|
||||
use reth_chainspec::{Chain, ChainSpec};
|
||||
use reth_chainspec::{Chain, ChainSpec, ChainSpecProvider};
|
||||
use reth_node_api::{
|
||||
payload::{EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes},
|
||||
validate_version_specific_fields, EngineTypes, EngineValidator, PayloadAttributes,
|
||||
@ -285,7 +285,6 @@ where
|
||||
pool,
|
||||
ctx.task_executor().clone(),
|
||||
payload_job_config,
|
||||
ctx.chain_spec(),
|
||||
payload_builder,
|
||||
);
|
||||
let (payload_service, payload_builder) =
|
||||
@ -304,7 +303,7 @@ pub struct CustomPayloadBuilder;
|
||||
|
||||
impl<Pool, Client> PayloadBuilder<Pool, Client> for CustomPayloadBuilder
|
||||
where
|
||||
Client: StateProviderFactory,
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
|
||||
Pool: TransactionPool,
|
||||
{
|
||||
type Attributes = CustomPayloadBuilderAttributes;
|
||||
@ -315,7 +314,9 @@ where
|
||||
args: BuildArguments<Pool, Client, Self::Attributes, Self::BuiltPayload>,
|
||||
) -> Result<BuildOutcome<Self::BuiltPayload>, PayloadBuilderError> {
|
||||
let BuildArguments { client, pool, cached_reads, config, cancel, best_payload } = args;
|
||||
let PayloadConfig { parent_block, extra_data, attributes, chain_spec } = config;
|
||||
let PayloadConfig { parent_block, extra_data, attributes } = config;
|
||||
|
||||
let chain_spec = client.chain_spec();
|
||||
|
||||
// This reuses the default EthereumPayloadBuilder to build the payload
|
||||
// but any custom logic can be implemented here
|
||||
@ -326,12 +327,7 @@ where
|
||||
client,
|
||||
pool,
|
||||
cached_reads,
|
||||
config: PayloadConfig {
|
||||
parent_block,
|
||||
extra_data,
|
||||
attributes: attributes.0,
|
||||
chain_spec,
|
||||
},
|
||||
config: PayloadConfig { parent_block, extra_data, attributes: attributes.0 },
|
||||
cancel,
|
||||
best_payload,
|
||||
})
|
||||
@ -342,9 +338,10 @@ where
|
||||
client: &Client,
|
||||
config: PayloadConfig<Self::Attributes>,
|
||||
) -> Result<Self::BuiltPayload, PayloadBuilderError> {
|
||||
let PayloadConfig { parent_block, extra_data, attributes, chain_spec } = config;
|
||||
let PayloadConfig { parent_block, extra_data, attributes } = config;
|
||||
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,
|
||||
PayloadConfig { parent_block, extra_data, attributes: attributes.0, chain_spec })
|
||||
PayloadConfig { parent_block, extra_data, attributes: attributes.0})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ use reth::{
|
||||
transaction_pool::TransactionPool,
|
||||
};
|
||||
use reth_basic_payload_builder::{BasicPayloadJobGeneratorConfig, PayloadBuilder, PayloadConfig};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_node_api::PayloadBuilderAttributes;
|
||||
use reth_payload_builder::{PayloadBuilderError, PayloadJobGenerator};
|
||||
use reth_primitives::{BlockNumberOrTag, Bytes};
|
||||
@ -22,8 +21,6 @@ pub struct EmptyBlockPayloadJobGenerator<Client, Pool, Tasks, Builder> {
|
||||
executor: Tasks,
|
||||
/// The configuration for the job generator.
|
||||
_config: BasicPayloadJobGeneratorConfig,
|
||||
/// The chain spec.
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
/// The type responsible for building payloads.
|
||||
///
|
||||
/// See [PayloadBuilder]
|
||||
@ -40,10 +37,9 @@ impl<Client, Pool, Tasks, Builder> EmptyBlockPayloadJobGenerator<Client, Pool, T
|
||||
pool: Pool,
|
||||
executor: Tasks,
|
||||
config: BasicPayloadJobGeneratorConfig,
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
builder: Builder,
|
||||
) -> Self {
|
||||
Self { client, pool, executor, _config: config, builder, chain_spec }
|
||||
Self { client, pool, executor, _config: config, builder }
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,12 +76,7 @@ where
|
||||
// we already know the hash, so we can seal it
|
||||
block.seal(attributes.parent())
|
||||
};
|
||||
let config = PayloadConfig::new(
|
||||
Arc::new(parent_block),
|
||||
Bytes::default(),
|
||||
attributes,
|
||||
Arc::clone(&self.chain_spec),
|
||||
);
|
||||
let config = PayloadConfig::new(Arc::new(parent_block), Bytes::default(), attributes);
|
||||
Ok(EmptyBlockPayloadJob {
|
||||
client: self.client.clone(),
|
||||
_pool: self.pool.clone(),
|
||||
|
||||
@ -56,7 +56,6 @@ where
|
||||
pool,
|
||||
ctx.task_executor().clone(),
|
||||
payload_job_config,
|
||||
ctx.chain_spec().clone(),
|
||||
reth_ethereum_payload_builder::EthereumPayloadBuilder::new(EthEvmConfig::new(
|
||||
ctx.chain_spec(),
|
||||
)),
|
||||
|
||||
Reference in New Issue
Block a user