Speed up local cluster partitioning tests (#11177)
* Fix long local cluster partition tests by skipping slot warmup Co-authored-by: Carl <carl@solana.com>
This commit is contained in:
@ -1145,9 +1145,7 @@ mod tests {
|
||||
// Create the set of relevant voters for the next epoch
|
||||
let new_epoch = last_known_epoch + 1;
|
||||
let first_slot_in_new_epoch = bank.epoch_schedule().get_first_slot_in_epoch(new_epoch);
|
||||
let new_keypairs: Vec<_> = (0..10)
|
||||
.map(|_| ValidatorVoteKeypairs::new(Keypair::new(), Keypair::new(), Keypair::new()))
|
||||
.collect();
|
||||
let new_keypairs: Vec<_> = (0..10).map(|_| ValidatorVoteKeypairs::new_rand()).collect();
|
||||
let new_epoch_authorized_voters: HashMap<_, _> = new_keypairs
|
||||
.iter()
|
||||
.chain(validator_voting_keypairs[0..5].iter())
|
||||
@ -1186,15 +1184,14 @@ mod tests {
|
||||
let ref_count_per_vote = 2;
|
||||
|
||||
// Create some voters at genesis
|
||||
let validator_keypairs: Vec<_> = (0..2)
|
||||
.map(|_| ValidatorVoteKeypairs::new(Keypair::new(), Keypair::new(), Keypair::new()))
|
||||
.collect();
|
||||
let validator_keypairs: Vec<_> =
|
||||
(0..2).map(|_| ValidatorVoteKeypairs::new_rand()).collect();
|
||||
|
||||
let GenesisConfigInfo { genesis_config, .. } =
|
||||
genesis_utils::create_genesis_config_with_vote_accounts(
|
||||
10_000,
|
||||
&validator_keypairs,
|
||||
100,
|
||||
vec![100; validator_keypairs.len()],
|
||||
);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
@ -1331,14 +1328,13 @@ mod tests {
|
||||
Vec<ValidatorVoteKeypairs>,
|
||||
Arc<RpcSubscriptions>,
|
||||
) {
|
||||
let validator_voting_keypairs: Vec<_> = (0..10)
|
||||
.map(|_| ValidatorVoteKeypairs::new(Keypair::new(), Keypair::new(), Keypair::new()))
|
||||
.collect();
|
||||
let validator_voting_keypairs: Vec<_> =
|
||||
(0..10).map(|_| ValidatorVoteKeypairs::new_rand()).collect();
|
||||
let GenesisConfigInfo { genesis_config, .. } =
|
||||
genesis_utils::create_genesis_config_with_vote_accounts(
|
||||
10_000,
|
||||
&validator_voting_keypairs,
|
||||
100,
|
||||
vec![100; validator_voting_keypairs.len()],
|
||||
);
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let vote_tracker = VoteTracker::new(&bank);
|
||||
|
@ -687,12 +687,7 @@ pub mod test {
|
||||
create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs,
|
||||
},
|
||||
};
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
hash::Hash,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
};
|
||||
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey, signature::Signer};
|
||||
use solana_vote_program::{
|
||||
vote_state::{Vote, VoteStateVersions, MAX_LOCKOUT_HISTORY},
|
||||
vote_transaction,
|
||||
@ -947,14 +942,8 @@ pub mod test {
|
||||
HeaviestSubtreeForkChoice,
|
||||
) {
|
||||
let keypairs: HashMap<_, _> = std::iter::repeat_with(|| {
|
||||
let node_keypair = Keypair::new();
|
||||
let vote_keypair = Keypair::new();
|
||||
let stake_keypair = Keypair::new();
|
||||
let node_pubkey = node_keypair.pubkey();
|
||||
(
|
||||
node_pubkey,
|
||||
ValidatorVoteKeypairs::new(node_keypair, vote_keypair, stake_keypair),
|
||||
)
|
||||
let vote_keypairs = ValidatorVoteKeypairs::new_rand();
|
||||
(vote_keypairs.node_keypair.pubkey(), vote_keypairs)
|
||||
})
|
||||
.take(num_keypairs)
|
||||
.collect();
|
||||
@ -990,7 +979,11 @@ pub mod test {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
voting_keypair: _,
|
||||
} = create_genesis_config_with_vote_accounts(1_000_000_000, &validator_keypairs, stake);
|
||||
} = create_genesis_config_with_vote_accounts(
|
||||
1_000_000_000,
|
||||
&validator_keypairs,
|
||||
vec![stake; validator_keypairs.len()],
|
||||
);
|
||||
|
||||
let bank0 = Bank::new(&genesis_config);
|
||||
|
||||
|
@ -168,7 +168,7 @@ impl ForkProgress {
|
||||
num_dropped_blocks_on_fork: u64,
|
||||
) -> Self {
|
||||
let validator_fork_info = {
|
||||
if bank.collector_id() == my_pubkey {
|
||||
if bank.collector_id() == my_pubkey && bank.slot() > 0 {
|
||||
let stake = bank.epoch_vote_account_stake(voting_pubkey);
|
||||
Some(ValidatorStakeInfo::new(
|
||||
*voting_pubkey,
|
||||
|
@ -1182,7 +1182,7 @@ mod test {
|
||||
} = genesis_utils::create_genesis_config_with_vote_accounts(
|
||||
1_000_000_000,
|
||||
&[&keypairs],
|
||||
10000,
|
||||
vec![10000],
|
||||
);
|
||||
let bank0 = Arc::new(Bank::new(&genesis_config));
|
||||
let bank9 = Bank::new_from_parent(&bank0, &Pubkey::default(), duplicate_slot);
|
||||
@ -1244,7 +1244,7 @@ mod test {
|
||||
genesis_utils::create_genesis_config_with_vote_accounts(
|
||||
1_000_000_000,
|
||||
&[keypairs],
|
||||
100,
|
||||
vec![100],
|
||||
);
|
||||
let bank0 = Bank::new(&genesis_config);
|
||||
|
||||
|
@ -1955,9 +1955,8 @@ pub(crate) mod tests {
|
||||
Blockstore::open(&ledger_path)
|
||||
.expect("Expected to be able to open database ledger"),
|
||||
);
|
||||
let validator_authorized_voter_keypairs: Vec<_> = (0..20)
|
||||
.map(|_| ValidatorVoteKeypairs::new(Keypair::new(), Keypair::new(), Keypair::new()))
|
||||
.collect();
|
||||
let validator_authorized_voter_keypairs: Vec<_> =
|
||||
(0..20).map(|_| ValidatorVoteKeypairs::new_rand()).collect();
|
||||
|
||||
let validator_voting_keys: HashMap<_, _> = validator_authorized_voter_keypairs
|
||||
.iter()
|
||||
@ -1967,7 +1966,7 @@ pub(crate) mod tests {
|
||||
genesis_utils::create_genesis_config_with_vote_accounts(
|
||||
10_000,
|
||||
&validator_authorized_voter_keypairs,
|
||||
100,
|
||||
vec![100; validator_authorized_voter_keypairs.len()],
|
||||
);
|
||||
let bank0 = Bank::new(&genesis_config);
|
||||
let mut progress = ProgressMap::default();
|
||||
@ -2658,15 +2657,9 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_compute_bank_stats_confirmed() {
|
||||
let node_keypair = Keypair::new();
|
||||
let vote_keypair = Keypair::new();
|
||||
let stake_keypair = Keypair::new();
|
||||
let node_pubkey = node_keypair.pubkey();
|
||||
let mut keypairs = HashMap::new();
|
||||
keypairs.insert(
|
||||
node_pubkey,
|
||||
ValidatorVoteKeypairs::new(node_keypair, vote_keypair, stake_keypair),
|
||||
);
|
||||
let vote_keypairs = ValidatorVoteKeypairs::new_rand();
|
||||
let node_pubkey = vote_keypairs.node_keypair.pubkey();
|
||||
let keypairs: HashMap<_, _> = vec![(node_pubkey, vote_keypairs)].into_iter().collect();
|
||||
|
||||
let (bank_forks, mut progress, mut heaviest_subtree_fork_choice) =
|
||||
initialize_state(&keypairs, 10_000);
|
||||
@ -2985,14 +2978,8 @@ pub(crate) mod tests {
|
||||
#[test]
|
||||
fn test_update_slot_propagated_threshold_from_votes() {
|
||||
let keypairs: HashMap<_, _> = iter::repeat_with(|| {
|
||||
let node_keypair = Keypair::new();
|
||||
let vote_keypair = Keypair::new();
|
||||
let stake_keypair = Keypair::new();
|
||||
let node_pubkey = node_keypair.pubkey();
|
||||
(
|
||||
node_pubkey,
|
||||
ValidatorVoteKeypairs::new(node_keypair, vote_keypair, stake_keypair),
|
||||
)
|
||||
let vote_keypairs = ValidatorVoteKeypairs::new_rand();
|
||||
(vote_keypairs.node_keypair.pubkey(), vote_keypairs)
|
||||
})
|
||||
.take(10)
|
||||
.collect();
|
||||
@ -3165,17 +3152,10 @@ pub(crate) mod tests {
|
||||
#[test]
|
||||
fn test_update_propagation_status() {
|
||||
// Create genesis stakers
|
||||
let node_keypair = Keypair::new();
|
||||
let vote_keypair = Keypair::new();
|
||||
let stake_keypair = Keypair::new();
|
||||
let vote_pubkey = Arc::new(vote_keypair.pubkey());
|
||||
let mut keypairs = HashMap::new();
|
||||
|
||||
keypairs.insert(
|
||||
node_keypair.pubkey(),
|
||||
ValidatorVoteKeypairs::new(node_keypair, vote_keypair, stake_keypair),
|
||||
);
|
||||
|
||||
let vote_keypairs = ValidatorVoteKeypairs::new_rand();
|
||||
let node_pubkey = vote_keypairs.node_keypair.pubkey();
|
||||
let vote_pubkey = Arc::new(vote_keypairs.vote_keypair.pubkey());
|
||||
let keypairs: HashMap<_, _> = vec![(node_pubkey, vote_keypairs)].into_iter().collect();
|
||||
let stake = 10_000;
|
||||
let (mut bank_forks, mut progress_map, _) = initialize_state(&keypairs, stake);
|
||||
|
||||
@ -3257,14 +3237,8 @@ pub(crate) mod tests {
|
||||
#[test]
|
||||
fn test_chain_update_propagation_status() {
|
||||
let keypairs: HashMap<_, _> = iter::repeat_with(|| {
|
||||
let node_keypair = Keypair::new();
|
||||
let vote_keypair = Keypair::new();
|
||||
let stake_keypair = Keypair::new();
|
||||
let node_pubkey = node_keypair.pubkey();
|
||||
(
|
||||
node_pubkey,
|
||||
ValidatorVoteKeypairs::new(node_keypair, vote_keypair, stake_keypair),
|
||||
)
|
||||
let vote_keypairs = ValidatorVoteKeypairs::new_rand();
|
||||
(vote_keypairs.node_keypair.pubkey(), vote_keypairs)
|
||||
})
|
||||
.take(10)
|
||||
.collect();
|
||||
@ -3340,14 +3314,8 @@ pub(crate) mod tests {
|
||||
fn test_chain_update_propagation_status2() {
|
||||
let num_validators = 6;
|
||||
let keypairs: HashMap<_, _> = iter::repeat_with(|| {
|
||||
let node_keypair = Keypair::new();
|
||||
let vote_keypair = Keypair::new();
|
||||
let stake_keypair = Keypair::new();
|
||||
let node_pubkey = node_keypair.pubkey();
|
||||
(
|
||||
node_pubkey,
|
||||
ValidatorVoteKeypairs::new(node_keypair, vote_keypair, stake_keypair),
|
||||
)
|
||||
let vote_keypairs = ValidatorVoteKeypairs::new_rand();
|
||||
(vote_keypairs.node_keypair.pubkey(), vote_keypairs)
|
||||
})
|
||||
.take(num_validators)
|
||||
.collect();
|
||||
|
@ -1786,7 +1786,7 @@ pub mod tests {
|
||||
blockhash: Hash,
|
||||
alice: Keypair,
|
||||
leader_pubkey: Pubkey,
|
||||
leader_vote_keypair: Keypair,
|
||||
leader_vote_keypair: Arc<Keypair>,
|
||||
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
||||
confirmed_block_signatures: Vec<Signature>,
|
||||
}
|
||||
@ -1847,7 +1847,7 @@ pub mod tests {
|
||||
vote,
|
||||
);
|
||||
let vote_msg = Message::new(&[vote_ix], Some(&leader_vote_keypair.pubkey()));
|
||||
let vote_tx = Transaction::new(&[&leader_vote_keypair], vote_msg, Hash::default());
|
||||
let vote_tx = Transaction::new(&[&*leader_vote_keypair], vote_msg, Hash::default());
|
||||
let shreds = entries_to_test_shreds(
|
||||
vec![next_entry_mut(&mut Hash::default(), 0, vec![vote_tx])],
|
||||
1,
|
||||
@ -3208,7 +3208,7 @@ pub mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
fn new_bank_forks() -> (Arc<RwLock<BankForks>>, Keypair, Keypair) {
|
||||
fn new_bank_forks() -> (Arc<RwLock<BankForks>>, Keypair, Arc<Keypair>) {
|
||||
let GenesisConfigInfo {
|
||||
mut genesis_config,
|
||||
mint_keypair,
|
||||
|
@ -928,11 +928,13 @@ mod tests {
|
||||
fn test_vote_subscribe() {
|
||||
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new_for_tests()));
|
||||
|
||||
let validator_voting_keypairs: Vec<_> = (0..10)
|
||||
.map(|_| ValidatorVoteKeypairs::new(Keypair::new(), Keypair::new(), Keypair::new()))
|
||||
.collect();
|
||||
let GenesisConfigInfo { genesis_config, .. } =
|
||||
create_genesis_config_with_vote_accounts(10_000, &validator_voting_keypairs, 100);
|
||||
let validator_voting_keypairs: Vec<_> =
|
||||
(0..10).map(|_| ValidatorVoteKeypairs::new_rand()).collect();
|
||||
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config_with_vote_accounts(
|
||||
10_000,
|
||||
&validator_voting_keypairs,
|
||||
vec![100; validator_voting_keypairs.len()],
|
||||
);
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let bank_forks = BankForks::new(bank);
|
||||
|
@ -849,6 +849,8 @@ impl TestValidator {
|
||||
} = create_genesis_config_with_leader_ex(
|
||||
mint_lamports,
|
||||
&contact_info.id,
|
||||
Arc::new(Keypair::new()),
|
||||
Arc::new(Keypair::new()),
|
||||
42,
|
||||
bootstrap_validator_lamports,
|
||||
);
|
||||
@ -865,7 +867,6 @@ impl TestValidator {
|
||||
|
||||
let (ledger_path, blockhash) = create_new_tmp_ledger!(&genesis_config);
|
||||
|
||||
let leader_voting_keypair = Arc::new(voting_keypair);
|
||||
let config = ValidatorConfig {
|
||||
rpc_ports: Some((node.info.rpc.port(), node.info.rpc_pubsub.port())),
|
||||
..ValidatorConfig::default()
|
||||
@ -874,8 +875,8 @@ impl TestValidator {
|
||||
node,
|
||||
&node_keypair,
|
||||
&ledger_path,
|
||||
&leader_voting_keypair.pubkey(),
|
||||
vec![leader_voting_keypair.clone()],
|
||||
&voting_keypair.pubkey(),
|
||||
vec![voting_keypair.clone()],
|
||||
None,
|
||||
true,
|
||||
&config,
|
||||
@ -887,7 +888,7 @@ impl TestValidator {
|
||||
alice: mint_keypair,
|
||||
ledger_path,
|
||||
genesis_hash: blockhash,
|
||||
vote_pubkey: leader_voting_keypair.pubkey(),
|
||||
vote_pubkey: voting_keypair.pubkey(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user