From 640a4dc18a77cf4f7f6aef1dee3c501d97dd7bd7 Mon Sep 17 00:00:00 2001 From: Ilia Zyrin Date: Mon, 24 Feb 2025 12:34:18 +0100 Subject: [PATCH] logging improvements --- src/liquidator.rs | 8 +++----- src/transaction_manager.rs | 40 +++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/liquidator.rs b/src/liquidator.rs index 7a0dfad..d67d4f0 100644 --- a/src/liquidator.rs +++ b/src/liquidator.rs @@ -281,8 +281,7 @@ impl Liquidator { } } - /// Starts processing/evaluate all account, checking - /// if a liquidation is necessary/needed + /// Checks if liquidation is needed for each account, one by one async fn process_all_accounts(&mut self) -> anyhow::Result> { // Update switchboard pull prices with crossbar let swb_feed_hashes = self @@ -614,9 +613,9 @@ impl Liquidator { Ok(balance) } - /// Will load marginfi accounts into the liquidator itself + /// Loading marginfi accounts into the liquidator itself /// makes it easier and better, than holding it in a shared - /// state engine, as it shouldn't be blocked by another threads + /// state engine, as it shouldn't be blocked by other threads pub async fn load_marginfi_accounts( &mut self, rpc_client: Arc, @@ -653,7 +652,6 @@ impl Liquidator { Ok(()) } - /// Loads all marginfi account address into a [`Vec`] async fn load_marginfi_account_addresses( &self, rpc_client: Arc, diff --git a/src/transaction_manager.rs b/src/transaction_manager.rs index 0ffee5d..d5d69a0 100644 --- a/src/transaction_manager.rs +++ b/src/transaction_manager.rs @@ -4,7 +4,9 @@ use jito_protos::searcher::{ searcher_service_client::SearcherServiceClient, GetTipAccountsRequest, NextScheduledLeaderRequest, SubscribeBundleResultsRequest, }; -use jito_searcher_client::{get_searcher_client_no_auth, send_bundle_with_confirmation}; +use jito_searcher_client::{ + get_searcher_client_no_auth, send_bundle_with_confirmation, BundleRejectionError, +}; use log::{debug, error, info}; use solana_address_lookup_table_program::state::AddressLookupTable; use solana_client::{nonblocking::rpc_client::RpcClient, rpc_client::RpcClient as NonBlockRpc}; @@ -185,7 +187,7 @@ impl TransactionManager { tokio::spawn(async move { if let Err(e) = result.await { ERROR_COUNT.inc(); - error!("Failed to send transaction: {:?}", e); + debug!("Failed to send transaction: {:?}", e); } drop(permit); }); @@ -204,22 +206,38 @@ impl TransactionManager { .await? .into_inner(); - if let Err(e) = send_bundle_with_confirmation( + send_bundle_with_confirmation( &transactions, &rpc, &mut searcher_client, &mut bundle_results_subscription, ) .await - { - return Err(anyhow::anyhow!( - "Failed to send a bundle of {} transactions: {:?}", - transactions.len(), - e - )); - } + .map_err(|e| { + if let Some(BundleRejectionError::SimulationFailure(_, msg)) = + e.downcast_ref::() + { + if msg + .as_ref() + .is_some_and(|m| m.contains("custom program error: 0x1781")) + { + error!( + "Illegal Liquidation: {:?}", + transactions + .first() + .unwrap() + .message + .instructions() + .first() + .unwrap() + ); + } else { + error!("SimulationFailure: {:?}", msg); + } + }; - Ok(()) + anyhow::anyhow!("{:?}", e) + }) } /// Configures the instructions