Add local cluster tests that broadcast duplicate slots (#13995)
* Add duplicate node local cluster test * fix clippy * remove dupe test
This commit is contained in:
@ -280,18 +280,23 @@ pub fn check_for_new_roots(num_new_roots: usize, contact_infos: &[ContactInfo],
|
||||
let mut last_print = Instant::now();
|
||||
let loop_start = Instant::now();
|
||||
let loop_timeout = Duration::from_secs(60);
|
||||
let mut num_roots_map = HashMap::new();
|
||||
while !done {
|
||||
assert!(loop_start.elapsed() < loop_timeout);
|
||||
|
||||
for (i, ingress_node) in contact_infos.iter().enumerate() {
|
||||
let client = create_client(ingress_node.client_facing_addr(), VALIDATOR_PORT_RANGE);
|
||||
let slot = client.get_slot().unwrap_or(0);
|
||||
roots[i].insert(slot);
|
||||
let min_node = roots.iter().map(|r| r.len()).min().unwrap_or(0);
|
||||
done = min_node >= num_new_roots;
|
||||
let root_slot = client
|
||||
.get_slot_with_commitment(CommitmentConfig::finalized())
|
||||
.unwrap_or(0);
|
||||
roots[i].insert(root_slot);
|
||||
num_roots_map.insert(ingress_node.id, roots[i].len());
|
||||
let num_roots = roots.iter().map(|r| r.len()).min().unwrap();
|
||||
done = num_roots >= num_new_roots;
|
||||
if done || last_print.elapsed().as_secs() > 3 {
|
||||
info!(
|
||||
"{} {} min observed roots {}/16",
|
||||
test_name, ingress_node.id, min_node
|
||||
"{} waiting for {} new roots.. observed: {:?}",
|
||||
test_name, num_new_roots, num_roots_map
|
||||
);
|
||||
last_print = Instant::now();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use solana_client::{
|
||||
thin_client::{create_client, ThinClient},
|
||||
};
|
||||
use solana_core::{
|
||||
broadcast_stage::BroadcastStageType,
|
||||
broadcast_stage::{BroadcastDuplicatesConfig, BroadcastStageType},
|
||||
consensus::{Tower, SWITCH_FORK_THRESHOLD, VOTE_THRESHOLD_DEPTH},
|
||||
optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
|
||||
validator::ValidatorConfig,
|
||||
@ -1967,32 +1967,52 @@ fn test_fail_entry_verification_leader() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(unused_attributes)]
|
||||
#[serial]
|
||||
#[ignore]
|
||||
#[allow(unused_attributes)]
|
||||
fn test_fake_shreds_broadcast_leader() {
|
||||
test_faulty_node(BroadcastStageType::BroadcastFakeShreds);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
#[ignore]
|
||||
#[allow(unused_attributes)]
|
||||
fn test_duplicate_shreds_broadcast_leader() {
|
||||
test_faulty_node(BroadcastStageType::BroadcastDuplicates(
|
||||
BroadcastDuplicatesConfig {
|
||||
stake_partition: 50,
|
||||
duplicate_send_delay: 1,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
fn test_faulty_node(faulty_node_type: BroadcastStageType) {
|
||||
solana_logger::setup_with_default(RUST_LOG_FILTER);
|
||||
let num_nodes = 2;
|
||||
solana_logger::setup_with_default("solana_local_cluster=info");
|
||||
let num_nodes = 3;
|
||||
|
||||
let error_validator_config = ValidatorConfig {
|
||||
broadcast_stage_type: faulty_node_type,
|
||||
..ValidatorConfig::default()
|
||||
};
|
||||
let mut validator_configs = Vec::with_capacity(num_nodes - 1);
|
||||
let mut validator_configs = Vec::with_capacity(num_nodes);
|
||||
validator_configs.resize_with(num_nodes - 1, ValidatorConfig::default);
|
||||
validator_configs.push(error_validator_config);
|
||||
|
||||
// Push a faulty_bootstrap = vec![error_validator_config];
|
||||
validator_configs.insert(0, error_validator_config);
|
||||
let node_stakes = vec![300, 100];
|
||||
let mut validator_keys = Vec::with_capacity(num_nodes);
|
||||
validator_keys.resize_with(num_nodes, || (Arc::new(Keypair::new()), true));
|
||||
|
||||
let node_stakes = vec![60, 50, 60];
|
||||
assert_eq!(node_stakes.len(), num_nodes);
|
||||
assert_eq!(validator_keys.len(), num_nodes);
|
||||
|
||||
let mut cluster_config = ClusterConfig {
|
||||
cluster_lamports: 10_000,
|
||||
node_stakes,
|
||||
validator_configs,
|
||||
slots_per_epoch: MINIMUM_SLOTS_PER_EPOCH * 2,
|
||||
stakers_slot_offset: MINIMUM_SLOTS_PER_EPOCH * 2,
|
||||
validator_keys: Some(validator_keys),
|
||||
slots_per_epoch: MINIMUM_SLOTS_PER_EPOCH * 2u64,
|
||||
stakers_slot_offset: MINIMUM_SLOTS_PER_EPOCH * 2u64,
|
||||
..ClusterConfig::default()
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user