clean feature: vote_stake_checked_instructions (#34079)

This commit is contained in:
Justin Starry 2023-11-18 00:34:11 +08:00 committed by GitHub
parent 29947ba867
commit 85db4da73e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 85 additions and 121 deletions

View File

@ -228,10 +228,6 @@ declare_process_instruction!(Entrypoint, DEFAULT_COMPUTE_UNITS, |invoke_context|
}
Ok(StakeInstruction::InitializeChecked) => {
let mut me = get_stake_account()?;
if invoke_context
.feature_set
.is_active(&feature_set::vote_stake_checked_instructions::id())
{
instruction_context.check_number_of_instruction_accounts(4)?;
let staker_pubkey = transaction_context.get_key_of_account_at_index(
instruction_context.get_index_of_instruction_account_in_transaction(2)?,
@ -248,19 +244,11 @@ declare_process_instruction!(Entrypoint, DEFAULT_COMPUTE_UNITS, |invoke_context|
withdrawer: *withdrawer_pubkey,
};
let rent =
get_sysvar_with_account_check::rent(invoke_context, instruction_context, 1)?;
let rent = get_sysvar_with_account_check::rent(invoke_context, instruction_context, 1)?;
initialize(&mut me, &authorized, &Lockup::default(), &rent)
} else {
Err(InstructionError::InvalidInstructionData)
}
}
Ok(StakeInstruction::AuthorizeChecked(stake_authorize)) => {
let mut me = get_stake_account()?;
if invoke_context
.feature_set
.is_active(&feature_set::vote_stake_checked_instructions::id())
{
let clock =
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 1)?;
instruction_context.check_number_of_instruction_accounts(4)?;
@ -281,16 +269,9 @@ declare_process_instruction!(Entrypoint, DEFAULT_COMPUTE_UNITS, |invoke_context|
&clock,
custodian_pubkey,
)
} else {
Err(InstructionError::InvalidInstructionData)
}
}
Ok(StakeInstruction::AuthorizeCheckedWithSeed(args)) => {
let mut me = get_stake_account()?;
if invoke_context
.feature_set
.is_active(&feature_set::vote_stake_checked_instructions::id())
{
instruction_context.check_number_of_instruction_accounts(2)?;
let clock =
get_sysvar_with_account_check::clock(invoke_context, instruction_context, 2)?;
@ -316,16 +297,9 @@ declare_process_instruction!(Entrypoint, DEFAULT_COMPUTE_UNITS, |invoke_context|
&clock,
custodian_pubkey,
)
} else {
Err(InstructionError::InvalidInstructionData)
}
}
Ok(StakeInstruction::SetLockupChecked(lockup_checked)) => {
let mut me = get_stake_account()?;
if invoke_context
.feature_set
.is_active(&feature_set::vote_stake_checked_instructions::id())
{
let custodian_pubkey =
get_optional_pubkey(transaction_context, instruction_context, 2, true)?;
@ -336,9 +310,6 @@ declare_process_instruction!(Entrypoint, DEFAULT_COMPUTE_UNITS, |invoke_context|
};
let clock = invoke_context.get_sysvar_cache().get_clock()?;
set_lockup(&mut me, &lockup, &signers, &clock)
} else {
Err(InstructionError::InvalidInstructionData)
}
}
Ok(StakeInstruction::GetMinimumDelegation) => {
let feature_set = invoke_context.feature_set.as_ref();

View File

@ -219,10 +219,6 @@ declare_process_instruction!(Entrypoint, DEFAULT_COMPUTE_UNITS, |invoke_context|
)
}
VoteInstruction::AuthorizeChecked(vote_authorize) => {
if invoke_context
.feature_set
.is_active(&feature_set::vote_stake_checked_instructions::id())
{
instruction_context.check_number_of_instruction_accounts(4)?;
let voter_pubkey = transaction_context.get_key_of_account_at_index(
instruction_context.get_index_of_instruction_account_in_transaction(3)?,
@ -240,9 +236,6 @@ declare_process_instruction!(Entrypoint, DEFAULT_COMPUTE_UNITS, |invoke_context|
&clock,
&invoke_context.feature_set,
)
} else {
Err(InstructionError::InvalidInstructionData)
}
}
}
});