reth_consensus/
noop.rs

1use crate::{Consensus, ConsensusError, FullConsensus, HeaderValidator, PostExecutionInput};
2use alloy_primitives::U256;
3use reth_primitives::{BlockWithSenders, NodePrimitives, SealedBlock, SealedHeader};
4
5/// A Consensus implementation that does nothing.
6#[derive(Debug, Copy, Clone, Default)]
7#[non_exhaustive]
8pub struct NoopConsensus;
9
10impl<H> HeaderValidator<H> for NoopConsensus {
11    fn validate_header(&self, _header: &SealedHeader<H>) -> Result<(), ConsensusError> {
12        Ok(())
13    }
14
15    fn validate_header_against_parent(
16        &self,
17        _header: &SealedHeader<H>,
18        _parent: &SealedHeader<H>,
19    ) -> Result<(), ConsensusError> {
20        Ok(())
21    }
22
23    fn validate_header_with_total_difficulty(
24        &self,
25        _header: &H,
26        _total_difficulty: U256,
27    ) -> Result<(), ConsensusError> {
28        Ok(())
29    }
30}
31
32impl<H, B> Consensus<H, B> for NoopConsensus {
33    fn validate_body_against_header(
34        &self,
35        _body: &B,
36        _header: &SealedHeader<H>,
37    ) -> Result<(), ConsensusError> {
38        Ok(())
39    }
40
41    fn validate_block_pre_execution(
42        &self,
43        _block: &SealedBlock<H, B>,
44    ) -> Result<(), ConsensusError> {
45        Ok(())
46    }
47}
48
49impl<N: NodePrimitives> FullConsensus<N> for NoopConsensus {
50    fn validate_block_post_execution(
51        &self,
52        _block: &BlockWithSenders<N::Block>,
53        _input: PostExecutionInput<'_, N::Receipt>,
54    ) -> Result<(), ConsensusError> {
55        Ok(())
56    }
57}