Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pectra): Revert EIP-7742 #1807

Merged
merged 4 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions crates/consensus-any/src/block/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ pub struct AnyHeader {
/// EIP-7685 requests hash.
#[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))]
pub requests_hash: Option<B256>,
/// EIP-7744 target blob count.
#[cfg_attr(
feature = "serde",
serde(
default,
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)
)]
pub target_blobs_per_block: Option<u64>,
}

impl AnyHeader {
Expand Down Expand Up @@ -142,7 +132,6 @@ impl AnyHeader {
excess_blob_gas,
parent_beacon_block_root,
requests_hash,
target_blobs_per_block,
} = self;

Ok(Header {
Expand All @@ -167,7 +156,6 @@ impl AnyHeader {
excess_blob_gas,
parent_beacon_block_root,
requests_hash,
target_blobs_per_block,
})
}

Expand Down Expand Up @@ -197,7 +185,6 @@ impl AnyHeader {
excess_blob_gas,
parent_beacon_block_root,
requests_hash,
target_blobs_per_block,
} = self;

Header {
Expand All @@ -222,7 +209,6 @@ impl AnyHeader {
excess_blob_gas,
parent_beacon_block_root,
requests_hash,
target_blobs_per_block,
}
}
}
Expand Down Expand Up @@ -308,10 +294,6 @@ impl BlockHeader for AnyHeader {
self.requests_hash
}

fn target_blobs_per_block(&self) -> Option<u64> {
self.target_blobs_per_block
}

fn extra_data(&self) -> &Bytes {
&self.extra_data
}
Expand Down Expand Up @@ -341,7 +323,6 @@ impl From<Header> for AnyHeader {
excess_blob_gas,
parent_beacon_block_root,
requests_hash,
target_blobs_per_block,
} = value;

Self {
Expand All @@ -366,7 +347,6 @@ impl From<Header> for AnyHeader {
excess_blob_gas,
parent_beacon_block_root,
requests_hash,
target_blobs_per_block,
}
}
}
Expand Down
72 changes: 2 additions & 70 deletions crates/consensus/src/block/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use alloy_eips::{
eip1559::{calc_next_block_base_fee, BaseFeeParams},
eip1898::BlockWithParent,
eip4844::{self},
eip7742,
merge::ALLOWED_FUTURE_BLOCK_TIME_SECONDS,
BlockNumHash,
};
Expand Down Expand Up @@ -127,18 +126,6 @@ pub struct Header {
/// [EIP-7685]: https://eips.ethereum.org/EIPS/eip-7685
#[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))]
pub requests_hash: Option<B256>,
/// The target number of blobs in the block, introduced in [EIP-7742].
///
/// [EIP-7742]: https://eips.ethereum.org/EIPS/eip-7742
#[cfg_attr(
feature = "serde",
serde(
default,
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)
)]
pub target_blobs_per_block: Option<u64>,
}

impl AsRef<Self> for Header {
Expand Down Expand Up @@ -171,7 +158,6 @@ impl Default for Header {
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_hash: None,
target_blobs_per_block: None,
}
}
}
Expand Down Expand Up @@ -233,24 +219,12 @@ impl Header {
/// Calculate excess blob gas for the next block according to the EIP-4844
/// spec.
///
/// If [`Self::target_blobs_per_block`] is [`Some`], uses EIP-7742 formula for calculating
/// the excess blob gas, otherwise uses EIP-4844 formula.
///
/// Returns a `None` if no excess blob gas is set, no EIP-4844 support
pub fn next_block_excess_blob_gas(&self) -> Option<u64> {
let excess_blob_gas = self.excess_blob_gas?;
let blob_gas_used = self.blob_gas_used?;

Some(self.target_blobs_per_block.map_or_else(
|| eip4844::calc_excess_blob_gas(excess_blob_gas, blob_gas_used),
|target_blobs_per_block| {
eip7742::calc_excess_blob_gas(
excess_blob_gas,
blob_gas_used,
target_blobs_per_block,
)
},
))
Some(eip4844::calc_excess_blob_gas(excess_blob_gas, blob_gas_used))
}

/// Calculate a heuristic for the in-memory size of the [Header].
Expand Down Expand Up @@ -325,10 +299,6 @@ impl Header {
length += requests_hash.length();
}

if let Some(target_blobs_per_block) = self.target_blobs_per_block {
length += target_blobs_per_block.length();
}

length
}

Expand Down Expand Up @@ -407,10 +377,6 @@ impl Encodable for Header {
if let Some(ref requests_hash) = self.requests_hash {
requests_hash.encode(out);
}

if let Some(ref target_blobs_per_block) = self.target_blobs_per_block {
target_blobs_per_block.encode(out);
}
}

