Skip to content

Commit

Permalink
Fix 0 - 1 which caused a panic
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Mar 9, 2024
1 parent 157acc4 commit f7d16b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions coordinator/src/substrate/cosign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ async fn advance_cosign_protocol_inner(
let mut window_end_exclusive = last_intended_to_cosign_block + COSIGN_DISTANCE;
// If we've never triggered a cosign, don't skip any cosigns based on proximity
if last_intended_to_cosign_block == INITIAL_INTENDED_COSIGN {
window_end_exclusive = 0;
window_end_exclusive = 1;
}

// The consensus rules for this are `last_intended_to_cosign_block + 1`
let scan_start_block = last_intended_to_cosign_block + 1;
// As a practical optimization, we don't re-scan old blocks since old blocks are independent to
// new state
let scan_start_block = scan_start_block.max(ScanCosignFrom::get(&txn).unwrap_or(0));
let scan_start_block = scan_start_block.max(ScanCosignFrom::get(&txn).unwrap_or(1));

// Check all blocks within the window to see if they should be cosigned
// If so, we're skipping them and need to flag them as skipped so that once the window closes, we
Expand Down Expand Up @@ -317,7 +317,7 @@ pub async fn advance_cosign_protocol(
latest_number: u64,
) -> Result<(), SeraiError> {
loop {
let scan_from = ScanCosignFrom::get(db).unwrap_or(0);
let scan_from = ScanCosignFrom::get(db).unwrap_or(1);
// Only scan 1000 blocks at a time to limit a massive txn from forming
let scan_to = latest_number.min(scan_from + 1000);
advance_cosign_protocol_inner(db, key, serai, scan_to).await?;
Expand Down

0 comments on commit f7d16b3

Please sign in to comment.