From b1bf420524160e1b926c41d7242fd4c09435e7f3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 29 Nov 2021 21:06:13 +0000 Subject: [PATCH] fix checks in process_vote_authorize (backport #21465) (#21486) * fix checks in process_vote_authorize (#21465) (cherry picked from commit 09799590ac43337954e7cfd2d815b0d8a818a964) # Conflicts: # cli/src/vote.rs * resolve conflicts Co-authored-by: DimAn Co-authored-by: Justin Starry --- cli/src/vote.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cli/src/vote.rs b/cli/src/vote.rs index b29cfd7ac3..3c4ba497bf 100644 --- a/cli/src/vote.rs +++ b/cli/src/vote.rs @@ -666,24 +666,19 @@ pub fn process_vote_authorize( let authorized = config.signers[authorized]; let new_authorized_signer = new_authorized.map(|index| config.signers[index]); - check_unique_pubkeys( - (&authorized.pubkey(), "authorized_account".to_string()), - (new_authorized_pubkey, "new_authorized_pubkey".to_string()), - )?; - let (_, vote_state) = get_vote_account(rpc_client, vote_account_pubkey, config.commitment)?; match vote_authorize { VoteAuthorize::Voter => { + let current_epoch = rpc_client.get_epoch_info()?.epoch; let current_authorized_voter = vote_state .authorized_voters() - .last() + .get_authorized_voter(current_epoch) .ok_or_else(|| { CliError::RpcRequestError( "Invalid vote account state; no authorized voters found".to_string(), ) - })? - .1; - check_current_authority(current_authorized_voter, &authorized.pubkey())?; + })?; + check_current_authority(¤t_authorized_voter, &authorized.pubkey())?; if let Some(signer) = new_authorized_signer { if signer.is_interactive() { return Err(CliError::BadParameter(format!( @@ -694,6 +689,10 @@ pub fn process_vote_authorize( } } VoteAuthorize::Withdrawer => { + check_unique_pubkeys( + (&authorized.pubkey(), "authorized_account".to_string()), + (new_authorized_pubkey, "new_authorized_pubkey".to_string()), + )?; check_current_authority(&vote_state.authorized_withdrawer, &authorized.pubkey())? } }