Remove active features stake program v3 and v4 (#22612)
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
This commit is contained in:
parent
0cf886302d
commit
a7f2fff219
|
@ -123,9 +123,6 @@ pub fn process_instruction(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StakeInstruction::DelegateStake => {
|
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)?;
|
let vote = keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
||||||
|
|
||||||
me.delegate(
|
me.delegate(
|
||||||
|
@ -143,7 +140,6 @@ pub fn process_instruction(
|
||||||
first_instruction_account + 4,
|
first_instruction_account + 4,
|
||||||
)?)?,
|
)?)?,
|
||||||
&signers,
|
&signers,
|
||||||
can_reverse_deactivation,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
StakeInstruction::Split(lamports) => {
|
StakeInstruction::Split(lamports) => {
|
||||||
|
@ -154,9 +150,6 @@ pub fn process_instruction(
|
||||||
StakeInstruction::Merge => {
|
StakeInstruction::Merge => {
|
||||||
let source_stake =
|
let source_stake =
|
||||||
&keyed_account_at_index(keyed_accounts, first_instruction_account + 1)?;
|
&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(
|
me.merge(
|
||||||
invoke_context,
|
invoke_context,
|
||||||
source_stake,
|
source_stake,
|
||||||
|
@ -169,7 +162,6 @@ pub fn process_instruction(
|
||||||
first_instruction_account + 3,
|
first_instruction_account + 3,
|
||||||
)?)?,
|
)?)?,
|
||||||
&signers,
|
&signers,
|
||||||
can_merge_expired_lockups,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
StakeInstruction::Withdraw(lamports) => {
|
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 + 4)?,
|
||||||
keyed_account_at_index(keyed_accounts, first_instruction_account + 5).ok(),
|
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(
|
StakeInstruction::Deactivate => me.deactivate(
|
||||||
|
@ -200,15 +189,8 @@ pub fn process_instruction(
|
||||||
&signers,
|
&signers,
|
||||||
),
|
),
|
||||||
StakeInstruction::SetLockup(lockup) => {
|
StakeInstruction::SetLockup(lockup) => {
|
||||||
let clock = if invoke_context
|
let clock = invoke_context.get_sysvar_cache().get_clock()?;
|
||||||
.feature_set
|
me.set_lockup(&lockup, &signers, &clock)
|
||||||
.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())
|
|
||||||
}
|
}
|
||||||
StakeInstruction::InitializeChecked => {
|
StakeInstruction::InitializeChecked => {
|
||||||
if invoke_context
|
if invoke_context
|
||||||
|
@ -326,8 +308,8 @@ pub fn process_instruction(
|
||||||
epoch: lockup_checked.epoch,
|
epoch: lockup_checked.epoch,
|
||||||
custodian,
|
custodian,
|
||||||
};
|
};
|
||||||
let clock = Some(invoke_context.get_sysvar_cache().get_clock()?);
|
let clock = invoke_context.get_sysvar_cache().get_clock()?;
|
||||||
me.set_lockup(&lockup, &signers, clock.as_deref())
|
me.set_lockup(&lockup, &signers, &clock)
|
||||||
} else {
|
} else {
|
||||||
Err(InstructionError::InvalidInstructionData)
|
Err(InstructionError::InvalidInstructionData)
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -256,28 +256,17 @@ impl Meta {
|
||||||
&mut self,
|
&mut self,
|
||||||
lockup: &LockupArgs,
|
lockup: &LockupArgs,
|
||||||
signers: &HashSet<Pubkey>,
|
signers: &HashSet<Pubkey>,
|
||||||
clock: Option<&Clock>,
|
clock: &Clock,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
match clock {
|
// post-stake_program_v4 behavior:
|
||||||
None => {
|
// * custodian can update the lockup while in force
|
||||||
// pre-stake_program_v4 behavior: custodian can set lockups at any time
|
// * withdraw authority can set a new lockup
|
||||||
if !signers.contains(&self.lockup.custodian) {
|
if self.lockup.is_in_force(clock, None) {
|
||||||
return Err(InstructionError::MissingRequiredSignature);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if !signers.contains(&self.authorized.withdrawer) {
|
||||||
|
return Err(InstructionError::MissingRequiredSignature);
|
||||||
}
|
}
|
||||||
if let Some(unix_timestamp) = lockup.unix_timestamp {
|
if let Some(unix_timestamp) = lockup.unix_timestamp {
|
||||||
self.lockup.unix_timestamp = unix_timestamp;
|
self.lockup.unix_timestamp = unix_timestamp;
|
||||||
|
|
|
@ -65,10 +65,6 @@ pub mod filter_stake_delegation_accounts {
|
||||||
solana_sdk::declare_id!("GE7fRxmW46K6EmCD9AMZSbnaJ2e3LfqCZzdHi9hmYAgi");
|
solana_sdk::declare_id!("GE7fRxmW46K6EmCD9AMZSbnaJ2e3LfqCZzdHi9hmYAgi");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod stake_program_v3 {
|
|
||||||
solana_sdk::declare_id!("Ego6nTu7WsBcZBvVqJQKp6Yku2N3mrfG8oYCfaLZkAeK");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod require_custodian_for_locked_stake_authorize {
|
pub mod require_custodian_for_locked_stake_authorize {
|
||||||
solana_sdk::declare_id!("D4jsDcXaqdW8tDAWn8H4R25Cdns2YwLneujSL1zvjW6R");
|
solana_sdk::declare_id!("D4jsDcXaqdW8tDAWn8H4R25Cdns2YwLneujSL1zvjW6R");
|
||||||
}
|
}
|
||||||
|
@ -85,10 +81,6 @@ pub mod check_init_vote_data {
|
||||||
solana_sdk::declare_id!("3ccR6QpxGYsAbWyfevEtBNGfWV4xBffxRj2tD6A9i39F");
|
solana_sdk::declare_id!("3ccR6QpxGYsAbWyfevEtBNGfWV4xBffxRj2tD6A9i39F");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod stake_program_v4 {
|
|
||||||
solana_sdk::declare_id!("Dc7djyhP9aLfdq2zktpvskeAjpG56msCU1yexpxXiWZb");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod secp256k1_recover_syscall_enabled {
|
pub mod secp256k1_recover_syscall_enabled {
|
||||||
solana_sdk::declare_id!("6RvdSWHh8oh72Dp7wMTS2DBkf3fRPtChfNrAo3cZZoXJ");
|
solana_sdk::declare_id!("6RvdSWHh8oh72Dp7wMTS2DBkf3fRPtChfNrAo3cZZoXJ");
|
||||||
}
|
}
|
||||||
|
@ -320,14 +312,12 @@ lazy_static! {
|
||||||
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
||||||
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
|
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
|
||||||
(filter_stake_delegation_accounts::id(), "filter stake_delegation_accounts #14062"),
|
(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"),
|
(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"),
|
(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::enable::id(), "full inflation enabled by Certus One"),
|
||||||
(full_inflation::mainnet::certusone::vote::id(), "community vote allowing Certus One to enable full inflation"),
|
(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"),
|
(warp_timestamp_again::id(), "warp timestamp again, adjust bounding to 25% fast 80% slow #15204"),
|
||||||
(check_init_vote_data::id(), "check initialized Vote data"),
|
(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"),
|
(secp256k1_recover_syscall_enabled::id(), "secp256k1_recover syscall"),
|
||||||
(system_transfer_zero_check::id(), "perform all checks for transfers of 0 lamports"),
|
(system_transfer_zero_check::id(), "perform all checks for transfers of 0 lamports"),
|
||||||
(blake3_syscall_enabled::id(), "blake3 syscall"),
|
(blake3_syscall_enabled::id(), "blake3 syscall"),
|
||||||
|
|
|
@ -464,13 +464,16 @@ mod tests {
|
||||||
let custodian_keypair = Keypair::new();
|
let custodian_keypair = Keypair::new();
|
||||||
let custodian_pubkey = custodian_keypair.pubkey();
|
let custodian_pubkey = custodian_keypair.pubkey();
|
||||||
|
|
||||||
|
let withdrawer_keypair = Keypair::new();
|
||||||
|
let withdrawer_pubkey = withdrawer_keypair.pubkey();
|
||||||
|
|
||||||
let message = new_stake_account(
|
let message = new_stake_account(
|
||||||
&fee_payer_pubkey,
|
&fee_payer_pubkey,
|
||||||
&funding_pubkey,
|
&funding_pubkey,
|
||||||
&base_pubkey,
|
&base_pubkey,
|
||||||
lamports,
|
lamports,
|
||||||
&Pubkey::default(),
|
&Pubkey::default(),
|
||||||
&Pubkey::default(),
|
&withdrawer_pubkey,
|
||||||
&custodian_pubkey,
|
&custodian_pubkey,
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
@ -483,16 +486,17 @@ mod tests {
|
||||||
let lockups = get_lockups(&bank_client, &base_pubkey, 1);
|
let lockups = get_lockups(&bank_client, &base_pubkey, 1);
|
||||||
let messages = lockup_stake_accounts(
|
let messages = lockup_stake_accounts(
|
||||||
&fee_payer_pubkey,
|
&fee_payer_pubkey,
|
||||||
&custodian_pubkey,
|
&withdrawer_pubkey,
|
||||||
&LockupArgs {
|
&LockupArgs {
|
||||||
unix_timestamp: Some(1),
|
unix_timestamp: Some(1),
|
||||||
|
custodian: Some(custodian_pubkey),
|
||||||
..LockupArgs::default()
|
..LockupArgs::default()
|
||||||
},
|
},
|
||||||
&lockups,
|
&lockups,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
let signers = [&fee_payer_keypair, &custodian_keypair];
|
let signers = [&fee_payer_keypair, &withdrawer_keypair];
|
||||||
for message in messages {
|
for message in messages {
|
||||||
bank_client
|
bank_client
|
||||||
.send_and_confirm_message(&signers, message)
|
.send_and_confirm_message(&signers, message)
|
||||||
|
@ -501,6 +505,7 @@ mod tests {
|
||||||
|
|
||||||
let account = get_account_at(&bank_client, &base_pubkey, 0);
|
let account = get_account_at(&bank_client, &base_pubkey, 0);
|
||||||
let lockup = stake_state::lockup_from(&account).unwrap();
|
let lockup = stake_state::lockup_from(&account).unwrap();
|
||||||
|
assert_eq!(lockup.custodian, custodian_pubkey);
|
||||||
assert_eq!(lockup.unix_timestamp, 1);
|
assert_eq!(lockup.unix_timestamp, 1);
|
||||||
assert_eq!(lockup.epoch, 0);
|
assert_eq!(lockup.epoch, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue