Add authorized-voter add/remove-all commands
This commit is contained in:
@ -106,7 +106,7 @@ struct SkippedSlotsInfo {
|
||||
pub struct ReplayStageConfig {
|
||||
pub my_pubkey: Pubkey,
|
||||
pub vote_account: Pubkey,
|
||||
pub authorized_voter_keypairs: Vec<Arc<Keypair>>,
|
||||
pub authorized_voter_keypairs: Arc<RwLock<Vec<Arc<Keypair>>>>,
|
||||
pub exit: Arc<AtomicBool>,
|
||||
pub subscriptions: Arc<RpcSubscriptions>,
|
||||
pub leader_schedule_cache: Arc<LeaderScheduleCache>,
|
||||
@ -531,7 +531,7 @@ impl ReplayStage {
|
||||
&mut tower,
|
||||
&mut progress,
|
||||
&vote_account,
|
||||
&authorized_voter_keypairs,
|
||||
&authorized_voter_keypairs.read().unwrap(),
|
||||
&cluster_info,
|
||||
&blockstore,
|
||||
&leader_schedule_cache,
|
||||
|
@ -56,6 +56,7 @@ pub struct TestValidatorGenesis {
|
||||
epoch_schedule: Option<EpochSchedule>,
|
||||
pub validator_exit: Arc<RwLock<ValidatorExit>>,
|
||||
pub start_progress: Arc<RwLock<ValidatorStartProgress>>,
|
||||
pub authorized_voter_keypairs: Arc<RwLock<Vec<Arc<Keypair>>>>,
|
||||
}
|
||||
|
||||
impl TestValidatorGenesis {
|
||||
@ -399,6 +400,16 @@ impl TestValidator {
|
||||
let mut rpc_config = config.rpc_config.clone();
|
||||
rpc_config.identity_pubkey = validator_identity.pubkey();
|
||||
|
||||
{
|
||||
let mut authorized_voter_keypairs = config.authorized_voter_keypairs.write().unwrap();
|
||||
if !authorized_voter_keypairs
|
||||
.iter()
|
||||
.any(|x| x.pubkey() == vote_account_address)
|
||||
{
|
||||
authorized_voter_keypairs.push(Arc::new(validator_vote_account))
|
||||
}
|
||||
}
|
||||
|
||||
let validator_config = ValidatorConfig {
|
||||
rpc_addrs: Some((
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), node.info.rpc.port()),
|
||||
@ -434,8 +445,8 @@ impl TestValidator {
|
||||
node,
|
||||
&Arc::new(validator_identity),
|
||||
&ledger_path,
|
||||
&validator_vote_account.pubkey(),
|
||||
vec![Arc::new(validator_vote_account)],
|
||||
&vote_account_address,
|
||||
config.authorized_voter_keypairs.clone(),
|
||||
vec![],
|
||||
&validator_config,
|
||||
true, // should_check_duplicate_instance
|
||||
|
@ -100,7 +100,7 @@ impl Tvu {
|
||||
#[allow(clippy::new_ret_no_self, clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
vote_account: &Pubkey,
|
||||
authorized_voter_keypairs: Vec<Arc<Keypair>>,
|
||||
authorized_voter_keypairs: Arc<RwLock<Vec<Arc<Keypair>>>>,
|
||||
bank_forks: &Arc<RwLock<BankForks>>,
|
||||
cluster_info: &Arc<ClusterInfo>,
|
||||
sockets: Sockets,
|
||||
@ -389,7 +389,7 @@ pub mod tests {
|
||||
let tower = Tower::new_with_key(&target1_keypair.pubkey());
|
||||
let tvu = Tvu::new(
|
||||
&vote_keypair.pubkey(),
|
||||
vec![Arc::new(vote_keypair)],
|
||||
Arc::new(RwLock::new(vec![Arc::new(vote_keypair)])),
|
||||
&bank_forks,
|
||||
&cref1,
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ impl Validator {
|
||||
identity_keypair: &Arc<Keypair>,
|
||||
ledger_path: &Path,
|
||||
vote_account: &Pubkey,
|
||||
mut authorized_voter_keypairs: Vec<Arc<Keypair>>,
|
||||
authorized_voter_keypairs: Arc<RwLock<Vec<Arc<Keypair>>>>,
|
||||
cluster_entrypoints: Vec<ContactInfo>,
|
||||
config: &ValidatorConfig,
|
||||
should_check_duplicate_instance: bool,
|
||||
@ -311,12 +311,13 @@ impl Validator {
|
||||
|
||||
if config.voting_disabled {
|
||||
warn!("voting disabled");
|
||||
authorized_voter_keypairs.clear();
|
||||
authorized_voter_keypairs.write().unwrap().clear();
|
||||
} else {
|
||||
for authorized_voter_keypair in &authorized_voter_keypairs {
|
||||
for authorized_voter_keypair in authorized_voter_keypairs.read().unwrap().iter() {
|
||||
warn!("authorized voter: {}", authorized_voter_keypair.pubkey());
|
||||
}
|
||||
}
|
||||
|
||||
report_target_features();
|
||||
|
||||
for cluster_entrypoint in &cluster_entrypoints {
|
||||
@ -1559,7 +1560,7 @@ mod tests {
|
||||
&Arc::new(validator_keypair),
|
||||
&validator_ledger_path,
|
||||
&voting_keypair.pubkey(),
|
||||
vec![voting_keypair.clone()],
|
||||
Arc::new(RwLock::new(vec![voting_keypair.clone()])),
|
||||
vec![leader_node.info],
|
||||
&config,
|
||||
true, // should_check_duplicate_instance
|
||||
@ -1635,7 +1636,7 @@ mod tests {
|
||||
&Arc::new(validator_keypair),
|
||||
&validator_ledger_path,
|
||||
&vote_account_keypair.pubkey(),
|
||||
vec![Arc::new(vote_account_keypair)],
|
||||
Arc::new(RwLock::new(vec![Arc::new(vote_account_keypair)])),
|
||||
vec![leader_node.info.clone()],
|
||||
&config,
|
||||
true, // should_check_duplicate_instance
|
||||
|
Reference in New Issue
Block a user