Skip to content

Commit

Permalink
logging improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Zyrin authored and Ilia Zyrin committed Feb 24, 2025
1 parent bd4d0a0 commit 640a4dc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
8 changes: 3 additions & 5 deletions src/liquidator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<PreparedLiquidatableAccount>> {
// Update switchboard pull prices with crossbar
let swb_feed_hashes = self
Expand Down Expand Up @@ -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<RpcClient>,
Expand Down Expand Up @@ -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<RpcClient>,
Expand Down
40 changes: 29 additions & 11 deletions src/transaction_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
});
Expand All @@ -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::<BundleRejectionError>()
{
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
Expand Down

0 comments on commit 640a4dc

Please sign in to comment.