Add explicit comment about get_stake_account to StakeInstruction enum (#26824)

Add explicit comment about get_stake_account
This commit is contained in:
Tyera Eulberg 2022-07-27 19:44:52 -07:00 committed by GitHub
parent b660ac511d
commit 2481ebb150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -455,6 +455,20 @@ pub fn process_instruction(
Err(InstructionError::InvalidInstructionData)
}
}
// In order to prevent consensus issues, any new StakeInstruction variant added before the
// `add_get_minimum_delegation_instruction_to_stake_program` is activated needs to check
// the validity of the stake account by calling the `get_stake_account()` method outside
// its own feature gate, as per the following pattern:
// ```
// Ok(StakeInstruction::Variant) -> {
// let mut me = get_stake_account()?;
// if invoke_context
// .feature_set
// .is_active(&feature_set::stake_variant_feature::id()) { .. }
// }
// ```
// TODO: Remove this comment when `add_get_minimum_delegation_instruction_to_stake_program`
// is cleaned up
Err(err) => {
if !invoke_context.feature_set.is_active(
&feature_set::add_get_minimum_delegation_instruction_to_stake_program::id(),