refactor: change PayloadConfig to use parent header instead of parent block (#12159)

This commit is contained in:
Léa Narzis
2024-10-29 16:52:00 +07:00
committed by GitHub
parent b48fa68f65
commit 7880d4ddb0
6 changed files with 47 additions and 39 deletions

View File

@ -341,7 +341,7 @@ 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 } = config;
let PayloadConfig { parent_header, extra_data, attributes } = config;
let chain_spec = client.chain_spec();
@ -354,7 +354,7 @@ where
client,
pool,
cached_reads,
config: PayloadConfig { parent_block, extra_data, attributes: attributes.0 },
config: PayloadConfig { parent_header, extra_data, attributes: attributes.0 },
cancel,
best_payload,
})
@ -365,10 +365,10 @@ where
client: &Client,
config: PayloadConfig<Self::Attributes>,
) -> Result<Self::BuiltPayload, PayloadBuilderError> {
let PayloadConfig { parent_block, extra_data, attributes } = config;
let PayloadConfig { parent_header, 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})
PayloadConfig { parent_header, extra_data, attributes: attributes.0})
}
}

View File

@ -8,7 +8,7 @@ use reth::{
use reth_basic_payload_builder::{BasicPayloadJobGeneratorConfig, PayloadBuilder, PayloadConfig};
use reth_node_api::PayloadBuilderAttributes;
use reth_payload_builder::{PayloadBuilderError, PayloadJobGenerator};
use reth_primitives::BlockNumberOrTag;
use reth_primitives::{BlockNumberOrTag, SealedHeader};
use std::sync::Arc;
/// The generator type that creates new jobs that builds empty blocks.
@ -77,7 +77,10 @@ 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);
let hash = parent_block.hash();
let header = SealedHeader::new(parent_block.header().clone(), hash);
let config = PayloadConfig::new(Arc::new(header), Bytes::default(), attributes);
Ok(EmptyBlockPayloadJob {
client: self.client.clone(),
_pool: self.pool.clone(),