Skip to content

Commit

Permalink
Fix wraparound when leader schedule close to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
helius-kurt committed Aug 5, 2024
1 parent cc4b526 commit f73a78d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions validator-firewall/src/leader_tracker.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ops::Range;
use aya::maps::{Array, Map};
use log::{error, info, warn};
use rangemap::RangeInclusiveSet;
Expand Down Expand Up @@ -167,6 +168,10 @@ impl RPCLeaderTracker {
)
.await
{
Err(e) => {
error!("Failed to get leader schedule: {e}");
Err(())
}
Ok(sched) => {
if sched.is_none() {
error!("Failed to get leader schedule.");
Expand All @@ -177,19 +182,20 @@ impl RPCLeaderTracker {
for slot in my_slots {
let end: u64 = *slot as u64;

leader_ranges.insert(end - self.slot_buffer..=end);

let range = end.saturating_sub(self.slot_buffer)..=end;
leader_ranges.insert(range);
}
leader_ranges.insert(0..=10);
// let rngs: Vec<Range<u64>> =leader_ranges.iter().collect();
info!("Leader ranges: {leader_ranges:?}");

Ok(leader_ranges)
} else {
error!("No slots found for: {my_id}");
Err(())
}
}
Err(e) => {
error!("Failed to get leader schedule: {e}");
Err(())
}
};
}
}
Expand Down

0 comments on commit f73a78d

Please sign in to comment.