pub trait Consensus<H = Header, B = BlockBody>:
AsHeaderValidator<H>
+ HeaderValidator<H>
+ Debug
+ Send
+ Sync {
// Required methods
fn validate_body_against_header(
&self,
body: &B,
header: &SealedHeader<H>,
) -> Result<(), ConsensusError>;
fn validate_block_pre_execution(
&self,
block: &SealedBlock<H, B>,
) -> Result<(), ConsensusError>;
fn validate_block_post_execution(
&self,
block: &BlockWithSenders,
input: PostExecutionInput<'_>,
) -> Result<(), ConsensusError>;
}
Expand description
Consensus is a protocol that chooses canonical chain.
Required Methods§
Sourcefn validate_body_against_header(
&self,
body: &B,
header: &SealedHeader<H>,
) -> Result<(), ConsensusError>
fn validate_body_against_header( &self, body: &B, header: &SealedHeader<H>, ) -> Result<(), ConsensusError>
Ensures that body field values match the header.
Sourcefn validate_block_pre_execution(
&self,
block: &SealedBlock<H, B>,
) -> Result<(), ConsensusError>
fn validate_block_pre_execution( &self, block: &SealedBlock<H, B>, ) -> Result<(), ConsensusError>
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
Sourcefn validate_block_post_execution(
&self,
block: &BlockWithSenders,
input: PostExecutionInput<'_>,
) -> Result<(), ConsensusError>
fn validate_block_post_execution( &self, block: &BlockWithSenders, input: PostExecutionInput<'_>, ) -> Result<(), ConsensusError>
Validate a block considering world state, i.e. things that can not be checked before execution.
See the Yellow Paper sections 4.3.2 “Holistic Validity”.
Note: validating blocks does not include other validations of the Consensus
Implementations on Foreign Types§
Source§impl<'a, H, B, T: 'a + Consensus<H, B> + ?Sized> Consensus<H, B> for &'a T
impl<'a, H, B, T: 'a + Consensus<H, B> + ?Sized> Consensus<H, B> for &'a T
fn validate_body_against_header( &self, body: &B, header: &SealedHeader<H>, ) -> Result<(), ConsensusError>
fn validate_block_pre_execution( &self, block: &SealedBlock<H, B>, ) -> Result<(), ConsensusError>
fn validate_block_post_execution( &self, block: &BlockWithSenders, input: PostExecutionInput<'_>, ) -> Result<(), ConsensusError>
Source§impl<H, B, T: Consensus<H, B> + ?Sized> Consensus<H, B> for Arc<T>
impl<H, B, T: Consensus<H, B> + ?Sized> Consensus<H, B> for Arc<T>
fn validate_body_against_header( &self, body: &B, header: &SealedHeader<H>, ) -> Result<(), ConsensusError>
fn validate_block_pre_execution( &self, block: &SealedBlock<H, B>, ) -> Result<(), ConsensusError>
fn validate_block_post_execution( &self, block: &BlockWithSenders, input: PostExecutionInput<'_>, ) -> Result<(), ConsensusError>
Implementors§
impl<H, B> Consensus<H, B> for NoopConsensus
impl<H, B> Consensus<H, B> for TestConsensus
Available on crate feature
test-utils
only.