Skip to content

Commit 61d9d21

Browse files
authored
Withdraw authority no longer implies a custodian (solana-labs#11302)
* Withdraw authority no longer implies a custodian Before this change, if the withdraw authority and custodian had the same public key, then a withdraw authority signature would imply a custodian signature and lockup would be not be enforced. After this change, the client's withdraw instruction must explictly reference a custodian account in its optional sixth account argument. Likewise, the fee-payer no longer implies either a withdraw authority or custodian. * Fix test The test was configuring the stake account with the fee-payer as the withdraw authority, but then passing in a different key to the withdraw instruction's withdraw authority parameter. It only worked because the second transaction was signed by the fee-payer.
1 parent 0f551d4 commit 61d9d21

File tree

5 files changed

+124
-43
lines changed

5 files changed

+124
-43
lines changed

cli/src/stake.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use solana_stake_program::{
3232
stake_state::{Authorized, Lockup, Meta, StakeAuthorize, StakeState},
3333
};
3434
use solana_vote_program::vote_state::VoteState;
35-
use std::{collections::HashSet, ops::Deref, sync::Arc};
35+
use std::{ops::Deref, sync::Arc};
3636

3737
pub const STAKE_AUTHORITY_ARG: ArgConstant<'static> = ArgConstant {
3838
name: "stake_authority",
@@ -1485,7 +1485,7 @@ pub fn build_stake_state(
14851485
let (active_stake, activating_stake, deactivating_stake) = stake
14861486
.delegation
14871487
.stake_activating_and_deactivating(current_epoch, Some(stake_history));
1488-
let lockup = if lockup.is_in_force(clock, &HashSet::new()) {
1488+
let lockup = if lockup.is_in_force(clock, None) {
14891489
Some(lockup.into())
14901490
} else {
14911491
None
@@ -1535,7 +1535,7 @@ pub fn build_stake_state(
15351535
authorized,
15361536
lockup,
15371537
}) => {
1538-
let lockup = if lockup.is_in_force(clock, &HashSet::new()) {
1538+
let lockup = if lockup.is_in_force(clock, None) {
15391539
Some(lockup.into())
15401540
} else {
15411541
None

core/src/non_circulating_supply.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ pub fn calculate_non_circulating_supply(bank: &Arc<Bank>) -> NonCirculatingSuppl
2323
let stake_account = StakeState::from(&account).unwrap_or_default();
2424
match stake_account {
2525
StakeState::Initialized(meta) => {
26-
if meta.lockup.is_in_force(&clock, &HashSet::default())
26+
if meta.lockup.is_in_force(&clock, None)
2727
|| withdraw_authority_list.contains(&meta.authorized.withdrawer)
2828
{
2929
non_circulating_accounts_set.insert(*pubkey);
3030
}
3131
}
3232
StakeState::Stake(meta, _stake) => {
33-
if meta.lockup.is_in_force(&clock, &HashSet::default())
33+
if meta.lockup.is_in_force(&clock, None)
3434
|| withdraw_authority_list.contains(&meta.authorized.withdrawer)
3535
{
3636
non_circulating_accounts_set.insert(*pubkey);

programs/stake/src/stake_instruction.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ pub fn process_instruction(
454454
to,
455455
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
456456
&StakeHistory::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
457-
&signers,
457+
next_keyed_account(keyed_accounts)?,
458+
keyed_accounts.next(),
458459
)
459460
}
460461
StakeInstruction::Deactivate => me.deactivate(

0 commit comments

Comments
 (0)