From 56ccfca1264f8dca44247278b4ea174921e9cc76 Mon Sep 17 00:00:00 2001 From: Kirill Lykov Date: Sun, 2 Mar 2025 15:40:50 +0100 Subject: [PATCH] Use STS new_with_client everywhere --- banks-server/src/banks_server.rs | 21 ++++-- rpc/src/rpc.rs | 65 ++++++++++++++----- rpc/src/rpc_service.rs | 16 +++-- .../src/send_transaction_service.rs | 3 + 4 files changed, 78 insertions(+), 27 deletions(-) diff --git a/banks-server/src/banks_server.rs b/banks-server/src/banks_server.rs index 6744154d5e4398..9eb40bd2172d14 100644 --- a/banks-server/src/banks_server.rs +++ b/banks-server/src/banks_server.rs @@ -27,8 +27,9 @@ use { transaction::{self, MessageHash, SanitizedTransaction, VersionedTransaction}, }, solana_send_transaction_service::{ - send_transaction_service::{SendTransactionService, TransactionInfo}, + send_transaction_service::{Config, SendTransactionService, TransactionInfo}, tpu_info::NullTpuInfo, + transaction_client::ConnectionCacheClient, }, std::{ io, @@ -454,14 +455,22 @@ pub async fn start_tcp_server( .map(move |chan| { let (sender, receiver) = unbounded(); - SendTransactionService::new::( + let client = ConnectionCacheClient::::new( + connection_cache.clone(), tpu_addr, - &bank_forks, None, - receiver, - &connection_cache, - 5_000, + None, 0, + ); + + SendTransactionService::new_with_client( + &bank_forks, + receiver, + client, + Config { + retry_rate_ms: 5_000, + ..Config::default() + }, exit.clone(), ); diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 58043b97b739e7..34b045ffdc4751 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -128,7 +128,9 @@ use { solana_ledger::get_tmp_ledger_path, solana_runtime::commitment::CommitmentSlots, solana_send_transaction_service::{ + send_transaction_service::Config as SendTransactionServiceConfig, send_transaction_service::SendTransactionService, tpu_info::NullTpuInfo, + transaction_client::ConnectionCacheClient, }, solana_streamer::socket::SocketAddrSpace, }; @@ -472,14 +474,24 @@ impl JsonRpcRequestProcessor { .tpu(connection_cache.protocol()) .unwrap(); let (transaction_sender, transaction_receiver) = unbounded(); - SendTransactionService::new::( + + let client = ConnectionCacheClient::::new( + connection_cache.clone(), tpu_address, - &bank_forks, None, - transaction_receiver, - &connection_cache, - 1000, + None, 1, + ); + + SendTransactionService::new_with_client( + &bank_forks, + transaction_receiver, + client, + SendTransactionServiceConfig { + retry_rate_ms: 1_000, + leader_forward_count: 1, + ..SendTransactionServiceConfig::default() + }, exit.clone(), ); @@ -6681,15 +6693,24 @@ pub mod tests { Arc::new(PrioritizationFeeCache::default()), service_runtime(rpc_threads, rpc_blocking_threads, rpc_niceness_adj), ); - SendTransactionService::new::( + + let client = ConnectionCacheClient::::new( + connection_cache.clone(), tpu_address, - &bank_forks, None, - receiver, - &connection_cache, - 1000, + None, 1, - exit, + ); + SendTransactionService::new_with_client( + &bank_forks, + receiver, + client, + SendTransactionServiceConfig { + retry_rate_ms: 1_000, + leader_forward_count: 1, + ..SendTransactionServiceConfig::default() + }, + exit.clone(), ); let mut bad_transaction = system_transaction::transfer( @@ -6963,16 +6984,26 @@ pub mod tests { Arc::new(PrioritizationFeeCache::default()), service_runtime(rpc_threads, rpc_blocking_threads, rpc_niceness_adj), ); - SendTransactionService::new::( + + let client = ConnectionCacheClient::::new( + connection_cache.clone(), tpu_address, - &bank_forks, None, - receiver, - &connection_cache, - 1000, + None, 1, - exit, ); + SendTransactionService::new_with_client( + &bank_forks, + receiver, + client, + SendTransactionServiceConfig { + retry_rate_ms: 1_000, + leader_forward_count: 1, + ..SendTransactionServiceConfig::default() + }, + exit.clone(), + ); + assert_eq!( request_processor.get_block_commitment(0), RpcBlockCommitment { diff --git a/rpc/src/rpc_service.rs b/rpc/src/rpc_service.rs index e948ea76e34a8b..609fa7f71d524d 100644 --- a/rpc/src/rpc_service.rs +++ b/rpc/src/rpc_service.rs @@ -36,7 +36,10 @@ use { exit::Exit, genesis_config::DEFAULT_GENESIS_DOWNLOAD_PATH, hash::Hash, native_token::lamports_to_sol, }, - solana_send_transaction_service::send_transaction_service::{self, SendTransactionService}, + solana_send_transaction_service::{ + send_transaction_service::{self, SendTransactionService}, + transaction_client::ConnectionCacheClient, + }, solana_storage_bigtable::CredentialType, std::{ net::SocketAddr, @@ -467,12 +470,17 @@ impl JsonRpcService { let leader_info = poh_recorder.map(|recorder| ClusterTpuInfo::new(cluster_info.clone(), recorder)); - let _send_transaction_service = Arc::new(SendTransactionService::new_with_config( + let client = ConnectionCacheClient::new( + connection_cache, tpu_address, - &bank_forks, + send_transaction_service_config.tpu_peers.clone(), leader_info, + send_transaction_service_config.leader_forward_count, + ); + let _send_transaction_service = Arc::new(SendTransactionService::new_with_client( + &bank_forks, receiver, - &connection_cache, + client, send_transaction_service_config, exit, )); diff --git a/send-transaction-service/src/send_transaction_service.rs b/send-transaction-service/src/send_transaction_service.rs index 908c83f5494967..f9227d260d064d 100644 --- a/send-transaction-service/src/send_transaction_service.rs +++ b/send-transaction-service/src/send_transaction_service.rs @@ -146,6 +146,7 @@ impl Default for Config { pub const MAX_RETRY_SLEEP_MS: u64 = 1000; impl SendTransactionService { + #[deprecated(since = "2.2.0", note = "Please use `new_with_client` instead.")] pub fn new( tpu_address: SocketAddr, bank_forks: &Arc>, @@ -161,6 +162,7 @@ impl SendTransactionService { leader_forward_count, ..Config::default() }; + #[allow(deprecated)] Self::new_with_config( tpu_address, bank_forks, @@ -172,6 +174,7 @@ impl SendTransactionService { ) } + #[deprecated(since = "2.2.0", note = "Please use `new_with_client` instead.")] pub fn new_with_config( tpu_address: SocketAddr, bank_forks: &Arc>,