pub trait VerificationPredicates: Send + Sync {
type Sha256: MerkleHash + Sha256 + Default;
// Provided methods
fn validator_sets_match(
&self,
validators: &ValidatorSet,
header_validators_hash: Hash,
) -> Result<(), VerificationError> { ... }
fn next_validators_match(
&self,
next_validators: &ValidatorSet,
header_next_validators_hash: Hash,
) -> Result<(), VerificationError> { ... }
fn header_matches_commit(
&self,
header: &Header,
commit_hash: Hash,
) -> Result<(), VerificationError> { ... }
fn valid_commit(
&self,
signed_header: &SignedHeader,
validators: &ValidatorSet,
commit_validator: &dyn CommitValidator,
) -> Result<(), VerificationError> { ... }
fn is_within_trust_period(
&self,
trusted_header_time: Time,
trusting_period: Duration,
now: Time,
) -> Result<(), VerificationError> { ... }
fn is_header_from_past(
&self,
untrusted_header_time: Time,
clock_drift: Duration,
now: Time,
) -> Result<(), VerificationError> { ... }
fn is_monotonic_bft_time(
&self,
untrusted_header_time: Time,
trusted_header_time: Time,
) -> Result<(), VerificationError> { ... }
fn is_monotonic_height(
&self,
untrusted_height: Height,
trusted_height: Height,
) -> Result<(), VerificationError> { ... }
fn is_matching_chain_id(
&self,
untrusted_chain_id: &ChainId,
trusted_chain_id: &ChainId,
) -> Result<(), VerificationError> { ... }
fn has_sufficient_validators_and_signers_overlap(
&self,
untrusted_sh: &SignedHeader,
trusted_validators: &ValidatorSet,
trust_threshold: &TrustThreshold,
untrusted_validators: &ValidatorSet,
calculator: &dyn VotingPowerCalculator,
) -> Result<(), VerificationError> { ... }
fn has_sufficient_signers_overlap(
&self,
untrusted_sh: &SignedHeader,
untrusted_validators: &ValidatorSet,
calculator: &dyn VotingPowerCalculator,
) -> Result<(), VerificationError> { ... }
fn valid_next_validator_set(
&self,
untrusted_validators_hash: Hash,
trusted_next_validators_hash: Hash,
) -> Result<(), VerificationError> { ... }
}Expand description
Defines the various predicates used to validate and verify light blocks.
A default, spec abiding implementation is provided for each method.
This enables test implementations to only override a single method rather than have to re-define every predicate.
Required Associated Types§
Sourcetype Sha256: MerkleHash + Sha256 + Default
type Sha256: MerkleHash + Sha256 + Default
The implementation of SHA256 digest
Provided Methods§
Sourcefn validator_sets_match(
&self,
validators: &ValidatorSet,
header_validators_hash: Hash,
) -> Result<(), VerificationError>
fn validator_sets_match( &self, validators: &ValidatorSet, header_validators_hash: Hash, ) -> Result<(), VerificationError>
Compare the provided validator_set_hash against the hash produced from hashing the validator set.
Sourcefn next_validators_match(
&self,
next_validators: &ValidatorSet,
header_next_validators_hash: Hash,
) -> Result<(), VerificationError>
fn next_validators_match( &self, next_validators: &ValidatorSet, header_next_validators_hash: Hash, ) -> Result<(), VerificationError>
Check that the hash of the next validator set in the header match the actual one.
Sourcefn header_matches_commit(
&self,
header: &Header,
commit_hash: Hash,
) -> Result<(), VerificationError>
fn header_matches_commit( &self, header: &Header, commit_hash: Hash, ) -> Result<(), VerificationError>
Check that the hash of the header in the commit matches the actual one.
Sourcefn valid_commit(
&self,
signed_header: &SignedHeader,
validators: &ValidatorSet,
commit_validator: &dyn CommitValidator,
) -> Result<(), VerificationError>
fn valid_commit( &self, signed_header: &SignedHeader, validators: &ValidatorSet, commit_validator: &dyn CommitValidator, ) -> Result<(), VerificationError>
Validate the commit using the given commit validator.
Sourcefn is_within_trust_period(
&self,
trusted_header_time: Time,
trusting_period: Duration,
now: Time,
) -> Result<(), VerificationError>
fn is_within_trust_period( &self, trusted_header_time: Time, trusting_period: Duration, now: Time, ) -> Result<(), VerificationError>
Check that the trusted header is within the trusting period, adjusting for clock drift.
Sourcefn is_header_from_past(
&self,
untrusted_header_time: Time,
clock_drift: Duration,
now: Time,
) -> Result<(), VerificationError>
fn is_header_from_past( &self, untrusted_header_time: Time, clock_drift: Duration, now: Time, ) -> Result<(), VerificationError>
Check that the untrusted header is from past.
Sourcefn is_monotonic_bft_time(
&self,
untrusted_header_time: Time,
trusted_header_time: Time,
) -> Result<(), VerificationError>
fn is_monotonic_bft_time( &self, untrusted_header_time: Time, trusted_header_time: Time, ) -> Result<(), VerificationError>
Check that time passed monotonically between the trusted header and the untrusted one.
Sourcefn is_monotonic_height(
&self,
untrusted_height: Height,
trusted_height: Height,
) -> Result<(), VerificationError>
fn is_monotonic_height( &self, untrusted_height: Height, trusted_height: Height, ) -> Result<(), VerificationError>
Check that the height increased between the trusted header and the untrusted one.
Sourcefn is_matching_chain_id(
&self,
untrusted_chain_id: &ChainId,
trusted_chain_id: &ChainId,
) -> Result<(), VerificationError>
fn is_matching_chain_id( &self, untrusted_chain_id: &ChainId, trusted_chain_id: &ChainId, ) -> Result<(), VerificationError>
Check that the chain-ids of the trusted header and the untrusted one are the same
Sourcefn has_sufficient_validators_and_signers_overlap(
&self,
untrusted_sh: &SignedHeader,
trusted_validators: &ValidatorSet,
trust_threshold: &TrustThreshold,
untrusted_validators: &ValidatorSet,
calculator: &dyn VotingPowerCalculator,
) -> Result<(), VerificationError>
fn has_sufficient_validators_and_signers_overlap( &self, untrusted_sh: &SignedHeader, trusted_validators: &ValidatorSet, trust_threshold: &TrustThreshold, untrusted_validators: &ValidatorSet, calculator: &dyn VotingPowerCalculator, ) -> Result<(), VerificationError>
Checks that there is enough overlap between validators and the untrusted signed header.
First of all, checks that enough validators from the
trusted_validators set signed the untrusted header to reach given
trust_threshold.
Second of all, checks that enough validators from the
untrusted_validators set signed the untrusted header to reach a trust
threshold of ⅔.
If both of those conditions aren’t met, it’s unspecified which error is returned.
Note also that the method isn’t guaranteed to verify all the signatures present in the signed header. If there are invalid signatures, the method may or may not return an error depending on which validators those signatures correspond to.
Sourcefn has_sufficient_signers_overlap(
&self,
untrusted_sh: &SignedHeader,
untrusted_validators: &ValidatorSet,
calculator: &dyn VotingPowerCalculator,
) -> Result<(), VerificationError>
fn has_sufficient_signers_overlap( &self, untrusted_sh: &SignedHeader, untrusted_validators: &ValidatorSet, calculator: &dyn VotingPowerCalculator, ) -> Result<(), VerificationError>
Check that there is enough signers overlap between the given, untrusted validator set and the untrusted signed header.
Sourcefn valid_next_validator_set(
&self,
untrusted_validators_hash: Hash,
trusted_next_validators_hash: Hash,
) -> Result<(), VerificationError>
fn valid_next_validator_set( &self, untrusted_validators_hash: Hash, trusted_next_validators_hash: Hash, ) -> Result<(), VerificationError>
Check that the hash of the next validator set in the trusted block matches the hash of the validator set in the untrusted one.
Implementors§
Source§impl VerificationPredicates for ProdPredicates
Available on crate feature rust-crypto only.
impl VerificationPredicates for ProdPredicates
rust-crypto only.