Skip to content

Commit

Permalink
Test for epoch flags that are not respected until after a restart
Browse files Browse the repository at this point in the history
  • Loading branch information
mystenmark authored and williampsmith committed Jun 25, 2024
1 parent 72de287 commit da2e5d8
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ impl AuthorityPerEpochStore {
epoch_id
);
let epoch_start_configuration = Arc::new(epoch_start_configuration);
info!("epoch flags: {:?}", epoch_start_configuration.flags());
metrics.current_epoch.set(epoch_id as i64);
metrics
.current_voting_right
Expand Down
4 changes: 4 additions & 0 deletions crates/sui-core/src/state_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@ impl StateAccumulatorV2 {
checkpoint_acc: Option<Accumulator>,
) -> SuiResult {
let _scope = monitored_scope("AccumulateRunningRoot");
tracing::info!(
"accumulating running root for checkpoint {}",
checkpoint_seq_num
);

// For the last checkpoint of the epoch, this function will be called once by the
// checkpoint builder, and again by checkpoint executor.
Expand Down
67 changes: 66 additions & 1 deletion crates/sui-e2e-tests/tests/reconfiguration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use futures::future::join_all;
use rand::rngs::OsRng;
use std::collections::{BTreeSet, HashSet};
use std::sync::Arc;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use sui_core::consensus_adapter::position_submit_certificate;
use sui_json_rpc_types::SuiTransactionBlockEffectsAPI;
Expand Down Expand Up @@ -710,6 +710,71 @@ async fn do_test_reconfig_with_committee_change_stress() {
}
}

#[cfg(msim)]
#[sim_test]
async fn test_epoch_flag_upgrade() {
use std::any;

use sui_core::authority::epoch_start_configuration::EpochFlag;
use sui_core::authority::epoch_start_configuration::EpochStartConfigTrait;
use sui_macros::register_fail_point_arg;

let initial_flags_nodes = Arc::new(Mutex::new(HashSet::new()));
register_fail_point_arg("initial_epoch_flags", move || {
// only alter flags on each node once
let current_node = sui_simulator::current_simnode_id();

// override flags on up to 2 nodes.
let mut initial_flags_nodes = initial_flags_nodes.lock().unwrap();
if initial_flags_nodes.len() >= 2 || !initial_flags_nodes.insert(current_node) {
return None;
}

// start with no flags set
Some(Vec::<EpochFlag>::new())
});

let test_cluster = TestClusterBuilder::new()
.with_epoch_duration_ms(30000)
.build()
.await;

let mut any_empty = false;
for node in test_cluster.all_node_handles() {
any_empty = any_empty
|| node.with(|node| {
node.state()
.epoch_store_for_testing()
.epoch_start_config()
.flags()
.is_empty()
});
}
assert!(any_empty);

test_cluster.wait_for_epoch_all_nodes(1).await;

let mut any_empty = false;
for node in test_cluster.all_node_handles() {
any_empty = any_empty
|| node.with(|node| {
node.state()
.epoch_store_for_testing()
.epoch_start_config()
.flags()
.is_empty()
});
}
assert!(!any_empty);

sleep(Duration::from_secs(15)).await;

test_cluster.stop_all_validators().await;
test_cluster.start_all_validators().await;

test_cluster.wait_for_epoch_all_nodes(2).await;
}

#[cfg(msim)]
#[sim_test]
async fn safe_mode_reconfig_test() {
Expand Down

0 comments on commit da2e5d8

Please sign in to comment.