Skip to content

Commit

Permalink
ibc-types-lightclients-tendermint: add validity check for validator s…
Browse files Browse the repository at this point in the history
…et hash
  • Loading branch information
avahowell committed Feb 26, 2024
1 parent ca4cc5e commit 49a947c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/ibc-types-lightclients-tendermint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ pub enum Error {
header_chain_id: String,
chain_id: String,
},
/// The given hash of the validators does not matches the given hash in the signed header. Expected: `{signed_header_validators_hash}`, got: `{validators_hash}`
MismatchValidatorsHashes {
validators_hash: Hash,
signed_header_validators_hash: Hash,
},
/// invalid raw client id: `{client_id}`
InvalidRawClientId { client_id: String },
}
Expand Down
7 changes: 7 additions & 0 deletions crates/ibc-types-lightclients-tendermint/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ impl TryFrom<RawHeader> for Header {
});
}

if header.validator_set.hash() != header.signed_header.header.validators_hash {
return Err(Error::MismatchValidatorsHashes {
signed_header_validators_hash: header.signed_header.header.validators_hash,
validators_hash: header.validator_set.hash(),
});
}

Ok(header)
}
}
Expand Down

0 comments on commit 49a947c

Please sign in to comment.