Skip to content

Commit

Permalink
cope with Solana raising stake minimum delegation to 1.0 sol
Browse files Browse the repository at this point in the history
  • Loading branch information
kkonevets committed Sep 7, 2022
1 parent ec92adc commit a570ecf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 17 additions & 5 deletions cli/maintainer/src/maintenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use solana_program::{
program_pack::Pack,
pubkey::Pubkey,
rent::Rent,
stake::state::StakeState,
stake_history::StakeHistory,
};
use solana_sdk::{
Expand Down Expand Up @@ -674,15 +675,26 @@ impl SolidoState {
validator: &PubkeyAndEntry<Validator>,
stake_account: &(Pubkey, StakeAccount),
amount: Lamports,
) -> (Pubkey, Instruction) {
) -> Option<(Pubkey, Instruction)> {
let stake_rent_exempt_amount = StakeState::get_rent_exempt_reserve(&self.rent);
dbg!(stake_rent_exempt_amount);
let minimum_stake_amount =
(Lamports(1_000_000_000) + Lamports(stake_rent_exempt_amount)).ok()?;
if amount < minimum_stake_amount {
// Due to Solana aiming to raise stake minimum delegation to 1SOL we should
// wait till stake amount be large enogh for stake account to exist.
// https://github.com/solana-labs/solana/issues/24357
return None;
}

let (validator_unstake_account, _) = validator.find_stake_account_address(
&self.solido_program_id,
&self.solido_address,
validator.entry.unstake_seeds.end,
StakeType::Unstake,
);
let (stake_account_address, _) = stake_account;
(
Some((
validator_unstake_account,
lido::instruction::unstake(
&self.solido_program_id,
Expand All @@ -696,7 +708,7 @@ impl SolidoState {
},
amount,
),
)
))
}

/// If there is a validator being deactivated, try to unstake its funds.
Expand Down Expand Up @@ -728,7 +740,7 @@ impl SolidoState {
validator,
&stake_accounts[0],
stake_account_balance.balance.total(),
);
)?;
let task = MaintenanceOutput::UnstakeFromInactiveValidator(Unstake {
validator_vote_account: validator.pubkey,
from_stake_account: stake_account_address,
Expand Down Expand Up @@ -1132,7 +1144,7 @@ impl SolidoState {
}

let (unstake_account, instruction) =
self.get_unstake_instruction(validator, stake_account, amount);
self.get_unstake_instruction(validator, stake_account, amount)?;
let task = MaintenanceOutput::UnstakeFromActiveValidator(Unstake {
validator_vote_account: validator.pubkey,
from_stake_account: stake_account.0,
Expand Down
1 change: 0 additions & 1 deletion program/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
// By putting everything in a single module, we sidestep this problem.
pub mod tests;

#[macro_use]
extern crate testlib;

0 comments on commit a570ecf

Please sign in to comment.