chore: add version to PayloadBuilderAttributes::try_new (#12137)

This commit is contained in:
0xOsiris
2024-10-28 07:37:36 -07:00
committed by GitHub
parent af5ae5a792
commit 3f4634ccbc
7 changed files with 24 additions and 6 deletions

View File

@ -22,7 +22,9 @@ use reth_errors::RethResult;
use reth_evm::execute::{BlockExecutorProvider, Executor};
use reth_execution_types::ExecutionOutcome;
use reth_fs_util as fs;
use reth_node_api::{NodeTypesWithDB, NodeTypesWithEngine, PayloadBuilderAttributes};
use reth_node_api::{
EngineApiMessageVersion, NodeTypesWithDB, NodeTypesWithEngine, PayloadBuilderAttributes,
};
use reth_node_ethereum::{EthEvmConfig, EthExecutorProvider};
use reth_payload_builder::database::CachedReads;
use reth_primitives::{
@ -227,6 +229,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
reth_payload_builder::EthPayloadBuilderAttributes::try_new(
best_block.hash(),
payload_attrs,
EngineApiMessageVersion::default() as u8,
)?,
);

View File

@ -1165,7 +1165,7 @@ where
attrs: <N::Engine as PayloadTypes>::PayloadAttributes,
head: Header,
state: ForkchoiceState,
_version: EngineApiMessageVersion,
version: EngineApiMessageVersion,
) -> OnForkChoiceUpdated {
// 7. Client software MUST ensure that payloadAttributes.timestamp is greater than timestamp
// of a block referenced by forkchoiceState.headBlockHash. If this condition isn't held
@ -1183,6 +1183,7 @@ where
match <<N:: Engine as PayloadTypes>::PayloadBuilderAttributes as PayloadBuilderAttributes>::try_new(
state.head_block_hash,
attrs,
version as u8
) {
Ok(attributes) => {
// send the payload to the builder and return the receiver for the pending payload

View File

@ -2492,7 +2492,7 @@ where
attrs: T::PayloadAttributes,
head: &Header,
state: ForkchoiceState,
_version: EngineApiMessageVersion,
version: EngineApiMessageVersion,
) -> OnForkChoiceUpdated {
// 7. Client software MUST ensure that payloadAttributes.timestamp is greater than timestamp
// of a block referenced by forkchoiceState.headBlockHash. If this condition isn't held
@ -2510,6 +2510,7 @@ where
match <T::PayloadBuilderAttributes as PayloadBuilderAttributes>::try_new(
state.head_block_hash,
attrs,
version as u8,
) {
Ok(attributes) => {
// send the payload to the builder and return the receiver for the pending payload

View File

@ -237,7 +237,11 @@ impl PayloadBuilderAttributes for EthPayloadBuilderAttributes {
/// Creates a new payload builder for the given parent block and the attributes.
///
/// Derives the unique [`PayloadId`] for the given parent and attributes
fn try_new(parent: B256, attributes: PayloadAttributes) -> Result<Self, Infallible> {
fn try_new(
parent: B256,
attributes: PayloadAttributes,
_version: u8,
) -> Result<Self, Infallible> {
Ok(Self::new(parent, attributes))
}

View File

@ -43,7 +43,11 @@ impl PayloadBuilderAttributes for OptimismPayloadBuilderAttributes {
/// Creates a new payload builder for the given parent block and the attributes.
///
/// Derives the unique [`PayloadId`] for the given parent and attributes
fn try_new(parent: B256, attributes: OpPayloadAttributes) -> Result<Self, Self::Error> {
fn try_new(
parent: B256,
attributes: OpPayloadAttributes,
_version: u8,
) -> Result<Self, Self::Error> {
let id = payload_id_optimism(&parent, &attributes);
let transactions = attributes

View File

@ -88,6 +88,7 @@ pub trait PayloadBuilderAttributes: Send + Sync + std::fmt::Debug {
fn try_new(
parent: B256,
rpc_payload_attributes: Self::RpcPayloadAttributes,
version: u8,
) -> Result<Self, Self::Error>
where
Self: Sized;

View File

@ -110,7 +110,11 @@ impl PayloadBuilderAttributes for CustomPayloadBuilderAttributes {
type RpcPayloadAttributes = CustomPayloadAttributes;
type Error = Infallible;
fn try_new(parent: B256, attributes: CustomPayloadAttributes) -> Result<Self, Infallible> {
fn try_new(
parent: B256,
attributes: CustomPayloadAttributes,
_version: u8,
) -> Result<Self, Infallible> {
Ok(Self(EthPayloadBuilderAttributes::new(parent, attributes.inner)))
}