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

Commit 4ab60e6

Browse files
authored
stake-pool: Also set the sol deposit authority on init (#2532)
1 parent 675d65b commit 4ab60e6

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

stake-pool/program/src/processor.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,17 @@ impl Processor {
592592
return Err(StakePoolError::WrongAccountMint.into());
593593
}
594594

595-
let stake_deposit_authority = match next_account_info(account_info_iter) {
596-
Ok(stake_deposit_authority_info) => *stake_deposit_authority_info.key,
597-
Err(_) => find_deposit_authority_program_address(program_id, stake_pool_info.key).0,
598-
};
595+
let (stake_deposit_authority, sol_deposit_authority) =
596+
match next_account_info(account_info_iter) {
597+
Ok(deposit_authority_info) => (
598+
*deposit_authority_info.key,
599+
Some(*deposit_authority_info.key),
600+
),
601+
Err(_) => (
602+
find_deposit_authority_program_address(program_id, stake_pool_info.key).0,
603+
None,
604+
),
605+
};
599606
let (withdraw_authority_key, stake_withdraw_bump_seed) =
600607
crate::find_withdraw_authority_program_address(program_id, stake_pool_info.key);
601608

@@ -676,7 +683,7 @@ impl Processor {
676683
stake_pool.stake_withdrawal_fee = withdrawal_fee;
677684
stake_pool.next_stake_withdrawal_fee = None;
678685
stake_pool.stake_referral_fee = referral_fee;
679-
stake_pool.sol_deposit_authority = None;
686+
stake_pool.sol_deposit_authority = sol_deposit_authority;
680687
stake_pool.sol_deposit_fee = deposit_fee;
681688
stake_pool.sol_referral_fee = referral_fee;
682689
stake_pool.sol_withdraw_authority = None;

stake-pool/program/tests/deposit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,11 +794,11 @@ async fn fail_with_uninitialized_validator_list() {} // TODO
794794
async fn fail_with_out_of_dated_pool_balances() {} // TODO
795795

796796
#[tokio::test]
797-
async fn success_with_stake_deposit_authority() {
797+
async fn success_with_deposit_authority() {
798798
let (mut banks_client, payer, recent_blockhash) = program_test().start().await;
799799
let stake_deposit_authority = Keypair::new();
800800
let stake_pool_accounts =
801-
StakePoolAccounts::new_with_stake_deposit_authority(stake_deposit_authority);
801+
StakePoolAccounts::new_with_deposit_authority(stake_deposit_authority);
802802
stake_pool_accounts
803803
.initialize_stake_pool(&mut banks_client, &payer, &recent_blockhash, 1)
804804
.await
@@ -876,11 +876,11 @@ async fn success_with_stake_deposit_authority() {
876876
}
877877

878878
#[tokio::test]
879-
async fn fail_without_stake_deposit_authority_signature() {
879+
async fn fail_without_deposit_authority_signature() {
880880
let (mut banks_client, payer, recent_blockhash) = program_test().start().await;
881881
let stake_deposit_authority = Keypair::new();
882882
let mut stake_pool_accounts =
883-
StakePoolAccounts::new_with_stake_deposit_authority(stake_deposit_authority);
883+
StakePoolAccounts::new_with_deposit_authority(stake_deposit_authority);
884884
stake_pool_accounts
885885
.initialize_stake_pool(&mut banks_client, &payer, &recent_blockhash, 1)
886886
.await

stake-pool/program/tests/helpers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ impl StakePoolAccounts {
671671
}
672672
}
673673

674-
pub fn new_with_stake_deposit_authority(stake_deposit_authority: Keypair) -> Self {
674+
pub fn new_with_deposit_authority(stake_deposit_authority: Keypair) -> Self {
675675
let mut stake_pool_accounts = Self::new();
676676
stake_pool_accounts.stake_deposit_authority = stake_deposit_authority.pubkey();
677677
stake_pool_accounts.stake_deposit_authority_keypair = Some(stake_deposit_authority);

stake-pool/program/tests/initialize.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,11 +1275,11 @@ async fn fail_with_bad_reserve() {
12751275
}
12761276

12771277
#[tokio::test]
1278-
async fn success_with_required_stake_deposit_authority() {
1278+
async fn success_with_deposit_authority() {
12791279
let (mut banks_client, payer, recent_blockhash) = program_test().start().await;
1280-
let stake_deposit_authority = Keypair::new();
1281-
let stake_pool_accounts =
1282-
StakePoolAccounts::new_with_stake_deposit_authority(stake_deposit_authority);
1280+
let deposit_authority = Keypair::new();
1281+
let stake_pool_accounts = StakePoolAccounts::new_with_deposit_authority(deposit_authority);
1282+
let deposit_authority = stake_pool_accounts.stake_deposit_authority;
12831283
stake_pool_accounts
12841284
.initialize_stake_pool(&mut banks_client, &payer, &recent_blockhash, 1)
12851285
.await
@@ -1290,8 +1290,6 @@ async fn success_with_required_stake_deposit_authority() {
12901290
get_account(&mut banks_client, &stake_pool_accounts.stake_pool.pubkey()).await;
12911291
let stake_pool =
12921292
try_from_slice_unchecked::<state::StakePool>(stake_pool_account.data.as_slice()).unwrap();
1293-
assert_eq!(
1294-
stake_pool.stake_deposit_authority,
1295-
stake_pool_accounts.stake_deposit_authority
1296-
);
1293+
assert_eq!(stake_pool.stake_deposit_authority, deposit_authority);
1294+
assert_eq!(stake_pool.sol_deposit_authority.unwrap(), deposit_authority);
12971295
}

0 commit comments

Comments
 (0)