sui_core/validator_client_monitor/
mod.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4mod metrics;
5mod monitor;
6mod stats;
7
8#[cfg(test)]
9mod tests;
10
11pub use metrics::ValidatorClientMetrics;
12pub use monitor::ValidatorClientMonitor;
13use std::time::Duration;
14use strum::EnumIter;
15use sui_types::{base_types::AuthorityName, messages_grpc::PingType};
16
17/// Operation types for validator performance tracking
18#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, EnumIter)]
19pub enum OperationType {
20    Submit,
21    Effects,
22    FastPath,
23    HealthCheck,
24    Consensus,
25}
26
27impl OperationType {
28    pub fn as_str(&self) -> &str {
29        match self {
30            OperationType::Submit => "submit",
31            OperationType::Effects => "effects",
32            OperationType::HealthCheck => "health_check",
33            OperationType::FastPath => "fast_path",
34            OperationType::Consensus => "consensus",
35        }
36    }
37}
38
39/// Feedback from TransactionDriver operations
40#[derive(Debug, Clone)]
41pub struct OperationFeedback {
42    /// The unique authority name (public key)
43    pub authority_name: AuthorityName,
44    /// The human-readable display name for the validator
45    pub display_name: String,
46    /// The operation type
47    pub operation: OperationType,
48    /// The ping type. If it's not a ping request, then this is None.
49    pub ping_type: Option<PingType>,
50    /// Result of the operation: Ok(latency) if successful, Err(()) if failed.
51    /// Only errors specific to the target validator should be recorded,
52    /// for example, timeout, unavailability or misbehavior from validators can be recorded.
53    /// But other errors unrelated to a specific validator, for example invalid user transaction,
54    /// should not be recorded.
55    pub result: Result<Duration, ()>,
56}