fn length(&self) -> usize {
Expand Down Expand Up @@ -450,7 +416,6 @@ impl Decodable for Header {
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_hash: None,
target_blobs_per_block: None,
};
if started_len - buf.len() < rlp_head.payload_length {
this.base_fee_per_gas = Some(u64::decode(buf)?);
Expand Down Expand Up @@ -480,11 +445,6 @@ impl Decodable for Header {
this.requests_hash = Some(B256::decode(buf)?);
}

// Decode target blob count.
if started_len - buf.len() < rlp_head.payload_length {
this.target_blobs_per_block = Some(u64::decode(buf)?);
}

let consumed = started_len - buf.len();
if consumed != rlp_head.payload_length {
return Err(alloy_rlp::Error::ListLengthMismatch {
Expand Down Expand Up @@ -561,7 +521,6 @@ impl<'a> arbitrary::Arbitrary<'a> for Header {
parent_beacon_block_root: u.arbitrary()?,
requests_hash: u.arbitrary()?,
withdrawals_root: u.arbitrary()?,
target_blobs_per_block: u.arbitrary()?,
};

Ok(generate_valid_header(
Expand Down Expand Up @@ -637,9 +596,6 @@ pub trait BlockHeader {
/// Retrieves the requests hash of the block, if available
fn requests_hash(&self) -> Option<B256>;

/// Retrieves the target blob count of the block, if available
fn target_blobs_per_block(&self) -> Option<u64>;

/// Retrieves the block's extra data field
fn extra_data(&self) -> &Bytes;

Expand All @@ -653,24 +609,12 @@ pub trait BlockHeader {
/// Calculate excess blob gas for the next block according to the EIP-4844
/// spec.
///
/// If [`BlockHeader::target_blobs_per_block`] is [`Some`], uses EIP-7742 formula for
/// calculating the excess blob gas, otherwise uses EIP-4844 formula.
///
/// Returns a `None` if no excess blob gas is set, no EIP-4844 support
fn next_block_excess_blob_gas(&self) -> Option<u64> {
let excess_blob_gas = self.excess_blob_gas()?;
let blob_gas_used = self.blob_gas_used()?;

Some(self.target_blobs_per_block().map_or_else(
|| eip4844::calc_excess_blob_gas(excess_blob_gas, blob_gas_used),
|target_blobs_per_block| {
eip7742::calc_excess_blob_gas(
excess_blob_gas,
blob_gas_used,
target_blobs_per_block,
)
},
))
Some(eip4844::calc_excess_blob_gas(excess_blob_gas, blob_gas_used))
}

/// Returns the blob fee for the next block according to the EIP-4844 spec.
Expand Down Expand Up @@ -821,10 +765,6 @@ impl BlockHeader for Header {
self.requests_hash
}

fn target_blobs_per_block(&self) -> Option<u64> {
self.target_blobs_per_block
}

fn extra_data(&self) -> &Bytes {
&self.extra_data
}
Expand Down Expand Up @@ -912,10 +852,6 @@ impl<T: BlockHeader> BlockHeader for alloy_serde::WithOtherFields<T> {
self.inner.requests_hash()
}

fn target_blobs_per_block(&self) -> Option<u64> {
self.inner.target_blobs_per_block()
}

fn extra_data(&self) -> &Bytes {
self.inner.extra_data()
}
Expand Down Expand Up @@ -976,8 +912,6 @@ pub(crate) mod serde_bincode_compat {
parent_beacon_block_root: Option<B256>,
#[serde(default)]
requests_hash: Option<B256>,
#[serde(default)]
target_blobs_per_block: Option<u64>,
extra_data: Cow<'a, Bytes>,
}

Expand Down Expand Up @@ -1005,7 +939,6 @@ pub(crate) mod serde_bincode_compat {
parent_beacon_block_root: value.parent_beacon_block_root,
requests_hash: value.requests_hash,
extra_data: Cow::Borrowed(&value.extra_data),
target_blobs_per_block: value.target_blobs_per_block,
}
}
}
Expand Down Expand Up @@ -1034,7 +967,6 @@ pub(crate) mod serde_bincode_compat {
parent_beacon_block_root: value.parent_beacon_block_root,
requests_hash: value.requests_hash,
extra_data: value.extra_data.into_owned(),
target_blobs_per_block: value.target_blobs_per_block,
}
}
}
Expand Down
18 changes: 0 additions & 18 deletions crates/eips/src/eip7742.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/eips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,3 @@ pub mod eip7685;
pub mod eip7691;

pub mod eip7702;

pub mod eip7742;
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,5 @@
}
]
},
"target_blobs_per_block": "6",
"signature": "0xa37afc405ef69e4f331e79f9de77e0df870609898c0e10a1cfcd8162e8771c4e4fefa7258059d83f72fb599b12f1bb73068476ebfaedc65e5a068425693ba272f277d83e11334e87a7d1425a2fbd369ed9351f0eb14fdc8bd93115543f6a4c67"
}
10 changes: 0 additions & 10 deletions crates/rpc-types-beacon/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ struct BeaconPayloadAttributes {
withdrawals: Option<Vec<Withdrawal>>,
#[serde(skip_serializing_if = "Option::is_none")]
parent_beacon_block_root: Option<B256>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde_as(as = "Option<DisplayFromStr>")]
target_blobs_per_block: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde_as(as = "Option<DisplayFromStr>")]
max_blobs_per_block: Option<u64>,
}

