diff --git a/bench-batch-simulate-bundle/src/main.rs b/bench-batch-simulate-bundle/src/main.rs index 56e8762ddb..7aed653ec2 100644 --- a/bench-batch-simulate-bundle/src/main.rs +++ b/bench-batch-simulate-bundle/src/main.rs @@ -232,7 +232,7 @@ fn spawn_slots_subscribe_thread( node_name: String, exit: Arc, ) -> JoinHandle<()> { - let mut slots_sub = PubsubClient::slot_subscribe(&*pubsub_addr).unwrap(); + let mut slots_sub = PubsubClient::slot_subscribe(&pubsub_addr).unwrap(); thread::spawn(move || loop { if exit.load(Ordering::Acquire) { let _ = slots_sub.0.shutdown(); @@ -243,7 +243,7 @@ fn spawn_slots_subscribe_thread( Ok(slot_info) => info!("[RPC={} slot={:?}]", node_name, slot_info.slot), Err(e) => { error!("error receiving on slots_sub channel: {}", e); - slots_sub = PubsubClient::slot_subscribe(&*pubsub_addr).unwrap(); + slots_sub = PubsubClient::slot_subscribe(&pubsub_addr).unwrap(); } } }) @@ -270,7 +270,7 @@ fn fetch_n_highest_cost_transactions( }; let block = rpc_client .get_block_with_config(slot, config) - .expect(&*format!("failed to fetch block at slot: {}", slot)); + .unwrap_or_else(|_| panic!("failed to fetch block at slot: {}", slot)); let parent_slot = block.parent_slot; ( diff --git a/tip-distributor/src/claim_mev_workflow.rs b/tip-distributor/src/claim_mev_workflow.rs index 96274948f4..72a7a6f3cc 100644 --- a/tip-distributor/src/claim_mev_workflow.rs +++ b/tip-distributor/src/claim_mev_workflow.rs @@ -1,12 +1,11 @@ -use solana_program::native_token::LAMPORTS_PER_SOL; use { crate::{read_json_from_file, send_transactions_with_retry, GeneratedMerkleTreeCollection}, anchor_lang::{AccountDeserialize, InstructionData, ToAccountMetas}, log::{debug, info, warn}, solana_client::{nonblocking::rpc_client::RpcClient, rpc_request::RpcError}, solana_program::{ - fee_calculator::DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE, stake::state::StakeState, - system_program, + fee_calculator::DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE, native_token::LAMPORTS_PER_SOL, + stake::state::StakeState, system_program, }, solana_rpc_client_api::client_error, solana_sdk::{ diff --git a/tip-distributor/src/merkle_root_upload_workflow.rs b/tip-distributor/src/merkle_root_upload_workflow.rs index 4925087fae..2ae7a36031 100644 --- a/tip-distributor/src/merkle_root_upload_workflow.rs +++ b/tip-distributor/src/merkle_root_upload_workflow.rs @@ -6,6 +6,9 @@ use { anchor_lang::AccountDeserialize, log::{error, info}, solana_client::nonblocking::rpc_client::RpcClient, + solana_program::{ + fee_calculator::DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE, native_token::LAMPORTS_PER_SOL, + }, solana_sdk::{ commitment_config::CommitmentConfig, pubkey::Pubkey, @@ -68,6 +71,16 @@ pub fn upload_merkle_root( info!("num trees to upload: {:?}", trees.len()); + // heuristic to make sure we have enough funds to cover execution, assumes all trees need updating + { + let initial_balance = rpc_client.get_balance(&keypair.pubkey()).await.expect("failed to get balance"); + let desired_balance = trees.len() as u64 * DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE; + if initial_balance < desired_balance { + let sol_to_deposit = (desired_balance - initial_balance + LAMPORTS_PER_SOL - 1) / LAMPORTS_PER_SOL; // rounds up to nearest sol + panic!("Expected to have at least {} lamports in {}, current balance is {} lamports, deposit {} SOL to continue.", + desired_balance, &keypair.pubkey(), initial_balance, sol_to_deposit) + } + } let mut trees_needing_update: Vec = vec![]; for tree in trees { let account = rpc_client diff --git a/tip-distributor/src/stake_meta_generator_workflow.rs b/tip-distributor/src/stake_meta_generator_workflow.rs index 1020b3f2e8..bcf6c31439 100644 --- a/tip-distributor/src/stake_meta_generator_workflow.rs +++ b/tip-distributor/src/stake_meta_generator_workflow.rs @@ -145,11 +145,13 @@ pub fn generate_stake_meta_collection( ) -> Result { assert!(bank.is_frozen()); - let epoch_vote_accounts = bank.epoch_vote_accounts(bank.epoch()).expect(&*format!( - "No epoch_vote_accounts found for slot {} at epoch {}", - bank.slot(), - bank.epoch() - )); + let epoch_vote_accounts = bank.epoch_vote_accounts(bank.epoch()).unwrap_or_else(|| { + panic!( + "No epoch_vote_accounts found for slot {} at epoch {}", + bank.slot(), + bank.epoch() + ) + }); let l_stakes = bank.stakes_cache.stakes(); let delegations = l_stakes.stake_delegations();