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
+29 -1
View File
@@ -56,16 +56,25 @@ impl FormatBase64VersionedTransaction for VersionedTransaction {
pub async fn poll_transaction_confirmation(
rpc: &SolanaRpcClient,
txt_sig: Signature,
wait_confirmation: bool,
) -> Result<Signature> {
// 如果不需要等待确认,立即返回签名
if !wait_confirmation {
return Ok(txt_sig);
}
let timeout: Duration = Duration::from_secs(15); // 🔧 增加到15秒,避免网络拥堵时超时
let interval: Duration = Duration::from_millis(1000);
let start: Instant = Instant::now();
let mut poll_count = 0u32;
loop {
if start.elapsed() >= timeout {
return Err(anyhow::anyhow!("Transaction {}'s confirmation timed out", txt_sig));
}
poll_count += 1;
let status = rpc.get_signature_statuses(&[txt_sig]).await?;
match status.value[0].clone() {
Some(status) => {
@@ -77,8 +86,27 @@ pub async fn poll_transaction_confirmation(
{
return Ok(txt_sig);
}
// 如果 getSignatureStatuses 返回了错误,立即获取详细信息
if status.err.is_some() {
// 直接跳转到获取交易详情
}
}
None => {}
None => {
// 交易还未上链,继续等待,不调用 getTransaction
sleep(interval).await;
continue;
}
}
// 优化:只在以下情况调用 getTransaction
// 1. getSignatureStatuses 返回了错误
// 2. 或者已经轮询了较长时间(超过10次,即10秒)
let should_get_transaction = status.value[0].as_ref().map(|s| s.err.is_some()).unwrap_or(false)
|| poll_count >= 10;
if !should_get_transaction {
sleep(interval).await;
continue;
}
let tx_details = match rpc