Remove active features stake program v3 and v4 (#22612)

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
This commit is contained in:
Brooks Prumo 2022-01-21 19:27:53 -06:00 committed by GitHub
parent 0cf886302d
commit a7f2fff219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 389 deletions

View File

@ -123,9 +123,6 @@ pub fn process_instruction(
}
}
StakeInstruction::DelegateStake => {
let can_reverse_deactivation = invoke_context
.feature_set
.is_active(&feature_set::stake_program_v4::id());
let vote = keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
me.delegate(
@ -143,7 +140,6 @@ pub fn process_instruction(
first_instruction_account + 4,
)?)?,
&signers,
can_reverse_deactivation,
)
}
StakeInstruction::Split(lamports) => {
@ -154,9 +150,6 @@ pub fn process_instruction(
StakeInstruction::Merge => {
let source_stake =
&keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
let can_merge_expired_lockups = invoke_context
.feature_set
.is_active(&feature_set::stake_program_v4::id());
me.merge(
invoke_context,
source_stake,
@ -169,7 +162,6 @@ pub fn process_instruction(
first_instruction_account + 3,
)?)?,
&signers,
can_merge_expired_lockups,
)
}
StakeInstruction::Withdraw(lamports) => {
@ -187,9 +179,6 @@ pub fn process_instruction(
)?)?,
keyed_account_at_index(keyed_accounts, first_instruction_account + 4)?,
keyed_account_at_index(keyed_accounts, first_instruction_account + 5).ok(),
invoke_context
.feature_set
.is_active(&feature_set::stake_program_v4::id()),
)
}
StakeInstruction::Deactivate => me.deactivate(
@ -200,15 +189,8 @@ pub fn process_instruction(
&signers,
),
StakeInstruction::SetLockup(lockup) => {
let clock = if invoke_context
.feature_set
.is_active(&feature_set::stake_program_v4::id())
{
Some(invoke_context.get_sysvar_cache().get_clock()?)
} else {
None
};
me.set_lockup(&lockup, &signers, clock.as_deref())
let clock = invoke_context.get_sysvar_cache().get_clock()?;
me.set_lockup(&lockup, &signers, &clock)
}
StakeInstruction::InitializeChecked => {
if invoke_context
@ -326,8 +308,8 @@ pub fn process_instruction(
epoch: lockup_checked.epoch,
custodian,
};
let clock = Some(invoke_context.get_sysvar_cache().get_clock()?);
me.set_lockup(&lockup, &signers, clock.as_deref())
let clock = invoke_context.get_sysvar_cache().get_clock()?;
me.set_lockup(&lockup, &signers, &clock)
} else {
Err(InstructionError::InvalidInstructionData)
}

File diff suppressed because it is too large Load Diff

View File

@ -256,28 +256,17 @@ impl Meta {
&mut self,
lockup: &LockupArgs,
signers: &HashSet<Pubkey>,
clock: Option<&Clock>,
clock: &Clock,
) -> Result<(), InstructionError> {
match clock {
None => {
// pre-stake_program_v4 behavior: custodian can set lockups at any time
if !signers.contains(&self.lockup.custodian) {
return Err(InstructionError::MissingRequiredSignature);
}
}
Some(clock) => {
// post-stake_program_v4 behavior:
// * custodian can update the lockup while in force
// * withdraw authority can set a new lockup
//
if self.lockup.is_in_force(clock, None) {
if !signers.contains(&self.lockup.custodian) {
return Err(InstructionError::MissingRequiredSignature);
}
} else if !signers.contains(&self.authorized.withdrawer) {
return Err(InstructionError::MissingRequiredSignature);
}
// post-stake_program_v4 behavior:
// * custodian can update the lockup while in force
// * withdraw authority can set a new lockup
if self.lockup.is_in_force(clock, None) {
if !signers.contains(&self.lockup.custodian) {
return Err(InstructionError::MissingRequiredSignature);
}
} else if !signers.contains(&self.authorized.withdrawer) {
return Err(InstructionError::MissingRequiredSignature);
}
if let Some(unix_timestamp) = lockup.unix_timestamp {
self.lockup.unix_timestamp = unix_timestamp;

View File

@ -65,10 +65,6 @@ pub mod filter_stake_delegation_accounts {
solana_sdk::declare_id!("GE7fRxmW46K6EmCD9AMZSbnaJ2e3LfqCZzdHi9hmYAgi");
}
pub mod stake_program_v3 {
solana_sdk::declare_id!("Ego6nTu7WsBcZBvVqJQKp6Yku2N3mrfG8oYCfaLZkAeK");
}
pub mod require_custodian_for_locked_stake_authorize {
solana_sdk::declare_id!("D4jsDcXaqdW8tDAWn8H4R25Cdns2YwLneujSL1zvjW6R");
}
@ -85,10 +81,6 @@ pub mod check_init_vote_data {
solana_sdk::declare_id!("3ccR6QpxGYsAbWyfevEtBNGfWV4xBffxRj2tD6A9i39F");
}
pub mod stake_program_v4 {
solana_sdk::declare_id!("Dc7djyhP9aLfdq2zktpvskeAjpG56msCU1yexpxXiWZb");
}
pub mod secp256k1_recover_syscall_enabled {
solana_sdk::declare_id!("6RvdSWHh8oh72Dp7wMTS2DBkf3fRPtChfNrAo3cZZoXJ");
}
@ -320,14 +312,12 @@ lazy_static! {
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
(filter_stake_delegation_accounts::id(), "filter stake_delegation_accounts #14062"),
(stake_program_v3::id(), "solana_stake_program v3"),
(require_custodian_for_locked_stake_authorize::id(), "require custodian to authorize withdrawer change for locked stake"),
(spl_token_v2_self_transfer_fix::id(), "spl-token self-transfer fix"),
(full_inflation::mainnet::certusone::enable::id(), "full inflation enabled by Certus One"),
(full_inflation::mainnet::certusone::vote::id(), "community vote allowing Certus One to enable full inflation"),
(warp_timestamp_again::id(), "warp timestamp again, adjust bounding to 25% fast 80% slow #15204"),
(check_init_vote_data::id(), "check initialized Vote data"),
(stake_program_v4::id(), "solana_stake_program v4"),
(secp256k1_recover_syscall_enabled::id(), "secp256k1_recover syscall"),
(system_transfer_zero_check::id(), "perform all checks for transfers of 0 lamports"),
(blake3_syscall_enabled::id(), "blake3 syscall"),

View File

@ -464,13 +464,16 @@ mod tests {
let custodian_keypair = Keypair::new();
let custodian_pubkey = custodian_keypair.pubkey();
let withdrawer_keypair = Keypair::new();
let withdrawer_pubkey = withdrawer_keypair.pubkey();
let message = new_stake_account(
&fee_payer_pubkey,
&funding_pubkey,
&base_pubkey,
lamports,
&Pubkey::default(),
&Pubkey::default(),
&withdrawer_pubkey,
&custodian_pubkey,
0,
);
@ -483,16 +486,17 @@ mod tests {
let lockups = get_lockups(&bank_client, &base_pubkey, 1);
let messages = lockup_stake_accounts(
&fee_payer_pubkey,
&custodian_pubkey,
&withdrawer_pubkey,
&LockupArgs {
unix_timestamp: Some(1),
custodian: Some(custodian_pubkey),
..LockupArgs::default()
},
&lockups,
None,
);
let signers = [&fee_payer_keypair, &custodian_keypair];
let signers = [&fee_payer_keypair, &withdrawer_keypair];
for message in messages {
bank_client
.send_and_confirm_message(&signers, message)
@ -501,6 +505,7 @@ mod tests {
let account = get_account_at(&bank_client, &base_pubkey, 0);
let lockup = stake_state::lockup_from(&account).unwrap();
assert_eq!(lockup.custodian, custodian_pubkey);
assert_eq!(lockup.unix_timestamp, 1);
assert_eq!(lockup.epoch, 0);