Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit d0bf715

Browse files
authored
Set staking authority instruction removed (#1469)
* Set staking authority instruction removed * Fixed fmt errors
1 parent 662f38f commit d0bf715

File tree

4 files changed

+3
-441
lines changed

4 files changed

+3
-441
lines changed

stake-pool/cli/src/main.rs

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use spl_stake_pool::{
3030
instruction::{
3131
add_validator_stake_account, create_validator_stake_account, deposit,
3232
initialize as initialize_pool, remove_validator_stake_account, set_owner,
33-
set_staking_authority, update_list_balance, update_pool_balance, withdraw, Fee as PoolFee,
33+
update_list_balance, update_pool_balance, withdraw, Fee as PoolFee,
3434
InitArgs as PoolInitArgs,
3535
},
3636
processor::Processor as PoolProcessor,
@@ -947,44 +947,6 @@ fn command_withdraw(
947947
Ok(Some(transaction))
948948
}
949949

950-
fn command_set_staking_auth(
951-
config: &Config,
952-
pool: &Pubkey,
953-
stake_account: &Pubkey,
954-
new_staker: &Pubkey,
955-
) -> CommandResult {
956-
let pool_data = config.rpc_client.get_account_data(&pool)?;
957-
let pool_data: StakePool = StakePool::deserialize(pool_data.as_slice()).unwrap();
958-
959-
let pool_withdraw_authority: Pubkey = PoolProcessor::authority_id(
960-
&spl_stake_pool::id(),
961-
pool,
962-
PoolProcessor::AUTHORITY_WITHDRAW,
963-
pool_data.withdraw_bump_seed,
964-
)
965-
.unwrap();
966-
967-
let mut transaction = Transaction::new_with_payer(
968-
&[set_staking_authority(
969-
&spl_stake_pool::id(),
970-
&pool,
971-
&config.owner.pubkey(),
972-
&pool_withdraw_authority,
973-
&stake_account,
974-
&new_staker,
975-
&stake_program_id(),
976-
)?],
977-
Some(&config.fee_payer.pubkey()),
978-
);
979-
980-
let (recent_blockhash, fee_calculator) = config.rpc_client.get_recent_blockhash()?;
981-
check_fee_payer_balance(config, fee_calculator.calculate_fee(&transaction.message()))?;
982-
let mut signers = vec![config.fee_payer.as_ref(), config.owner.as_ref()];
983-
unique_signers!(signers);
984-
transaction.sign(&signers, recent_blockhash);
985-
Ok(Some(transaction))
986-
}
987-
988950
fn command_set_owner(
989951
config: &Config,
990952
pool: &Pubkey,
@@ -1299,35 +1261,6 @@ fn main() {
12991261
.help("Stake account to receive SOL from the stake pool. Defaults to a new stake account."),
13001262
)
13011263
)
1302-
.subcommand(SubCommand::with_name("set-staking-auth").about("Changes staking authority of one of the accounts from the stake pool.")
1303-
.arg(
1304-
Arg::with_name("pool")
1305-
.long("pool")
1306-
.validator(is_pubkey)
1307-
.value_name("ADDRESS")
1308-
.takes_value(true)
1309-
.required(true)
1310-
.help("Stake pool address."),
1311-
)
1312-
.arg(
1313-
Arg::with_name("stake_account")
1314-
.long("stake-account")
1315-
.validator(is_pubkey)
1316-
.value_name("ADDRESS")
1317-
.takes_value(true)
1318-
.required(true)
1319-
.help("Stake account address to change staking authority."),
1320-
)
1321-
.arg(
1322-
Arg::with_name("new_staker")
1323-
.long("new-staker")
1324-
.validator(is_pubkey)
1325-
.value_name("ADDRESS")
1326-
.takes_value(true)
1327-
.required(true)
1328-
.help("Public key of the new staker account."),
1329-
)
1330-
)
13311264
.subcommand(SubCommand::with_name("set-owner").about("Changes owner or fee receiver account for the stake pool.")
13321265
.arg(
13331266
Arg::with_name("pool")
@@ -1470,12 +1403,6 @@ fn main() {
14701403
&stake_receiver,
14711404
)
14721405
}
1473-
("set-staking-auth", Some(arg_matches)) => {
1474-
let pool_account: Pubkey = pubkey_of(arg_matches, "pool").unwrap();
1475-
let stake_account: Pubkey = pubkey_of(arg_matches, "stake_account").unwrap();
1476-
let new_staker: Pubkey = pubkey_of(arg_matches, "new_staker").unwrap();
1477-
command_set_staking_auth(&config, &pool_account, &stake_account, &new_staker)
1478-
}
14791406
("set-owner", Some(arg_matches)) => {
14801407
let pool_account: Pubkey = pubkey_of(arg_matches, "pool").unwrap();
14811408
let new_owner: Option<Pubkey> = pubkey_of(arg_matches, "new_owner");

stake-pool/program/src/instruction.rs

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,6 @@ pub enum StakePoolInstruction {
140140
/// userdata: amount to withdraw
141141
Withdraw(u64),
142142

143-
/// Update the staking pubkey for a stake
144-
///
145-
/// 0. `[w]` StakePool
146-
/// 1. `[s]` Owner
147-
/// 2. `[]` withdraw authority
148-
/// 3. `[w]` Stake to update the staking pubkey
149-
/// 4. '[]` Staking pubkey.
150-
/// 5. '[]' Sysvar clock account (reserved for future use)
151-
/// 6. `[]` Stake program id,
152-
SetStakingAuthority,
153-
154143
/// Update owner
155144
///
156145
/// 0. `[w]` StakePool
@@ -182,8 +171,7 @@ impl StakePoolInstruction {
182171
let val: &u64 = unpack(input)?;
183172
Self::Withdraw(*val)
184173
}
185-
8 => Self::SetStakingAuthority,
186-
9 => Self::SetOwner,
174+
8 => Self::SetOwner,
187175
_ => return Err(ProgramError::InvalidAccountData),
188176
})
189177
}
@@ -223,11 +211,8 @@ impl StakePoolInstruction {
223211
let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
224212
*value = *val;
225213
}
226-
Self::SetStakingAuthority => {
227-
output[0] = 8;
228-
}
229214
Self::SetOwner => {
230-
output[0] = 9;
215+
output[0] = 8;
231216
}
232217
}
233218
Ok(output)
@@ -486,34 +471,6 @@ pub fn withdraw(
486471
})
487472
}
488473

