feat: consensus trait generic over NodePrimitives (#13026)

This commit is contained in:
Arsenii Kulikov
2024-11-30 02:26:36 +04:00
committed by GitHub
parent 55ddaab1e4
commit 5d71150355
26 changed files with 166 additions and 113 deletions

View File

@ -22,6 +22,7 @@ reth-trie-common.workspace = true
# op-reth
reth-optimism-forks.workspace = true
reth-optimism-chainspec.workspace = true
reth-optimism-primitives.workspace = true
# ethereum
alloy-primitives.workspace = true

View File

@ -12,7 +12,9 @@
use alloy_consensus::{Header, EMPTY_OMMER_ROOT_HASH};
use alloy_primitives::{B64, U256};
use reth_chainspec::EthereumHardforks;
use reth_consensus::{Consensus, ConsensusError, HeaderValidator, PostExecutionInput};
use reth_consensus::{
Consensus, ConsensusError, FullConsensus, HeaderValidator, 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,
@ -21,6 +23,7 @@ use reth_consensus_common::validation::{
};
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_forks::OpHardforks;
use reth_optimism_primitives::OpPrimitives;
use reth_primitives::{BlockBody, BlockWithSenders, GotExpected, SealedBlock, SealedHeader};
use std::{sync::Arc, time::SystemTime};
@ -46,6 +49,16 @@ impl OpBeaconConsensus {
}
}
impl FullConsensus<OpPrimitives> for OpBeaconConsensus {
fn validate_block_post_execution(
&self,
block: &BlockWithSenders,
input: PostExecutionInput<'_>,
) -> Result<(), ConsensusError> {
validate_block_post_execution(block, &self.chain_spec, input.receipts)
}
}
impl Consensus for OpBeaconConsensus {
fn validate_body_against_header(
&self,
@ -80,14 +93,6 @@ impl Consensus for OpBeaconConsensus {
Ok(())
}
fn validate_block_post_execution(
&self,
block: &BlockWithSenders,
input: PostExecutionInput<'_>,
) -> Result<(), ConsensusError> {
validate_block_post_execution(block, &self.chain_spec, input.receipts)
}
}
impl HeaderValidator for OpBeaconConsensus {