pub struct PredicateVerifier<P, C, V> { /* private fields */ }Expand description
Predicate verifier encapsulating components necessary to facilitate verification.
Implementations§
Source§impl<P, C, V> PredicateVerifier<P, C, V>
impl<P, C, V> PredicateVerifier<P, C, V>
Sourcepub fn new(
predicates: P,
voting_power_calculator: C,
commit_validator: V,
) -> Self
pub fn new( predicates: P, voting_power_calculator: C, commit_validator: V, ) -> Self
Constructor.
Sourcepub fn verify_validator_sets(
&self,
untrusted: &UntrustedBlockState<'_>,
) -> Verdict
pub fn verify_validator_sets( &self, untrusted: &UntrustedBlockState<'_>, ) -> Verdict
Validates an UntrustedBlockState.
Sourcepub fn verify_commit(&self, untrusted: &UntrustedBlockState<'_>) -> Verdict
pub fn verify_commit(&self, untrusted: &UntrustedBlockState<'_>) -> Verdict
Verify that more than 2/3 of the validators correctly committed the block.
Sourcepub fn validate_against_trusted(
&self,
untrusted: &UntrustedBlockState<'_>,
trusted: &TrustedBlockState<'_>,
options: &Options,
now: Time,
) -> Verdict
pub fn validate_against_trusted( &self, untrusted: &UntrustedBlockState<'_>, trusted: &TrustedBlockState<'_>, options: &Options, now: Time, ) -> Verdict
Validate an UntrustedBlockState coming from a client update,
based on the given TrustedBlockState, Options and current time.
Sourcepub fn check_header_is_from_past(
&self,
untrusted: &UntrustedBlockState<'_>,
options: &Options,
now: Time,
) -> Verdict
pub fn check_header_is_from_past( &self, untrusted: &UntrustedBlockState<'_>, options: &Options, now: Time, ) -> Verdict
Ensure the header isn’t from a future time
Sourcepub fn verify_commit_against_trusted(
&self,
untrusted: &UntrustedBlockState<'_>,
trusted: &TrustedBlockState<'_>,
options: &Options,
) -> Verdict
pub fn verify_commit_against_trusted( &self, untrusted: &UntrustedBlockState<'_>, trusted: &TrustedBlockState<'_>, options: &Options, ) -> Verdict
Check there is enough overlap between the validator sets of the trusted and untrusted blocks.
Trait Implementations§
Source§impl<P: Clone, C: Clone, V: Clone> Clone for PredicateVerifier<P, C, V>
impl<P: Clone, C: Clone, V: Clone> Clone for PredicateVerifier<P, C, V>
Source§fn clone(&self) -> PredicateVerifier<P, C, V>
fn clone(&self) -> PredicateVerifier<P, C, V>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P: Default, C: Default, V: Default> Default for PredicateVerifier<P, C, V>
impl<P: Default, C: Default, V: Default> Default for PredicateVerifier<P, C, V>
Source§fn default() -> PredicateVerifier<P, C, V>
fn default() -> PredicateVerifier<P, C, V>
Source§impl<P, C, V> Verifier for PredicateVerifier<P, C, V>
impl<P, C, V> Verifier for PredicateVerifier<P, C, V>
Source§fn verify_update_header(
&self,
untrusted: UntrustedBlockState<'_>,
trusted: TrustedBlockState<'_>,
options: &Options,
now: Time,
) -> Verdict
fn verify_update_header( &self, untrusted: UntrustedBlockState<'_>, trusted: TrustedBlockState<'_>, options: &Options, now: Time, ) -> Verdict
Validate the given light block state by performing the following checks ->
- Validate the untrusted header
- Ensure the header validator hashes match the given validators
- Ensure the header next validator hashes match the given next validators
- Ensure the header matches the commit
- Ensure commit is valid
- Validate the untrusted header against the trusted header
- Ensure the latest trusted header hasn’t expired
- Ensure the header isn’t from a future time
- Check that the untrusted block is more recent than the trusted state
- If the untrusted block is the very next block after the trusted block, check that their (next) validator sets hashes match.
- Otherwise, ensure that the untrusted block has a greater height than the trusted block.
- Check there is enough overlap between the validator sets of the trusted and untrusted blocks.
- Verify that more than 2/3 of the validators correctly committed the block.
NOTE: If the untrusted state’s next_validators field is None,
this will not (and will not be able to) check whether the untrusted
state’s next_validators_hash field is valid.
NOTE: It is the caller’s responsibility to ensure that
trusted.next_validators.hash() == trusted.next_validators_hash,
as typically the trusted.next_validators validator set comes from the relayer,
and trusted.next_validators_hash is the hash stored on chain.
Source§fn verify_misbehaviour_header(
&self,
untrusted: UntrustedBlockState<'_>,
trusted: TrustedBlockState<'_>,
options: &Options,
now: Time,
) -> Verdict
fn verify_misbehaviour_header( &self, untrusted: UntrustedBlockState<'_>, trusted: TrustedBlockState<'_>, options: &Options, now: Time, ) -> Verdict
Verify a header received in MsgSubmitMisbehaviour.
The verification for these headers is a bit more relaxed in order to catch FLA attacks.
In particular the “header in the future” check for the header should be skipped.