Skip to content

Commit

Permalink
better exit
Browse files Browse the repository at this point in the history
  • Loading branch information
esemeniuc committed Oct 6, 2023
1 parent cbb1fe7 commit a255bb7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
4 changes: 3 additions & 1 deletion core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2360,7 +2360,9 @@ impl ReplayStage {

// If we are a non voting validator or have an incorrect setup preventing us from
// generating vote txs, no need to refresh
let Some(last_vote_tx_blockhash) = tower.last_vote_tx_blockhash() else { return };
let Some(last_vote_tx_blockhash) = tower.last_vote_tx_blockhash() else {
return;
};

if my_latest_landed_vote >= last_voted_slot
|| heaviest_bank_on_same_fork
Expand Down
2 changes: 1 addition & 1 deletion frozen-abi/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ pub fn frozen_abi(attrs: TokenStream, item: TokenStream) -> TokenStream {
"the required \"digest\" = ... attribute is missing.",
)
.to_compile_error()
.into()
.into();
};

let item = parse_macro_input!(item as Item);
Expand Down
9 changes: 5 additions & 4 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,11 @@ fn get_latest_optimistic_slots(
let Some(latest_slot) = blockstore
.get_latest_optimistic_slots(1)
.expect("get_latest_optimistic_slots() failed")
.pop() else {
eprintln!("Blockstore does not contain any optimistically confirmed slots");
return vec![];
};
.pop()
else {
eprintln!("Blockstore does not contain any optimistically confirmed slots");
return vec![];
};
let latest_slot = latest_slot.0;

let slot_iter = AncestorIterator::new_inclusive(latest_slot, blockstore).map(|slot| {
Expand Down
34 changes: 15 additions & 19 deletions tip-distributor/src/claim_mev_workflow.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::TreeNode;

use {
crate::{
read_json_from_file, sign_and_send_transactions_with_retries,
GeneratedMerkleTreeCollection, MAX_FETCH_RETRIES,
GeneratedMerkleTreeCollection, TreeNode, MAX_FETCH_RETRIES,
},
anchor_lang::{AccountDeserialize, InstructionData, ToAccountMetas},
itertools::Itertools,
Expand Down Expand Up @@ -154,12 +152,8 @@ pub async fn claim_mev_tips(

// Try sending txns to RPC
let mut retries = 0;
let mut transactions_len = 0;
let mut failed_transactions = HashMap::new();
loop {
if retries >= max_loop_retries {
break;
}
let transaction_prepare_start = Instant::now();
let (
skipped_merkle_root_count,
Expand Down Expand Up @@ -203,16 +197,15 @@ pub async fn claim_mev_tips(
if transactions.is_empty() {
return Ok(());
}
transactions_len = transactions.len();

if let Some((start_balance, desired_balance, sol_to_deposit)) =
is_sufficient_balance(&payer_pubkey, &rpc_client, transactions.len() as u64).await
{
panic!("Expected to have at least {desired_balance} lamports in {payer_pubkey}. Current balance is {start_balance} lamports. Deposit {sol_to_deposit} SOL to continue.");
}
let transactions_len = transactions.len();

info!("Sending {transactions_len} tip claim transactions. {zero_lamports_count} would transfer zero lamports, {below_min_rent_count} would be below minimum rent");

info!("Sending {} tip claim transactions. {zero_lamports_count} would transfer zero lamports, {below_min_rent_count} would be below minimum rent",transactions.len());
let send_start = Instant::now();
let (remaining_transactions, new_failed_transactions) =
sign_and_send_transactions_with_retries(
Expand Down Expand Up @@ -248,17 +241,20 @@ pub async fn claim_mev_tips(

failed_transactions.extend(new_failed_transactions);
retries += 1;
}

if !failed_transactions.is_empty() {
panic!(
"Failed after {max_loop_retries} retries. {} remaining mev claim transactions, {} failed requests.",
transactions_len,
failed_transactions.len()
);
}
if retries >= max_loop_retries {
if !remaining_transactions.is_empty() {
panic!(
"Failed after {max_loop_retries} retries. {} remaining mev claim transactions, {} failed requests.",
remaining_transactions.len(),
failed_transactions.len()
);
}

Ok(())
info!("Finished after {:?}", account_fetch_start.elapsed());
return Ok(());
}
}
}

fn build_transactions(
Expand Down

0 comments on commit a255bb7

Please sign in to comment.