Feat: Extend BuiltPayload type (#10583)

Co-authored-by: Oliver <onbjerg@users.noreply.github.com>
This commit is contained in:
malik
2024-08-31 18:27:12 +01:00
committed by GitHub
parent 3efe22eae7
commit 17f6225fa5
7 changed files with 68 additions and 14 deletions

View File

@ -6,7 +6,7 @@ use reth_evm_ethereum::revm_spec_by_timestamp_after_merge;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
use reth_primitives::{
constants::EIP1559_INITIAL_BASE_FEE, Address, BlobTransactionSidecar, EthereumHardfork, Header,
SealedBlock, Withdrawals, B256, U256,
Receipt, SealedBlock, Withdrawals, B256, U256,
};
use reth_rpc_types::engine::{
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4,
@ -35,14 +35,21 @@ pub struct EthBuiltPayload {
/// The blobs, proofs, and commitments in the block. If the block is pre-cancun, this will be
/// empty.
pub(crate) sidecars: Vec<BlobTransactionSidecar>,
/// The receipts of the block
pub(crate) receipts: Vec<Receipt>,
}
// === impl BuiltPayload ===
impl EthBuiltPayload {
/// Initializes the payload with the given initial block.
pub const fn new(id: PayloadId, block: SealedBlock, fees: U256) -> Self {
Self { id, block, fees, sidecars: Vec::new() }
pub const fn new(
id: PayloadId,
block: SealedBlock,
fees: U256,
receipts: Vec<Receipt>,
) -> Self {
Self { id, block, fees, sidecars: Vec::new(), receipts }
}
/// Returns the identifier of the payload.
@ -79,6 +86,10 @@ impl BuiltPayload for EthBuiltPayload {
fn fees(&self) -> U256 {
self.fees
}
fn receipts(&self) -> &[Receipt] {
&self.receipts
}
}
impl<'a> BuiltPayload for &'a EthBuiltPayload {
@ -89,6 +100,10 @@ impl<'a> BuiltPayload for &'a EthBuiltPayload {
fn fees(&self) -> U256 {
(**self).fees()
}
fn receipts(&self) -> &[Receipt] {
&self.receipts
}
}
// V1 engine_getPayloadV1 response