Skip to content

Commit

Permalink
plugin: Add more retry attempts and more logs (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aursen authored Sep 26, 2024
1 parent 16e7322 commit 8785373
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions plugin/src/builders/thread_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 4 additions & 2 deletions plugin/src/executors/state/executable_threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,6 +51,7 @@ impl ExecutableThreads {
.collect()
}
}

pub async fn remove_executed_threads(
&self,
executed_threads: &HashMap<Pubkey, (Signature, u64)>,
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/executors/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/observers/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/observers/webhook.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/pool_position.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 8785373

Please sign in to comment.