From 8785373bdb9fd7da0ff15ab9ea15291110f973d9 Mon Sep 17 00:00:00 2001 From: "Jean Marchand (Exotic Markets)" Date: Thu, 26 Sep 2024 22:17:49 +0700 Subject: [PATCH] plugin: Add more retry attempts and more logs (#63) --- Cargo.lock | 1 - plugin/Cargo.toml | 1 - plugin/src/builders/thread_exec.rs | 12 +++++++----- plugin/src/executors/state/executable_threads.rs | 6 ++++-- plugin/src/executors/tx.rs | 2 +- plugin/src/observers/thread.rs | 2 +- plugin/src/observers/webhook.rs | 2 +- plugin/src/pool_position.rs | 2 +- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bfd4703f..e51b488e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3773,7 +3773,6 @@ dependencies = [ "solana-client", "solana-geyser-plugin-interface", "solana-logger", - "solana-program", "solana-quic-client", "solana-sdk", "thiserror", diff --git a/plugin/Cargo.toml b/plugin/Cargo.toml index 830bb306..85b90b56 100644 --- a/plugin/Cargo.toml +++ b/plugin/Cargo.toml @@ -36,7 +36,6 @@ solana-client.workspace = true solana-quic-client.workspace = true solana-geyser-plugin-interface.workspace = true solana-logger.workspace = true -solana-program.workspace = true solana-sdk.workspace = true tokio.workspace = true futures.workspace = true diff --git a/plugin/src/builders/thread_exec.rs b/plugin/src/builders/thread_exec.rs index e015ec56..27d6eeed 100644 --- a/plugin/src/builders/thread_exec.rs +++ b/plugin/src/builders/thread_exec.rs @@ -11,13 +11,14 @@ use solana_client::{ rpc_config::{RpcSimulateTransactionAccountsConfig, RpcSimulateTransactionConfig}, rpc_custom_error::JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED, }; -use solana_program::{ +use solana_sdk::{ + account::Account, + commitment_config::CommitmentConfig, + compute_budget::ComputeBudgetInstruction, instruction::{AccountMeta, Instruction}, pubkey::Pubkey, -}; -use solana_sdk::{ - account::Account, commitment_config::CommitmentConfig, - compute_budget::ComputeBudgetInstruction, signature::Keypair, signer::Signer, + signature::Keypair, + signer::Signer, transaction::Transaction, }; @@ -77,6 +78,7 @@ pub async fn build_thread_exec_tx( // Exit early if the transaction exceeds the size limit. if sim_tx.message_data().len() > TRANSACTION_MESSAGE_SIZE_LIMIT { + info!("The transaction is too big to be send in one shot."); break; } diff --git a/plugin/src/executors/state/executable_threads.rs b/plugin/src/executors/state/executable_threads.rs index 87074b4d..34459a3d 100644 --- a/plugin/src/executors/state/executable_threads.rs +++ b/plugin/src/executors/state/executable_threads.rs @@ -10,7 +10,7 @@ use tokio::sync::RwLock; use crate::{executors::tx::ExecutableThreadMetadata, pool_position::PoolPosition}; /// Number of times to retry a thread simulation. -static MAX_THREAD_SIMULATION_FAILURES: u32 = 5; +static MAX_THREAD_SIMULATION_FAILURES: u32 = 10; /// Number of slots to wait before trying to execute a thread while not in the pool. static THREAD_TIMEOUT_WINDOW: u64 = 24; @@ -51,6 +51,7 @@ impl ExecutableThreads { .collect() } } + pub async fn remove_executed_threads( &self, executed_threads: &HashMap, @@ -82,8 +83,9 @@ impl ExecutableThreads { }); // Drop threads that cross the simulation failure threshold. - w_state.retain(|_thread_pubkey, metadata| { + w_state.retain(|thread_pubkey, metadata| { if metadata.simulation_failures > MAX_THREAD_SIMULATION_FAILURES { + info!("Dropped thread: {thread_pubkey}"); self.1.fetch_add(1, Ordering::Relaxed); false } else { diff --git a/plugin/src/executors/tx.rs b/plugin/src/executors/tx.rs index 017c6c62..6a63025b 100644 --- a/plugin/src/executors/tx.rs +++ b/plugin/src/executors/tx.rs @@ -14,10 +14,10 @@ use solana_client::{ tpu_client::TpuClientConfig, }; use solana_geyser_plugin_interface::geyser_plugin_interface::Result as PluginResult; -use solana_program::pubkey::Pubkey; use solana_quic_client::{QuicConfig, QuicConnectionManager, QuicPool}; use solana_sdk::{ commitment_config::CommitmentConfig, + pubkey::Pubkey, signature::{Keypair, Signature}, transaction::Transaction, }; diff --git a/plugin/src/observers/thread.rs b/plugin/src/observers/thread.rs index c4c3e201..b7babc20 100644 --- a/plugin/src/observers/thread.rs +++ b/plugin/src/observers/thread.rs @@ -10,7 +10,7 @@ use log::info; use sablier_cron::Schedule; use sablier_thread_program::state::{Equality, Trigger, TriggerContext, VersionedThread}; use sablier_utils::pyth::{get_oracle_key, PriceFeedMessage}; -use solana_program::{clock::Clock, pubkey::Pubkey}; +use solana_sdk::{clock::Clock, pubkey::Pubkey}; use crate::{error::PluginError, observers::state::PythThread}; diff --git a/plugin/src/observers/webhook.rs b/plugin/src/observers/webhook.rs index 15e484ed..69395c17 100644 --- a/plugin/src/observers/webhook.rs +++ b/plugin/src/observers/webhook.rs @@ -1,7 +1,7 @@ use std::{collections::HashSet, fmt::Debug, sync::Arc}; use sablier_webhook_program::state::Webhook; -use solana_program::pubkey::Pubkey; +use solana_sdk::pubkey::Pubkey; use super::state::Webhooks; diff --git a/plugin/src/pool_position.rs b/plugin/src/pool_position.rs index 1519aa72..08b0160d 100644 --- a/plugin/src/pool_position.rs +++ b/plugin/src/pool_position.rs @@ -1,4 +1,4 @@ -use {solana_program::pubkey::Pubkey, std::fmt::Debug}; +use {solana_sdk::pubkey::Pubkey, std::fmt::Debug}; #[derive(Clone, Debug, Default)] pub struct PoolPosition {