Protect against underflow in relayer (#1508)

trevor/deploy-v2
Asa Oines 2 years ago committed by GitHub
parent af52ae9823
commit eb3550ad39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      rust/hyperlane-base/src/types/multisig.rs

@ -62,14 +62,16 @@ impl MultisigCheckpointSyncer {
// The highest viable checkpoint index is the minimum of the highest index
// we (supposedly) have a quorum for, and the maximum index for which we can
// generate a proof.
let mut index = std::cmp::min(*highest_quorum_index, maximum_index);
while index >= minimum_index {
let start_index = highest_quorum_index.min(&maximum_index);
if minimum_index > *start_index {
return Ok(None);
}
for index in (minimum_index..=*start_index).rev() {
if let Ok(Some(checkpoint)) =
self.fetch_checkpoint(index, validators, threshold).await
{
return Ok(Some(checkpoint));
}
index -= 1;
}
}
Ok(None)

Loading…
Cancel
Save