Skip to content

Commit 494b359

Browse files
authored
fix subtract with overflow in relative_min_window_density() consensus.rs
Panic with message: `Subtract with overflow` at core/src/consensus.rs:78:27 When debug vars: max_slot: 98879 global_slot + 1: 98880
1 parent f63efa5 commit 494b359

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/src/consensus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn relative_min_window_density(b1: &MinaConsensusState, b2: &MinaConsensusSt
7575

7676
let projected_window = {
7777
// Compute shift count
78-
let shift_count = (max_slot - global_slot(b1) - 1).clamp(0, SUB_WINDOWS_PER_WINDOW);
78+
let shift_count = (max_slot.wrapping_sub(global_slot(b1) + 1)).clamp(0, SUB_WINDOWS_PER_WINDOW);
7979

8080
// Initialize projected window
8181
let mut projected_window = b1

0 commit comments

Comments
 (0)