Trait Consensus

pub trait Consensus<B>: AsHeaderValidator<<B as Block>::Header>
where B: Block,
{ type Error; // Required methods fn validate_body_against_header( &self, body: &<B as Block>::Body, header: &SealedHeader<<B as Block>::Header>, ) -> Result<(), Self::Error>; fn validate_block_pre_execution( &self, block: &SealedBlock<B>, ) -> Result<(), Self::Error>; }
Available on crate feature consensus only.
Expand description

Consensus is a protocol that chooses canonical chain.

Required Associated Types§

type Error

The error type related to consensus.

Required Methods§

fn validate_body_against_header( &self, body: &<B as Block>::Body, header: &SealedHeader<<B as Block>::Header>, ) -> Result<(), Self::Error>

Ensures that body field values match the header.

fn validate_block_pre_execution( &self, block: &SealedBlock<B>, ) -> Result<(), Self::Error>

Validate a block disregarding world state, i.e. things that can be checked before sender recovery and execution.

See the Yellow Paper sections 4.3.2 “Holistic Validity”, 4.3.4 “Block Header Validity”, and 11.1 “Ommer Validation”.

This should not be called for the genesis block.

Note: validating blocks does not include other validations of the Consensus

Implementations on Foreign Types§

§

impl<'a, B, T> Consensus<B> for &'a T
where B: Block, T: 'a + Consensus<B> + ?Sized, &'a T: AsHeaderValidator<<B as Block>::Header>,

§

type Error = <T as Consensus<B>>::Error

§

fn validate_body_against_header( &self, body: &<B as Block>::Body, header: &SealedHeader<<B as Block>::Header>, ) -> Result<(), <&'a T as Consensus<B>>::Error>

§

fn validate_block_pre_execution( &self, block: &SealedBlock<B>, ) -> Result<(), <&'a T as Consensus<B>>::Error>

§

impl<B, T> Consensus<B> for Arc<T>
where B: Block, T: Consensus<B> + ?Sized, Arc<T>: AsHeaderValidator<<B as Block>::Header>,

§

type Error = <T as Consensus<B>>::Error

§

fn validate_body_against_header( &self, body: &<B as Block>::Body, header: &SealedHeader<<B as Block>::Header>, ) -> Result<(), <Arc<T> as Consensus<B>>::Error>

§

fn validate_block_pre_execution( &self, block: &SealedBlock<B>, ) -> Result<(), <Arc<T> as Consensus<B>>::Error>

Implementors§

§

impl<B> Consensus<B> for NoopConsensus
where B: Block,

§

impl<B> Consensus<B> for TestConsensus
where B: Block,

§

impl<B, ChainSpec> Consensus<B> for EthBeaconConsensus<ChainSpec>
where ChainSpec: Send + Sync + EthChainSpec + EthereumHardforks + Debug, B: Block,

impl<ChainSpec: EthChainSpec + OpHardforks, B: Block> Consensus<B> for OpBeaconConsensus<ChainSpec>