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

Commit 01765b9

Browse files
authored
stake-pool: Reduce wait for active stake merges (#2553)
* stake-pool: Reduce wait to one epoch for active merges * Remove stake_program references * Remove credits observed point from docs
1 parent 287c3be commit 01765b9

File tree

12 files changed

+33
-100
lines changed

12 files changed

+33
-100
lines changed

docs/src/stake-pool.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,12 +1097,6 @@ reserve.
10971097

10981098
In this way, a user's funds are never at risk, and always redeemable.
10991099

1100-
### Staking Credits Observed on Deposit
1101-
1102-
A deposited stake account's "credits observed" must match the destination
1103-
account's "credits observed". Typically, this means you must wait an additional
1104-
epoch after activation for your stake account to match up with the stake pool's account.
1105-
11061100
### Transaction sizes
11071101

11081102
The Solana transaction processor has two important limitations:

stake-pool/program/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub mod big_vec;
66
pub mod error;
77
pub mod instruction;
88
pub mod processor;
9-
pub mod stake_program;
109
pub mod state;
1110

1211
#[cfg(not(feature = "no-entrypoint"))]

stake-pool/program/src/processor.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use {
55
error::StakePoolError,
66
find_deposit_authority_program_address,
77
instruction::{FundingType, PreferredValidatorType, StakePoolInstruction},
8-
minimum_reserve_lamports, minimum_stake_lamports, stake_program,
8+
minimum_reserve_lamports, minimum_stake_lamports,
99
state::{
1010
AccountType, Fee, FeeType, StakePool, StakeStatus, ValidatorList, ValidatorListHeader,
1111
ValidatorStakeInfo,
@@ -674,7 +674,7 @@ impl Processor {
674674
stake_pool.total_lamports = total_lamports;
675675
stake_pool.pool_token_supply = 0;
676676
stake_pool.last_update_epoch = Clock::get()?.epoch;
677-
stake_pool.lockup = stake_program::Lockup::default();
677+
stake_pool.lockup = stake::state::Lockup::default();
678678
stake_pool.epoch_fee = epoch_fee;
679679
stake_pool.next_epoch_fee = None;
680680
stake_pool.preferred_deposit_validator_vote_address = None;
@@ -1530,9 +1530,7 @@ impl Processor {
15301530
if let Some(stake::state::StakeState::Stake(_, validator_stake)) =
15311531
validator_stake_state
15321532
{
1533-
if stake_program::active_stakes_can_merge(&stake, &validator_stake)
1534-
.is_ok()
1535-
{
1533+
if validator_stake.delegation.activation_epoch < clock.epoch {
15361534
let additional_lamports = transient_stake_info
15371535
.lamports()
15381536
.saturating_sub(stake.delegation.stake);

stake-pool/program/src/stake_program.rs

Lines changed: 0 additions & 77 deletions
This file was deleted.

stake-pool/program/src/state.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use spl_token::state::{Account, AccountState};
44
use {
55
crate::{
6-
big_vec::BigVec, error::StakePoolError, stake_program::Lockup, MAX_WITHDRAWAL_FEE_INCREASE,
6+
big_vec::BigVec, error::StakePoolError, MAX_WITHDRAWAL_FEE_INCREASE,
77
WITHDRAWAL_BASELINE_FEE,
88
},
99
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
@@ -17,6 +17,7 @@ use {
1717
program_memory::sol_memcmp,
1818
program_pack::{Pack, Sealed},
1919
pubkey::{Pubkey, PUBKEY_BYTES},
20+
stake::state::Lockup,
2021
},
2122
spl_math::checked_ceil_div::CheckedCeilDiv,
2223
std::{convert::TryFrom, fmt, matches},

stake-pool/program/tests/deposit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async fn setup() -> (
8989
)
9090
.await;
9191

92-
slot += 2 * slots_per_epoch;
92+
slot += slots_per_epoch;
9393
context.warp_to_slot(slot).unwrap();
9494
stake_pool_accounts
9595
.update_all(

stake-pool/program/tests/huge_pool.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use {
2424
find_stake_program_address, find_transient_stake_program_address,
2525
find_withdraw_authority_program_address, id,
2626
instruction::{self, PreferredValidatorType},
27-
stake_program,
2827
state::{AccountType, Fee, StakePool, StakeStatus, ValidatorList, ValidatorStakeInfo},
2928
MAX_VALIDATORS_TO_UPDATE, MINIMUM_ACTIVE_STAKE,
3029
},
@@ -72,7 +71,7 @@ async fn setup(
7271
total_lamports: 0,
7372
pool_token_supply: 0,
7473
last_update_epoch: 0,
75-
lockup: stake_program::Lockup::default(),
74+
lockup: stake::state::Lockup::default(),
7675
epoch_fee: stake_pool_accounts.epoch_fee,
7776
next_epoch_fee: None,
7877
preferred_deposit_validator_vote_address: None,

stake-pool/program/tests/set_epoch_fee.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ async fn fail_not_updated() {
190190
};
191191

192192
// move forward so an update is required
193-
context.warp_to_slot(50_000).unwrap();
193+
let first_normal_slot = context.genesis_config().epoch_schedule.first_normal_slot;
194+
let slots_per_epoch = context.genesis_config().epoch_schedule.slots_per_epoch;
195+
context
196+
.warp_to_slot(first_normal_slot + slots_per_epoch)
197+
.unwrap();
194198

195199
let transaction = Transaction::new_signed_with_payer(
196200
&[instruction::set_fee(

stake-pool/program/tests/set_withdrawal_fee.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,11 @@ async fn fail_not_updated() {
633633
};
634634

635635
// move forward so an update is required
636-
context.warp_to_slot(50_000).unwrap();
636+
let first_normal_slot = context.genesis_config().epoch_schedule.first_normal_slot;
637+
let slots_per_epoch = context.genesis_config().epoch_schedule.slots_per_epoch;
638+
context
639+
.warp_to_slot(first_normal_slot + slots_per_epoch)
640+
.unwrap();
637641

638642
let transaction = Transaction::new_signed_with_payer(
639643
&[instruction::set_fee(

stake-pool/program/tests/update_stake_pool_balance.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ async fn success() {
107107
}
108108

109109
// Update epoch
110-
context.warp_to_slot(50_000).unwrap();
110+
let first_normal_slot = context.genesis_config().epoch_schedule.first_normal_slot;
111+
let slots_per_epoch = context.genesis_config().epoch_schedule.slots_per_epoch;
112+
context
113+
.warp_to_slot(first_normal_slot + slots_per_epoch)
114+
.unwrap();
111115

112116
// Update list and pool
113117
let error = stake_pool_accounts
@@ -213,7 +217,11 @@ async fn success_ignoring_extra_lamports() {
213217
}
214218

215219
// Update epoch
216-
context.warp_to_slot(50_000).unwrap();
220+
let first_normal_slot = context.genesis_config().epoch_schedule.first_normal_slot;
221+
let slots_per_epoch = context.genesis_config().epoch_schedule.slots_per_epoch;
222+
context
223+
.warp_to_slot(first_normal_slot + slots_per_epoch)
224+
.unwrap();
217225

218226
// Update list and pool
219227
let error = stake_pool_accounts

0 commit comments

Comments
 (0)