Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rent to transient stake accounts #519

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions bot/src/stake_pool_v0.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use solana_sdk::instruction::Instruction;
use solana_sdk::system_instruction;
use std::env;
use {
crate::{
generic_stake_pool::*,
Expand Down Expand Up @@ -725,14 +728,26 @@ where
} else {
deactivating_total += amount_to_remove;

let mut instructions = stake_instruction::split_with_seed(
let mut instructions: Vec<Instruction> = vec![];

// Testnet now requires that stake accounts have a rent-exempt minimum
if env::var("ADD_RENT_EXEMPT_MINIMUM").is_ok() {
instructions.push(system_instruction::transfer(
&authorized_staker.pubkey(),
&transient_stake_address,
DELEGATION_RENT,
));
}

instructions.append(&mut stake_instruction::split_with_seed(
&stake_address,
&authorized_staker.pubkey(),
amount_to_remove,
&transient_stake_address,
&authorized_staker.pubkey(),
&transient_stake_address_seed,
);
));

instructions.push(stake_instruction::deactivate_stake(
&transient_stake_address,
&authorized_staker.pubkey(),
Expand Down Expand Up @@ -812,23 +827,19 @@ where
Sol(reserve_stake_balance)
);

let num_transaction_errors = if dry_run {
0
} else {
match send_and_confirm_transactions_with_spinner(
client,
false,
transactions,
authorized_staker,
) {
Ok(errors) => errors.iter().filter(|err| err.is_some()).count(),
Err(e) => {
error!("Sending transactions failed: {:?}", e);
if ignore_stake_distribution_errors {
return Ok((activating_total, deactivating_total));
} else {
return Err("Some transactions failed to land".into());
}
let num_transaction_errors = match send_and_confirm_transactions_with_spinner(
client,
dry_run,
transactions,
authorized_staker,
) {
Ok(errors) => errors.iter().filter(|err| err.is_some()).count(),
Err(e) => {
error!("Sending transactions failed: {:?}", e);
if ignore_stake_distribution_errors {
return Ok((activating_total, deactivating_total));
} else {
return Err("Some transactions failed to land".into());
}
}
};
Expand Down
Loading