Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system_invariant_violation macro #20105

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/mysten-common/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ macro_rules! debug_fatal {
if cfg!(debug_assertions) {
$crate::fatal!($($arg)*);
} else {
// TODO: Export invariant metric for alerting
tracing::error!(debug_fatal = true, $($arg)*);
let location = concat!(file!(), ':', line!());
if let Some(metrics) = mysten_metrics::get_metrics() {
metrics.system_invariant_violations.with_label_values(&[location]).inc();
}
}
}};
}
Expand Down
12 changes: 10 additions & 2 deletions crates/mysten-metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ use std::time::Instant;

use once_cell::sync::OnceCell;
use prometheus::{
register_histogram_with_registry, register_int_gauge_vec_with_registry, Histogram, IntGaugeVec,
Registry, TextEncoder,
register_histogram_with_registry, register_int_counter_vec_with_registry,
register_int_gauge_vec_with_registry, Histogram, IntCounterVec, IntGaugeVec, Registry,
TextEncoder,
};
use tap::TapFallible;
use tracing::{warn, Span};
Expand Down Expand Up @@ -69,6 +70,7 @@ pub struct Metrics {
pub scope_duration_ns: IntGaugeVec,
pub scope_entrance: IntGaugeVec,
pub thread_stall_duration_sec: Histogram,
pub system_invariant_violations: IntCounterVec,
}

impl Metrics {
Expand Down Expand Up @@ -143,6 +145,12 @@ impl Metrics {
registry,
)
.unwrap(),
system_invariant_violations: register_int_counter_vec_with_registry!(
"system_invariant_violations",
"Number of system invariant violations",
&["name"],
registry,
).unwrap(),
}
}
}
Expand Down
13 changes: 2 additions & 11 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ use mysten_metrics::{monitored_scope, spawn_monitored_task};

use crate::jsonrpc_index::IndexStore;
use crate::jsonrpc_index::{CoinInfo, ObjectIndexChanges};
use mysten_common::debug_fatal;
use once_cell::sync::OnceCell;
use shared_crypto::intent::{AppId, Intent, IntentMessage, IntentScope, IntentVersion};
use sui_archival::reader::ArchiveReaderBalancer;
Expand Down Expand Up @@ -303,8 +304,6 @@ pub struct AuthorityMetrics {
/// bytecode verifier metrics for tracking timeouts
pub bytecode_verifier_metrics: Arc<BytecodeVerifierMetrics>,

pub authenticator_state_update_failed: IntCounter,

/// Count of zklogin signatures
pub zklogin_sig_count: IntCounter,
/// Count of multisig signatures
Expand Down Expand Up @@ -736,12 +735,6 @@ impl AuthorityMetrics {
).unwrap(),
limits_metrics: Arc::new(LimitsMetrics::new(registry)),
bytecode_verifier_metrics: Arc::new(BytecodeVerifierMetrics::new(registry)),
authenticator_state_update_failed: register_int_counter_with_registry!(
"authenticator_state_update_failed",
"Number of failed authenticator state updates",
registry,
)
.unwrap(),
zklogin_sig_count: register_int_counter_with_registry!(
"zklogin_sig_count",
"Count of zkLogin signatures",
Expand Down Expand Up @@ -1511,10 +1504,8 @@ impl AuthorityState {
certificate.data().transaction_data().kind()
{
if let Some(err) = &execution_error_opt {
error!("Authenticator state update failed: {err}");
self.metrics.authenticator_state_update_failed.inc();
debug_fatal!("Authenticator state update failed: {:?}", err);
}
debug_assert!(execution_error_opt.is_none());
epoch_store.update_authenticator_state(auth_state);

// double check that the signature verifier always matches the authenticator state
Expand Down
Loading