Skip to content

Commit

Permalink
Export metrics for buffer stake and number of submitting validators (M…
Browse files Browse the repository at this point in the history
  • Loading branch information
mystenmark authored Mar 24, 2023
1 parent 49af84b commit a49609f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
11 changes: 2 additions & 9 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use prometheus::{
use serde::de::DeserializeOwned;
use serde::Serialize;
use sui_framework::{MoveStdlib, SuiFramework, SuiSystem, SystemPackage};
use tap::{TapFallible, TapOptional};
use tap::TapFallible;
use tokio::sync::mpsc::unbounded_channel;
use tokio::sync::oneshot;
use tokio_retry::strategy::{jitter, ExponentialBackoff};
Expand Down Expand Up @@ -3175,14 +3175,7 @@ impl AuthorityState {
) -> anyhow::Result<(SuiSystemState, TransactionEffects)> {
let next_epoch = epoch_store.epoch() + 1;

let buffer_stake_bps = epoch_store
.get_override_protocol_upgrade_buffer_stake()
.tap_some(|b| warn!("using overrided buffer stake value of {}", b))
.unwrap_or_else(|| {
epoch_store
.protocol_config()
.buffer_stake_for_protocol_upgrade_bps()
});
let buffer_stake_bps = epoch_store.get_effective_buffer_stake_bps();

let (next_epoch_protocol_version, next_epoch_system_packages) =
Self::choose_protocol_version_and_system_packages(
Expand Down
25 changes: 21 additions & 4 deletions crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use sui_types::messages::{
VerifiedCertificate, VerifiedExecutableTransaction, VerifiedSignedTransaction,
};
use sui_types::signature::GenericSignature;
use tracing::{debug, info, trace, warn};
use tracing::{debug, error, info, trace, warn};
use typed_store::rocks::{
point_lookup_db_options, DBBatch, DBMap, DBOptions, MetricConf, TypedStoreError,
};
Expand Down Expand Up @@ -68,6 +68,7 @@ use sui_types::storage::{transaction_input_object_keys, ObjectKey, ParentSync};
use sui_types::sui_system_state::epoch_start_sui_system_state::{
EpochStartSystemState, EpochStartSystemStateTrait,
};
use tap::TapOptional;
use tokio::time::Instant;
use typed_store::{retry_transaction_forever, Map};
use typed_store_derive::DBMapUtils;
Expand Down Expand Up @@ -375,10 +376,11 @@ impl AuthorityPerEpochStore {
.epoch_start_state()
.protocol_version();
let protocol_config = ProtocolConfig::get_for_version(protocol_version);

let execution_component = ExecutionComponents::new(&protocol_config, store, cache_metrics);
let signature_verifier =
SignatureVerifier::new(committee.clone(), signature_verifier_metrics);
Arc::new(Self {
let s = Arc::new(Self {
committee,
protocol_config,
tables,
Expand All @@ -398,7 +400,9 @@ impl AuthorityPerEpochStore {
metrics,
epoch_start_configuration,
execution_component,
})
});
s.update_buffer_stake_metric();
s
}

pub fn get_parent_path(&self) -> PathBuf {
Expand Down Expand Up @@ -979,6 +983,7 @@ impl AuthorityPerEpochStore {
self.tables
.override_protocol_upgrade_buffer_stake
.remove(&OVERRIDE_PROTOCOL_UPGRADE_BUFFER_STAKE_INDEX)?;
self.update_buffer_stake_metric();
Ok(())
}

Expand All @@ -992,14 +997,26 @@ impl AuthorityPerEpochStore {
&OVERRIDE_PROTOCOL_UPGRADE_BUFFER_STAKE_INDEX,
&new_stake_bps,
)?;
self.update_buffer_stake_metric();
Ok(())
}

pub fn get_override_protocol_upgrade_buffer_stake(&self) -> Option<u64> {
fn update_buffer_stake_metric(&self) {
self.metrics
.effective_buffer_stake
.set(self.get_effective_buffer_stake_bps() as i64);
}

pub fn get_effective_buffer_stake_bps(&self) -> u64 {
self.tables
.override_protocol_upgrade_buffer_stake
.get(&OVERRIDE_PROTOCOL_UPGRADE_BUFFER_STAKE_INDEX)
.expect("force_protocol_upgrade read cannot fail")
.tap_some(|b| warn!("using overrided buffer stake value of {}", b))
.unwrap_or_else(|| {
self.protocol_config()
.buffer_stake_for_protocol_upgrade_bps()
})
}

/// Record most recently advertised capabilities of all authorities
Expand Down
8 changes: 8 additions & 0 deletions crates/sui-core/src/epoch/epoch_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ pub struct EpochMetrics {
/// without committing results to the store. It's useful to know whether this execution leads
/// to safe_mode, since in theory the result could be different from checkpoint executor.
pub checkpoint_builder_advance_epoch_is_safe_mode: IntGauge,

/// Buffer stake current in effect for this epoch
pub effective_buffer_stake: IntGauge,
}

impl EpochMetrics {
Expand Down Expand Up @@ -158,6 +161,11 @@ impl EpochMetrics {
"Whether the advance epoch execution leads to safe mode while building the last checkpoint",
registry,
).unwrap(),
effective_buffer_stake: register_int_gauge_with_registry!(
"effective_buffer_stake",
"Buffer stake current in effect for this epoch",
registry,
).unwrap(),
};
Arc::new(this)
}
Expand Down
14 changes: 6 additions & 8 deletions crates/sui-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,13 @@ impl SuiNode {
batch_verifier_metrics,
);

if let Some(override_buffer_stake) =
epoch_store.get_override_protocol_upgrade_buffer_stake()
{
let default_buffer_stake = epoch_store
.protocol_config()
.buffer_stake_for_protocol_upgrade_bps();

let effective_buffer_stake = epoch_store.get_effective_buffer_stake_bps();
let default_buffer_stake = epoch_store
.protocol_config()
.buffer_stake_for_protocol_upgrade_bps();
if effective_buffer_stake != default_buffer_stake {
warn!(
?override_buffer_stake,
?effective_buffer_stake,
?default_buffer_stake,
"buffer_stake_for_protocol_upgrade_bps is currently overridden"
);
Expand Down

0 comments on commit a49609f

Please sign in to comment.