Clean up activated `reject_non_rent_exempt_vote_withdraws` feature (#26558)
Clean up activated reject_non_rent_exempt_vote_withdraws feature
This commit is contained in:
parent
493108f026
commit
dcfd823ca8
|
@ -175,14 +175,7 @@ pub fn process_instruction(
|
||||||
}
|
}
|
||||||
VoteInstruction::Withdraw(lamports) => {
|
VoteInstruction::Withdraw(lamports) => {
|
||||||
instruction_context.check_number_of_instruction_accounts(2)?;
|
instruction_context.check_number_of_instruction_accounts(2)?;
|
||||||
let rent_sysvar = if invoke_context
|
let rent_sysvar = invoke_context.get_sysvar_cache().get_rent()?;
|
||||||
.feature_set
|
|
||||||
.is_active(&feature_set::reject_non_rent_exempt_vote_withdraws::id())
|
|
||||||
{
|
|
||||||
Some(invoke_context.get_sysvar_cache().get_rent()?)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let clock_if_feature_active = if invoke_context
|
let clock_if_feature_active = if invoke_context
|
||||||
.feature_set
|
.feature_set
|
||||||
|
@ -201,7 +194,7 @@ pub fn process_instruction(
|
||||||
lamports,
|
lamports,
|
||||||
1,
|
1,
|
||||||
&signers,
|
&signers,
|
||||||
rent_sysvar.as_deref(),
|
&rent_sysvar,
|
||||||
clock_if_feature_active.as_deref(),
|
clock_if_feature_active.as_deref(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1181,28 +1174,9 @@ mod tests {
|
||||||
Err(VoteError::ActiveVoteAccountClose.into()),
|
Err(VoteError::ActiveVoteAccountClose.into()),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Both features disabled:
|
// Following features disabled:
|
||||||
// reject_non_rent_exempt_vote_withdraws
|
|
||||||
// reject_vote_account_close_unless_zero_credit_epoch
|
// 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
|
// full withdraw, with 0 credit epoch
|
||||||
instruction_accounts[0].pubkey = vote_pubkey_1;
|
instruction_accounts[0].pubkey = vote_pubkey_1;
|
||||||
process_instruction_disabled_features(
|
process_instruction_disabled_features(
|
||||||
|
|
|
@ -1547,7 +1547,7 @@ pub fn withdraw<S: std::hash::BuildHasher>(
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
to_account_index: usize,
|
to_account_index: usize,
|
||||||
signers: &HashSet<Pubkey, S>,
|
signers: &HashSet<Pubkey, S>,
|
||||||
rent_sysvar: Option<&Rent>,
|
rent_sysvar: &Rent,
|
||||||
clock: Option<&Clock>,
|
clock: Option<&Clock>,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
let mut vote_account = instruction_context
|
let mut vote_account = instruction_context
|
||||||
|
@ -1583,7 +1583,7 @@ pub fn withdraw<S: std::hash::BuildHasher>(
|
||||||
datapoint_debug!("vote-account-close", ("allow", 1, i64));
|
datapoint_debug!("vote-account-close", ("allow", 1, i64));
|
||||||
vote_account.set_state(&VoteStateVersions::new_current(VoteState::default()))?;
|
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());
|
let min_rent_exempt_balance = rent_sysvar.minimum_balance(vote_account.get_data().len());
|
||||||
if remaining_balance < min_rent_exempt_balance {
|
if remaining_balance < min_rent_exempt_balance {
|
||||||
return Err(InstructionError::InsufficientFunds);
|
return Err(InstructionError::InsufficientFunds);
|
||||||
|
|
Loading…
Reference in New Issue