diff --git a/crates/provider/src/ext/engine.rs b/crates/provider/src/ext/engine.rs index 42456fb3402c..de7e1fded714 100644 --- a/crates/provider/src/ext/engine.rs +++ b/crates/provider/src/ext/engine.rs @@ -4,8 +4,8 @@ use alloy_primitives::{BlockHash, B256}; use alloy_rpc_types_engine::{ ClientVersionV1, ExecutionPayloadBodiesV1, ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4, ExecutionPayloadInputV2, - ExecutionPayloadV1, ExecutionPayloadV3, ExecutionPayloadV4, ForkchoiceState, ForkchoiceUpdated, - PayloadAttributes, PayloadId, PayloadStatus, + ExecutionPayloadV1, ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadAttributes, + PayloadId, PayloadStatus, }; use alloy_transport::{Transport, TransportResult}; @@ -46,9 +46,11 @@ pub trait EngineApi: Send + Sync { /// See also async fn new_payload_v4( &self, - payload: ExecutionPayloadV4, + payload: ExecutionPayloadV3, versioned_hashes: Vec, parent_beacon_block_root: B256, + // TODO + execution_requests: Vec, ) -> TransportResult; /// Updates the execution layer client with the given fork choice, as specified for the Paris @@ -210,7 +212,7 @@ where async fn new_payload_v4( &self, - payload: ExecutionPayloadV4, + payload: ExecutionPayloadV3, versioned_hashes: Vec, parent_beacon_block_root: B256, ) -> TransportResult { diff --git a/crates/rpc-types-beacon/src/payload.rs b/crates/rpc-types-beacon/src/payload.rs index d6a68b1d95e1..47e776ce967a 100644 --- a/crates/rpc-types-beacon/src/payload.rs +++ b/crates/rpc-types-beacon/src/payload.rs @@ -16,7 +16,6 @@ use alloy_eips::{ use alloy_primitives::{Address, Bloom, Bytes, B256, U256}; use alloy_rpc_types_engine::{ ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, - ExecutionPayloadV4, }; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_with::{serde_as, DeserializeAs, DisplayFromStr, SerializeAs}; @@ -406,76 +405,6 @@ pub mod beacon_payload_v3 { } } -#[serde_as] -#[derive(Debug, Serialize, Deserialize)] -struct BeaconExecutionPayloadV4<'a> { - /// Inner V1 payload - #[serde(flatten)] - payload_inner: BeaconExecutionPayloadV3<'a>, - deposit_requests: Vec, - withdrawal_requests: Vec, - consolidation_requests: Vec, -} - -impl<'a> From> for ExecutionPayloadV4 { - fn from(payload: BeaconExecutionPayloadV4<'a>) -> Self { - let BeaconExecutionPayloadV4 { - payload_inner, - deposit_requests, - withdrawal_requests, - consolidation_requests, - } = payload; - Self { - payload_inner: payload_inner.into(), - deposit_requests, - withdrawal_requests, - consolidation_requests, - } - } -} - -impl<'a> From<&'a ExecutionPayloadV4> for BeaconExecutionPayloadV4<'a> { - fn from(value: &'a ExecutionPayloadV4) -> Self { - let ExecutionPayloadV4 { - payload_inner, - deposit_requests, - withdrawal_requests, - consolidation_requests, - } = value; - BeaconExecutionPayloadV4 { - payload_inner: payload_inner.into(), - deposit_requests: deposit_requests.clone(), - withdrawal_requests: withdrawal_requests.clone(), - consolidation_requests: consolidation_requests.clone(), - } - } -} - -/// A helper serde module to convert from/to the Beacon API which uses quoted decimals rather than -/// big-endian hex. -pub mod beacon_payload_v4 { - use super::*; - - /// Serialize the payload attributes for the beacon API. - pub fn serialize( - payload_attributes: &ExecutionPayloadV4, - serializer: S, - ) -> Result - where - S: Serializer, - { - BeaconExecutionPayloadV4::from(payload_attributes).serialize(serializer) - } - - /// Deserialize the payload attributes for the beacon API. - pub fn deserialize<'de, D>(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - BeaconExecutionPayloadV4::deserialize(deserializer).map(Into::into) - } -} - /// Represents all possible payload versions. #[derive(Debug, Serialize)] #[serde(untagged)] @@ -486,8 +415,6 @@ enum BeaconExecutionPayload<'a> { V2(BeaconExecutionPayloadV2<'a>), /// V3 payload V3(BeaconExecutionPayloadV3<'a>), - /// V4 payload - V4(BeaconExecutionPayloadV4<'a>), } // Deserializes untagged ExecutionPayload by trying each variant in falling order @@ -499,13 +426,11 @@ impl<'de> Deserialize<'de> for BeaconExecutionPayload<'de> { #[derive(Deserialize)] #[serde(untagged)] enum BeaconExecutionPayloadDesc<'a> { - V4(BeaconExecutionPayloadV4<'a>), V3(BeaconExecutionPayloadV3<'a>), V2(BeaconExecutionPayloadV2<'a>), V1(BeaconExecutionPayloadV1<'a>), } match BeaconExecutionPayloadDesc::deserialize(deserializer)? { - BeaconExecutionPayloadDesc::V4(payload) => Ok(Self::V4(payload)), BeaconExecutionPayloadDesc::V3(payload) => Ok(Self::V3(payload)), BeaconExecutionPayloadDesc::V2(payload) => Ok(Self::V2(payload)), BeaconExecutionPayloadDesc::V1(payload) => Ok(Self::V1(payload)), @@ -519,7 +444,6 @@ impl<'a> From> for ExecutionPayload { BeaconExecutionPayload::V1(payload) => Self::V1(ExecutionPayloadV1::from(payload)), BeaconExecutionPayload::V2(payload) => Self::V2(ExecutionPayloadV2::from(payload)), BeaconExecutionPayload::V3(payload) => Self::V3(ExecutionPayloadV3::from(payload)), - BeaconExecutionPayload::V4(payload) => Self::V4(ExecutionPayloadV4::from(payload)), } } } @@ -536,9 +460,6 @@ impl<'a> From<&'a ExecutionPayload> for BeaconExecutionPayload<'a> { ExecutionPayload::V3(payload) => { BeaconExecutionPayload::V3(BeaconExecutionPayloadV3::from(payload)) } - ExecutionPayload::V4(payload) => { - BeaconExecutionPayload::V4(BeaconExecutionPayloadV4::from(payload)) - } } } } diff --git a/crates/rpc-types-beacon/src/relay.rs b/crates/rpc-types-beacon/src/relay.rs index 77963d57a617..51a3710192b8 100644 --- a/crates/rpc-types-beacon/src/relay.rs +++ b/crates/rpc-types-beacon/src/relay.rs @@ -6,7 +6,6 @@ use crate::{BlsPublicKey, BlsSignature}; use alloy_primitives::{Address, B256, U256}; use alloy_rpc_types_engine::{ BlobsBundleV1, ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, - ExecutionPayloadV4, }; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, DisplayFromStr}; @@ -148,10 +147,12 @@ pub struct SignedBidSubmissionV4 { /// The [`BidTrace`] message associated with the submission. pub message: BidTrace, /// The execution payload for the submission. - #[serde(with = "crate::payload::beacon_payload_v4")] - pub execution_payload: ExecutionPayloadV4, + #[serde(with = "crate::payload::beacon_payload_v3")] + pub execution_payload: ExecutionPayloadV3, /// The Electra block bundle for this bid. pub blobs_bundle: BlobsBundleV1, + /// The Pectra execution requests for this bid. + pub execution_requests: Vec, /// The signature associated with the submission. pub signature: BlsSignature, } diff --git a/crates/rpc-types-engine/src/payload.rs b/crates/rpc-types-engine/src/payload.rs index faa00b4af97d..00ade06c0462 100644 --- a/crates/rpc-types-engine/src/payload.rs +++ b/crates/rpc-types-engine/src/payload.rs @@ -139,8 +139,8 @@ pub struct ExecutionPayloadEnvelopeV3 { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct ExecutionPayloadEnvelopeV4 { - /// Execution payload V4 - pub execution_payload: ExecutionPayloadV4, + /// Execution payload V3 + pub execution_payload: ExecutionPayloadV3, /// The expected value to be received by the feeRecipient in wei pub block_value: U256, /// The blobs, commitments, and proofs associated with the executed payload. @@ -148,6 +148,8 @@ pub struct ExecutionPayloadEnvelopeV4 { /// Introduced in V3, this represents a suggestion from the execution layer if the payload /// should be used instead of an externally provided one. pub should_override_builder: bool, + /// TODO + pub execution_requests: Vec, } /// This structure maps on the ExecutionPayload structure of the beacon chain spec. @@ -444,157 +446,6 @@ impl ssz::Encode for ExecutionPayloadV3 { } } -/// This structure maps on the ExecutionPayloadV4 structure of the beacon chain spec. -/// -/// See also: -/// -/// This structure has the syntax of ExecutionPayloadV3 and appends the new fields: depositRequests -/// and withdrawalRequests. -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct ExecutionPayloadV4 { - /// Inner V3 payload - #[cfg_attr(feature = "serde", serde(flatten))] - pub payload_inner: ExecutionPayloadV3, - /// Array of deposit requests. - /// - /// This maps directly to the deposit requests defined in [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110). - pub deposit_requests: Vec, - /// Array of execution layer triggerable withdrawal requests. - /// - /// See [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002). - pub withdrawal_requests: Vec, - /// Array of consolidation requests. - /// - /// See [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251). - pub consolidation_requests: Vec, -} - -impl ExecutionPayloadV4 { - /// Returns the withdrawals for the payload. - pub const fn withdrawals(&self) -> &Vec { - self.payload_inner.withdrawals() - } - - /// Returns the timestamp for the payload. - pub const fn timestamp(&self) -> u64 { - self.payload_inner.payload_inner.timestamp() - } -} - -#[cfg(feature = "ssz")] -impl ssz::Decode for ExecutionPayloadV4 { - fn is_ssz_fixed_len() -> bool { - false - } - - fn from_ssz_bytes(bytes: &[u8]) -> Result { - let mut builder = ssz::SszDecoderBuilder::new(bytes); - - builder.register_type::()?; - builder.register_type::
()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::>()?; - builder.register_type::>()?; - builder.register_type::()?; - builder.register_type::()?; - builder.register_type::>()?; - builder.register_type::>()?; - builder.register_type::>()?; - - let mut decoder = builder.build()?; - - Ok(Self { - payload_inner: ExecutionPayloadV3 { - payload_inner: ExecutionPayloadV2 { - payload_inner: ExecutionPayloadV1 { - parent_hash: decoder.decode_next()?, - fee_recipient: decoder.decode_next()?, - state_root: decoder.decode_next()?, - receipts_root: decoder.decode_next()?, - logs_bloom: decoder.decode_next()?, - prev_randao: decoder.decode_next()?, - block_number: decoder.decode_next()?, - gas_limit: decoder.decode_next()?, - gas_used: decoder.decode_next()?, - timestamp: decoder.decode_next()?, - extra_data: decoder.decode_next()?, - base_fee_per_gas: decoder.decode_next()?, - block_hash: decoder.decode_next()?, - transactions: decoder.decode_next()?, - }, - withdrawals: decoder.decode_next()?, - }, - blob_gas_used: decoder.decode_next()?, - excess_blob_gas: decoder.decode_next()?, - }, - deposit_requests: decoder.decode_next()?, - withdrawal_requests: decoder.decode_next()?, - consolidation_requests: decoder.decode_next()?, - }) - } -} - -#[cfg(feature = "ssz")] -impl ssz::Encode for ExecutionPayloadV4 { - fn is_ssz_fixed_len() -> bool { - false - } - - fn ssz_append(&self, buf: &mut Vec) { - let offset = ::ssz_fixed_len() * 5 - +
::ssz_fixed_len() - + ::ssz_fixed_len() - + ::ssz_fixed_len() * 6 - + ::ssz_fixed_len() - + ssz::BYTES_PER_LENGTH_OFFSET * 6; - - let mut encoder = ssz::SszEncoder::container(buf, offset); - - encoder.append(&self.payload_inner.payload_inner.payload_inner.parent_hash); - encoder.append(&self.payload_inner.payload_inner.payload_inner.fee_recipient); - encoder.append(&self.payload_inner.payload_inner.payload_inner.state_root); - encoder.append(&self.payload_inner.payload_inner.payload_inner.receipts_root); - encoder.append(&self.payload_inner.payload_inner.payload_inner.logs_bloom); - encoder.append(&self.payload_inner.payload_inner.payload_inner.prev_randao); - encoder.append(&self.payload_inner.payload_inner.payload_inner.block_number); - encoder.append(&self.payload_inner.payload_inner.payload_inner.gas_limit); - encoder.append(&self.payload_inner.payload_inner.payload_inner.gas_used); - encoder.append(&self.payload_inner.payload_inner.payload_inner.timestamp); - encoder.append(&self.payload_inner.payload_inner.payload_inner.extra_data); - encoder.append(&self.payload_inner.payload_inner.payload_inner.base_fee_per_gas); - encoder.append(&self.payload_inner.payload_inner.payload_inner.block_hash); - encoder.append(&self.payload_inner.payload_inner.payload_inner.transactions); - encoder.append(&self.payload_inner.payload_inner.withdrawals); - encoder.append(&self.payload_inner.blob_gas_used); - encoder.append(&self.payload_inner.excess_blob_gas); - encoder.append(&self.deposit_requests); - encoder.append(&self.withdrawal_requests); - encoder.append(&self.consolidation_requests); - - encoder.finalize(); - } - - fn ssz_bytes_len(&self) -> usize { - ::ssz_bytes_len(&self.payload_inner) - + ssz::BYTES_PER_LENGTH_OFFSET * 3 - + self.deposit_requests.ssz_bytes_len() - + self.withdrawal_requests.ssz_bytes_len() - + self.consolidation_requests.ssz_bytes_len() - } -} - /// This includes all bundled blob related data of an executed payload. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -733,8 +584,6 @@ pub enum ExecutionPayload { V2(ExecutionPayloadV2), /// V3 payload V3(ExecutionPayloadV3), - /// V4 payload - V4(ExecutionPayloadV4), } impl ExecutionPayload { @@ -744,7 +593,6 @@ impl ExecutionPayload { Self::V1(payload) => payload, Self::V2(payload) => &payload.payload_inner, Self::V3(payload) => &payload.payload_inner.payload_inner, - Self::V4(payload) => &payload.payload_inner.payload_inner.payload_inner, } } @@ -754,7 +602,6 @@ impl ExecutionPayload { Self::V1(payload) => payload, Self::V2(payload) => &mut payload.payload_inner, Self::V3(payload) => &mut payload.payload_inner.payload_inner, - Self::V4(payload) => &mut payload.payload_inner.payload_inner.payload_inner, } } @@ -764,7 +611,6 @@ impl ExecutionPayload { Self::V1(payload) => payload, Self::V2(payload) => payload.payload_inner, Self::V3(payload) => payload.payload_inner.payload_inner, - Self::V4(payload) => payload.payload_inner.payload_inner.payload_inner, } } @@ -774,7 +620,6 @@ impl ExecutionPayload { Self::V1(_) => None, Self::V2(payload) => Some(payload), Self::V3(payload) => Some(&payload.payload_inner), - Self::V4(payload) => Some(&payload.payload_inner.payload_inner), } } @@ -784,7 +629,6 @@ impl ExecutionPayload { Self::V1(_) => None, Self::V2(payload) => Some(payload), Self::V3(payload) => Some(&mut payload.payload_inner), - Self::V4(payload) => Some(&mut payload.payload_inner.payload_inner), } } @@ -793,7 +637,6 @@ impl ExecutionPayload { match self { Self::V1(_) | Self::V2(_) => None, Self::V3(payload) => Some(payload), - Self::V4(payload) => Some(&payload.payload_inner), } } @@ -802,23 +645,6 @@ impl ExecutionPayload { match self { Self::V1(_) | Self::V2(_) => None, Self::V3(payload) => Some(payload), - Self::V4(payload) => Some(&mut payload.payload_inner), - } - } - - /// Returns a reference to the V4 payload, if any. - pub const fn as_v4(&self) -> Option<&ExecutionPayloadV4> { - match self { - Self::V1(_) | Self::V2(_) | Self::V3(_) => None, - Self::V4(payload) => Some(payload), - } - } - - /// Returns a mutable reference to the V4 payload, if any. - pub fn as_v4_mut(&mut self) -> Option<&mut ExecutionPayloadV4> { - match self { - Self::V1(_) | Self::V2(_) | Self::V3(_) => None, - Self::V4(payload) => Some(payload), } } @@ -879,12 +705,6 @@ impl From for ExecutionPayload { } } -impl From for ExecutionPayload { - fn from(payload: ExecutionPayloadV4) -> Self { - Self::V4(payload) - } -} - // Deserializes untagged ExecutionPayload by trying each variant in falling order #[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ExecutionPayload { @@ -895,13 +715,11 @@ impl<'de> serde::Deserialize<'de> for ExecutionPayload { #[derive(serde::Deserialize)] #[serde(untagged)] enum ExecutionPayloadDesc { - V4(ExecutionPayloadV4), V3(ExecutionPayloadV3), V2(ExecutionPayloadV2), V1(ExecutionPayloadV1), } match ExecutionPayloadDesc::deserialize(deserializer)? { - ExecutionPayloadDesc::V4(payload) => Ok(Self::V4(payload)), ExecutionPayloadDesc::V3(payload) => Ok(Self::V3(payload)), ExecutionPayloadDesc::V2(payload) => Ok(Self::V2(payload)), ExecutionPayloadDesc::V1(payload) => Ok(Self::V1(payload)),