chore: alloy 0.4 (#11334)

This commit is contained in:
Matthias Seitz
2024-09-30 14:48:37 +02:00
committed by GitHub
parent e8153e5e2c
commit a5538bc041
80 changed files with 425 additions and 518 deletions

View File

@ -16,8 +16,8 @@ use revm_primitives::calc_excess_blob_gas;
pub const fn validate_header_gas(header: &Header) -> Result<(), ConsensusError> {
if header.gas_used > header.gas_limit {
return Err(ConsensusError::HeaderGasUsedExceedsGasLimit {
gas_used: header.gas_used as u64,
gas_limit: header.gas_limit as u64,
gas_used: header.gas_used,
gas_limit: header.gas_limit,
})
}
Ok(())
@ -66,8 +66,7 @@ pub fn validate_shanghai_withdrawals(block: &SealedBlock) -> Result<(), Consensu
pub fn validate_cancun_gas(block: &SealedBlock) -> Result<(), ConsensusError> {
// Check that the blob gas used in the header matches the sum of the blob gas used by each
// blob tx
let header_blob_gas_used =
block.blob_gas_used.ok_or(ConsensusError::BlobGasUsedMissing)? as u64;
let header_blob_gas_used = block.blob_gas_used.ok_or(ConsensusError::BlobGasUsedMissing)?;
let total_blob_gas = block.blob_gas_used();
if total_blob_gas != header_blob_gas_used {
return Err(ConsensusError::BlobGasUsedDiff(GotExpected {
@ -151,25 +150,25 @@ pub fn validate_4844_header_standalone(header: &Header) -> Result<(), ConsensusE
return Err(ConsensusError::ParentBeaconBlockRootMissing)
}
if blob_gas_used as u64 > MAX_DATA_GAS_PER_BLOCK {
if blob_gas_used > MAX_DATA_GAS_PER_BLOCK {
return Err(ConsensusError::BlobGasUsedExceedsMaxBlobGasPerBlock {
blob_gas_used: blob_gas_used as u64,
blob_gas_used,
max_blob_gas_per_block: MAX_DATA_GAS_PER_BLOCK,
})
}
if blob_gas_used as u64 % DATA_GAS_PER_BLOB != 0 {
if blob_gas_used % DATA_GAS_PER_BLOB != 0 {
return Err(ConsensusError::BlobGasUsedNotMultipleOfBlobGasPerBlob {
blob_gas_used: blob_gas_used as u64,
blob_gas_used,
blob_gas_per_blob: DATA_GAS_PER_BLOB,
})
}
// `excess_blob_gas` must also be a multiple of `DATA_GAS_PER_BLOB`. This will be checked later
// (via `calc_excess_blob_gas`), but it doesn't hurt to catch the problem sooner.
if excess_blob_gas as u64 % DATA_GAS_PER_BLOB != 0 {
if excess_blob_gas % DATA_GAS_PER_BLOB != 0 {
return Err(ConsensusError::ExcessBlobGasNotMultipleOfBlobGasPerBlob {
excess_blob_gas: excess_blob_gas as u64,
excess_blob_gas,
blob_gas_per_blob: DATA_GAS_PER_BLOB,
})
}
@ -225,7 +224,7 @@ pub fn validate_against_parent_eip1559_base_fee<ChainSpec: EthChainSpec + Ethere
chain_spec: &ChainSpec,
) -> Result<(), ConsensusError> {
if chain_spec.fork(EthereumHardfork::London).active_at_block(header.number) {
let base_fee = header.base_fee_per_gas.ok_or(ConsensusError::BaseFeeMissing)? as u64;
let base_fee = header.base_fee_per_gas.ok_or(ConsensusError::BaseFeeMissing)?;
let expected_base_fee =
if chain_spec.fork(EthereumHardfork::London).transitions_at_block(header.number) {
@ -235,7 +234,7 @@ pub fn validate_against_parent_eip1559_base_fee<ChainSpec: EthChainSpec + Ethere
// them.
parent
.next_block_base_fee(chain_spec.base_fee_params_at_timestamp(header.timestamp))
.ok_or(ConsensusError::BaseFeeMissing)? as u64
.ok_or(ConsensusError::BaseFeeMissing)?
};
if expected_base_fee != base_fee {
return Err(ConsensusError::BaseFeeDiff(GotExpected {
@ -277,14 +276,13 @@ pub fn validate_against_parent_4844(
// > are evaluated as 0.
//
// This means in the first post-fork block, calc_excess_blob_gas will return 0.
let parent_blob_gas_used = parent.blob_gas_used.unwrap_or(0) as u64;
let parent_excess_blob_gas = parent.excess_blob_gas.unwrap_or(0) as u64;
let parent_blob_gas_used = parent.blob_gas_used.unwrap_or(0);
let parent_excess_blob_gas = parent.excess_blob_gas.unwrap_or(0);
if header.blob_gas_used.is_none() {
return Err(ConsensusError::BlobGasUsedMissing)
}
let excess_blob_gas =
header.excess_blob_gas.ok_or(ConsensusError::ExcessBlobGasMissing)? as u64;
let excess_blob_gas = header.excess_blob_gas.ok_or(ConsensusError::ExcessBlobGasMissing)?;
let expected_excess_blob_gas =
calc_excess_blob_gas(parent_excess_blob_gas, parent_blob_gas_used);
@ -540,7 +538,7 @@ mod tests {
let transaction = mock_blob_tx(1, 10);
let sealed = Header {
base_fee_per_gas: Some(1337u128),
base_fee_per_gas: Some(1337),
withdrawals_root: Some(proofs::calculate_withdrawals_root(&[])),
blob_gas_used: Some(1),
transactions_root: proofs::calculate_transaction_root(&[transaction.clone()]),