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

@ -14,9 +14,8 @@ extern crate alloc;
use alloc::sync::Arc;
use alloy_consensus::{BlockHeader as _, EMPTY_OMMER_ROOT_HASH};
use alloy_eips::eip7840::BlobParams;
use alloy_primitives::{B64, U256};
use reth_chainspec::EthereumHardforks;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_consensus::{
Consensus, ConsensusError, FullConsensus, HeaderValidator, PostExecutionInput,
};
@ -149,8 +148,8 @@ impl<H: BlockHeader> HeaderValidator<H> for OpBeaconConsensus {
}
// ensure that the blob gas fields for this block
if self.chain_spec.is_cancun_active_at_timestamp(header.timestamp()) {
validate_against_parent_4844(header.header(), parent.header(), BlobParams::cancun())?;
if let Some(blob_params) = self.chain_spec.blob_params_at_timestamp(header.timestamp()) {
validate_against_parent_4844(header.header(), parent.header(), blob_params)?;
}
Ok(())

View File

@ -14,10 +14,10 @@ extern crate alloc;
use alloc::sync::Arc;
use alloy_consensus::{BlockHeader, Header};
use alloy_eips::eip7840::BlobParams;
use alloy_primitives::{Address, U256};
use core::fmt::Debug;
use op_alloy_consensus::EIP1559ParamError;
use reth_chainspec::EthChainSpec;
use reth_evm::{env::EvmEnv, ConfigureEvm, ConfigureEvmEnv, Database, Evm, NextBlockEnvAttributes};
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_primitives::OpTransactionSigned;
@ -194,7 +194,9 @@ impl ConfigureEvmEnv for OpEvmConfig {
// if the parent block did not have excess blob gas (i.e. it was pre-cancun), but it is
// cancun now, we need to set the excess blob gas to the default value(0)
let blob_excess_gas_and_price = parent
.next_block_excess_blob_gas(BlobParams::cancun())
.maybe_next_block_excess_blob_gas(
self.chain_spec().blob_params_at_timestamp(attributes.timestamp),
)
.or_else(|| (spec_id.is_enabled_in(SpecId::CANCUN)).then_some(0))
.map(|gas| BlobExcessGasAndPrice::new(gas, false));