Skip to main content

iota_config/
validator_client_monitor_config.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2024 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5//! Configuration for the Validator Client Monitor
6//!
7//! The Validator Client Monitor tracks client-observed performance metrics for
8//! validators in the IOTA network. It runs from the perspective of a fullnode
9//! and monitors:
10//! - Transaction submission latency
11//! - Effects retrieval latency
12//! - Health check response times
13//! - Success/failure rates
14
15use std::time::Duration;
16
17use serde::{Deserialize, Serialize};
18
19/// Configuration for validator client monitoring from the client perspective
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(rename_all = "kebab-case")]
22pub struct ValidatorClientMonitorConfig {
23    /// How often to perform health checks on validators.
24    #[serde(default = "default_health_check_interval")]
25    pub health_check_interval: Duration,
26
27    /// Timeout for health check requests.
28    #[serde(default = "default_health_check_timeout")]
29    pub health_check_timeout: Duration,
30
31    /// Weight for reliability when computing validator scores.
32    ///
33    /// Controls importance of reliability when adjusting the validator's
34    /// latency for transaction submission selection. The higher the weight,
35    /// the more penalty is given to unreliable validators. Default to 2.0.
36    /// Value should be positive.
37    #[serde(default = "default_reliability_weight")]
38    pub reliability_weight: f64,
39
40    /// Size of the moving window for latency measurements
41    #[serde(default = "default_latency_moving_window_size")]
42    pub latency_moving_window_size: usize,
43
44    /// Size of the moving window for reliability measurements
45    #[serde(default = "default_reliability_moving_window_size")]
46    pub reliability_moving_window_size: usize,
47}
48
49impl Default for ValidatorClientMonitorConfig {
50    fn default() -> Self {
51        Self {
52            health_check_interval: default_health_check_interval(),
53            health_check_timeout: default_health_check_timeout(),
54            reliability_weight: default_reliability_weight(),
55            latency_moving_window_size: default_latency_moving_window_size(),
56            reliability_moving_window_size: default_reliability_moving_window_size(),
57        }
58    }
59}
60
61fn default_health_check_interval() -> Duration {
62    Duration::from_secs(10)
63}
64
65fn default_health_check_timeout() -> Duration {
66    Duration::from_secs(2)
67}
68
69fn default_reliability_weight() -> f64 {
70    2.0
71}
72
73fn default_latency_moving_window_size() -> usize {
74    40
75}
76
77fn default_reliability_moving_window_size() -> usize {
78    20
79}