Skip to content

Commit

Permalink
Rename OverloadThresholdConfig to AuthorityOverloadConfig (MystenLabs…
Browse files Browse the repository at this point in the history
…#16262)

## Description 

The config is no longer just threshold. Should be a safe change since it
is not being explicitly set in prod.

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
halfprice authored Feb 15, 2024
1 parent 744141f commit df41d5f
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 80 deletions.
12 changes: 6 additions & 6 deletions crates/sui-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ pub struct NodeConfig {
#[serde(default = "default_zklogin_oauth_providers")]
pub zklogin_oauth_providers: BTreeMap<Chain, BTreeSet<String>>,

#[serde(default = "default_overload_threshold_config")]
pub overload_threshold_config: OverloadThresholdConfig,
#[serde(default = "default_authority_overload_config")]
pub authority_overload_config: AuthorityOverloadConfig,

#[serde(skip_serializing_if = "Option::is_none")]
pub run_with_range: Option<RunWithRange>,
Expand Down Expand Up @@ -686,7 +686,7 @@ pub struct TransactionKeyValueStoreWriteConfig {
/// resolves.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct OverloadThresholdConfig {
pub struct AuthorityOverloadConfig {
#[serde(default = "default_max_txn_age_in_queue")]
pub max_txn_age_in_queue: Duration,

Expand Down Expand Up @@ -757,7 +757,7 @@ fn default_safe_transaction_ready_rate() -> u32 {
100
}

impl Default for OverloadThresholdConfig {
impl Default for AuthorityOverloadConfig {
fn default() -> Self {
Self {
max_txn_age_in_queue: default_max_txn_age_in_queue(),
Expand All @@ -774,8 +774,8 @@ impl Default for OverloadThresholdConfig {
}
}

fn default_overload_threshold_config() -> OverloadThresholdConfig {
OverloadThresholdConfig::default()
fn default_authority_overload_config() -> AuthorityOverloadConfig {
AuthorityOverloadConfig::default()
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq)]
Expand Down
18 changes: 9 additions & 9 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use std::{
sync::Arc,
vec,
};
use sui_config::node::{OverloadThresholdConfig, StateDebugDumpConfig};
use sui_config::node::{AuthorityOverloadConfig, StateDebugDumpConfig};
use sui_config::NodeConfig;
use sui_types::type_resolver::LayoutResolver;
use tap::{TapFallible, TapOptional};
Expand Down Expand Up @@ -748,7 +748,7 @@ pub struct AuthorityState {
debug_dump_config: StateDebugDumpConfig,

/// Config for when we consider the node overloaded.
overload_threshold_config: OverloadThresholdConfig,
authority_overload_config: AuthorityOverloadConfig,

/// Current overload status in this authority. Updated periodically.
pub overload_info: AuthorityOverloadInfo,
Expand Down Expand Up @@ -778,7 +778,7 @@ impl AuthorityState {
}

pub fn max_txn_age_in_queue(&self) -> Duration {
self.overload_threshold_config.max_txn_age_in_queue
self.authority_overload_config.max_txn_age_in_queue
}

pub fn get_epoch_state_commitments(
Expand Down Expand Up @@ -935,12 +935,12 @@ impl AuthorityState {
}

pub fn check_system_overload_at_signing(&self) -> bool {
self.overload_threshold_config
self.authority_overload_config
.check_system_overload_at_signing
}

pub fn check_system_overload_at_execution(&self) -> bool {
self.overload_threshold_config
self.authority_overload_config
.check_system_overload_at_execution
}

Expand Down Expand Up @@ -2501,7 +2501,7 @@ impl AuthorityState {
certificate_deny_config: CertificateDenyConfig,
indirect_objects_threshold: usize,
debug_dump_config: StateDebugDumpConfig,
overload_threshold_config: OverloadThresholdConfig,
authority_overload_config: AuthorityOverloadConfig,
archive_readers: ArchiveReaderBalancer,
) -> Arc<Self> {
Self::check_protocol_version(supported_protocol_versions, epoch_store.protocol_version());
Expand Down Expand Up @@ -2554,7 +2554,7 @@ impl AuthorityState {
transaction_deny_config,
certificate_deny_config,
debug_dump_config,
overload_threshold_config: overload_threshold_config.clone(),
authority_overload_config: authority_overload_config.clone(),
overload_info: AuthorityOverloadInfo::default(),
});

Expand All @@ -2567,9 +2567,9 @@ impl AuthorityState {
));

// Don't start the overload monitor when max_load_shedding_percentage is 0.
if overload_threshold_config.max_load_shedding_percentage > 0 {
if authority_overload_config.max_load_shedding_percentage > 0 {
let authority_state = Arc::downgrade(&state);
spawn_monitored_task!(overload_monitor(authority_state, overload_threshold_config));
spawn_monitored_task!(overload_monitor(authority_state, authority_overload_config));
}

// TODO: This doesn't belong to the constructor of AuthorityState.
Expand Down
12 changes: 6 additions & 6 deletions crates/sui-core/src/authority/test_authority_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use std::sync::Arc;
use sui_archival::reader::ArchiveReaderBalancer;
use sui_config::certificate_deny_config::CertificateDenyConfig;
use sui_config::genesis::Genesis;
use sui_config::node::{AuthorityOverloadConfig, StateDebugDumpConfig};
use sui_config::node::{
AuthorityStorePruningConfig, DBCheckpointConfig, ExpensiveSafetyCheckConfig,
};
use sui_config::node::{OverloadThresholdConfig, StateDebugDumpConfig};
use sui_config::transaction_deny_config::TransactionDenyConfig;
use sui_macros::nondeterministic;
use sui_protocol_config::{ProtocolConfig, SupportedProtocolVersions};
Expand Down Expand Up @@ -53,7 +53,7 @@ pub struct TestAuthorityBuilder<'a> {
accounts: Vec<AccountConfig>,
/// By default, we don't insert the genesis checkpoint, which isn't needed by most tests.
insert_genesis_checkpoint: bool,
overload_threshold_config: Option<OverloadThresholdConfig>,
authority_overload_config: Option<AuthorityOverloadConfig>,
}

impl<'a> TestAuthorityBuilder<'a> {
Expand Down Expand Up @@ -145,8 +145,8 @@ impl<'a> TestAuthorityBuilder<'a> {
self
}

pub fn with_overload_threshold_config(mut self, config: OverloadThresholdConfig) -> Self {
assert!(self.overload_threshold_config.replace(config).is_none());
pub fn with_authority_overload_config(mut self, config: AuthorityOverloadConfig) -> Self {
assert!(self.authority_overload_config.replace(config).is_none());
self
}

Expand Down Expand Up @@ -249,7 +249,7 @@ impl<'a> TestAuthorityBuilder<'a> {
};
let transaction_deny_config = self.transaction_deny_config.unwrap_or_default();
let certificate_deny_config = self.certificate_deny_config.unwrap_or_default();
let overload_threshold_config = self.overload_threshold_config.unwrap_or_default();
let authority_overload_config = self.authority_overload_config.unwrap_or_default();
let mut pruning_config = AuthorityStorePruningConfig::default();
if !epoch_store
.protocol_config()
Expand Down Expand Up @@ -279,7 +279,7 @@ impl<'a> TestAuthorityBuilder<'a> {
StateDebugDumpConfig {
dump_file_directory: Some(tempdir().unwrap().into_path()),
},
overload_threshold_config,
authority_overload_config,
ArchiveReaderBalancer::default(),
)
.await;
Expand Down
14 changes: 7 additions & 7 deletions crates/sui-core/src/overload_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::sync::Weak;
use std::time::Duration;
use std::time::{SystemTime, UNIX_EPOCH};
use sui_config::node::OverloadThresholdConfig;
use sui_config::node::AuthorityOverloadConfig;
use sui_types::digests::TransactionDigest;
use sui_types::error::SuiError;
use sui_types::error::SuiResult;
Expand Down Expand Up @@ -47,7 +47,7 @@ const ADDITIONAL_LOAD_SHEDDING: f64 = 0.1;
// when the signals indicates overload.
pub async fn overload_monitor(
authority_state: Weak<AuthorityState>,
config: OverloadThresholdConfig,
config: AuthorityOverloadConfig,
) {
info!("Starting system overload monitor.");

Expand All @@ -67,7 +67,7 @@ pub async fn overload_monitor(
// Returns whether the authority state exists.
fn check_authority_overload(
authority_state: &Weak<AuthorityState>,
config: &OverloadThresholdConfig,
config: &AuthorityOverloadConfig,
) -> bool {
let authority_arc = authority_state.upgrade();
if authority_arc.is_none() {
Expand Down Expand Up @@ -153,7 +153,7 @@ fn calculate_load_shedding_percentage(txn_ready_rate: f64, execution_rate: f64)
// When txn_ready_rate is less than execution_rate, we gradually reduce load shedding percentage until
// the queueing latency is back to normal.
fn check_overload_signals(
config: &OverloadThresholdConfig,
config: &AuthorityOverloadConfig,
current_load_shedding_percentage: u32,
queueing_latency: Duration,
txn_ready_rate: f64,
Expand Down Expand Up @@ -323,7 +323,7 @@ mod tests {

#[test]
pub fn test_check_overload_signals() {
let config = OverloadThresholdConfig {
let config = AuthorityOverloadConfig {
execution_queue_latency_hard_limit: Duration::from_secs(10),
execution_queue_latency_soft_limit: Duration::from_secs(1),
max_load_shedding_percentage: 90,
Expand Down Expand Up @@ -400,12 +400,12 @@ mod tests {

#[tokio::test(flavor = "current_thread")]
pub async fn test_check_authority_overload() {
let config = OverloadThresholdConfig {
let config = AuthorityOverloadConfig {
safe_transaction_ready_rate: 0,
..Default::default()
};
let state = TestAuthorityBuilder::new()
.with_overload_threshold_config(config.clone())
.with_authority_overload_config(config.clone())
.build()
.await;

Expand Down
6 changes: 3 additions & 3 deletions crates/sui-core/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::sync::Arc;
use std::time::Duration;
use sui_config::genesis::Genesis;
use sui_config::local_ip_utils;
use sui_config::node::OverloadThresholdConfig;
use sui_config::node::AuthorityOverloadConfig;
use sui_framework::BuiltInFramework;
use sui_genesis_builder::validator_info::ValidatorInfo;
use sui_macros::nondeterministic;
Expand Down Expand Up @@ -287,7 +287,7 @@ pub async fn init_local_authorities(
pub async fn init_local_authorities_with_overload_thresholds(
committee_size: usize,
genesis_objects: Vec<Object>,
overload_thresholds: OverloadThresholdConfig,
overload_thresholds: AuthorityOverloadConfig,
) -> (
AuthorityAggregator<LocalAuthorityClient>,
Vec<Arc<AuthorityState>>,
Expand All @@ -298,7 +298,7 @@ pub async fn init_local_authorities_with_overload_thresholds(
let authorities = join_all(key_pairs.iter().map(|(_, key_pair)| {
TestAuthorityBuilder::new()
.with_genesis_and_keypair(&genesis, key_pair)
.with_overload_threshold_config(overload_thresholds.clone())
.with_authority_overload_config(overload_thresholds.clone())
.build()
}))
.await;
Expand Down
12 changes: 6 additions & 6 deletions crates/sui-core/src/unit_tests/execution_driver_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::sync::Arc;
use std::time::Duration;

use itertools::Itertools;
use sui_config::node::OverloadThresholdConfig;
use sui_config::node::AuthorityOverloadConfig;
use sui_test_transaction_builder::TestTransactionBuilder;
use sui_types::base_types::TransactionDigest;
use sui_types::committee::Committee;
Expand Down Expand Up @@ -597,7 +597,7 @@ async fn test_txn_age_overload() {
init_local_authorities_with_overload_thresholds(
4,
gas_objects.clone(),
OverloadThresholdConfig {
AuthorityOverloadConfig {
max_txn_age_in_queue: Duration::from_secs(5),
..Default::default()
},
Expand Down Expand Up @@ -726,13 +726,13 @@ async fn test_authority_txn_signing_pushback() {

// Initialize an AuthorityState. Disable overload monitor by setting max_load_shedding_percentage to 0;
// Set check_system_overload_at_signing to true.
let overload_config = OverloadThresholdConfig {
let overload_config = AuthorityOverloadConfig {
check_system_overload_at_signing: true,
max_load_shedding_percentage: 0,
..Default::default()
};
let authority_state = TestAuthorityBuilder::new()
.with_overload_threshold_config(overload_config)
.with_authority_overload_config(overload_config)
.build()
.await;
authority_state
Expand Down Expand Up @@ -853,13 +853,13 @@ async fn test_authority_txn_execution_pushback() {

// Initialize an AuthorityState. Disable overload monitor by setting max_load_shedding_percentage to 0;
// Set check_system_overload_at_execution to true.
let overload_config = OverloadThresholdConfig {
let overload_config = AuthorityOverloadConfig {
check_system_overload_at_execution: true,
max_load_shedding_percentage: 0,
..Default::default()
};
let authority_state = TestAuthorityBuilder::new()
.with_overload_threshold_config(overload_config)
.with_authority_overload_config(overload_config)
.build()
.await;
authority_state
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-e2e-tests/tests/shared_objects_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use futures::join;
use rand::distributions::Distribution;
use std::ops::Deref;
use std::time::{Duration, SystemTime};
use sui_config::node::OverloadThresholdConfig;
use sui_config::node::AuthorityOverloadConfig;
use sui_core::authority::EffectsNotifyRead;
use sui_core::consensus_adapter::position_submit_certificate;
use sui_json_rpc_types::SuiTransactionBlockEffectsAPI;
Expand Down Expand Up @@ -534,7 +534,7 @@ async fn access_clock_object_test() {
async fn shared_object_sync() {
let test_cluster = TestClusterBuilder::new()
// Set the threshold high enough so it won't be triggered.
.with_overload_threshold_config(OverloadThresholdConfig {
.with_authority_overload_config(AuthorityOverloadConfig {
max_txn_age_in_queue: Duration::from_secs(60),
..Default::default()
})
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ impl SuiNode {
config.certificate_deny_config.clone(),
config.indirect_objects_threshold,
config.state_debug_dump_config.clone(),
config.overload_threshold_config.clone(),
config.authority_overload_config.clone(),
archive_readers,
)
.await;
Expand Down
16 changes: 8 additions & 8 deletions crates/sui-swarm-config/src/network_config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{num::NonZeroUsize, path::Path, sync::Arc};

use rand::rngs::OsRng;
use sui_config::genesis::{TokenAllocation, TokenDistributionScheduleBuilder};
use sui_config::node::OverloadThresholdConfig;
use sui_config::node::AuthorityOverloadConfig;
use sui_macros::nondeterministic;
use sui_protocol_config::SupportedProtocolVersions;
use sui_types::base_types::{AuthorityName, SuiAddress};
Expand Down Expand Up @@ -60,7 +60,7 @@ pub struct ConfigBuilder<R = OsRng> {
additional_objects: Vec<Object>,
jwk_fetch_interval: Option<Duration>,
num_unpruned_validators: Option<usize>,
overload_threshold_config: Option<OverloadThresholdConfig>,
authority_overload_config: Option<AuthorityOverloadConfig>,
data_ingestion_dir: Option<PathBuf>,
}

Expand All @@ -76,7 +76,7 @@ impl ConfigBuilder {
additional_objects: vec![],
jwk_fetch_interval: None,
num_unpruned_validators: None,
overload_threshold_config: None,
authority_overload_config: None,
data_ingestion_dir: None,
}
}
Expand Down Expand Up @@ -195,8 +195,8 @@ impl<R> ConfigBuilder<R> {
self
}

pub fn with_overload_threshold_config(mut self, c: OverloadThresholdConfig) -> Self {
self.overload_threshold_config = Some(c);
pub fn with_authority_overload_config(mut self, c: AuthorityOverloadConfig) -> Self {
self.authority_overload_config = Some(c);
self
}

Expand All @@ -211,7 +211,7 @@ impl<R> ConfigBuilder<R> {
additional_objects: self.additional_objects,
num_unpruned_validators: self.num_unpruned_validators,
jwk_fetch_interval: self.jwk_fetch_interval,
overload_threshold_config: self.overload_threshold_config,
authority_overload_config: self.authority_overload_config,
data_ingestion_dir: self.data_ingestion_dir,
}
}
Expand Down Expand Up @@ -359,9 +359,9 @@ impl<R: rand::RngCore + rand::CryptoRng> ConfigBuilder<R> {
builder = builder.with_jwk_fetch_interval(jwk_fetch_interval);
}

if let Some(overload_threshold_config) = &self.overload_threshold_config {
if let Some(authority_overload_config) = &self.authority_overload_config {
builder =
builder.with_overload_threshold_config(overload_threshold_config.clone());
builder.with_authority_overload_config(authority_overload_config.clone());
}

if let Some(path) = &self.data_ingestion_dir {
Expand Down
Loading

0 comments on commit df41d5f

Please sign in to comment.