Skip to content

Commit

Permalink
Ensure there is at least one non-absent signatures in the commit. See #…
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Oct 22, 2020
1 parent 6be5ebf commit 985eab3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions light-client/src/operations/commit_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,29 @@ impl CommitValidator for ProdCommitValidator {
signed_header: &SignedHeader,
validator_set: &ValidatorSet,
) -> Result<(), VerificationError> {
// TODO: `self.commit.block_id` cannot be zero in the same way as in Go
// Clarify if this another encoding related issue
if signed_header.commit.signatures.len() == 0 {
let signatures = &signed_header.commit.signatures;

// Check the the commit contains at least on non-absent signature.
// See https://github.com/informalsystems/tendermint-rs/issues/650
let has_non_absent_signatures = signatures.iter().any(|cs| !cs.is_absent());
if !has_non_absent_signatures {
bail!(VerificationError::ImplementationSpecific(
"no signatures for commit".to_string()
));
}

if signed_header.commit.signatures.len() != validator_set.validators().len() {
// Check that that the number of signatures matches the number of validators.
if signatures.len() != validator_set.validators().len() {
bail!(VerificationError::ImplementationSpecific(format!(
"pre-commit length: {} doesn't match validator length: {}",
signed_header.commit.signatures.len(),
signatures.len(),
validator_set.validators().len()
)));
}

// TODO: `commit.block_id` cannot be zero in the same way as in Go
// Clarify if this another encoding related issue

Ok(())
}

Expand Down

0 comments on commit 985eab3

Please sign in to comment.