diff --git a/utils/steward-cli/src/commands/actions/surgery.rs b/utils/steward-cli/src/commands/actions/surgery.rs index e806027e..c9819069 100644 --- a/utils/steward-cli/src/commands/actions/surgery.rs +++ b/utils/steward-cli/src/commands/actions/surgery.rs @@ -13,7 +13,8 @@ use crate::{ commands::command_args::Surgery, utils::{ accounts::{ - get_all_steward_accounts, get_steward_state_account, get_steward_state_address, + get_steward_config_account, get_steward_state_account, get_steward_state_address, + get_validator_list_account, }, transactions::configure_instruction, }, @@ -24,9 +25,21 @@ pub async fn command_surgery( client: &Arc, program_id: Pubkey, ) -> Result<()> { - let validator_list_index: u64 = 0; - let mark_for_removal: u8 = 0xFF; // TRUE - let immediate: u8 = 0x00; // FALSE + let validator_list_index: u64 = args.validator_list_index as u64; + let mark_for_removal: u8 = { + if args.mark_for_removal { + 0xFF // TRUE + } else { + 0x00 // FALSE + } + }; + let immediate: u8 = { + if args.immediate { + 0xFF // TRUE + } else { + 0x00 // FALSE + } + }; let authority = read_keypair_file(args.permissioned_parameters.authority_keypair_path) .expect("Failed reading keypair file ( Authority )"); @@ -34,15 +47,24 @@ pub async fn command_surgery( let steward_config_address = args.permissioned_parameters.steward_config; let steward_state_address = get_steward_state_address(&program_id, &steward_config_address); - let steward_state_account = - get_steward_state_account(client, &program_id, &steward_config_address); + let steward_config_account = + get_steward_config_account(client, &steward_config_address).await?; + let validator_list_account = + get_validator_list_account(client, &steward_config_account.validator_list).await?; { - // CHECK index + println!("Submit: {}", args.submit_ix); println!("Validator list index: {}", validator_list_index); println!("Mark for removal: {}", mark_for_removal); println!("Immediate: {}", immediate); + + let validator_to_mark = validator_list_account + .validators + .get(validator_list_index as usize) + .unwrap(); + + println!("Validator to mark: {:?}", validator_to_mark); } if args.submit_ix { diff --git a/utils/steward-cli/src/commands/command_args.rs b/utils/steward-cli/src/commands/command_args.rs index 2d2935b7..14c16a46 100644 --- a/utils/steward-cli/src/commands/command_args.rs +++ b/utils/steward-cli/src/commands/command_args.rs @@ -189,14 +189,14 @@ pub enum Commands { // Views ViewState(ViewState), ViewConfig(ViewConfig), - // ViewNextIndexToRemove(ViewNextIndexToRemove), + ViewNextIndexToRemove(ViewNextIndexToRemove), // Actions InitConfig(InitConfig), UpdateConfig(UpdateConfig), - // InitState(InitState), - // ResetState(ResetState), + InitState(InitState), + ResetState(ResetState), Surgery(Surgery), RemoveBadValidators(RemoveBadValidators), @@ -296,7 +296,15 @@ pub struct Surgery { #[command(flatten)] pub permissioned_parameters: PermissionedParameters, - /// Validator index of validator list to remove + #[arg(long)] + pub mark_for_removal: bool, + + #[arg(long)] + pub immediate: bool, + + #[arg(long)] + pub validator_list_index: usize, + #[arg(long, default_value = "false")] pub submit_ix: bool, } diff --git a/utils/steward-cli/src/main.rs b/utils/steward-cli/src/main.rs index c207e69d..aa119b76 100644 --- a/utils/steward-cli/src/main.rs +++ b/utils/steward-cli/src/main.rs @@ -42,15 +42,15 @@ async fn main() -> Result<()> { // ---- Views ---- Commands::ViewConfig(args) => command_view_config(args, &client, program_id).await, Commands::ViewState(args) => command_view_state(args, &client, program_id).await, - // Commands::ViewNextIndexToRemove(args) => { - // command_view_next_index_to_remove(args, &client, program_id).await - // } + Commands::ViewNextIndexToRemove(args) => { + command_view_next_index_to_remove(args, &client, program_id).await + } // --- Actions --- Commands::InitConfig(args) => command_init_config(args, &client, program_id).await, Commands::UpdateConfig(args) => command_update_config(args, &client, program_id).await, - // Commands::InitState(args) => command_init_state(args, &client, program_id).await, - // Commands::ResetState(args) => command_reset_state(args, &client, program_id).await, + Commands::InitState(args) => command_init_state(args, &client, program_id).await, + Commands::ResetState(args) => command_reset_state(args, &client, program_id).await, Commands::Surgery(args) => command_surgery(args, &client, program_id).await, Commands::AutoRemoveValidatorFromPool(args) => { command_auto_remove_validator_from_pool(args, &client, program_id).await