Skip to content

Commit

Permalink
Use STS new_with_client everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillLykov committed Mar 2, 2025
1 parent 81649e6 commit 56ccfca
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 27 deletions.
21 changes: 15 additions & 6 deletions banks-server/src/banks_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -454,14 +455,22 @@ pub async fn start_tcp_server(
.map(move |chan| {
let (sender, receiver) = unbounded();

SendTransactionService::new::<NullTpuInfo>(
let client = ConnectionCacheClient::<NullTpuInfo>::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(),
);

Expand Down
65 changes: 48 additions & 17 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -472,14 +474,24 @@ impl JsonRpcRequestProcessor {
.tpu(connection_cache.protocol())
.unwrap();
let (transaction_sender, transaction_receiver) = unbounded();
SendTransactionService::new::<NullTpuInfo>(

let client = ConnectionCacheClient::<NullTpuInfo>::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(),
);

Expand Down Expand Up @@ -6681,15 +6693,24 @@ pub mod tests {
Arc::new(PrioritizationFeeCache::default()),
service_runtime(rpc_threads, rpc_blocking_threads, rpc_niceness_adj),
);
SendTransactionService::new::<NullTpuInfo>(

let client = ConnectionCacheClient::<NullTpuInfo>::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(
Expand Down Expand Up @@ -6963,16 +6984,26 @@ pub mod tests {
Arc::new(PrioritizationFeeCache::default()),
service_runtime(rpc_threads, rpc_blocking_threads, rpc_niceness_adj),
);
SendTransactionService::new::<NullTpuInfo>(

let client = ConnectionCacheClient::<NullTpuInfo>::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 {
Expand Down
16 changes: 12 additions & 4 deletions rpc/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
));
Expand Down
3 changes: 3 additions & 0 deletions send-transaction-service/src/send_transaction_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: TpuInfo + std::marker::Send + 'static>(
tpu_address: SocketAddr,
bank_forks: &Arc<RwLock<BankForks>>,
Expand All @@ -161,6 +162,7 @@ impl SendTransactionService {
leader_forward_count,
..Config::default()
};
#[allow(deprecated)]
Self::new_with_config(
tpu_address,
bank_forks,
Expand All @@ -172,6 +174,7 @@ impl SendTransactionService {
)
}

#[deprecated(since = "2.2.0", note = "Please use `new_with_client` instead.")]
pub fn new_with_config<T: TpuInfo + std::marker::Send + 'static>(
tpu_address: SocketAddr,
bank_forks: &Arc<RwLock<BankForks>>,
Expand Down

0 comments on commit 56ccfca

Please sign in to comment.