chore: get rid of compat call (#7930)

This commit is contained in:
Matthias Seitz
2024-04-27 07:55:06 +02:00
committed by GitHub
parent cc4a418ddf
commit 43f58f16dd
2 changed files with 80 additions and 68 deletions

View File

@ -10,7 +10,7 @@
use reth_primitives::{ChainSpec, SealedBlock};
use reth_rpc_types::{engine::MaybeCancunPayloadFields, ExecutionPayload, PayloadError};
use reth_rpc_types_compat::engine::payload::{try_into_block, validate_block_hash};
use reth_rpc_types_compat::engine::payload::try_into_block;
use std::sync::Arc;
/// Execution payload validator.
@ -100,21 +100,27 @@ impl ExecutionPayloadValidator {
payload: ExecutionPayload,
cancun_fields: MaybeCancunPayloadFields,
) -> Result<SealedBlock, PayloadError> {
let block_hash = payload.block_hash();
let expected_hash = payload.block_hash();
// First parse the block
let block = try_into_block(payload, cancun_fields.parent_beacon_block_root())?;
let sealed_block =
try_into_block(payload, cancun_fields.parent_beacon_block_root())?.seal_slow();
let cancun_active = self.is_cancun_active_at_timestamp(block.timestamp);
// Ensure the hash included in the payload matches the block hash
if expected_hash != sealed_block.hash() {
return Err(PayloadError::BlockHash {
execution: sealed_block.hash(),
consensus: expected_hash,
})
}
if !cancun_active && block.has_blob_transactions() {
let cancun_active = self.is_cancun_active_at_timestamp(sealed_block.timestamp);
if !cancun_active && sealed_block.has_blob_transactions() {
// cancun not active but blob transactions present
return Err(PayloadError::PreCancunBlockWithBlobTransactions)
}
// Ensure the hash included in the payload matches the block hash
let sealed_block = validate_block_hash(block_hash, block)?;
// EIP-4844 checks
self.ensure_matching_blob_versioned_hashes(&sealed_block, &cancun_fields)?;