/// Optimism Payload Attributes
Expand Down Expand Up @@ -155,8 +149,6 @@ pub mod beacon_api_payload_attributes {
suggested_fee_recipient: payload_attributes.suggested_fee_recipient,
withdrawals: payload_attributes.withdrawals.clone(),
parent_beacon_block_root: payload_attributes.parent_beacon_block_root,
target_blobs_per_block: payload_attributes.target_blobs_per_block,
max_blobs_per_block: payload_attributes.max_blobs_per_block,
};
beacon_api_payload_attributes.serialize(serializer)
}
Expand All @@ -173,8 +165,6 @@ pub mod beacon_api_payload_attributes {
suggested_fee_recipient: beacon_api_payload_attributes.suggested_fee_recipient,
withdrawals: beacon_api_payload_attributes.withdrawals,
parent_beacon_block_root: beacon_api_payload_attributes.parent_beacon_block_root,
target_blobs_per_block: beacon_api_payload_attributes.target_blobs_per_block,
max_blobs_per_block: beacon_api_payload_attributes.max_blobs_per_block,
})
}
}
Expand Down
3 changes: 0 additions & 3 deletions crates/rpc-types-beacon/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ pub struct SignedBidSubmissionV4 {
pub blobs_bundle: BlobsBundleV1,
/// The Pectra execution requests for this bid.
pub execution_requests: ExecutionRequestsV4,
/// The EIP-7742 blobs per block for this bid.
#[serde_as(as = "DisplayFromStr")]
pub target_blobs_per_block: u64,
/// The signature associated with the submission.
pub signature: BlsSignature,
}
Expand Down
20 changes: 0 additions & 20 deletions crates/rpc-types-engine/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,26 +699,6 @@ pub struct PayloadAttributes {
/// See also <https://github.com/ethereum/execution-apis/blob/main/src/engine/cancun.md#payloadattributesv3>
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub parent_beacon_block_root: Option<B256>,
/// Target blob count for the block enabled with V4.
#[cfg_attr(
feature = "serde",
serde(
default,
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)
)]
pub target_blobs_per_block: Option<u64>,
/// Max blob count for block enabled with V4.
#[cfg_attr(
feature = "serde",
serde(
default,
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)
)]
pub max_blobs_per_block: Option<u64>,
}

/// This structure contains the result of processing a payload or fork choice update.
Expand Down
11 changes: 2 additions & 9 deletions crates/rpc-types-engine/src/prague.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ use alloy_primitives::B256;
pub struct PraguePayloadFields {
/// EIP-7685 requests.
pub requests: RequestsOrHash,
/// EIP-7742 target number of blobs in the block.
pub target_blobs_per_block: u64,
}

impl PraguePayloadFields {
/// Returns a new [`PraguePayloadFields`] instance.
pub fn new(requests: impl Into<RequestsOrHash>, target_blobs_per_block: u64) -> Self {
Self { requests: requests.into(), target_blobs_per_block }
pub fn new(requests: impl Into<RequestsOrHash>) -> Self {
Self { requests: requests.into() }
}
}

Expand All @@ -45,11 +43,6 @@ impl MaybePraguePayloadFields {
self.fields.as_ref().and_then(|fields| fields.requests.requests())
}

/// Returns the target blobs per block, if any.
pub fn target_blobs_per_block(&self) -> Option<u64> {
self.fields.as_ref().map(|fields| fields.target_blobs_per_block)
}

/// Calculates or retrieves the requests hash.
///
/// - If the `prague` field contains a list of requests, it calculates the requests hash
Expand Down
Loading
Loading