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_overlap(
&self,
untrusted_sh: &SignedHeader,
trusted_validators: &ValidatorSet,
trust_threshold: &TrustThreshold,
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_overlap(
&self,
untrusted_sh: &SignedHeader,
trusted_validators: &ValidatorSet,
trust_threshold: &TrustThreshold,
calculator: &dyn VotingPowerCalculator,
) -> Result<(), VerificationError>
fn has_sufficient_validators_overlap( &self, untrusted_sh: &SignedHeader, trusted_validators: &ValidatorSet, trust_threshold: &TrustThreshold, calculator: &dyn VotingPowerCalculator, ) -> Result<(), VerificationError>
Check that there is enough validators overlap between the trusted validator set and the untrusted signed header.
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.