feat: optimize RPC polling and remove data size limit

Significantly reduce RPC pressure and fix MaxLoadedAccountsDataSizeExceeded errors.

Major improvements:
1. Add wait_confirmation parameter to all swqos clients
   - Skip polling entirely when wait_transaction_confirmed=false (100% RPC reduction)
   - Optimize getTransaction calls to only execute on errors or after 10s (50% reduction)
   - Update all 13 swqos client implementations

2. Remove LoadedAccountsDataSize instruction and data_size_limit parameter
   - Eliminate MaxLoadedAccountsDataSizeExceeded errors reported by users
   - Clean up gas_fee_strategy, params, and transaction builder
   - Simplify compute budget instruction generation

Results:
- Single channel: 30 RPC calls → 0-15 calls (50-100% reduction)
- Multi-channel (3x): 90 RPC calls → 0-45 calls (50-100% reduction)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Wood
2025-12-28 13:15:16 +08:00
co-authored by Claude Sonnet 4.5
parent 710de8a92a
commit 321f4c4a25
22 changed files with 183 additions and 179 deletions
+12 -10
View File
@@ -29,12 +29,12 @@ pub struct Node1Client {
#[async_trait::async_trait]
impl SwqosClientTrait for Node1Client {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -140,7 +140,7 @@ impl Node1Client {
Ok(())
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -176,7 +176,7 @@ impl Node1Client {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -184,15 +184,17 @@ impl Node1Client {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [node1] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [node1] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}