feat: add Payload build abstraction (#2143)

This commit is contained in:
Matthias Seitz
2023-04-06 20:48:31 +02:00
committed by GitHub
parent f90f734a76
commit 2fd2825e24
9 changed files with 210 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
use super::{PayloadStatus, PayloadStatusEnum};
use reth_primitives::{H256, H64};
use crate::engine::PayloadId;
use reth_primitives::H256;
use serde::{Deserialize, Serialize};
/// This structure encapsulates the fork choice state
@@ -15,7 +16,7 @@ pub struct ForkchoiceState {
#[serde(rename_all = "camelCase")]
pub struct ForkchoiceUpdated {
pub payload_status: PayloadStatus,
pub payload_id: Option<H64>,
pub payload_id: Option<PayloadId>,
}
impl ForkchoiceUpdated {
@@ -32,7 +33,7 @@ impl ForkchoiceUpdated {
self
}
pub fn with_payload_id(mut self, id: H64) -> Self {
pub fn with_payload_id(mut self, id: PayloadId) -> Self {
self.payload_id = Some(id);
self
}

View File

@@ -2,11 +2,24 @@ use reth_primitives::{
constants::MIN_PROTOCOL_BASE_FEE_U256,
proofs::{self, EMPTY_LIST_HASH},
Address, Block, Bloom, Bytes, Header, SealedBlock, TransactionSigned, UintTryTo, Withdrawal,
H256, U256, U64,
H256, H64, U256, U64,
};
use reth_rlp::{Decodable, Encodable};
use serde::{ser::SerializeMap, Deserialize, Serialize, Serializer};
/// And 8-byte identifier for an execution payload.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub struct PayloadId(H64);
// === impl PayloadId ===
impl PayloadId {
/// Creates a new payload id from the given identifier.
pub fn new(id: [u8; 8]) -> Self {
Self(H64::from(id))
}
}
/// This structure maps on the ExecutionPayload structure of the beacon chain spec.
///
/// See also: <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#executionpayloadv1>