Skip to content

Commit

Permalink
fixed issues
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 1463d29 commit f1eef4f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
36 changes: 29 additions & 7 deletions utils/steward-cli/src/commands/actions/surgery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check failure on line 16 in utils/steward-cli/src/commands/actions/surgery.rs

View workflow job for this annotation

GitHub Actions / lint

unused import: `get_steward_state_account`
get_validator_list_account,
},
transactions::configure_instruction,
},
Expand All @@ -24,25 +25,46 @@ pub async fn command_surgery(
client: &Arc<RpcClient>,
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 )");

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 {
Expand Down
16 changes: 12 additions & 4 deletions utils/steward-cli/src/commands/command_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
}
Expand Down
10 changes: 5 additions & 5 deletions utils/steward-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1eef4f

Please sign in to comment.