Tiny cleanups in preparation for persistent tower (#10805)
This commit is contained in:
parent
9f5bd5fe81
commit
4164c69683
|
@ -321,6 +321,7 @@ impl Tower {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn record_vote(&mut self, slot: Slot, hash: Hash) -> Option<Slot> {
|
||||
let vote = Vote::new(vec![slot], hash);
|
||||
self.record_bank_vote(vote)
|
||||
|
@ -624,6 +625,12 @@ impl Tower {
|
|||
"vote account's node_pubkey doesn't match",
|
||||
);
|
||||
self.lockouts = vote_state;
|
||||
} else {
|
||||
info!(
|
||||
"vote account({}) not found in heaviest bank (slot={})",
|
||||
vote_account_pubkey,
|
||||
heaviest_bank.slot()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,18 +20,18 @@ use crate::{
|
|||
sigverify_stage::SigVerifyStage,
|
||||
};
|
||||
use crossbeam_channel::unbounded;
|
||||
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
|
||||
use solana_ledger::{
|
||||
blockstore::{Blockstore, CompletedSlotsReceiver},
|
||||
blockstore_processor::TransactionStatusSender,
|
||||
leader_schedule_cache::LeaderScheduleCache,
|
||||
};
|
||||
use solana_runtime::{bank_forks::BankForks, snapshot_package::AccountsPackageSender};
|
||||
use solana_sdk::{
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
net::UdpSocket,
|
||||
sync::{
|
||||
atomic::AtomicBool,
|
||||
|
@ -236,11 +236,15 @@ impl Tvu {
|
|||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use crate::banking_stage::create_test_recorder;
|
||||
use crate::cluster_info::{ClusterInfo, Node};
|
||||
use crate::{
|
||||
banking_stage::create_test_recorder,
|
||||
cluster_info::{ClusterInfo, Node},
|
||||
};
|
||||
use serial_test_derive::serial;
|
||||
use solana_ledger::create_new_tmp_ledger;
|
||||
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
|
||||
use solana_ledger::{
|
||||
create_new_tmp_ledger,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
};
|
||||
use solana_runtime::bank::Bank;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ use solana_sdk::{
|
|||
signature::{Keypair, Signer},
|
||||
timing::timestamp,
|
||||
};
|
||||
use solana_vote_program::vote_state::VoteState;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
|
@ -193,7 +194,6 @@ impl Validator {
|
|||
}
|
||||
}
|
||||
|
||||
info!("creating bank...");
|
||||
let (
|
||||
genesis_config,
|
||||
bank_forks,
|
||||
|
@ -205,11 +205,10 @@ impl Validator {
|
|||
) = new_banks_from_blockstore(config, ledger_path, poh_verify);
|
||||
|
||||
let leader_schedule_cache = Arc::new(leader_schedule_cache);
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let bank = bank_forks.working_bank();
|
||||
let bank_forks = Arc::new(RwLock::new(bank_forks));
|
||||
|
||||
info!("Starting validator from slot {}", bank.slot());
|
||||
info!("Starting validator with working bank slot {}", bank.slot());
|
||||
{
|
||||
let hard_forks: Vec<_> = bank.hard_forks().read().unwrap().iter().copied().collect();
|
||||
if !hard_forks.is_empty() {
|
||||
|
@ -217,16 +216,12 @@ impl Validator {
|
|||
}
|
||||
}
|
||||
|
||||
let mut validator_exit = ValidatorExit::default();
|
||||
let exit_ = exit.clone();
|
||||
validator_exit.register_exit(Box::new(move || exit_.store(true, Ordering::Relaxed)));
|
||||
let validator_exit = Arc::new(RwLock::new(Some(validator_exit)));
|
||||
|
||||
node.info.wallclock = timestamp();
|
||||
node.info.shred_version = compute_shred_version(
|
||||
&genesis_config.hash(),
|
||||
Some(&bank.hard_forks().read().unwrap()),
|
||||
);
|
||||
|
||||
Self::print_node_info(&node);
|
||||
|
||||
if let Some(expected_shred_version) = config.expected_shred_version {
|
||||
|
@ -239,6 +234,12 @@ impl Validator {
|
|||
}
|
||||
}
|
||||
|
||||
let mut validator_exit = ValidatorExit::default();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let exit_ = exit.clone();
|
||||
validator_exit.register_exit(Box::new(move || exit_.store(true, Ordering::Relaxed)));
|
||||
let validator_exit = Arc::new(RwLock::new(Some(validator_exit)));
|
||||
|
||||
let cluster_info = Arc::new(ClusterInfo::new(node.info.clone(), keypair.clone()));
|
||||
let blockstore = Arc::new(blockstore);
|
||||
let block_commitment_cache = Arc::new(RwLock::new(
|
||||
|
@ -620,7 +621,7 @@ fn new_banks_from_blockstore(
|
|||
)
|
||||
.unwrap_or_else(|err| {
|
||||
error!("Failed to load ledger: {:?}", err);
|
||||
std::process::exit(1);
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
leader_schedule_cache.set_fixed_leader_schedule(config.fixed_leader_schedule.clone());
|
||||
|
@ -865,8 +866,7 @@ fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: boo
|
|||
let my_id = cluster_info.id();
|
||||
|
||||
for (activated_stake, vote_account) in bank.vote_accounts().values() {
|
||||
let vote_state =
|
||||
solana_vote_program::vote_state::VoteState::from(&vote_account).unwrap_or_default();
|
||||
let vote_state = VoteState::from(&vote_account).unwrap_or_default();
|
||||
total_activated_stake += activated_stake;
|
||||
|
||||
if *activated_stake == 0 {
|
||||
|
|
|
@ -74,8 +74,7 @@
|
|||
|
||||
extern crate rand;
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
|
||||
#[derive(Clone, Default, Debug, Hash, Eq, PartialEq)]
|
||||
pub struct Fork {
|
||||
|
|
|
@ -185,7 +185,6 @@ impl LocalCluster {
|
|||
);
|
||||
|
||||
let mut validators = HashMap::new();
|
||||
error!("leader_pubkey: {}", leader_pubkey);
|
||||
let leader_info = ValidatorInfo {
|
||||
keypair: leader_keypair.clone(),
|
||||
voting_keypair: leader_voting_keypair,
|
||||
|
|
|
@ -830,6 +830,7 @@ fn test_snapshot_download() {
|
|||
#[test]
|
||||
#[serial]
|
||||
fn test_snapshot_restart_tower() {
|
||||
solana_logger::setup();
|
||||
// First set up the cluster with 2 nodes
|
||||
let snapshot_interval_slots = 10;
|
||||
let num_account_paths = 2;
|
||||
|
|
Loading…
Reference in New Issue