Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit comment about get_stake_account to StakeInstruction enum #26824

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions programs/stake/src/stake_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down