PredicateVerifier

Struct PredicateVerifier 

Source
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>

Source

pub fn new( predicates: P, voting_power_calculator: C, commit_validator: V, ) -> Self

Constructor.

Source

pub fn verify_validator_sets( &self, untrusted: &UntrustedBlockState<'_>, ) -> Verdict

Validates an UntrustedBlockState.

Source

pub fn verify_commit(&self, untrusted: &UntrustedBlockState<'_>) -> Verdict

Verify that more than 2/3 of the validators correctly committed the block.

Source

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.

Source

pub fn check_header_is_from_past( &self, untrusted: &UntrustedBlockState<'_>, options: &Options, now: Time, ) -> Verdict

Ensure the header isn’t from a future time

Source

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>

Source§

fn clone(&self) -> PredicateVerifier<P, C, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug, C: Debug, V: Debug> Debug for PredicateVerifier<P, C, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: Default, C: Default, V: Default> Default for PredicateVerifier<P, C, V>

Source§

fn default() -> PredicateVerifier<P, C, V>

Returns the “default value” for a type. Read more
Source§

impl<P: PartialEq, C: PartialEq, V: PartialEq> PartialEq for PredicateVerifier<P, C, V>

Source§

fn eq(&self, other: &PredicateVerifier<P, C, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

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

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.

Source§

impl<P: Eq, C: Eq, V: Eq> Eq for PredicateVerifier<P, C, V>

Source§

impl<P, C, V> StructuralPartialEq for PredicateVerifier<P, C, V>

Auto Trait Implementations§

§

impl<P, C, V> Freeze for PredicateVerifier<P, C, V>
where P: Freeze, C: Freeze, V: Freeze,

§

impl<P, C, V> RefUnwindSafe for PredicateVerifier<P, C, V>

§

impl<P, C, V> Send for PredicateVerifier<P, C, V>
where P: Send, C: Send, V: Send,

§

impl<P, C, V> Sync for PredicateVerifier<P, C, V>
where P: Sync, C: Sync, V: Sync,

§

impl<P, C, V> Unpin for PredicateVerifier<P, C, V>
where P: Unpin, C: Unpin, V: Unpin,

§

impl<P, C, V> UnwindSafe for PredicateVerifier<P, C, V>
where P: UnwindSafe, C: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.