From dcfd823ca87058b6972ff42941c1a276b27db393 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Tue, 12 Jul 2022 18:17:42 +0100 Subject: [PATCH] Clean up activated `reject_non_rent_exempt_vote_withdraws` feature (#26558) Clean up activated reject_non_rent_exempt_vote_withdraws feature --- programs/vote/src/vote_processor.rs | 32 +++-------------------------- programs/vote/src/vote_state/mod.rs | 4 ++-- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/programs/vote/src/vote_processor.rs b/programs/vote/src/vote_processor.rs index 9b4a685bbe..dc7098e8fa 100644 --- a/programs/vote/src/vote_processor.rs +++ b/programs/vote/src/vote_processor.rs @@ -175,14 +175,7 @@ pub fn process_instruction( } VoteInstruction::Withdraw(lamports) => { instruction_context.check_number_of_instruction_accounts(2)?; - let rent_sysvar = if invoke_context - .feature_set - .is_active(&feature_set::reject_non_rent_exempt_vote_withdraws::id()) - { - Some(invoke_context.get_sysvar_cache().get_rent()?) - } else { - None - }; + let rent_sysvar = invoke_context.get_sysvar_cache().get_rent()?; let clock_if_feature_active = if invoke_context .feature_set @@ -201,7 +194,7 @@ pub fn process_instruction( lamports, 1, &signers, - rent_sysvar.as_deref(), + &rent_sysvar, clock_if_feature_active.as_deref(), ) } @@ -1181,28 +1174,9 @@ mod tests { Err(VoteError::ActiveVoteAccountClose.into()), ); - // Both features disabled: - // reject_non_rent_exempt_vote_withdraws + // Following features disabled: // reject_vote_account_close_unless_zero_credit_epoch - // non rent exempt withdraw, with 0 credit epoch - instruction_accounts[0].pubkey = vote_pubkey_1; - process_instruction_disabled_features( - &serialize(&VoteInstruction::Withdraw(lamports - minimum_balance + 1)).unwrap(), - transaction_accounts.clone(), - instruction_accounts.clone(), - Ok(()), - ); - - // non rent exempt withdraw, without 0 credit epoch - instruction_accounts[0].pubkey = vote_pubkey_2; - process_instruction_disabled_features( - &serialize(&VoteInstruction::Withdraw(lamports - minimum_balance + 1)).unwrap(), - transaction_accounts.clone(), - instruction_accounts.clone(), - Ok(()), - ); - // full withdraw, with 0 credit epoch instruction_accounts[0].pubkey = vote_pubkey_1; process_instruction_disabled_features( diff --git a/programs/vote/src/vote_state/mod.rs b/programs/vote/src/vote_state/mod.rs index c9d99ebffa..48fcedbe84 100644 --- a/programs/vote/src/vote_state/mod.rs +++ b/programs/vote/src/vote_state/mod.rs @@ -1547,7 +1547,7 @@ pub fn withdraw( lamports: u64, to_account_index: usize, signers: &HashSet, - rent_sysvar: Option<&Rent>, + rent_sysvar: &Rent, clock: Option<&Clock>, ) -> Result<(), InstructionError> { let mut vote_account = instruction_context @@ -1583,7 +1583,7 @@ pub fn withdraw( datapoint_debug!("vote-account-close", ("allow", 1, i64)); vote_account.set_state(&VoteStateVersions::new_current(VoteState::default()))?; } - } else if let Some(rent_sysvar) = rent_sysvar { + } else { let min_rent_exempt_balance = rent_sysvar.minimum_balance(vote_account.get_data().len()); if remaining_balance < min_rent_exempt_balance { return Err(InstructionError::InsufficientFunds);