diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index de864e875..ff06db91e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,10 +32,6 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: rustfmt, clippy - toolchain: nightly-2025-02-19 - name: Install Protobuf Compiler run: | sudo apt-get update @@ -47,7 +43,7 @@ jobs: version: 1.0.9 - run: cargo sort --workspace --check - run: cargo fmt --all --check - - run: cargo +nightly-2025-02-19 clippy --all-features --all-targets --tests -- -D warnings + - run: cargo clippy --all-features --all-targets --tests -- -D warnings udeps: name: udeps @@ -62,13 +58,13 @@ jobs: sudo apt-get install -y protobuf-compiler libudev-dev libclang-dev - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: nightly-2025-02-19 + toolchain: nightly - name: Install cargo-udeps from crates.io uses: baptiste0928/cargo-install@v3 with: crate: cargo-udeps version: "0.1.57" - - run: cargo +nightly-2025-02-19 udeps --all-features --all-targets --tests + - run: cargo +nightly udeps --all-features --all-targets --tests build_release: name: build_release diff --git a/keepers/stakenet-keeper/src/entries/crank_steward.rs b/keepers/stakenet-keeper/src/entries/crank_steward.rs index c604093be..4a243921a 100644 --- a/keepers/stakenet-keeper/src/entries/crank_steward.rs +++ b/keepers/stakenet-keeper/src/entries/crank_steward.rs @@ -146,9 +146,7 @@ pub fn _get_update_stake_pool_ixs( if vote_account.epoch_credits.iter().last().is_none() { error!( - "šŸ†˜ ā‰ļø Error: Epoch credits has no entries? \nStake Account\n{:?}\nVote Account\n{:?}\n", - stake_account, - vote_account + "šŸ†˜ ā‰ļø Error: Epoch credits has no entries? \nStake Account\n{stake_account:?}\nVote Account\n{vote_account:?}\n" ); false } else { @@ -290,8 +288,7 @@ async fn _handle_instant_removal_validators( for i in 0..all_steward_accounts.validator_list_account.validators.len() as u64 { if validators_to_remove.get(i as usize).map_err(|e| { JitoTransactionError::Custom(format!( - "Error fetching bitmask index for immediate removed validator: {}/{} - {}", - i, num_validators, e + "Error fetching bitmask index for immediate removed validator: {i}/{num_validators} - {e}" )) })? { validator_index_to_remove = Some(i); @@ -299,7 +296,7 @@ async fn _handle_instant_removal_validators( } } - info!("Validator Index to Remove: {:?}", validator_index_to_remove); + info!("Validator Index to Remove: {validator_index_to_remove:?}"); let directed_stake_meta = get_directed_stake_meta_address(&all_steward_accounts.config_address, program_id); @@ -451,7 +448,7 @@ async fn _handle_adding_validators( return None; } } else { - info!("Validator {} below liveness minimum", vote_address); + info!("Validator {vote_address} below liveness minimum"); return None; } } @@ -632,8 +629,7 @@ async fn _handle_epoch_maintenance( for i in 0..num_validators { if validators_to_remove.get(i as usize).map_err(|e| { JitoTransactionError::Custom(format!( - "Error fetching bitmask index for removed validator: {}/{} - {}", - i, num_validators, e + "Error fetching bitmask index for removed validator: {i}/{num_validators} - {e}" )) })? { validator_index_to_remove = Some(i); @@ -641,7 +637,7 @@ async fn _handle_epoch_maintenance( } } - info!("Validator Index to Remove: {:?}", validator_index_to_remove); + info!("Validator Index to Remove: {validator_index_to_remove:?}"); let directed_stake_meta = get_directed_stake_meta_address(&all_steward_accounts.config_address, program_id); @@ -689,10 +685,7 @@ async fn _handle_epoch_maintenance( state_epoch = updated_state_account.state.current_epoch; current_epoch = client.get_epoch_info().await?.epoch; - info!( - "State Epoch: {} | Current Epoch: {}", - state_epoch, current_epoch - ); + info!("State Epoch: {state_epoch} | Current Epoch: {current_epoch}"); } Ok(stats) @@ -1304,18 +1297,18 @@ pub async fn crank_steward( match error { JitoSendTransactionError::ExceededRetries => { // Continue - error!("Exceeded Retries: {:?}", error); + error!("Exceeded Retries: {error:?}"); } JitoSendTransactionError::TransactionError(e) => { // Flag - error!("Transaction: {:?}", e); + error!("Transaction: {e:?}"); } JitoSendTransactionError::RpcSimulateTransactionResult(e) => { // Recover error!("\n\nERROR: "); e.logs.iter().for_each(|log| { log.iter().enumerate().for_each(|(i, log)| { - error!("{}: {:?}", i, log); + error!("{i}: {log:?}"); }); }); } diff --git a/keepers/stakenet-keeper/src/main.rs b/keepers/stakenet-keeper/src/main.rs index 1322c4d16..62078edd4 100644 --- a/keepers/stakenet-keeper/src/main.rs +++ b/keepers/stakenet-keeper/src/main.rs @@ -99,7 +99,7 @@ async fn random_cooldown(range: u8) { let mut rng = rand::thread_rng(); let sleep_duration = rng.gen_range(0..=60 * (range as u64 + 1)); - info!("\n\nā° Cooldown for {} seconds\n", sleep_duration); + info!("\n\nā° Cooldown for {sleep_duration} seconds\n"); sleep(Duration::from_secs(sleep_duration)).await; } @@ -133,13 +133,13 @@ async fn run_keeper(keeper_config: KeeperConfig) { // The fetch ( update ) functions fetch everything we need for the operations from the blockchain // Additionally, this function will update the keeper state. If update fails - it will skip the fire functions. if should_update(tick, &intervals) { - info!("Pre-fetching data for update...({})", tick); + info!("Pre-fetching data for update...({tick})"); match pre_create_update(&keeper_config, &mut keeper_state).await { Ok(_) => { keeper_state.increment_update_run_for_epoch(KeeperOperations::PreCreateUpdate); } Err(e) => { - error!("Failed to pre create update: {:?}", e); + error!("Failed to pre create update: {e:?}"); keeper_state .increment_update_error_for_epoch(KeeperOperations::PreCreateUpdate); @@ -150,7 +150,7 @@ async fn run_keeper(keeper_config: KeeperConfig) { } if keeper_config.pay_for_new_accounts { - info!("Creating missing accounts...({})", tick); + info!("Creating missing accounts...({tick})"); match create_missing_accounts(&keeper_config, &keeper_state).await { Ok(new_accounts_created) => { keeper_state.increment_update_run_for_epoch( @@ -174,7 +174,7 @@ async fn run_keeper(keeper_config: KeeperConfig) { }); } Err(e) => { - error!("Failed to create missing accounts: {:?}", e); + error!("Failed to create missing accounts: {e:?}"); keeper_state.increment_update_error_for_epoch( KeeperOperations::CreateMissingAccounts, @@ -186,13 +186,13 @@ async fn run_keeper(keeper_config: KeeperConfig) { } } - info!("Post-fetching data for update...({})", tick); + info!("Post-fetching data for update...({tick})"); match post_create_update(&keeper_config, &mut keeper_state).await { Ok(_) => { keeper_state.increment_update_run_for_epoch(KeeperOperations::PostCreateUpdate); } Err(e) => { - error!("Failed to post create update: {:?}", e); + error!("Failed to post create update: {e:?}"); keeper_state .increment_update_error_for_epoch(KeeperOperations::PostCreateUpdate); @@ -329,7 +329,7 @@ fn main() { let flag_args = Args::parse(); let run_flags = set_run_flags(&flag_args); - info!("{}\n\n", args); + info!("{args}\n\n"); let gossip_entrypoints = args.gossip_entrypoints diff --git a/keepers/stakenet-keeper/src/operations/block_metadata/db.rs b/keepers/stakenet-keeper/src/operations/block_metadata/db.rs index d692ccd6d..1b22fa544 100644 --- a/keepers/stakenet-keeper/src/operations/block_metadata/db.rs +++ b/keepers/stakenet-keeper/src/operations/block_metadata/db.rs @@ -68,8 +68,7 @@ impl DBSlotInfoState { } Err(BlockMetadataKeeperError::OtherError(format!( - "Could not map state {}", - state + "Could not map state {state}" ))) } } @@ -217,7 +216,7 @@ impl DBSlotInfo { } transaction.commit()?; transaction = connection.transaction()?; - info!("Wrote {} Mappings", write_counter); + info!("Wrote {write_counter} Mappings"); } Ok(write_counter) @@ -536,19 +535,19 @@ impl DBSlotInfo { starting_offset: usize, ) -> Result { let client = reqwest::blocking::Client::new(); - let base_url = format!("https://api.dune.com/api/v1/query/{}/results", query_id); + let base_url = format!("https://api.dune.com/api/v1/query/{query_id}/results"); let mut total_written = 0u64; let mut offset = starting_offset; let mut has_more = true; - info!("Starting Dune API fetch for query {}", query_id); + info!("Starting Dune API fetch for query {query_id}"); while has_more { // Build URL with pagination - let url = format!("{}?limit={}&offset={}", base_url, batch_size, offset); + let url = format!("{base_url}?limit={batch_size}&offset={offset}"); - info!("Fetching batch from Dune API, offset: {}", offset); + info!("Fetching batch from Dune API, offset: {offset}"); // Make API request let response = client @@ -556,7 +555,7 @@ impl DBSlotInfo { .header("X-Dune-API-Key", api_key) .send() .map_err(|e| { - BlockMetadataKeeperError::OtherError(format!("API request failed: {}", e)) + BlockMetadataKeeperError::OtherError(format!("API request failed: {e}")) })?; if !response.status().is_success() { @@ -567,7 +566,7 @@ impl DBSlotInfo { } let api_response: DuneApiResponse = response.json().map_err(|e| { - BlockMetadataKeeperError::OtherError(format!("Failed to parse JSON: {}", e)) + BlockMetadataKeeperError::OtherError(format!("Failed to parse JSON: {e}")) })?; let rows = api_response.result.rows; @@ -623,10 +622,7 @@ impl DBSlotInfo { std::thread::sleep(std::time::Duration::from_millis(100)); } - info!( - "Completed Dune API fetch. Total entries written: {}", - total_written - ); + info!("Completed Dune API fetch. Total entries written: {total_written}"); Ok(total_written) } diff --git a/keepers/stakenet-keeper/src/operations/block_metadata/operations.rs b/keepers/stakenet-keeper/src/operations/block_metadata/operations.rs index 697855c55..18ee971dc 100644 --- a/keepers/stakenet-keeper/src/operations/block_metadata/operations.rs +++ b/keepers/stakenet-keeper/src/operations/block_metadata/operations.rs @@ -212,17 +212,17 @@ async fn update_block_metadata( // Check if slot exists if DBSlotInfo::check_random_slot_exists_in_epoch(sqlite_connection, epoch, epoch_schedule)? { - info!("Epoch {} already exists", epoch); + info!("Epoch {epoch} already exists"); continue; } else { - info!("Updating epoch {}", epoch) + info!("Updating epoch {epoch}") } let epoch_leader_schedule_result = get_leader_schedule_safe(client, epoch_starting_slot).await; if epoch_leader_schedule_result.is_err() { - info!("Could not find leader schedule for epoch {}", epoch); + info!("Could not find leader schedule for epoch {epoch}"); continue; } @@ -244,14 +244,14 @@ async fn update_block_metadata( time_ms as f64 / 1000.0 ) } - Err(err) => error!("Error writing leaders {:?}", err), + Err(err) => error!("Error writing leaders {err:?}"), } // 1.b Log out missing vote accounts for leader in epoch_leader_schedule.keys() { if !identity_to_vote_map.contains_key(leader) { // TODO - error!("TODO Could not find Vote for {} in epoch {}", leader, epoch) + error!("TODO Could not find Vote for {leader} in epoch {epoch}") } } } @@ -275,7 +275,7 @@ async fn update_block_metadata( time_ms as f64 / 1000.0 ) } - Err(err) => error!("Error updating identity/vote mapping {:?}", err), + Err(err) => error!("Error updating identity/vote mapping {err:?}"), } } @@ -320,10 +320,7 @@ async fn update_block_metadata( DBSlotInfo::set_block_dne(sqlite_connection, slot)?; } _ => { - info!( - "Could not get block info for slot {} - skipping: {:?}", - slot, err - ) + info!("Could not get block info for slot {slot} - skipping: {err:?}") } }, } @@ -342,7 +339,7 @@ async fn update_block_metadata( blocks_per_second ) } - Err(err) => error!("Error writing blocks {:?}", err), + Err(err) => error!("Error writing blocks {err:?}"), } } @@ -374,7 +371,7 @@ async fn update_block_metadata( ) { Ok(map) => map, Err(err) => { - error!("Could not get update map - skipping... {:?}", err); + error!("Could not get update map - skipping... {err:?}"); continue; } }; @@ -483,7 +480,7 @@ async fn update_block_metadata( ixs.len(), time_ms as f64 / 1000.0, ); - info!("Block Metadata: {}", needs_update_counter); + info!("Block Metadata: {needs_update_counter}"); } // 5. Submit TXs @@ -540,12 +537,7 @@ pub async fn get_priority_fee_distribution_account_info( ), Err(error) => { let error_string = format!( - "Could not deserialize account data {}-{}-{} = {}: {:?}", - priority_fee_distribution_program_id, - vote_account, - epoch, - priority_fee_distribution_account, - error + "Could not deserialize account data {priority_fee_distribution_program_id}-{vote_account}-{epoch} = {priority_fee_distribution_account}: {error:?}" ); ( priority_fee_distribution_account, @@ -558,12 +550,7 @@ pub async fn get_priority_fee_distribution_account_info( } Err(error) => { let error_string = format!( - "Could not fetch account {}-{}-{} = {}: {:?}", - priority_fee_distribution_program_id, - vote_account, - epoch, - priority_fee_distribution_account, - error + "Could not fetch account {priority_fee_distribution_program_id}-{vote_account}-{epoch} = {priority_fee_distribution_account}: {error:?}" ); ( priority_fee_distribution_account, @@ -582,8 +569,7 @@ pub async fn get_leader_schedule_safe( match rpc_client.get_leader_schedule(Some(starting_slot)).await? { Some(schedule) => Ok(schedule), None => Err(BlockMetadataKeeperError::OtherError(format!( - "Could not get leader schedule for starting slot {}", - starting_slot + "Could not get leader schedule for starting slot {starting_slot}" ))), } } diff --git a/keepers/stakenet-keeper/src/operations/gossip_upload.rs b/keepers/stakenet-keeper/src/operations/gossip_upload.rs index c5660689c..76637e0e7 100644 --- a/keepers/stakenet-keeper/src/operations/gossip_upload.rs +++ b/keepers/stakenet-keeper/src/operations/gossip_upload.rs @@ -253,10 +253,7 @@ fn check_entry_valid( let signer = entry.pubkey(); if signer != validator_identity { - error!( - "Invalid gossip value retrieved for validator {}", - validator_identity - ); + error!("Invalid gossip value retrieved for validator {validator_identity}"); return false; } true @@ -278,7 +275,7 @@ fn build_gossip_entry( // are fully deprecated and will not be transmitted on the gossip network. if let Some(entry) = crds.get::<&CrdsValue>(&contact_info_key) { if !check_entry_valid(entry, validator_history, validator_identity) { - println!("Invalid entry for validator {}", validator_vote_pubkey); + println!("Invalid entry for validator {validator_vote_pubkey}"); return None; } return Some(vec![GossipEntry::new( diff --git a/keepers/stakenet-keeper/src/operations/metrics_emit.rs b/keepers/stakenet-keeper/src/operations/metrics_emit.rs index e2f7f5074..a4ab5c83d 100644 --- a/keepers/stakenet-keeper/src/operations/metrics_emit.rs +++ b/keepers/stakenet-keeper/src/operations/metrics_emit.rs @@ -58,7 +58,7 @@ pub async fn fire( } Err(e) => { errors_for_epoch += 1; - error!("Failed to emit metrics: {}", e); + error!("Failed to emit metrics: {e}"); } } } diff --git a/keepers/stakenet-keeper/src/operations/priority_fee_commission.rs b/keepers/stakenet-keeper/src/operations/priority_fee_commission.rs index a9ce27cf7..ce33a026e 100644 --- a/keepers/stakenet-keeper/src/operations/priority_fee_commission.rs +++ b/keepers/stakenet-keeper/src/operations/priority_fee_commission.rs @@ -92,7 +92,7 @@ pub async fn fire( Ok(stats) => { for message in stats.results.iter().chain(stats.results.iter()) { if let Err(e) = message { - log_error!("ERROR: {}", e); + log_error!("ERROR: {e}"); datapoint_error!( "priority-fee-commission-error", ("error", e.to_string(), String), diff --git a/keepers/stakenet-keeper/src/operations/stake_upload.rs b/keepers/stakenet-keeper/src/operations/stake_upload.rs index df7d1dca2..4ffcaac7d 100644 --- a/keepers/stakenet-keeper/src/operations/stake_upload.rs +++ b/keepers/stakenet-keeper/src/operations/stake_upload.rs @@ -193,7 +193,7 @@ fn stake_entry_uploaded( ) -> bool { let vote_account = Pubkey::from_str(&vote_account.vote_pubkey) .inspect_err(|e| { - error!("Invalid vote account pubkey: {}", e); + error!("Invalid vote account pubkey: {e}"); }) .expect("Invalid vote account pubkey"); if let Some(validator_history) = validator_history_map.get(&vote_account) { diff --git a/keepers/stakenet-keeper/src/state/keeper_config.rs b/keepers/stakenet-keeper/src/state/keeper_config.rs index 18a4f2de9..d54f2544b 100644 --- a/keepers/stakenet-keeper/src/state/keeper_config.rs +++ b/keepers/stakenet-keeper/src/state/keeper_config.rs @@ -1,6 +1,6 @@ use std::{fmt, net::SocketAddr, path::PathBuf, sync::Arc}; -use clap::{arg, command, Parser}; +use clap::Parser; use kobe_client::client::KobeClient; use rusqlite::Connection; use solana_client::nonblocking::rpc_client::RpcClient; diff --git a/keepers/stakenet-keeper/src/state/keeper_state.rs b/keepers/stakenet-keeper/src/state/keeper_state.rs index 61025eb6a..bab0f3351 100644 --- a/keepers/stakenet-keeper/src/state/keeper_state.rs +++ b/keepers/stakenet-keeper/src/state/keeper_state.rs @@ -338,8 +338,7 @@ impl KeeperState { .checked_sub(first_slot_in_epoch) .ok_or_else(|| { JitoTransactionError::Custom(format!( - "Slot calculation overflow: current_slot={}, first_slot={}", - current_slot, first_slot_in_epoch + "Slot calculation overflow: current_slot={current_slot}, first_slot={first_slot_in_epoch}" )) })?; diff --git a/sdk/src/models/errors.rs b/sdk/src/models/errors.rs index 420c8552c..3a8232291 100644 --- a/sdk/src/models/errors.rs +++ b/sdk/src/models/errors.rs @@ -9,7 +9,7 @@ use tokio::task::JoinError; #[derive(ThisError, Debug)] pub enum JitoTransactionError { #[error(transparent)] - ClientError(#[from] ClientError), + ClientError(#[from] Box), #[error(transparent)] TransactionExecutionError(#[from] JitoTransactionExecutionError), #[error(transparent)] @@ -18,6 +18,12 @@ pub enum JitoTransactionError { Custom(String), } +impl From for JitoTransactionError { + fn from(error: ClientError) -> Self { + JitoTransactionError::ClientError(Box::new(error)) + } +} + pub type Error = Box; #[derive(ThisError, Debug, Clone)] pub enum JitoTransactionExecutionError { @@ -30,7 +36,7 @@ pub enum JitoTransactionExecutionError { #[derive(ThisError, Debug)] pub enum JitoMultipleAccountsError { #[error(transparent)] - ClientError(#[from] ClientError), + ClientError(#[from] Box), #[error(transparent)] JoinError(#[from] JoinError), } @@ -54,7 +60,7 @@ pub enum JitoInstructionError { JitoTransactionError(#[from] JitoTransactionError), #[error(transparent)] - ClientError(#[from] ClientError), + ClientError(#[from] Box), #[error(transparent)] KobeApiError(#[from] KobeApiError), diff --git a/sdk/src/utils/accounts.rs b/sdk/src/utils/accounts.rs index 4ade87d41..35329dcd7 100644 --- a/sdk/src/utils/accounts.rs +++ b/sdk/src/utils/accounts.rs @@ -318,7 +318,7 @@ pub async fn get_steward_config_account( StewardConfig::try_deserialize(&mut config_raw_account.data.as_slice()) .map(Box::new) - .map_err(|e| JitoTransactionError::Custom(format!("Failed to deserialize config: {}", e))) + .map_err(|e| JitoTransactionError::Custom(format!("Failed to deserialize config: {e}"))) } pub async fn get_steward_state_account( @@ -333,8 +333,7 @@ pub async fn get_steward_state_account( StewardStateAccountV2::try_deserialize(&mut state_raw_account.data.as_slice()) .map_err(|e| { JitoTransactionError::Custom(format!( - "Failed to deserialize steward state account: {}", - e + "Failed to deserialize steward state account: {e}" )) }) .map(Box::new) @@ -348,7 +347,7 @@ pub async fn get_stake_pool_account( StakePool::try_deserialize(&mut stake_pool_account_raw.data.as_slice()) .map_err(|e| { - JitoTransactionError::Custom(format!("Failed to deserialize stake pool account: {}", e)) + JitoTransactionError::Custom(format!("Failed to deserialize stake pool account: {e}")) }) .map(Box::new) } @@ -397,8 +396,7 @@ pub async fn get_validator_list_account( ValidatorList::try_deserialize(&mut validator_list_account_raw.data.as_slice()) .map_err(|e| { JitoTransactionError::Custom(format!( - "Failed to deserialize validator list account: {}", - e + "Failed to deserialize validator list account: {e}" )) }) .map(Box::new) @@ -423,8 +421,7 @@ pub async fn get_directed_stake_whitelist( let whitelist = DirectedStakeWhitelist::try_deserialize(&mut whitelist_account_data.as_slice()) .map_err(|e| { JitoTransactionError::Custom(format!( - "Failed to deserialize directed stake whitelist account: {}", - e + "Failed to deserialize directed stake whitelist account: {e}" )) })?; @@ -443,7 +440,7 @@ pub async fn get_directed_stake_meta( let directed_stake_meta_pda = get_directed_stake_meta_address(steward_config_address, program_id); - log::info!("Directed stake meta PDA: {:?}", directed_stake_meta_pda); + log::info!("Directed stake meta PDA: {directed_stake_meta_pda}"); let directed_stake_meta_account_data = client.get_account_data(&directed_stake_meta_pda).await?; @@ -452,8 +449,7 @@ pub async fn get_directed_stake_meta( DirectedStakeMeta::try_deserialize(&mut directed_stake_meta_account_data.as_slice()) .map_err(|e| { JitoTransactionError::Custom(format!( - "Failed to deserialize directed stake meta account: {}", - e + "Failed to deserialize directed stake meta account: {e}" )) })?, ); @@ -481,8 +477,7 @@ pub async fn get_directed_stake_ticket( DirectedStakeTicket::try_deserialize(&mut directed_stake_ticket_account_data.as_slice()) .map_err(|e| { JitoTransactionError::Custom(format!( - "Failed to deserialize directed stake ticket account: {}", - e + "Failed to deserialize directed stake ticket account: {e}" )) })?; diff --git a/sdk/src/utils/debug.rs b/sdk/src/utils/debug.rs index 1b4f4bb91..8c74c0643 100644 --- a/sdk/src/utils/debug.rs +++ b/sdk/src/utils/debug.rs @@ -29,11 +29,11 @@ pub async fn debug_send_single_transaction( if debug_print.unwrap_or(false) { match &result { Ok(signature) => { - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Err(e) => { println!("Accounts: {:?}", &instructions.last().unwrap().accounts); - println!("Error: {:?}", e); + println!("Error: {e:?}"); } } } diff --git a/sdk/src/utils/instructions.rs b/sdk/src/utils/instructions.rs index 75c07d3bb..229495ca5 100644 --- a/sdk/src/utils/instructions.rs +++ b/sdk/src/utils/instructions.rs @@ -224,7 +224,7 @@ pub async fn compute_bam_targets( authority_pubkey: &Pubkey, program_id: &Pubkey, ) -> Result, JitoInstructionError> { - let epoch_info = client.get_epoch_info().await?; + let epoch_info = client.get_epoch_info().await.map_err(Box::new)?; let current_epoch = epoch_info.epoch; let last_epoch = epoch_info.epoch - 1; diff --git a/sdk/src/utils/transactions.rs b/sdk/src/utils/transactions.rs index aefe99e45..596b971d9 100644 --- a/sdk/src/utils/transactions.rs +++ b/sdk/src/utils/transactions.rs @@ -70,7 +70,7 @@ pub async fn get_multiple_accounts_batched( match result { Ok(Ok(accounts)) => accounts_result.extend(accounts), Ok(Err(e)) => { - return Err(JitoMultipleAccountsError::ClientError(e)); + return Err(JitoMultipleAccountsError::ClientError(Box::new(e))); } Err(e) => return Err(JitoMultipleAccountsError::JoinError(e)), } @@ -290,7 +290,7 @@ async fn parallel_confirm_transactions( .map(|(i, sig_status)| (sig_batch[i], sig_status.clone())) .collect::>(), Err(e) => { - info!("Failed getting signature statuses: {:?}", e); + info!("Failed getting signature statuses: {e:?}"); vec![] } } @@ -433,7 +433,7 @@ pub async fn _parallel_execute_transactions_surfpool( } _ => { results[idx] = Err(JitoSendTransactionError::TransactionError( - format!("TX Error: {:?}", tx_err), + format!("TX Error: {tx_err:?}"), )); } } @@ -498,12 +498,12 @@ pub async fn parallel_execute_transactions( // Future optimization: submit these in parallel batches and refresh blockhash for every batch match client.send_transaction(tx).await { Ok(signature) => { - debug!("🟨 Submitted: {:?}", signature); - println!("🟨 Submitted: {:?}", signature); + debug!("🟨 Submitted: {signature:?}"); + println!("🟨 Submitted: {signature:?}"); submitted_signatures.insert(signature, idx); } Err(e) => { - debug!("Transaction error: {:?}", e); + debug!("Transaction error: {e:?}"); match e.get_transaction_error() { Some(TransactionError::BlockhashNotFound) => { debug!("🟧 Blockhash not found"); @@ -519,22 +519,19 @@ pub async fn parallel_execute_transactions( match e.kind { solana_client::client_error::ClientErrorKind::Io(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - Io Error: {:?}", - e + "TX - Io Error: {e:?}" ))) } solana_client::client_error::ClientErrorKind::Reqwest(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - Reqwest Error: {:?}", - e + "TX - Reqwest Error: {e:?}" ))) } solana_client::client_error::ClientErrorKind::RpcError(e) => match e { solana_client::rpc_request::RpcError::RpcRequestError(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - RPC Error (Request): {:?}", - e + "TX - RPC Error (Request): {e:?}" ))) } solana_client::rpc_request::RpcError::RpcResponseError { @@ -547,70 +544,61 @@ pub async fn parallel_execute_transactions( results[idx] = Err(JitoSendTransactionError::TransactionError("TX - RPC Error (Request - Empty)".to_string())) }, solana_client::rpc_request::RpcResponseErrorData::SendTransactionPreflightFailure(e) => { - println!("🟄 Preflight Error: \n{:?}\n\n", e); + println!("🟄 Preflight Error: \n{e:?}\n\n"); results[idx] = Err(JitoSendTransactionError::RpcSimulateTransactionResult(e)) }, solana_client::rpc_request::RpcResponseErrorData::NodeUnhealthy { num_slots_behind } => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - RPC Error (Request - Unhealthy): slots behind: {:?}", - num_slots_behind + "TX - RPC Error (Request - Unhealthy): slots behind: {num_slots_behind:?}" ))) }, } } solana_client::rpc_request::RpcError::ParseError(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - RPC Error (Parse): {:?}", - e + "TX - RPC Error (Parse): {e:?}" ))) } solana_client::rpc_request::RpcError::ForUser(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - RPC Error (For User): {:?}", - e + "TX - RPC Error (For User): {e:?}" ))) } }, solana_client::client_error::ClientErrorKind::SerdeJson(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - Serde Json Error: {:?}", - e + "TX - Serde Json Error: {e:?}" ))) } solana_client::client_error::ClientErrorKind::SigningError(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - Signing Error: {:?}", - e + "TX - Signing Error: {e:?}" ))) } solana_client::client_error::ClientErrorKind::TransactionError( e, ) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - Transaction Error: {:?}", - e + "TX - Transaction Error: {e:?}" ))) } solana_client::client_error::ClientErrorKind::Custom(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - Custom Error: {:?}", - e + "TX - Custom Error: {e:?}" ))) } solana_client::client_error::ClientErrorKind::Middleware(e) => { results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "TX - Middleware Error: {:?}", - e + "TX - Middleware Error: {e:?}" ))) }, } } None => { - warn!("None Transaction error: {:?}", e); + warn!("None Transaction error: {e:?}"); results[idx] = Err(JitoSendTransactionError::TransactionError(format!( - "None transaction error {:?}", - e + "None transaction error {e:?}" ))) } } @@ -641,8 +629,8 @@ pub async fn parallel_execute_transactions( for signature in signatures { results[submitted_signatures[&signature]] = Ok(()); - debug!("🟩 Completed: {:?}", signature); - println!("🟩 Completed: {:?}", signature); + debug!("🟩 Completed: {signature:?}"); + println!("🟩 Completed: {signature:?}"); } if results.iter().all(|r| r.is_ok()) { @@ -699,7 +687,7 @@ pub async fn pack_instructions( instructions_with_grouping.push((instruction, ix_per_tx)); } Err(e) => { - error!("Could not simulate instruction: {:?}", e); + error!("Could not simulate instruction: {e:?}"); // Skip this instruction if there is an error continue; } @@ -1021,14 +1009,14 @@ pub fn format_steward_error_log(error: &JitoSendTransactionError) -> String { error_logs.push_str("Exceeded Retries"); } JitoSendTransactionError::TransactionError(e) => { - error_logs.push_str(format!("Transaction: {:?}", e).as_str()); + error_logs.push_str(format!("Transaction: {e:?}").as_str()); } JitoSendTransactionError::RpcSimulateTransactionResult(e) => { error_logs.push_str("Preflight Error:"); e.logs.iter().for_each(|log| { log.iter().enumerate().for_each(|(i, log)| { - error_logs.push_str(format!("{}: {:?}", i, log).as_str()); + error_logs.push_str(format!("{i}: {log:?}").as_str()); }); }); } @@ -1056,12 +1044,12 @@ pub fn print_base58_tx(ixs: &[Instruction]) { let writable = if account.is_writable { "W" } else { "" }; let signer = if account.is_signer { "S" } else { "" }; - println!("{:<44} {:>2} {:>1}", pubkey, writable, signer); + println!("{pubkey:<44} {writable:>2} {signer:>1}"); }); println!("\n"); let base58_string = bs58::encode(&ix.data).into_string(); - println!("{}\n", base58_string); + println!("{base58_string}\n"); }); } diff --git a/tests/src/steward_fixtures.rs b/tests/src/steward_fixtures.rs index 04a7b1cea..51f90e8e1 100644 --- a/tests/src/steward_fixtures.rs +++ b/tests/src/steward_fixtures.rs @@ -930,7 +930,7 @@ impl TestFixture { }; if let Err(e) = process_transaction_result { - panic!("Error: {}", e); + panic!("Error: {e}"); } } @@ -948,12 +948,12 @@ impl TestFixture { if let Err(e) = process_transaction_result { if !e.to_string().contains(error_message) { - panic!("Error: {}\n\nDoes not match {}", e, error_message); + panic!("Error: {e}\n\nDoes not match {error_message}"); } assert!(e.to_string().contains(error_message)); } else { - panic!("Error: Transaction succeeded. Expected {}", error_message); + panic!("Error: Transaction succeeded. Expected {error_message}"); } } } diff --git a/tests/src/validator_history_fixtures.rs b/tests/src/validator_history_fixtures.rs index 83502fdc4..e4e2624af 100644 --- a/tests/src/validator_history_fixtures.rs +++ b/tests/src/validator_history_fixtures.rs @@ -172,7 +172,7 @@ impl TestFixture { .process_transaction_with_preflight(transaction) .await { - panic!("Error: {}", e); + panic!("Error: {e}"); } self.set_priority_fee_oracle_authority().await; @@ -332,7 +332,7 @@ impl TestFixture { .process_transaction_with_preflight(transaction) .await { - panic!("Error: {}", e); + panic!("Error: {e}"); } } @@ -348,10 +348,10 @@ impl TestFixture { .process_transaction_with_preflight(transaction) .await { - println!("{} {}", e, error_message); + println!("{e} {error_message}"); assert!(e.to_string().contains(error_message)); } else { - panic!("Error: Transaction succeeded. Expected {}", error_message); + panic!("Error: Transaction succeeded. Expected {error_message}"); } } } diff --git a/tests/tests/steward/test_algorithms.rs b/tests/tests/steward/test_algorithms.rs index e40901d06..4f7f240ae 100644 --- a/tests/tests/steward/test_algorithms.rs +++ b/tests/tests/steward/test_algorithms.rs @@ -1645,7 +1645,7 @@ fn test_increase_stake_calculation() { 0, ); assert!(result.is_ok()); - println!("result: {:?}", result); + println!("result: {result:?}"); assert!(match result.unwrap() { RebalanceType::Increase(lamports) => lamports == 2000 * LAMPORTS_PER_SOL, _ => false, @@ -1720,7 +1720,7 @@ fn test_increase_stake_calculation() { 0, ); assert!(result.is_ok()); - println!("result: {:?}", result); + println!("result: {result:?}"); assert!(match result.unwrap() { RebalanceType::Increase(lamports) => lamports == 1000 * LAMPORTS_PER_SOL, _ => false, @@ -2059,7 +2059,7 @@ fn test_decrease_stake_calculation() { 0, 0, ); - println!("Should be None: {:?}", result); + println!("Should be None: {result:?}"); assert!(matches!(result.unwrap(), RebalanceType::None)); // Test: Stake deposit cap reached on target validator @@ -2273,7 +2273,7 @@ fn test_decrease_stake_default_lamports() { .stake_deposit_unstake(&state, 0, current_lamports, target_lamports) .unwrap(); - assert_eq!(result, 0, "Expected 0 unstake lamports, but got {}", result); + assert_eq!(result, 0, "Expected 0 unstake lamports, but got {result}"); } // Test when stake_deposit_unstake_total reaches stake_deposit_unstake_cap @@ -2283,7 +2283,6 @@ fn test_decrease_stake_default_lamports() { .unwrap(); assert_eq!( result, 0, - "Expected 0 unstake lamports when cap is reached, but got {}", - result + "Expected 0 unstake lamports when cap is reached, but got {result}" ); } diff --git a/tests/tests/steward/test_integration.rs b/tests/tests/steward/test_integration.rs index 677346811..d226704d6 100644 --- a/tests/tests/steward/test_integration.rs +++ b/tests/tests/steward/test_integration.rs @@ -939,7 +939,7 @@ async fn test_idle() { fixture.get_latest_blockhash().await, ); - println!("Submitting Idle tx: {:?}", tx); + println!("Submitting Idle tx: {tx:?}"); fixture.submit_transaction_assert_success(tx).await; let mut steward_state_account: StewardStateAccountV2 = @@ -1032,15 +1032,8 @@ async fn test_rebalance_increase() { initialize_directed_stake_meta(&fixture).await; fixture.realloc_directed_stake_meta().await; - let mut steward_config: Config = fixture - .load_and_deserialize(&fixture.steward_config.pubkey()) - .await; let mut steward_state_account: StewardStateAccountV2 = fixture.load_and_deserialize(&fixture.steward_state).await; - steward_config.parameters.scoring_unstake_cap_bps = 0; - steward_config.parameters.instant_unstake_cap_bps = 0; - steward_config.parameters.stake_deposit_unstake_cap_bps = 0; - steward_config.parameters.minimum_voting_epochs = 1; steward_state_account.state.state_tag = StewardStateEnum::Rebalance; steward_state_account.state.num_pool_validators = MAX_VALIDATORS as u64 - 1; steward_state_account.state.next_cycle_epoch = epoch_schedule.first_normal_epoch + 10; diff --git a/tests/tests/steward/test_migrate_state_to_v2.rs b/tests/tests/steward/test_migrate_state_to_v2.rs index fd6d24114..8bb90f1d0 100644 --- a/tests/tests/steward/test_migrate_state_to_v2.rs +++ b/tests/tests/steward/test_migrate_state_to_v2.rs @@ -205,8 +205,7 @@ async fn test_migrate_state_to_v2() { .instant_unstake .get(i) .unwrap_or(false), - "instant_unstake mismatch at index {}", - i + "instant_unstake mismatch at index {i}" ); } // Progress (BitMask - compare element by element) @@ -214,8 +213,7 @@ async fn test_migrate_state_to_v2() { assert_eq!( steward_state_v1.state.progress.get(i).unwrap_or(false), steward_state_v2.state.progress.get(i).unwrap_or(false), - "progress mismatch at index {}", - i + "progress mismatch at index {i}" ); } // Validators for immediate removal (BitMask - compare element by element) @@ -236,8 +234,7 @@ async fn test_migrate_state_to_v2() { .validators_for_immediate_removal .get(i) .unwrap_or(false), - "validators_for_immediate_removal mismatch at index {}", - i + "validators_for_immediate_removal mismatch at index {i}" ); } // Validators to remove (BitMask - compare element by element) @@ -253,8 +250,7 @@ async fn test_migrate_state_to_v2() { .validators_to_remove .get(i) .unwrap_or(false), - "validators_to_remove mismatch at index {}", - i + "validators_to_remove mismatch at index {i}" ); } // Start computing scores slot @@ -307,8 +303,7 @@ async fn test_migrate_state_to_v2() { for (i, &byte) in steward_state_v1.state._padding0.iter().enumerate() { assert_eq!( byte, 0, - "V1 padding byte at index {} should be 0, but was {}", - i, byte + "V1 padding byte at index {i} should be 0, but was {byte}" ); } @@ -316,8 +311,7 @@ async fn test_migrate_state_to_v2() { for (i, &byte) in steward_state_v2.state._padding0.iter().enumerate() { assert_eq!( byte, 0, - "V2 padding byte at index {} should be 0, but was {}", - i, byte + "V2 padding byte at index {i} should be 0, but was {byte}" ); } @@ -368,7 +362,7 @@ async fn test_migrate_state_to_v2_twice_fails() { match result { Err(e) => { // The migration should fail with InvalidAccountData error - println!("Expected error: {:?}", e); + println!("Expected error: {e:?}"); } Ok(_) => panic!("Migration should have failed the second time"), } diff --git a/tests/tests/steward/test_spl_passthrough.rs b/tests/tests/steward/test_spl_passthrough.rs index 53da310dc..ee4ed6923 100644 --- a/tests/tests/steward/test_spl_passthrough.rs +++ b/tests/tests/steward/test_spl_passthrough.rs @@ -93,14 +93,8 @@ async fn _setup_test_steward_state( let epoch_schedule: EpochSchedule = fixture.get_sysvar().await; - let mut steward_config: Config = fixture - .load_and_deserialize(&fixture.steward_config.pubkey()) - .await; let mut steward_state_account: StewardStateAccountV2 = fixture.load_and_deserialize(&fixture.steward_state).await; - steward_config.parameters.scoring_unstake_cap_bps = 0; - steward_config.parameters.instant_unstake_cap_bps = 0; - steward_config.parameters.stake_deposit_unstake_cap_bps = 0; steward_state_account.state.state_tag = StewardStateEnum::Idle; steward_state_account.state.num_pool_validators = validators_to_add as u64 - 1; steward_state_account.state.next_cycle_epoch = epoch_schedule.first_normal_epoch + 10; diff --git a/tests/tests/steward/test_steward.rs b/tests/tests/steward/test_steward.rs index 58670e321..d2732dd9e 100644 --- a/tests/tests/steward/test_steward.rs +++ b/tests/tests/steward/test_steward.rs @@ -878,9 +878,7 @@ async fn test_steward_state_account_sizes() { assert_eq!( v1_size, v2_size, - "StewardStateAccount ({} bytes) and StewardStateAccountV2 ({} bytes) must have the same size", - v1_size, - v2_size + "StewardStateAccount ({v1_size} bytes) and StewardStateAccountV2 ({v2_size} bytes) must have the same size" ); } diff --git a/utils/steward-cli/src/cli_signer.rs b/utils/steward-cli/src/cli_signer.rs index a32e3fb1f..9e71346f0 100644 --- a/utils/steward-cli/src/cli_signer.rs +++ b/utils/steward-cli/src/cli_signer.rs @@ -35,7 +35,7 @@ impl CliSigner { pub fn new_keypair_from_path(keypair_path: &str) -> anyhow::Result { match read_keypair_file(keypair_path) { Ok(keypair) => Ok(Self::new(Some(keypair), None)), - Err(e) => Err(anyhow!("{}", e)), + Err(e) => Err(anyhow!("{e}")), } } @@ -53,7 +53,7 @@ impl CliSigner { let device_count = wallet_manager .update_devices() .expect("Could not fetch devices"); - println!("Wallet found with {} device(s) connected", device_count); + println!("Wallet found with {device_count} device(s) connected"); let devices = wallet_manager.list_devices(); let device = devices.first().expect("No devices found"); diff --git a/utils/steward-cli/src/commands/actions/add_to_blacklist.rs b/utils/steward-cli/src/commands/actions/add_to_blacklist.rs index b52147354..efd5310e2 100644 --- a/utils/steward-cli/src/commands/actions/add_to_blacklist.rs +++ b/utils/steward-cli/src/commands/actions/add_to_blacklist.rs @@ -47,10 +47,7 @@ pub async fn command_add_to_blacklist( }, Err(_) => ("N/A".to_string(), false), }; - println!( - "{}\thttps://solscan.io/account/{}\t{}", - vote_account, history_address, vh_index - ); + println!("{vote_account}\thttps://solscan.io/account/{history_address}\t{vh_index}"); if account_exists { indices.push(vh_index.parse()?); } @@ -76,17 +73,17 @@ pub async fn command_add_to_blacklist( .squads_program_id .unwrap_or(squads_multisig::squads_multisig_program::ID); - println!(" Multisig Address: {}", multisig); - println!(" Squads Program ID: {}", squads_program_id); + println!(" Multisig Address: {multisig}"); + println!(" Squads Program ID: {squads_program_id}"); // Fetch the multisig account to get the transaction index println!(" Fetching multisig account..."); let multisig_account = get_multisig(client, &multisig).await.map_err(|e| { - eprintln!("āŒ Failed to fetch multisig account: {}", e); + eprintln!("āŒ Failed to fetch multisig account: {e}"); e })?; let transaction_index = multisig_account.transaction_index + 1; - println!(" Next transaction index: {}", transaction_index); + println!(" Next transaction index: {transaction_index}"); // Derive PDAs let vault_pda = @@ -99,15 +96,13 @@ pub async fn command_add_to_blacklist( // Assert vault PDA is blacklist authority if vault_pda != blacklist_authority { return Err(anyhow::anyhow!( - "Vault PDA {} does not match configured blacklist authority {}", - vault_pda, - blacklist_authority + "Vault PDA {vault_pda} does not match configured blacklist authority {blacklist_authority}" )); } - println!(" Vault PDA: {}", vault_pda); - println!(" Transaction PDA: {}", transaction_pda); - println!(" Proposal PDA: {}", proposal_pda); + println!(" Vault PDA: {vault_pda}"); + println!(" Transaction PDA: {transaction_pda}"); + println!(" Proposal PDA: {proposal_pda}"); // Create the transaction message for the vault transaction let message = TransactionMessage::try_compile(&vault_pda, &[blacklist_ix], &[])?; @@ -174,7 +169,7 @@ pub async fn command_add_to_blacklist( .await?; println!("Squads proposal created!"); - println!("Signature: {}", signature); + println!("Signature: {signature}"); } } else { // Direct execution @@ -207,7 +202,7 @@ pub async fn command_add_to_blacklist( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } } diff --git a/utils/steward-cli/src/commands/actions/add_to_directed_stake_whitelist.rs b/utils/steward-cli/src/commands/actions/add_to_directed_stake_whitelist.rs index cd4d0ed7e..bd7c912cd 100644 --- a/utils/steward-cli/src/commands/actions/add_to_directed_stake_whitelist.rs +++ b/utils/steward-cli/src/commands/actions/add_to_directed_stake_whitelist.rs @@ -45,7 +45,7 @@ pub async fn command_add_to_directed_stake_whitelist( program_id: Pubkey, ) -> Result<()> { let authority_keypair = read_keypair_file(&args.authority_keypair_path) - .map_err(|e| anyhow::anyhow!("Failed to read keypair: {}", e))?; + .map_err(|e| anyhow::anyhow!("Failed to read keypair: {e}"))?; let authority_pubkey = authority_keypair.pubkey(); let directed_stake_whitelist = diff --git a/utils/steward-cli/src/commands/actions/auto_add_validator_from_pool.rs b/utils/steward-cli/src/commands/actions/auto_add_validator_from_pool.rs index 80664d971..52412261d 100644 --- a/utils/steward-cli/src/commands/actions/auto_add_validator_from_pool.rs +++ b/utils/steward-cli/src/commands/actions/auto_add_validator_from_pool.rs @@ -106,7 +106,7 @@ pub async fn command_auto_add_validator_from_pool( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/auto_remove_validator_from_pool.rs b/utils/steward-cli/src/commands/actions/auto_remove_validator_from_pool.rs index 2b9ae36b0..3726abd27 100644 --- a/utils/steward-cli/src/commands/actions/auto_remove_validator_from_pool.rs +++ b/utils/steward-cli/src/commands/actions/auto_remove_validator_from_pool.rs @@ -119,7 +119,7 @@ pub async fn command_auto_remove_validator_from_pool( ) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/close_steward.rs b/utils/steward-cli/src/commands/actions/close_steward.rs index c4e5687fb..cae2a3e59 100644 --- a/utils/steward-cli/src/commands/actions/close_steward.rs +++ b/utils/steward-cli/src/commands/actions/close_steward.rs @@ -84,7 +84,7 @@ pub async fn command_close_steward( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/copy_directed_stake_targets.rs b/utils/steward-cli/src/commands/actions/copy_directed_stake_targets.rs index e02b991ac..0412861fa 100644 --- a/utils/steward-cli/src/commands/actions/copy_directed_stake_targets.rs +++ b/utils/steward-cli/src/commands/actions/copy_directed_stake_targets.rs @@ -107,7 +107,7 @@ pub(crate) async fn command_copy_directed_stake_targets( .validators .iter() .position(|v| v.vote_account_address == *vote_pubkey) - .ok_or_else(|| anyhow!("Vote pubkey {} not found in validator list", vote_pubkey))?; + .ok_or_else(|| anyhow!("Vote pubkey {vote_pubkey} not found in validator list"))?; let ix = solana_sdk::instruction::Instruction { program_id, diff --git a/utils/steward-cli/src/commands/actions/instant_remove_validator.rs b/utils/steward-cli/src/commands/actions/instant_remove_validator.rs index 9a2c0f621..2a144e9c1 100644 --- a/utils/steward-cli/src/commands/actions/instant_remove_validator.rs +++ b/utils/steward-cli/src/commands/actions/instant_remove_validator.rs @@ -83,7 +83,7 @@ pub async fn command_instant_remove_validator( ) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/manually_copy_all_vote_accounts.rs b/utils/steward-cli/src/commands/actions/manually_copy_all_vote_accounts.rs index 333241e63..cfff99c2c 100644 --- a/utils/steward-cli/src/commands/actions/manually_copy_all_vote_accounts.rs +++ b/utils/steward-cli/src/commands/actions/manually_copy_all_vote_accounts.rs @@ -93,7 +93,7 @@ pub async fn command_manually_copy_all_vote_accounts( let submit_stats = submit_packaged_transactions(client, txs_to_run, &payer, None, None).await?; - println!("Submit stats: {:?}", submit_stats); + println!("Submit stats: {submit_stats:?}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/manually_remove_validator.rs b/utils/steward-cli/src/commands/actions/manually_remove_validator.rs index 3e54e0bd8..b199b0886 100644 --- a/utils/steward-cli/src/commands/actions/manually_remove_validator.rs +++ b/utils/steward-cli/src/commands/actions/manually_remove_validator.rs @@ -105,7 +105,7 @@ pub async fn command_manually_remove_validator( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/migrate_state_to_v2.rs b/utils/steward-cli/src/commands/actions/migrate_state_to_v2.rs index 988ccad96..db313a146 100644 --- a/utils/steward-cli/src/commands/actions/migrate_state_to_v2.rs +++ b/utils/steward-cli/src/commands/actions/migrate_state_to_v2.rs @@ -57,7 +57,7 @@ pub async fn command_migrate_state_to_v2( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/pause.rs b/utils/steward-cli/src/commands/actions/pause.rs index 249077476..d7bb385fa 100644 --- a/utils/steward-cli/src/commands/actions/pause.rs +++ b/utils/steward-cli/src/commands/actions/pause.rs @@ -65,7 +65,7 @@ pub async fn command_pause(args: Pause, client: &Arc, program_id: Pub .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/remove_bad_validators.rs b/utils/steward-cli/src/commands/actions/remove_bad_validators.rs index 3824f753a..2121cc907 100644 --- a/utils/steward-cli/src/commands/actions/remove_bad_validators.rs +++ b/utils/steward-cli/src/commands/actions/remove_bad_validators.rs @@ -78,14 +78,13 @@ pub async fn command_remove_bad_validators( ) .collect::>(); - println!("Bad history accounts: {:?}", bad_history_accounts); + println!("Bad history accounts: {bad_history_accounts:?}"); let ixs_to_run = bad_history_accounts .iter() .map(|(validator_index, vote_account, history_account)| { println!( - "index: {}, vote_account: {}, history_account: {}\n", - validator_index, vote_account, history_account + "index: {validator_index}, vote_account: {vote_account}, history_account: {history_account}\n" ); let (stake_address, _) = find_stake_program_address( @@ -155,7 +154,7 @@ pub async fn command_remove_bad_validators( let submit_stats = submit_transactions(client, txs_to_run, &arc_payer, 20, 30).await?; - println!("Submit stats: {:?}", submit_stats); + println!("Submit stats: {submit_stats:?}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/remove_from_blacklist.rs b/utils/steward-cli/src/commands/actions/remove_from_blacklist.rs index 8471012d8..c49a0c516 100644 --- a/utils/steward-cli/src/commands/actions/remove_from_blacklist.rs +++ b/utils/steward-cli/src/commands/actions/remove_from_blacklist.rs @@ -64,7 +64,7 @@ pub async fn command_remove_from_blacklist( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/remove_from_directed_stake_whitelist.rs b/utils/steward-cli/src/commands/actions/remove_from_directed_stake_whitelist.rs index 161f2a100..ed1d6ec78 100644 --- a/utils/steward-cli/src/commands/actions/remove_from_directed_stake_whitelist.rs +++ b/utils/steward-cli/src/commands/actions/remove_from_directed_stake_whitelist.rs @@ -45,7 +45,7 @@ pub async fn command_remove_from_directed_stake_whitelist( program_id: Pubkey, ) -> Result<()> { let authority_keypair = read_keypair_file(&args.authority_keypair_path) - .map_err(|e| anyhow::anyhow!("Failed to read keypair: {}", e))?; + .map_err(|e| anyhow::anyhow!("Failed to read keypair: {e}"))?; let authority_pubkey = authority_keypair.pubkey(); let directed_stake_whitelist = diff --git a/utils/steward-cli/src/commands/actions/reset_state.rs b/utils/steward-cli/src/commands/actions/reset_state.rs index 77a77d0ec..39cc81c50 100644 --- a/utils/steward-cli/src/commands/actions/reset_state.rs +++ b/utils/steward-cli/src/commands/actions/reset_state.rs @@ -73,7 +73,7 @@ pub async fn command_reset_state( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/reset_validator_lamport_balances.rs b/utils/steward-cli/src/commands/actions/reset_validator_lamport_balances.rs index b0e3ad5f0..8bdf97197 100644 --- a/utils/steward-cli/src/commands/actions/reset_validator_lamport_balances.rs +++ b/utils/steward-cli/src/commands/actions/reset_validator_lamport_balances.rs @@ -70,7 +70,7 @@ pub async fn command_reset_validator_lamport_balances( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/resume.rs b/utils/steward-cli/src/commands/actions/resume.rs index 69cac2424..02ba3594e 100644 --- a/utils/steward-cli/src/commands/actions/resume.rs +++ b/utils/steward-cli/src/commands/actions/resume.rs @@ -71,7 +71,7 @@ pub async fn command_resume( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/revert_staker.rs b/utils/steward-cli/src/commands/actions/revert_staker.rs index b4f16ec5c..948daafd5 100644 --- a/utils/steward-cli/src/commands/actions/revert_staker.rs +++ b/utils/steward-cli/src/commands/actions/revert_staker.rs @@ -75,7 +75,7 @@ pub async fn command_revert_staker( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/set_staker.rs b/utils/steward-cli/src/commands/actions/set_staker.rs index 529937b67..6b67eb6c5 100644 --- a/utils/steward-cli/src/commands/actions/set_staker.rs +++ b/utils/steward-cli/src/commands/actions/set_staker.rs @@ -66,7 +66,7 @@ pub async fn command_set_staker( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/actions/update_authority.rs b/utils/steward-cli/src/commands/actions/update_authority.rs index 9a68fed53..57cb8fbf6 100644 --- a/utils/steward-cli/src/commands/actions/update_authority.rs +++ b/utils/steward-cli/src/commands/actions/update_authority.rs @@ -109,14 +109,14 @@ pub async fn command_update_authority( .squads_program_id .unwrap_or(squads_multisig::squads_multisig_program::ID); - println!(" Multisig Address: {}", multisig); - println!(" Squads Program ID: {}", squads_program_id); + println!(" Multisig Address: {multisig}"); + println!(" Squads Program ID: {squads_program_id}"); // Fetch the multisig account to get the transaction index println!(" Fetching multisig account..."); let multisig_account = get_multisig(client, &multisig).await?; let transaction_index = multisig_account.transaction_index + 1; - println!(" Next transaction index: {}", transaction_index); + println!(" Next transaction index: {transaction_index}"); // Derive PDAs let vault_pda = @@ -128,15 +128,13 @@ pub async fn command_update_authority( if vault_pda != admin { return Err(anyhow::anyhow!( - "Vault PDA {} does not match configured admin {}", - vault_pda, - admin + "Vault PDA {vault_pda} does not match configured admin {admin}" )); } - println!(" Vault PDA: {}", vault_pda); - println!(" Transaction PDA: {}", transaction_pda); - println!(" Proposal PDA: {}", proposal_pda); + println!(" Vault PDA: {vault_pda}"); + println!(" Transaction PDA: {transaction_pda}"); + println!(" Proposal PDA: {proposal_pda}"); // Create the transaction message for the vault transaction let message = TransactionMessage::try_compile(&vault_pda, &[ix], &[])?; @@ -197,7 +195,7 @@ pub async fn command_update_authority( .await?; println!("Squads proposal created!"); - println!("Signature: {}", signature); + println!("Signature: {signature}"); } } else { let blockhash = client.get_latest_blockhash().await?; @@ -230,7 +228,7 @@ pub async fn command_update_authority( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } } diff --git a/utils/steward-cli/src/commands/actions/update_config.rs b/utils/steward-cli/src/commands/actions/update_config.rs index 52fa7998e..a90faf048 100644 --- a/utils/steward-cli/src/commands/actions/update_config.rs +++ b/utils/steward-cli/src/commands/actions/update_config.rs @@ -100,7 +100,7 @@ pub async fn command_update_config( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); Ok(()) } diff --git a/utils/steward-cli/src/commands/actions/update_priority_fee_config.rs b/utils/steward-cli/src/commands/actions/update_priority_fee_config.rs index eb106b234..81cc1219d 100644 --- a/utils/steward-cli/src/commands/actions/update_priority_fee_config.rs +++ b/utils/steward-cli/src/commands/actions/update_priority_fee_config.rs @@ -101,7 +101,7 @@ pub async fn command_update_priority_fee_config( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); Ok(()) } diff --git a/utils/steward-cli/src/commands/actions/update_validator_list_balance.rs b/utils/steward-cli/src/commands/actions/update_validator_list_balance.rs index 8d7e00046..ddab0e04e 100644 --- a/utils/steward-cli/src/commands/actions/update_validator_list_balance.rs +++ b/utils/steward-cli/src/commands/actions/update_validator_list_balance.rs @@ -61,7 +61,7 @@ pub async fn command_update_validator_list_balance( ) .await?; - println!("Transaction signature: {}", signature); + println!("Transaction signature: {signature}"); Ok(()) } diff --git a/utils/steward-cli/src/commands/command_args.rs b/utils/steward-cli/src/commands/command_args.rs index f95774361..51117fc47 100644 --- a/utils/steward-cli/src/commands/command_args.rs +++ b/utils/steward-cli/src/commands/command_args.rs @@ -1,7 +1,8 @@ -use clap::{arg, command, Parser, Subcommand}; +use std::path::PathBuf; + +use clap::{Parser, Subcommand}; use jito_steward::{UpdateParametersArgs, UpdatePriorityFeeParametersArgs}; use solana_sdk::pubkey::Pubkey; -use std::path::PathBuf; use crate::commands::{ actions::{ diff --git a/utils/steward-cli/src/commands/cranks/compute_delegations.rs b/utils/steward-cli/src/commands/cranks/compute_delegations.rs index 9ef372f3c..739451cbc 100644 --- a/utils/steward-cli/src/commands/cranks/compute_delegations.rs +++ b/utils/steward-cli/src/commands/cranks/compute_delegations.rs @@ -76,7 +76,7 @@ pub async fn command_crank_compute_delegations( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/cranks/compute_directed_stake_meta.rs b/utils/steward-cli/src/commands/cranks/compute_directed_stake_meta.rs index b4fbafe5f..d52fca385 100644 --- a/utils/steward-cli/src/commands/cranks/compute_directed_stake_meta.rs +++ b/utils/steward-cli/src/commands/cranks/compute_directed_stake_meta.rs @@ -246,7 +246,7 @@ pub async fn command_crank_compute_directed_stake_meta( .await?; println!("\n=== Transaction Successful ==="); - println!("Signature: {}", signature); + println!("Signature: {signature}"); println!("Updated metadata:"); println!(" - {num_tickets} tickets processed"); println!(" - {tickets_with_balance} tickets with balance"); diff --git a/utils/steward-cli/src/commands/cranks/compute_instant_unstake.rs b/utils/steward-cli/src/commands/cranks/compute_instant_unstake.rs index 8697594cf..9482e4fc1 100644 --- a/utils/steward-cli/src/commands/cranks/compute_instant_unstake.rs +++ b/utils/steward-cli/src/commands/cranks/compute_instant_unstake.rs @@ -118,7 +118,7 @@ pub async fn command_crank_compute_instant_unstake( let submit_stats = submit_packaged_transactions(client, txs_to_run, &payer, None, None).await?; - println!("Submit stats: {:?}", submit_stats); + println!("Submit stats: {submit_stats:?}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/cranks/compute_score.rs b/utils/steward-cli/src/commands/cranks/compute_score.rs index 98dd31e10..1daa510f2 100644 --- a/utils/steward-cli/src/commands/cranks/compute_score.rs +++ b/utils/steward-cli/src/commands/cranks/compute_score.rs @@ -59,8 +59,7 @@ pub async fn command_crank_compute_score( .iter() .map(|(validator_index, vote_account, history_account)| { println!( - "index: {}, vote_account: {}, history_account: {}\n", - validator_index, vote_account, history_account + "index: {validator_index}, vote_account: {vote_account}, history_account: {history_account}\n" ); Instruction { @@ -112,7 +111,7 @@ pub async fn command_crank_compute_score( let submit_stats = submit_packaged_transactions(client, txs_to_run, &payer, None, None).await?; - println!("Submit stats: {:?}", submit_stats); + println!("Submit stats: {submit_stats:?}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/cranks/epoch_maintenance.rs b/utils/steward-cli/src/commands/cranks/epoch_maintenance.rs index 5204215ae..22bddba92 100644 --- a/utils/steward-cli/src/commands/cranks/epoch_maintenance.rs +++ b/utils/steward-cli/src/commands/cranks/epoch_maintenance.rs @@ -35,7 +35,7 @@ pub async fn command_crank_epoch_maintenance( let epoch = client.get_epoch_info().await?.epoch; if epoch == all_steward_accounts.state_account.state.current_epoch { - println!("Epoch is the same as the current epoch: {}", epoch); + println!("Epoch is the same as the current epoch: {epoch}"); return Ok(()); } @@ -80,7 +80,7 @@ pub async fn command_crank_epoch_maintenance( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/cranks/idle.rs b/utils/steward-cli/src/commands/cranks/idle.rs index f478072ed..2f4ef4365 100644 --- a/utils/steward-cli/src/commands/cranks/idle.rs +++ b/utils/steward-cli/src/commands/cranks/idle.rs @@ -76,7 +76,7 @@ pub async fn command_crank_idle( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/cranks/rebalance.rs b/utils/steward-cli/src/commands/cranks/rebalance.rs index c5d5d575e..31afa4bf4 100644 --- a/utils/steward-cli/src/commands/cranks/rebalance.rs +++ b/utils/steward-cli/src/commands/cranks/rebalance.rs @@ -70,7 +70,7 @@ pub async fn command_crank_rebalance( let ixs_to_run = validators_to_run .iter() .map(|(validator_index, vote_account, history_account)| { - println!("vote_account ({}): {}", validator_index, vote_account); + println!("vote_account ({validator_index}): {vote_account}"); let (stake_address, _) = find_stake_program_address( &spl_stake_pool::id(), @@ -147,7 +147,7 @@ pub async fn command_crank_rebalance( let submit_stats = submit_packaged_transactions(client, txs_to_run, &payer, None, None).await?; - println!("Submit stats: {:?}", submit_stats); + println!("Submit stats: {submit_stats:?}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/info/get_jitosol_balance.rs b/utils/steward-cli/src/commands/info/get_jitosol_balance.rs index 9ed1f88ab..de3e1959a 100644 --- a/utils/steward-cli/src/commands/info/get_jitosol_balance.rs +++ b/utils/steward-cli/src/commands/info/get_jitosol_balance.rs @@ -40,7 +40,7 @@ pub async fn command_get_jitosol_balance( } else { let ui_amount = token_balance.ui_amount.unwrap_or(0.0); println!("JitoSOL Balance for {}:", args.token_account); - println!(" Amount: {} JitoSOL", ui_amount); + println!(" Amount: {ui_amount} JitoSOL"); println!(" Raw Amount: {}", token_balance.amount); println!(" Decimals: {}", token_balance.decimals); } diff --git a/utils/steward-cli/src/commands/info/view_blacklist.rs b/utils/steward-cli/src/commands/info/view_blacklist.rs index 64caa0a42..f37b6b8b0 100644 --- a/utils/steward-cli/src/commands/info/view_blacklist.rs +++ b/utils/steward-cli/src/commands/info/view_blacklist.rs @@ -46,7 +46,7 @@ pub async fn command_view_blacklist( println!("{:<8} Vote Account", "Index"); println!("{}", "-".repeat(60)); for (index, vote_account) in blacklisted_validators { - println!("{:<8} {}", index, vote_account); + println!("{index:<8} {vote_account}"); } } diff --git a/utils/steward-cli/src/commands/info/view_config.rs b/utils/steward-cli/src/commands/info/view_config.rs index fc08e6696..37a7cafe6 100644 --- a/utils/steward-cli/src/commands/info/view_config.rs +++ b/utils/steward-cli/src/commands/info/view_config.rs @@ -39,7 +39,7 @@ fn _print_default_config( formatted_string += "------- Config -------\n"; formatted_string += "šŸ“š Accounts šŸ“š\n"; - formatted_string += &format!("Config: {}\n", steward_config); + formatted_string += &format!("Config: {steward_config}\n"); formatted_string += &format!("Admin: {}\n", config_account.admin); formatted_string += &format!("Blacklist Auth: {}\n", config_account.blacklist_authority); formatted_string += &format!( @@ -58,8 +58,8 @@ fn _print_default_config( "Directed Stake Ticket Override Auth: {}\n", config_account.directed_stake_ticket_override_authority ); - formatted_string += &format!("Staker: {}\n", staker); - formatted_string += &format!("State: {}\n", steward_state); + formatted_string += &format!("Staker: {staker}\n"); + formatted_string += &format!("State: {steward_state}\n"); formatted_string += &format!("Stake Pool: {}\n", config_account.stake_pool); formatted_string += &format!("Validator List: {}\n", config_account.validator_list); formatted_string += &format!( @@ -189,5 +189,5 @@ fn _print_default_config( ); formatted_string += "---------------------"; - println!("{}", formatted_string) + println!("{formatted_string}") } diff --git a/utils/steward-cli/src/commands/info/view_directed_stake_meta.rs b/utils/steward-cli/src/commands/info/view_directed_stake_meta.rs index 38f471427..aebcf9729 100644 --- a/utils/steward-cli/src/commands/info/view_directed_stake_meta.rs +++ b/utils/steward-cli/src/commands/info/view_directed_stake_meta.rs @@ -17,7 +17,7 @@ pub async fn command_view_directed_stake_meta( get_directed_stake_meta(client.clone(), &args.steward_config, &program_id).await?; let _stake_meta_address = get_directed_stake_meta_address(&args.steward_config, &program_id); - println!("Directed stake meta: {}", _stake_meta_address); + println!("Directed stake meta: {_stake_meta_address}"); println!("\nšŸ“Š DirectedStakeMeta Information:"); println!("\nDirectedStakeMeta Account: {stake_meta_address}"); diff --git a/utils/steward-cli/src/commands/info/view_directed_stake_tickets.rs b/utils/steward-cli/src/commands/info/view_directed_stake_tickets.rs index 487f1f249..799acf673 100644 --- a/utils/steward-cli/src/commands/info/view_directed_stake_tickets.rs +++ b/utils/steward-cli/src/commands/info/view_directed_stake_tickets.rs @@ -94,7 +94,7 @@ pub async fn command_view_directed_stake_tickets( println!("{}", serde_json::to_string_pretty(&json_output)?); } else { - println!("Found {} DirectedStakeTicket accounts:\n", tickets_count); + println!("Found {tickets_count} DirectedStakeTicket accounts:\n"); for (pda, ticket) in ticket_map { println!("Ticket: {pda}"); diff --git a/utils/steward-cli/src/commands/info/view_next_index_to_remove.rs b/utils/steward-cli/src/commands/info/view_next_index_to_remove.rs index ab094b303..b826704f9 100644 --- a/utils/steward-cli/src/commands/info/view_next_index_to_remove.rs +++ b/utils/steward-cli/src/commands/info/view_next_index_to_remove.rs @@ -31,7 +31,7 @@ fn _print_next_index_to_remove(state_account: &StewardStateAccountV2) { .get_unsafe(i as usize); if value { - println!("Validator {} is marked for removal", i); + println!("Validator {i} is marked for removal"); return; } } diff --git a/utils/steward-cli/src/commands/info/view_priority_fee_config.rs b/utils/steward-cli/src/commands/info/view_priority_fee_config.rs index 2b7166b74..d5a3c6ebb 100644 --- a/utils/steward-cli/src/commands/info/view_priority_fee_config.rs +++ b/utils/steward-cli/src/commands/info/view_priority_fee_config.rs @@ -32,7 +32,7 @@ fn print_priority_fee_config(steward_config: &Pubkey, config_account: &Config) { formatted_string += "------- Priority Fee Config -------\n"; formatted_string += "šŸ“š Accounts šŸ“š\n"; - formatted_string += &format!("Config: {}\n", steward_config); + formatted_string += &format!("Config: {steward_config}\n"); formatted_string += &format!( "Priority Fee Parameters Authority: {}\n", config_account.priority_fee_parameters_authority @@ -60,5 +60,5 @@ fn print_priority_fee_config(steward_config: &Pubkey, config_account: &Config) { ); formatted_string += "--------------------------------\n"; - println!("{}", formatted_string); + println!("{formatted_string}"); } diff --git a/utils/steward-cli/src/commands/info/view_state.rs b/utils/steward-cli/src/commands/info/view_state.rs index 744dbef12..f84754bc3 100644 --- a/utils/steward-cli/src/commands/info/view_state.rs +++ b/utils/steward-cli/src/commands/info/view_state.rs @@ -727,7 +727,7 @@ fn _print_default_state( formatted_string += "\n"; formatted_string += "---------------------"; - println!("{}", formatted_string) + println!("{formatted_string}") } } @@ -969,26 +969,24 @@ fn _print_verbose_state( None => "N/A", }; - formatted_string += &format!("Vote Account: {:?}\n", vote_account); - formatted_string += &format!("Stake Account: {:?}\n", stake_address); - formatted_string += - &format!("Transient Stake Account: {:?}\n", transient_stake_address); - formatted_string += &format!("Steward List Index: {}\n", index); + formatted_string += &format!("Vote Account: {vote_account:?}\n"); + formatted_string += &format!("Stake Account: {stake_address:?}\n"); + formatted_string += &format!("Transient Stake Account: {transient_stake_address:?}\n"); + formatted_string += &format!("Steward List Index: {index}\n"); let overall_rank_str = match overall_ranks.get(index) { Some(rank) => (rank + 1).to_string(), None => "N/A".into(), }; - formatted_string += &format!("Overall Rank: {}\n", overall_rank_str); + formatted_string += &format!("Overall Rank: {overall_rank_str}\n"); formatted_string += &format!("Score: {}\n", score.unwrap_or(&0)); if let Some(raw_score) = steward_state_account.state.raw_scores.get(index) { let validator_score_components = ValidatorScoreComponents::decode(*raw_score); formatted_string += &validator_score_components.to_string(); } - formatted_string += - &format!("Passing Eligibility Criteria: {}\n", eligibility_criteria); + formatted_string += &format!("Passing Eligibility Criteria: {eligibility_criteria}\n"); formatted_string += &format!( "Target Delegation Percent: {:.1}%\n", @@ -1057,7 +1055,7 @@ fn _print_verbose_state( StakeStatus::DeactivatingValidator => "🟄 Deactivating Validator", StakeStatus::ReadyForRemoval => "🟄 Ready for Removal", }; - formatted_string += &format!("Status: {}\n", status); + formatted_string += &format!("Status: {status}\n"); formatted_string += &format!( "Marked for removal: {}\n", steward_state_account @@ -1083,7 +1081,7 @@ fn _print_verbose_state( } } - println!("{}", formatted_string); + println!("{formatted_string}"); } if maybe_vote_account.is_none() { @@ -1092,18 +1090,18 @@ fn _print_verbose_state( top_scores.sort_by(|a, b| b.1.cmp(&a.1)); top_scores.iter().for_each(|(vote_account, score)| { - let formatted_score = format!("{}", score).chars().rev().enumerate().fold( + let formatted_score = format!("{score}").chars().rev().enumerate().fold( String::new(), |acc, (i, c)| { if i > 0 && i % 3 == 0 { - format!("{}_{}", c, acc) + format!("{c}_{acc}") } else { - format!("{}{}", c, acc) + format!("{c}{acc}") } }, ); - let vote_account = format!("{:?}", vote_account); - println!("{:<45} : {}", vote_account, formatted_score); + let vote_account = format!("{vote_account:?}"); + println!("{vote_account:<45} : {formatted_score}"); }); } } diff --git a/utils/steward-cli/src/commands/init/init_directed_stake_meta.rs b/utils/steward-cli/src/commands/init/init_directed_stake_meta.rs index 2470c9008..76a75deef 100644 --- a/utils/steward-cli/src/commands/init/init_directed_stake_meta.rs +++ b/utils/steward-cli/src/commands/init/init_directed_stake_meta.rs @@ -26,7 +26,7 @@ pub async fn command_init_directed_stake_meta( program_id: Pubkey, ) -> Result<()> { let authority_keypair = read_keypair_file(&args.authority_keypair_path) - .map_err(|e| anyhow::anyhow!("Failed to read keypair: {}", e))?; + .map_err(|e| anyhow::anyhow!("Failed to read keypair: {e}"))?; let authority_pubkey = authority_keypair.pubkey(); let (directed_stake_meta_pda, _bump) = Pubkey::find_program_address( @@ -35,9 +35,9 @@ pub async fn command_init_directed_stake_meta( ); println!("Initializing DirectedStakeMeta..."); - println!(" Authority: {}", authority_pubkey); + println!(" Authority: {authority_pubkey}"); println!(" Steward Config: {}", args.steward_config); - println!(" DirectedStakeMeta PDA: {}", directed_stake_meta_pda); + println!(" DirectedStakeMeta PDA: {directed_stake_meta_pda}"); let instruction = Instruction { program_id, @@ -76,8 +76,8 @@ pub async fn command_init_directed_stake_meta( .await?; println!("āœ… DirectedStakeMeta initialized successfully!"); - println!(" Transaction signature: {}", signature); - println!(" DirectedStakeMeta account: {}", directed_stake_meta_pda); + println!(" Transaction signature: {signature}"); + println!(" DirectedStakeMeta account: {directed_stake_meta_pda}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/init/init_directed_stake_ticket.rs b/utils/steward-cli/src/commands/init/init_directed_stake_ticket.rs index bd26f05fc..842ef186e 100644 --- a/utils/steward-cli/src/commands/init/init_directed_stake_ticket.rs +++ b/utils/steward-cli/src/commands/init/init_directed_stake_ticket.rs @@ -27,7 +27,7 @@ pub async fn command_init_directed_stake_ticket( program_id: Pubkey, ) -> Result<()> { let authority_keypair = read_keypair_file(&args.authority_keypair_path) - .map_err(|e| anyhow::anyhow!("Failed to read keypair: {}", e))?; + .map_err(|e| anyhow::anyhow!("Failed to read keypair: {e}"))?; let authority_pubkey = authority_keypair.pubkey(); let directed_stake_whitelist_pda = @@ -37,7 +37,7 @@ pub async fn command_init_directed_stake_ticket( get_directed_stake_ticket_address(&args.steward_config, &authority_pubkey, &program_id); println!("Initializing DirectedStakeTicket..."); - println!(" Authority: {}", authority_pubkey); + println!(" Authority: {authority_pubkey}"); println!(" Steward Config: {}", args.steward_config); println!( " Ticket Update Authority: {}", @@ -47,7 +47,7 @@ pub async fn command_init_directed_stake_ticket( " Ticket Holder Is Protocol: {}", args.ticket_holder_is_protocol ); - println!(" DirectedStakeTicket PDA: {}", directed_stake_ticket_pda); + println!(" DirectedStakeTicket PDA: {directed_stake_ticket_pda}"); let instruction = Instruction { program_id, @@ -90,11 +90,8 @@ pub async fn command_init_directed_stake_ticket( .await?; println!("āœ… DirectedStakeTicket initialized successfully!"); - println!(" Transaction signature: {}", signature); - println!( - " DirectedStakeTicket account: {}", - directed_stake_ticket_pda - ); + println!(" Transaction signature: {signature}"); + println!(" DirectedStakeTicket account: {directed_stake_ticket_pda}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/init/init_directed_stake_whitelist.rs b/utils/steward-cli/src/commands/init/init_directed_stake_whitelist.rs index 931974530..ce3113703 100644 --- a/utils/steward-cli/src/commands/init/init_directed_stake_whitelist.rs +++ b/utils/steward-cli/src/commands/init/init_directed_stake_whitelist.rs @@ -23,7 +23,7 @@ pub async fn command_init_directed_stake_whitelist( program_id: Pubkey, ) -> Result<()> { let authority_keypair = read_keypair_file(&args.authority_keypair_path) - .map_err(|e| anyhow::anyhow!("Failed to read keypair: {}", e))?; + .map_err(|e| anyhow::anyhow!("Failed to read keypair: {e}"))?; let authority_pubkey = authority_keypair.pubkey(); let (directed_stake_whitelist_pda, _bump) = Pubkey::find_program_address( @@ -32,12 +32,9 @@ pub async fn command_init_directed_stake_whitelist( ); println!("Initializing DirectedStakeWhitelist..."); - println!(" Authority: {}", authority_pubkey); + println!(" Authority: {authority_pubkey}"); println!(" Steward Config: {}", args.steward_config); - println!( - " DirectedStakeWhitelist PDA: {}", - directed_stake_whitelist_pda - ); + println!(" DirectedStakeWhitelist PDA: {directed_stake_whitelist_pda}"); let instruction = Instruction { program_id, @@ -75,11 +72,8 @@ pub async fn command_init_directed_stake_whitelist( .await?; println!("āœ… DirectedStakeWhitelist initialized successfully!"); - println!(" Transaction signature: {}", signature); - println!( - " DirectedStakeWhitelist account: {}", - directed_stake_whitelist_pda - ); + println!(" Transaction signature: {signature}"); + println!(" DirectedStakeWhitelist account: {directed_stake_whitelist_pda}"); } Ok(()) diff --git a/utils/steward-cli/src/commands/init/init_steward.rs b/utils/steward-cli/src/commands/init/init_steward.rs index 69c48fc3a..1d8e9eeef 100644 --- a/utils/steward-cli/src/commands/init/init_steward.rs +++ b/utils/steward-cli/src/commands/init/init_steward.rs @@ -102,7 +102,7 @@ pub async fn command_init_steward( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); println!("Steward Config: {}", steward_config.pubkey()); } diff --git a/utils/steward-cli/src/commands/init/realloc_directed_stake_meta.rs b/utils/steward-cli/src/commands/init/realloc_directed_stake_meta.rs index 3e292d903..a553489c3 100644 --- a/utils/steward-cli/src/commands/init/realloc_directed_stake_meta.rs +++ b/utils/steward-cli/src/commands/init/realloc_directed_stake_meta.rs @@ -105,10 +105,7 @@ pub async fn command_realloc_directed_stake_meta( reallocs_left_to_run -= reallocs_per_transaction; reallocs_ran += reallocs_per_transaction; - println!( - "{}/{}: Signature: {}", - reallocs_ran, reallocs_to_run, signature - ); + println!("{reallocs_ran}/{reallocs_to_run}: Signature: {signature}"); } Ok(()) @@ -164,7 +161,7 @@ async fn _realloc_x_times( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(signature) diff --git a/utils/steward-cli/src/commands/init/realloc_directed_stake_whitelist.rs b/utils/steward-cli/src/commands/init/realloc_directed_stake_whitelist.rs index ce4197797..130b489b3 100644 --- a/utils/steward-cli/src/commands/init/realloc_directed_stake_whitelist.rs +++ b/utils/steward-cli/src/commands/init/realloc_directed_stake_whitelist.rs @@ -107,10 +107,7 @@ pub async fn command_realloc_directed_stake_whitelist( reallocs_left_to_run -= reallocs_per_transaction; reallocs_ran += reallocs_per_transaction; - println!( - "{}/{}: Signature: {}", - reallocs_ran, reallocs_to_run, signature - ); + println!("{reallocs_ran}/{reallocs_to_run}: Signature: {signature}"); } Ok(()) @@ -166,7 +163,7 @@ async fn _realloc_x_times( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(signature) diff --git a/utils/steward-cli/src/commands/init/realloc_state.rs b/utils/steward-cli/src/commands/init/realloc_state.rs index a1df47d87..09f2726ad 100644 --- a/utils/steward-cli/src/commands/init/realloc_state.rs +++ b/utils/steward-cli/src/commands/init/realloc_state.rs @@ -91,13 +91,10 @@ pub async fn command_realloc_state( reallocs_left_to_run -= reallocs_per_transaction; reallocs_ran += reallocs_per_transaction; - println!( - "{}/{}: Signature: {}", - reallocs_ran, reallocs_to_run, signature - ); + println!("{reallocs_ran}/{reallocs_to_run}: Signature: {signature}"); } - println!("Steward State: {}", steward_state); + println!("Steward State: {steward_state}"); Ok(()) } @@ -151,7 +148,7 @@ async fn _realloc_x_times( .send_and_confirm_transaction_with_spinner(&transaction) .await?; - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Ok(signature) diff --git a/utils/steward-cli/src/main.rs b/utils/steward-cli/src/main.rs index 9eb1bc8bc..2bdc5a88c 100644 --- a/utils/steward-cli/src/main.rs +++ b/utils/steward-cli/src/main.rs @@ -277,7 +277,7 @@ async fn main() -> Result<()> { }; if let Err(e) = result { - eprintln!("\nāŒ Error: \n\n{:?}\n", e); + eprintln!("\nāŒ Error: \n\n{e:?}\n"); std::process::exit(1); } diff --git a/utils/steward-cli/src/utils/transactions.rs b/utils/steward-cli/src/utils/transactions.rs index 134001d05..8e3322505 100644 --- a/utils/steward-cli/src/utils/transactions.rs +++ b/utils/steward-cli/src/utils/transactions.rs @@ -121,11 +121,11 @@ pub async fn debug_send_single_transaction( if debug_print.unwrap_or(false) { match &result { Ok(signature) => { - println!("Signature: {}", signature); + println!("Signature: {signature}"); } Err(e) => { println!("Accounts: {:?}", &instructions.last().unwrap().accounts); - println!("Error: {:?}", e); + println!("Error: {e:?}"); } } } @@ -188,10 +188,10 @@ pub fn print_governance_ix(ixs: &[Instruction]) { } println!("Data: {:?}", gov_ix_data.data); let base64_ix = BASE64_STANDARD.encode(buffer.into_inner()); - println!("Base64 InstructionData: {:?}\n", base64_ix); + println!("Base64 InstructionData: {base64_ix:?}\n"); } Err(err) => { - println!("Failed to serialize InstructionData: {}", err); + println!("Failed to serialize InstructionData: {err}"); } } }); diff --git a/utils/validator-history-cli/src/commands/backfill_validator_age.rs b/utils/validator-history-cli/src/commands/backfill_validator_age.rs index 0c4e02ba5..4c2057363 100644 --- a/utils/validator-history-cli/src/commands/backfill_validator_age.rs +++ b/utils/validator-history-cli/src/commands/backfill_validator_age.rs @@ -1,5 +1,5 @@ use anchor_lang::{InstructionData, ToAccountMetas}; -use clap::{arg, command, Parser}; +use clap::Parser; use solana_client::nonblocking::rpc_client::RpcClient; use solana_sdk::compute_budget::ComputeBudgetInstruction; use solana_sdk::instruction::Instruction; @@ -78,21 +78,17 @@ pub async fn run(args: BackfillValidatorAge, rpc_url: String) { loop { match build_and_submit_transaction(&client, instructions.as_slice(), &keypair).await { Ok(sig) => { - println!("Transaction successful: {:?}", sig); + println!("Transaction successful: {sig:?}"); break; } Err(err) => { retry_count += 1; if retry_count >= max_retries { - println!( - "Transaction failed after {} retries: {:?}", - max_retries, err - ); + println!("Transaction failed after {max_retries} retries: {err:?}"); break; } println!( - "Transaction failed (attempt {}/{}): {:?}. Retrying...", - retry_count, max_retries, err + "Transaction failed (attempt {retry_count}/{max_retries}): {err:?}. Retrying..." ); time::sleep(Duration::from_secs(2)).await; } @@ -153,12 +149,9 @@ async fn validate_validator_history_accounts( num_closed += 1; } } - println!("\nNumber of valid vote accounts: {}", num_valid); - println!( - "Number of open but invalid vote accounts: {}", - num_open_but_invalid - ); - println!("Number of closed vote accounts: {}", num_closed); + println!("\nNumber of valid vote accounts: {num_valid}"); + println!("Number of open but invalid vote accounts: {num_open_but_invalid}"); + println!("Number of closed vote accounts: {num_closed}"); validated } @@ -284,8 +277,7 @@ fn compute_validator_ages( fn read_oracle_data(path: PathBuf) -> Vec { // Open file - let file = - File::open(&path).unwrap_or_else(|e| panic!("Failed to open file {:?}: {}", path, e)); + let file = File::open(&path).unwrap_or_else(|e| panic!("Failed to open file {path:?}: {e}")); let reader = BufReader::new(file); let mut lines = reader.lines(); // Skip header line @@ -299,7 +291,7 @@ fn read_oracle_data(path: PathBuf) -> Vec { let parts: Vec<&str> = line.split(',').collect(); // Assert three fields if parts.len() != 3 { - panic!("Skipping invalid line: {}", line); + panic!("Skipping invalid line: {line}"); } // Parse vote pubkey let vote_account = Pubkey::from_str(parts[0]) diff --git a/utils/validator-history-cli/src/commands/cranks/copy_gossip_contact_info.rs b/utils/validator-history-cli/src/commands/cranks/copy_gossip_contact_info.rs index d956ef241..1b379472e 100644 --- a/utils/validator-history-cli/src/commands/cranks/copy_gossip_contact_info.rs +++ b/utils/validator-history-cli/src/commands/cranks/copy_gossip_contact_info.rs @@ -314,10 +314,7 @@ fn check_entry_valid( let signer = entry.pubkey(); if signer != validator_identity { - error!( - "Invalid gossip value retrieved for validator {}", - validator_identity - ); + error!("Invalid gossip value retrieved for validator {validator_identity}"); return false; } true @@ -339,7 +336,7 @@ fn build_gossip_entry( // are fully deprecated and will not be transmitted on the gossip network. if let Some(entry) = crds.get::<&CrdsValue>(&contact_info_key) { if !check_entry_valid(entry, validator_history, validator_identity) { - error!("Invalid entry for validator {}", validator_vote_pubkey); + error!("Invalid entry for validator {validator_vote_pubkey}"); return None; } return Some(vec![GossipEntry::new( diff --git a/utils/validator-history-cli/src/main.rs b/utils/validator-history-cli/src/main.rs index 2c06e28fa..7a5776050 100644 --- a/utils/validator-history-cli/src/main.rs +++ b/utils/validator-history-cli/src/main.rs @@ -1,5 +1,7 @@ +use std::{collections::HashMap, path::PathBuf, sync::Arc, thread::sleep, time::Duration}; + use anchor_lang::{AccountDeserialize, Discriminator, InstructionData, ToAccountMetas}; -use clap::{arg, command, Parser, Subcommand}; +use clap::{Parser, Subcommand}; use dotenvy::dotenv; use ipinfo::{BatchReqOpts, IpInfo, IpInfoConfig}; use rusqlite::Connection; @@ -14,7 +16,6 @@ use solana_sdk::{ }; use spl_stake_pool::state::{StakePool, ValidatorList}; use stakenet_keeper::operations::block_metadata::db::DBSlotInfo; -use std::{collections::HashMap, path::PathBuf, sync::Arc, thread::sleep, time::Duration}; use validator_history::{ constants::MAX_ALLOC_BYTES, ClusterHistory, ClusterHistoryEntry, Config, ValidatorHistory, ValidatorHistoryEntry, @@ -319,7 +320,7 @@ fn command_init_config(args: InitConfig, client: RpcClient) { let signature = client .send_and_confirm_transaction_with_spinner(&transaction) .expect("Failed to send transaction"); - println!("Signature: {}", signature); + println!("Signature: {signature}"); } fn command_realloc_config(args: ReallocConfig, client: RpcClient) { @@ -350,7 +351,7 @@ fn command_realloc_config(args: ReallocConfig, client: RpcClient) { let signature = client .send_and_confirm_transaction_with_spinner(&transaction) .expect("Failed to send transaction"); - println!("Signature: {}", signature); + println!("Signature: {signature}"); } fn command_init_cluster_history(args: InitClusterHistory, client: RpcClient) { @@ -399,7 +400,7 @@ fn command_init_cluster_history(args: InitClusterHistory, client: RpcClient) { let signature = client .send_and_confirm_transaction_with_spinner(&transaction) .expect("Failed to send transaction"); - println!("Signature: {}", signature); + println!("Signature: {signature}"); } fn get_entry(validator_history: ValidatorHistory, epoch: u64) -> Option { @@ -674,15 +675,15 @@ fn command_cranker_status(args: CrankerStatus, client: RpcClient) { println!("{}", serde_json::to_string_pretty(&output).unwrap()); } else { println!("Total Validators:\t\t{}", config.counter); - println!("Validators with IP:\t\t{}", ips); - println!("Validators with Version:\t{}", versions); - println!("Validators with Client Type:\t{}", types); - println!("Validators with MEV Commission: {}", mev_comms); - println!("Validators with MEV Earned: \t{}", mev_earned); - println!("Validators with Commission:\t{}", comms); - println!("Validators with Epoch Credits:\t{}", epoch_credits); - println!("Validators with Stake:\t\t{}", stakes); - println!("Validators with Rank:\t\t{}", ranks); + println!("Validators with IP:\t\t{ips}"); + println!("Validators with Version:\t{versions}"); + println!("Validators with Client Type:\t{types}"); + println!("Validators with MEV Commission: {mev_comms}"); + println!("Validators with MEV Earned: \t{mev_earned}"); + println!("Validators with Commission:\t{comms}"); + println!("Validators with Epoch Credits:\t{epoch_credits}"); + println!("Validators with Stake:\t\t{stakes}"); + println!("Validators with Rank:\t\t{ranks}"); } } @@ -777,7 +778,7 @@ fn command_history(args: History, client: RpcClient) { ); } None => { - println!("Epoch {}:\tNo history", epoch); + println!("Epoch {epoch}:\tNo history"); } } } @@ -800,7 +801,7 @@ fn command_view_config(client: RpcClient) { "Tip Distribution Program: {}", config.tip_distribution_program ); - println!("Config Account: {}\n", config_pda); + println!("Config Account: {config_pda}\n"); println!("↺ State ↺"); println!("Validator History Account Counter: {}\n", config.counter); } @@ -894,7 +895,7 @@ fn command_backfill_cluster_history(args: BackfillClusterHistory, client: RpcCli let signature = client .send_and_confirm_transaction_with_spinner(&transaction) .expect("Failed to send transaction"); - println!("Signature: {}", signature); + println!("Signature: {signature}"); } fn command_update_oracle_authority(args: UpdateOracleAuthority, client: RpcClient) { @@ -927,7 +928,7 @@ fn command_update_oracle_authority(args: UpdateOracleAuthority, client: RpcClien let signature = client .send_and_confirm_transaction_with_spinner(&transaction) .expect("Failed to send transaction"); - println!("Signature: {}", signature); + println!("Signature: {signature}"); } async fn command_stake_by_country(args: StakeByCountry, client: RpcClient) { @@ -1092,7 +1093,7 @@ async fn command_stake_by_country(args: StakeByCountry, client: RpcClient) { } None => { // Country name not available - eprintln!("No country data for IP {}", ip_address); + eprintln!("No country data for IP {ip_address}"); } } } @@ -1114,10 +1115,10 @@ async fn command_stake_by_country(args: StakeByCountry, client: RpcClient) { match country_map.get(country) { Some(stake) => { let percentage = (*stake as f64 / total_stake as f64) * 100.0; - println!("Lamports: {stake}, Percentage: {:.2}%", percentage); + println!("Lamports: {stake}, Percentage: {percentage:.2}%"); } None => { - println!("Country not found: {}", country); + println!("Country not found: {country}"); println!( "Available countries: {}", country_map @@ -1137,10 +1138,7 @@ async fn command_stake_by_country(args: StakeByCountry, client: RpcClient) { println!("Total stake: {total_stake} lamports"); for (country, stake) in countries { let percentage = (*stake as f64 / total_stake as f64) * 100.0; - println!( - "Country: {}, Lamports: {}, Percentage: {:.2}%", - country, stake, percentage - ); + println!("Country: {country}, Lamports: {stake}, Percentage: {percentage:.2}%"); } } } @@ -1153,7 +1151,7 @@ fn command_get_config(client: RpcClient) { Ok(account) => match Config::try_deserialize(&mut account.data.as_slice()) { Ok(config) => { println!("Validator History Config:"); - println!(" Pubkey: {}", config_pda); + println!(" Pubkey: {config_pda}"); println!( " Tip Distribution Program: {}", config.tip_distribution_program @@ -1204,7 +1202,7 @@ async fn command_dune_priority_fee_backfill(args: DunePriorityFeeBackfill, clien .expect("Task panicked") .expect("Error running backfill"); - println!("Total entries written: {}", entries_written); + println!("Total entries written: {entries_written}"); } fn command_upload_validator_age(args: UploadValidatorAge, client: RpcClient) { @@ -1259,8 +1257,8 @@ fn command_upload_validator_age(args: UploadValidatorAge, client: RpcClient) { println!("Successfully uploaded validator age:"); println!(" Vote Account: {}", args.vote_account); println!(" Validator Age: {}", args.age); - println!(" Last Updated Epoch: {}", epoch); - println!(" Signature: {}", signature); + println!(" Last Updated Epoch: {epoch}"); + println!(" Signature: {signature}"); } #[tokio::main]