From bde76cf98bb24ca087aea8b58ecc66add9584ef9 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Tue, 28 Jun 2022 20:35:23 +0100 Subject: [PATCH] Fix active vote account close error (#26250) (cherry picked from commit fa77cc5e4833b061722730df41f9056e96ff8cbd) --- programs/vote/src/vote_error.rs | 3 +++ programs/vote/src/vote_processor.rs | 2 +- programs/vote/src/vote_state/mod.rs | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/programs/vote/src/vote_error.rs b/programs/vote/src/vote_error.rs index be4855d120d33a..4d11ecd39cdb1d 100644 --- a/programs/vote/src/vote_error.rs +++ b/programs/vote/src/vote_error.rs @@ -64,6 +64,9 @@ pub enum VoteError { #[error("Proposed root is not in slot hashes")] RootOnDifferentFork, + + #[error("Cannot close vote account unless it stopped voting at least one full epoch ago")] + ActiveVoteAccountClose, } impl DecodeError for VoteError { diff --git a/programs/vote/src/vote_processor.rs b/programs/vote/src/vote_processor.rs index 45b615e6c02d35..7bf2b210ec673e 100644 --- a/programs/vote/src/vote_processor.rs +++ b/programs/vote/src/vote_processor.rs @@ -1207,7 +1207,7 @@ mod tests { &serialize(&VoteInstruction::Withdraw(lamports)).unwrap(), transaction_accounts.clone(), instruction_accounts.clone(), - Err(InstructionError::ActiveVoteAccountClose), + Err(VoteError::ActiveVoteAccountClose.into()), ); // Both features disabled: diff --git a/programs/vote/src/vote_state/mod.rs b/programs/vote/src/vote_state/mod.rs index e2d46e3c2d7ab5..7b61ecc5894863 100644 --- a/programs/vote/src/vote_state/mod.rs +++ b/programs/vote/src/vote_state/mod.rs @@ -1306,7 +1306,7 @@ pub fn withdraw( if reject_active_vote_account_close { datapoint_debug!("vote-account-close", ("reject-active", 1, i64)); - return Err(InstructionError::ActiveVoteAccountClose); + return Err(VoteError::ActiveVoteAccountClose.into()); } else { // Deinitialize upon zero-balance datapoint_debug!("vote-account-close", ("allow", 1, i64));