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