From 51f563453ee7eb48b7c432559f0d629917d58d29 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 Jan 2025 20:25:43 +0100 Subject: [PATCH 1/2] feat: introduce maybe helpers for blob calc --- crates/consensus/src/block/header.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/consensus/src/block/header.rs b/crates/consensus/src/block/header.rs index be0ea2c1b4e..b5597c93c2e 100644 --- a/crates/consensus/src/block/header.rs +++ b/crates/consensus/src/block/header.rs @@ -639,6 +639,14 @@ pub trait BlockHeader { Some(blob_params.next_block_excess_blob_gas(self.excess_blob_gas()?, self.blob_gas_used()?)) } + /// Convenience function for [`Self::next_block_excess_blob_gas`] with an optional + /// [`BlobParams`] argument. + /// + /// Returns `None` if the `blob_params` are `None`. + fn maybe_next_block_excess_blob_gas(&self, blob_params: Option) -> Option { + self.next_block_excess_blob_gas(blob_params?) + } + /// Returns the blob fee for the next block according to the EIP-4844 spec. /// /// Returns `None` if `excess_blob_gas` is None. @@ -648,6 +656,14 @@ pub trait BlockHeader { Some(blob_params.calc_blob_fee(self.next_block_excess_blob_gas(blob_params)?)) } + /// Convenience function for [`Self::next_block_blob_fee`] with an optional [`BlobParams`] + /// argument. + /// + /// Returns `None` if the `blob_params` are `None`. + fn maybe_next_block_blob_fee(&self, blob_params: Option) -> Option { + self.next_block_blob_fee(blob_params?) + } + /// Calculate base fee for next block according to the EIP-1559 spec. /// /// Returns a `None` if no base fee is set, no EIP-1559 support From f7e0974d951e4ee70c3eb954b8d2055e2277c493 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 Jan 2025 20:28:53 +0100 Subject: [PATCH 2/2] feat: introduce maybe helpers for blob calc --- crates/consensus/src/block/header.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/consensus/src/block/header.rs b/crates/consensus/src/block/header.rs index b5597c93c2e..1f63a3b4873 100644 --- a/crates/consensus/src/block/header.rs +++ b/crates/consensus/src/block/header.rs @@ -643,7 +643,7 @@ pub trait BlockHeader { /// [`BlobParams`] argument. /// /// Returns `None` if the `blob_params` are `None`. - fn maybe_next_block_excess_blob_gas(&self, blob_params: Option) -> Option { + fn maybe_next_block_excess_blob_gas(&self, blob_params: Option) -> Option { self.next_block_excess_blob_gas(blob_params?) }