489-
/// Creates a 'set staking authority' instruction.
490-
pub fn set_staking_authority(
491-
program_id: &Pubkey,
492-
stake_pool: &Pubkey,
493-
stake_pool_owner: &Pubkey,
494-
stake_pool_withdraw: &Pubkey,
495-
stake_account_to_update: &Pubkey,
496-
stake_account_new_authority: &Pubkey,
497-
stake_program_id: &Pubkey,
498-
) -> Result<Instruction, ProgramError> {
499-
let args = StakePoolInstruction::SetStakingAuthority;
500-
let data = args.serialize()?;
501-
let accounts = vec![
502-
AccountMeta::new(*stake_pool, false),
503-
AccountMeta::new_readonly(*stake_pool_owner, true),
504-
AccountMeta::new_readonly(*stake_pool_withdraw, false),
505-
AccountMeta::new(*stake_account_to_update, false),
506-
AccountMeta::new_readonly(*stake_account_new_authority, false),
507-
AccountMeta::new_readonly(sysvar::clock::id(), false),
508-
AccountMeta::new_readonly(*stake_program_id, false),
509-
];
510-
Ok(Instruction {
511-
program_id: *program_id,
512-
accounts,
513-
data,
514-
})
515-
}
516-
517474
/// Creates a 'set owner' instruction.
518475
pub fn set_owner(
519476
program_id: &Pubkey,

stake-pool/program/src/processor.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,51 +1147,6 @@ impl Processor {
11471147

11481148
Ok(())
11491149
}
1150-
/// Processes [SetStakeAuthority](enum.Instruction.html).
1151-
pub fn process_set_staking_auth(
1152-
program_id: &Pubkey,
1153-
accounts: &[AccountInfo],
1154-
) -> ProgramResult {
1155-
let account_info_iter = &mut accounts.iter();
1156-
let stake_pool_info = next_account_info(account_info_iter)?;
1157-
let owner_info = next_account_info(account_info_iter)?;
1158-
let withdraw_info = next_account_info(account_info_iter)?;
1159-
let stake_info = next_account_info(account_info_iter)?;
1160-
let staker_info = next_account_info(account_info_iter)?;
1161-
// (Reserved)
1162-
let reserved = next_account_info(account_info_iter)?;
1163-
// Stake program id
1164-
let stake_program_info = next_account_info(account_info_iter)?;
1165-
1166-
// Check program ids
1167-
if *stake_program_info.key != stake::id() {
1168-
return Err(ProgramError::IncorrectProgramId);
1169-
}
1170-
1171-
let stake_pool = StakePool::deserialize(&stake_pool_info.data.borrow())?;
1172-
if !stake_pool.is_initialized() {
1173-
return Err(StakePoolError::InvalidState.into());
1174-
}
1175-
1176-
// Check authority account
1177-
stake_pool.check_authority_withdraw(withdraw_info.key, program_id, stake_pool_info.key)?;
1178-
1179-
// Check owner validity and signature
1180-
stake_pool.check_owner(owner_info)?;
1181-
1182-
Self::stake_authorize(
1183-
stake_pool_info.key,
1184-
stake_info.clone(),
1185-
withdraw_info.clone(),
1186-
Self::AUTHORITY_WITHDRAW,
1187-
stake_pool.withdraw_bump_seed,
1188-
staker_info.key,
1189-
stake::StakeAuthorize::Staker,
1190-
reserved.clone(),
1191-
stake_program_info.clone(),
1192-
)?;
1193-
Ok(())
1194-
}
11951150

11961151
/// Processes [SetOwner](enum.Instruction.html).
11971152
pub fn process_set_owner(_program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
@@ -1257,10 +1212,6 @@ impl Processor {
12571212
msg!("Instruction: Withdraw");
12581213
Self::process_withdraw(program_id, amount, accounts)
12591214
}
1260-
StakePoolInstruction::SetStakingAuthority => {
1261-
msg!("Instruction: SetStakingAuthority");
1262-
Self::process_set_staking_auth(program_id, accounts)
1263-
}
12641215
StakePoolInstruction::SetOwner => {
12651216
msg!("Instruction: SetOwner");
12661217
Self::process_set_owner(program_id, accounts)

0 commit comments

Comments
 (0)