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: introduce maybe helpers for blob calc #1962

Merged
merged 2 commits into from
Jan 29, 2025
Merged
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
16 changes: 16 additions & 0 deletions crates/consensus/src/block/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlobParams>) -> Option<u64> {
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.
Expand All @@ -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<BlobParams>) -> Option<u128> {
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
Expand Down