feat: make Consensus trait generic over block parts (#12451)

This commit is contained in:
Arsenii Kulikov
2024-11-11 20:35:01 +04:00
committed by GitHub
parent 11fd5aa45e
commit 24b3e63ab3
12 changed files with 219 additions and 114 deletions

View File

@ -15,13 +15,15 @@ use reth_chainspec::EthereumHardforks;
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_consensus_common::validation::{
validate_against_parent_4844, validate_against_parent_eip1559_base_fee,
validate_against_parent_hash_number, validate_against_parent_timestamp, validate_cancun_gas,
validate_header_base_fee, validate_header_extradata, validate_header_gas,
validate_shanghai_withdrawals,
validate_against_parent_hash_number, validate_against_parent_timestamp,
validate_body_against_header, validate_cancun_gas, validate_header_base_fee,
validate_header_extradata, validate_header_gas, validate_shanghai_withdrawals,
};
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_forks::OpHardforks;
use reth_primitives::{BlockWithSenders, GotExpected, Header, SealedBlock, SealedHeader};
use reth_primitives::{
BlockBody, BlockWithSenders, GotExpected, Header, SealedBlock, SealedHeader,
};
use std::{sync::Arc, time::SystemTime};
mod proof;
@ -119,6 +121,14 @@ impl Consensus for OpBeaconConsensus {
Ok(())
}
fn validate_body_against_header(
&self,
body: &BlockBody,
header: &SealedHeader,
) -> Result<(), ConsensusError> {
validate_body_against_header(body, header)
}
fn validate_block_pre_execution(&self, block: &SealedBlock) -> Result<(), ConsensusError> {
// Check ommers hash
let ommers_hash = reth_primitives::proofs::calculate_ommers_root(&block.body.ommers);