Skip to content

Commit

Permalink
added admin mark ix
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Krueger authored and Christian Krueger committed Jul 31, 2024
1 parent e59ba78 commit 1463d29
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
45 changes: 45 additions & 0 deletions programs/steward/src/instructions/admin_mark_for_removal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use anchor_lang::prelude::*;

use crate::{utils::get_config_admin, Config, StewardStateAccount};

#[derive(Accounts)]
pub struct AdminMarkForRemoval<'info> {
#[account(mut)]
pub config: AccountLoader<'info, Config>,

#[account(
mut,
seeds = [StewardStateAccount::SEED, config.key().as_ref()],
bump
)]
pub state_account: AccountLoader<'info, StewardStateAccount>,

#[account(mut, address = get_config_admin(&config)?)]
pub authority: Signer<'info>,
}

/*
Used by the admin to unstick the machine
*/
pub fn handler(
ctx: Context<AdminMarkForRemoval>,
validator_list_index: usize,
mark_for_removal: bool,
immediate: bool,
) -> Result<()> {
let mut state = ctx.accounts.state_account.load_mut()?;

if immediate {
state
.state
.validators_for_immediate_removal
.set(validator_list_index, mark_for_removal)?;
} else {
state
.state
.validators_to_remove
.set(validator_list_index, mark_for_removal)?;
}

Ok(())
}
2 changes: 2 additions & 0 deletions programs/steward/src/instructions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(ambiguous_glob_reexports)]
pub mod add_validator_to_blacklist;
pub mod admin_mark_for_removal;
pub mod auto_add_validator_to_pool;
pub mod auto_remove_validator_from_pool;
pub mod close_steward_accounts;
Expand All @@ -21,6 +22,7 @@ pub mod spl_passthrough;
pub mod update_parameters;

pub use add_validator_to_blacklist::*;
pub use admin_mark_for_removal::*;
pub use auto_add_validator_to_pool::*;
pub use auto_remove_validator_from_pool::*;
pub use close_steward_accounts::*;
Expand Down
16 changes: 16 additions & 0 deletions programs/steward/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ If manual intervention is required, the following spl-stake-pool instructions ar
*/
#[program]
pub mod steward {

use super::*;

/* Initialization instructions */
Expand Down Expand Up @@ -191,6 +192,21 @@ pub mod steward {
instructions::reset_steward_state::handler(ctx)
}

/// Admin to mark or unmark validator for removal and unstuck the machine
pub fn admin_mark_for_removal(
ctx: Context<AdminMarkForRemoval>,
validator_list_index: u64,
mark_for_removal: u8,
immediate: u8,
) -> Result<()> {
instructions::admin_mark_for_removal::handler(
ctx,
validator_list_index as usize,
mark_for_removal != 0,
immediate != 0,
)
}

/// Closes Steward PDA accounts associated with a given Config (StewardStateAccount, and Staker).
/// Config is not closed as it is a Keypair, so lamports can simply be withdrawn.
/// Reclaims lamports to authority
Expand Down

0 comments on commit 1463d29

Please sign in to comment.