Skip to content

Commit fc033a9

Browse files
committed
Remove slot time check interval, it was never used
1 parent e763fa1 commit fc033a9

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

chain-alerter/src/alerts/tests.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use crate::subspace::{
1717
};
1818
use anyhow::Ok;
1919
use std::assert_matches::assert_matches;
20-
use std::time::Duration;
2120
use subxt::ext::futures::{FutureExt, StreamExt};
2221

2322
/// The extrinsic and event for a recent sudo call.
@@ -643,7 +642,6 @@ async fn no_expected_test_slot_time_alert() -> anyhow::Result<()> {
643642
let second_block = mock_block_info(200000, Slot(200));
644643

645644
let mut naive_slot_time_monitor = MemorySlotTimeMonitor::new(SlotTimeMonitorConfig::new(
646-
Duration::from_secs(1),
647645
2, // max_block_buffer - small buffer for testing
648646
2f64, // slow_slots_threshold
649647
0.1f64, // fast_slots_threshold
@@ -676,7 +674,6 @@ async fn expected_test_slot_time_alert() -> anyhow::Result<()> {
676674
let second_block = mock_block_info(200000, Slot(200));
677675

678676
let mut strict_slot_time_monitor = MemorySlotTimeMonitor::new(SlotTimeMonitorConfig::new(
679-
Duration::from_secs(1),
680677
2, // max_block_buffer - small buffer for testing
681678
0.2f64, // slow_slots_threshold
682679
0.1f64, // fast_slots_threshold
@@ -732,7 +729,6 @@ async fn test_slot_time_above_slow_threshold() -> anyhow::Result<()> {
732729
let second_block = mock_block_info(200000, Slot(101));
733730

734731
let mut slot_time_monitor = MemorySlotTimeMonitor::new(SlotTimeMonitorConfig::new(
735-
Duration::from_secs(1),
736732
2, // max_block_buffer - small buffer for testing
737733
2f64, // slow_slots_threshold
738734
0.01f64, // fast_slots_threshold
@@ -788,7 +784,6 @@ async fn test_slot_time_below_fast_threshold() -> anyhow::Result<()> {
788784
let second_block = mock_block_info(200000, Slot(200));
789785

790786
let mut slot_time_monitor = MemorySlotTimeMonitor::new(SlotTimeMonitorConfig::new(
791-
Duration::from_secs(1),
792787
2, // max_block_buffer - small buffer for testing
793788
10f64, // slow_slots_threshold
794789
2f64, // fast_slots_threshold
@@ -840,7 +835,6 @@ async fn test_slot_time_alerts_ignored_during_startup() -> anyhow::Result<()> {
840835
let second_block = mock_block_info(2000, Slot(200));
841836

842837
let mut slot_time_monitor = MemorySlotTimeMonitor::new(SlotTimeMonitorConfig::new(
843-
Duration::from_secs(1),
844838
2, // max_block_buffer - small buffer for testing
845839
0.5f64, // slow_slots_threshold (0.1 < 0.5, so would normally trigger)
846840
0.1f64, // fast_slots_threshold
@@ -874,7 +868,6 @@ async fn test_slot_time_alerts_not_triggered_when_buffer_not_full() -> anyhow::R
874868
let second_block = mock_block_info(200000, Slot(200));
875869

876870
let mut slot_time_monitor = MemorySlotTimeMonitor::new(SlotTimeMonitorConfig::new(
877-
Duration::from_secs(1),
878871
3, // max_block_buffer - need 3 blocks to fill buffer
879872
0.5f64, // slow_slots_threshold (1.0 > 0.5, so would trigger if buffer was full)
880873
0.1f64, // fast_slots_threshold

chain-alerter/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use crate::farming_monitor::{
2626
use crate::format::fmt_duration;
2727
use crate::slack::{SLACK_OAUTH_SECRET_PATH, SlackClientInfo};
2828
use crate::slot_time_monitor::{
29-
DEFAULT_CHECK_INTERVAL, DEFAULT_FAST_SLOTS_THRESHOLD, DEFAULT_MAX_BLOCK_BUFFER,
30-
DEFAULT_SLOW_SLOTS_THRESHOLD, SlotTimeMonitorConfig,
29+
DEFAULT_FAST_SLOTS_THRESHOLD, DEFAULT_MAX_BLOCK_BUFFER, DEFAULT_SLOW_SLOTS_THRESHOLD,
30+
SlotTimeMonitorConfig,
3131
};
3232
use crate::subspace::{
3333
BlockInfo, BlockLink, BlockNumber, BlockPosition, BlockSubscription, LOCAL_SUBSPACE_NODE_URL,
@@ -1020,7 +1020,6 @@ async fn check_best_blocks(
10201020

10211021
// Slot time monitor is used to check if the slot time is within the expected range.
10221022
let mut slot_time_monitor = MemorySlotTimeMonitor::new(SlotTimeMonitorConfig::new(
1023-
DEFAULT_CHECK_INTERVAL,
10241023
DEFAULT_MAX_BLOCK_BUFFER,
10251024
DEFAULT_SLOW_SLOTS_THRESHOLD,
10261025
DEFAULT_FAST_SLOTS_THRESHOLD,

chain-alerter/src/slot_time_monitor.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::alerts::{Alert, AlertKind, BlockCheckMode};
77
use crate::subspace::BlockInfo;
88
use anyhow::Ok;
99
use std::collections::VecDeque;
10-
use std::time::Duration;
1110
use tokio::sync::mpsc;
1211
use tracing::warn;
1312

@@ -24,11 +23,9 @@ pub const DEFAULT_SLOW_SLOTS_THRESHOLD: f64 = 1.10;
2423
pub const DEFAULT_FAST_SLOTS_THRESHOLD: f64 = 0.94;
2524

2625
/// The default maximum block buffer size.
26+
/// The check interval is approximately 6 times this number (the target block time is 6 seconds).
2727
pub const DEFAULT_MAX_BLOCK_BUFFER: usize = 100;
2828

29-
/// The default check interval for the slot time monitor.
30-
pub const DEFAULT_CHECK_INTERVAL: Duration = Duration::from_secs(600);
31-
3229
/// Interface for slot time monitors that consume blocks and perform checks.
3330
pub trait SlotTimeMonitor {
3431
/// Ingest a block and update internal state; may emit alerts.
@@ -43,8 +40,6 @@ pub trait SlotTimeMonitor {
4340
/// Configuration for the slot time monitor.
4441
#[derive(Clone, Debug)]
4542
pub struct SlotTimeMonitorConfig {
46-
/// Interval between checks of slot timing.
47-
pub check_interval: Duration,
4843
/// Maximum block buffer
4944
pub max_block_buffer: usize,
5045
/// Minimum threshold for alerting based on time-per-slot ratio.
@@ -90,19 +85,12 @@ pub enum AlertingStatus {
9085
impl SlotTimeMonitorConfig {
9186
/// Create a new slot time monitor configuration with the provided parameters.
9287
pub fn new(
93-
check_interval: Duration,
9488
max_block_buffer: usize,
9589
slow_slots_threshold: f64,
9690
fast_slots_threshold: f64,
9791
alert_tx: mpsc::Sender<Alert>,
9892
) -> Self {
99-
assert!(
100-
u64::try_from(check_interval.as_millis()).is_ok(),
101-
"unexpectedly large check interval"
102-
);
103-
10493
Self {
105-
check_interval,
10694
max_block_buffer,
10795
slow_slots_threshold,
10896
fast_slots_threshold,

0 commit comments

Comments
 (0)