feat: integrate blob_params_at_timestamp (#14128)

This commit is contained in:
joshieDo
2025-01-31 18:18:34 +00:00
committed by GitHub
parent 214f3b3b8e
commit d3acdda21b
11 changed files with 55 additions and 58 deletions

View File

@ -165,7 +165,13 @@ pub trait EthFees: LoadFee {
for header in &headers {
base_fee_per_gas.push(header.base_fee_per_gas().unwrap_or_default() as u128);
gas_used_ratio.push(header.gas_used() as f64 / header.gas_limit() as f64);
base_fee_per_blob_gas.push(header.blob_fee(BlobParams::cancun()).unwrap_or_default());
let blob_params = self.provider()
.chain_spec()
.blob_params_at_timestamp(header.timestamp())
.unwrap_or_else(BlobParams::cancun);
base_fee_per_blob_gas.push(header.blob_fee(blob_params).unwrap_or_default());
blob_gas_used_ratio.push(
header.blob_gas_used().unwrap_or_default() as f64
/ alloy_eips::eip4844::MAX_DATA_GAS_PER_BLOCK as f64,
@ -206,7 +212,12 @@ pub trait EthFees: LoadFee {
// Same goes for the `base_fee_per_blob_gas`:
// > "[..] includes the next block after the newest of the returned range, because this value can be derived from the newest block.
base_fee_per_blob_gas.push(last_header.next_block_blob_fee(BlobParams::cancun()).unwrap_or_default());
base_fee_per_blob_gas.push(
last_header
.maybe_next_block_blob_fee(
self.provider().chain_spec().blob_params_at_timestamp(last_header.timestamp())
).unwrap_or_default()
);
};
Ok(FeeHistory {
@ -331,7 +342,11 @@ pub trait LoadFee: LoadBlock {
async move {
self.block_with_senders(BlockNumberOrTag::Latest.into())
.await?
.and_then(|h| h.next_block_blob_fee(BlobParams::cancun()))
.and_then(|h| {
h.maybe_next_block_blob_fee(
self.provider().chain_spec().blob_params_at_timestamp(h.timestamp()),
)
})
.ok_or(EthApiError::ExcessBlobGasNotSet.into())
.map(U256::from)
}