From 76ec779b17caa9b0ae0b3c8c228217d859d0c3db Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 18 Mar 2024 19:18:57 +0000 Subject: [PATCH] seems to be working....need to test more --- bench-tps/src/main.rs | 16 ++++++++-------- client/src/connection_cache.rs | 14 +++++++------- client/src/nonblocking/tpu_client.rs | 4 ++-- client/src/thin_client.rs | 4 ++-- client/src/tpu_client.rs | 2 +- dos/src/main.rs | 7 +++---- gossip/src/gossip_service.rs | 8 ++++---- local-cluster/src/local_cluster.rs | 12 ++++++------ 8 files changed, 33 insertions(+), 34 deletions(-) diff --git a/bench-tps/src/main.rs b/bench-tps/src/main.rs index d57669f183e214..a5da5a515703c5 100644 --- a/bench-tps/src/main.rs +++ b/bench-tps/src/main.rs @@ -8,7 +8,7 @@ use { keypairs::get_keypairs, send_batch::{generate_durable_nonce_accounts, generate_keypairs}, }, - solana_client::connection_cache::ConnectionCacheWrapper, + solana_client::connection_cache::ConnectionCache, solana_genesis::Base64Account, solana_rpc_client::rpc_client::RpcClient, solana_sdk::{ @@ -77,15 +77,15 @@ fn create_connection_cache( bind_address: IpAddr, client_node_id: Option<&Keypair>, commitment_config: CommitmentConfig, -) -> ConnectionCacheWrapper { +) -> ConnectionCache { if !use_quic { - return ConnectionCacheWrapper::with_udp( + return ConnectionCache::with_udp( "bench-tps-connection_cache_udp", tpu_connection_pool_size, ); } if client_node_id.is_none() { - return ConnectionCacheWrapper::new_quic( + return ConnectionCache::new_quic( "bench-tps-connection_cache_quic", tpu_connection_pool_size, ); @@ -108,7 +108,7 @@ fn create_connection_cache( Arc::new(stakes), HashMap::::default(), // overrides ))); - ConnectionCacheWrapper::new_with_client_options( + ConnectionCache::new_with_client_options( "bench-tps-connection_cache_quic", tpu_connection_pool_size, None, @@ -122,7 +122,7 @@ fn create_client( external_client_type: &ExternalClientType, json_rpc_url: &str, websocket_url: &str, - connection_cache: ConnectionCacheWrapper, + connection_cache: ConnectionCache, commitment_config: CommitmentConfig, ) -> Arc { match external_client_type { @@ -136,7 +136,7 @@ fn create_client( commitment_config, )); match connection_cache { - ConnectionCacheWrapper::Udp(cache) => Arc::new( + ConnectionCache::Udp(cache) => Arc::new( TpuClient::new_with_connection_cache( rpc_client, websocket_url, @@ -148,7 +148,7 @@ fn create_client( exit(1); }), ), - ConnectionCacheWrapper::Quic(cache) => Arc::new( + ConnectionCache::Quic(cache) => Arc::new( TpuClient::new_with_connection_cache( rpc_client, websocket_url, diff --git a/client/src/connection_cache.rs b/client/src/connection_cache.rs index 3f62343be27a40..a94bc7cd3d8ca8 100644 --- a/client/src/connection_cache.rs +++ b/client/src/connection_cache.rs @@ -28,7 +28,7 @@ const DEFAULT_CONNECTION_CACHE_USE_QUIC: bool = true; /// A thin wrapper over connection-cache/ConnectionCache to ease /// construction of the ConnectionCache for code dealing both with udp and quic. /// For the scenario only using udp or quic, use connection-cache/ConnectionCache directly. -pub enum ConnectionCacheWrapper { +pub enum ConnectionCache { Quic(Arc>), Udp(Arc>), } @@ -46,7 +46,7 @@ pub enum NonblockingClientConnection { Udp(Arc<::NonblockingClientConnection>), } -impl NotifyKeyUpdate for ConnectionCacheWrapper { +impl NotifyKeyUpdate for ConnectionCache { fn update_key(&self, key: &Keypair) -> Result<(), Box> { match self { Self::Udp(_) => Ok(()), @@ -55,11 +55,11 @@ impl NotifyKeyUpdate for ConnectionCacheWrapper { } } -impl ConnectionCacheWrapper { +impl ConnectionCache { pub fn new(name: &'static str) -> Self { if DEFAULT_CONNECTION_CACHE_USE_QUIC { let cert_info = (&Keypair::new(), IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); - ConnectionCacheWrapper::new_with_client_options( + ConnectionCache::new_with_client_options( name, DEFAULT_CONNECTION_POOL_SIZE, None, // client_endpoint @@ -67,7 +67,7 @@ impl ConnectionCacheWrapper { None, // stake_info ) } else { - ConnectionCacheWrapper::with_udp(name, DEFAULT_CONNECTION_POOL_SIZE) + ConnectionCache::with_udp(name, DEFAULT_CONNECTION_POOL_SIZE) } } @@ -223,7 +223,7 @@ impl solana_connection_cache::nonblocking::client_connection::ClientConnection mod tests { use { super::*, - crate::connection_cache::ConnectionCacheWrapper, + crate::connection_cache::ConnectionCache, crossbeam_channel::unbounded, solana_sdk::{net::DEFAULT_TPU_COALESCE, signature::Keypair}, solana_streamer::{ @@ -275,7 +275,7 @@ mod tests { ) .unwrap(); - let connection_cache = ConnectionCacheWrapper::new_with_client_options( + let connection_cache = ConnectionCache::new_with_client_options( "connection_cache_test", 1, // connection_pool_size Some(response_recv_endpoint), // client_endpoint diff --git a/client/src/nonblocking/tpu_client.rs b/client/src/nonblocking/tpu_client.rs index a46f0d816d88f8..6eb26a7aefce3a 100644 --- a/client/src/nonblocking/tpu_client.rs +++ b/client/src/nonblocking/tpu_client.rs @@ -1,7 +1,7 @@ pub use solana_tpu_client::nonblocking::tpu_client::{LeaderTpuService, TpuSenderError}; use { - // crate::{connection_cache::ConnectionCache, tpu_client::TpuClientConfig}, - crate::tpu_client::TpuClientConfig, + crate::{connection_cache::ConnectionCache, tpu_client::TpuClientConfig}, + // crate::tpu_client::TpuClientConfig, solana_connection_cache::connection_cache::{ ConnectionCache as BackendConnectionCache, ConnectionManager, ConnectionPool, NewConnectionConfig, diff --git a/client/src/thin_client.rs b/client/src/thin_client.rs index 2e3c23aa46c660..540130ae44a87f 100644 --- a/client/src/thin_client.rs +++ b/client/src/thin_client.rs @@ -4,8 +4,8 @@ //! unstable and may change in future releases. #[allow(deprecated)] use { - // crate::connection_cache::{dispatch, ConnectionCache}, - crate::connection_cache::dispatch, + crate::connection_cache::{dispatch, ConnectionCache}, + // crate::connection_cache::dispatch, solana_quic_client::{QuicConfig, QuicConnectionManager, QuicPool}, solana_rpc_client::rpc_client::RpcClient, solana_rpc_client_api::config::RpcProgramAccountsConfig, diff --git a/client/src/tpu_client.rs b/client/src/tpu_client.rs index 6971a961a62271..4eb5cd9bb9d794 100644 --- a/client/src/tpu_client.rs +++ b/client/src/tpu_client.rs @@ -1,5 +1,5 @@ use { - // crate::connection_cache::ConnectionCache, + crate::connection_cache::ConnectionCache, solana_connection_cache::connection_cache::{ ConnectionCache as BackendConnectionCache, ConnectionManager, ConnectionPool, NewConnectionConfig, diff --git a/dos/src/main.rs b/dos/src/main.rs index 138d55fc526b7f..6eac3114070193 100644 --- a/dos/src/main.rs +++ b/dos/src/main.rs @@ -261,10 +261,9 @@ fn create_sender_thread( "connection_cache_dos_quic", DEFAULT_TPU_CONNECTION_POOL_SIZE, ), - false => ConnectionCache::with_udp( - "connection_cache_dos_udp", - DEFAULT_TPU_CONNECTION_POOL_SIZE, - ), + false => { + ConnectionCache::with_udp("connection_cache_dos_udp", DEFAULT_TPU_CONNECTION_POOL_SIZE) + } }; let connection = connection_cache.get_connection(target); diff --git a/gossip/src/gossip_service.rs b/gossip/src/gossip_service.rs index 30f9371314df26..85ab63e2907d8b 100644 --- a/gossip/src/gossip_service.rs +++ b/gossip/src/gossip_service.rs @@ -4,7 +4,7 @@ use { crate::{cluster_info::ClusterInfo, legacy_contact_info::LegacyContactInfo as ContactInfo}, crossbeam_channel::{unbounded, Sender}, rand::{thread_rng, Rng}, - solana_client::{connection_cache::ConnectionCacheWrapper, rpc_client::RpcClient}, + solana_client::{connection_cache::ConnectionCache, rpc_client::RpcClient}, solana_perf::recycler::Recycler, solana_runtime::bank_forks::BankForks, solana_sdk::{ @@ -197,7 +197,7 @@ pub fn discover( /// Creates a TpuClient by selecting a valid node at random pub fn get_client( nodes: &[ContactInfo], - connection_cache: Arc, + connection_cache: Arc, ) -> TpuClientWrapper { let select = thread_rng().gen_range(0..nodes.len()); @@ -205,7 +205,7 @@ pub fn get_client( let rpc_url = format!("http://{}", nodes[select].rpc().unwrap()); match &*connection_cache { - ConnectionCacheWrapper::Quic(cache) => TpuClientWrapper::Quic( + ConnectionCache::Quic(cache) => TpuClientWrapper::Quic( TpuClient::new_with_connection_cache( Arc::new(RpcClient::new(rpc_url)), rpc_pubsub_url.as_str(), @@ -216,7 +216,7 @@ pub fn get_client( panic!("Could not create TpuClient with Quic Cache {err:?}"); }), ), - ConnectionCacheWrapper::Udp(cache) => TpuClientWrapper::Udp( + ConnectionCache::Udp(cache) => TpuClientWrapper::Udp( TpuClient::new_with_connection_cache( Arc::new(RpcClient::new(rpc_url)), rpc_pubsub_url.as_str(), diff --git a/local-cluster/src/local_cluster.rs b/local-cluster/src/local_cluster.rs index 3afcadadc8667c..f301b71d569958 100644 --- a/local-cluster/src/local_cluster.rs +++ b/local-cluster/src/local_cluster.rs @@ -8,7 +8,7 @@ use { log::*, solana_accounts_db::utils::create_accounts_run_and_snapshot_dirs, solana_client::{ - connection_cache::ConnectionCacheWrapper, rpc_client::RpcClient, thin_client::ThinClient, + connection_cache::ConnectionCache, rpc_client::RpcClient, thin_client::ThinClient, }, solana_core::{ consensus::tower_storage::FileTowerStorage, @@ -145,7 +145,7 @@ pub struct LocalCluster { pub entry_point_info: ContactInfo, pub validators: HashMap, pub genesis_config: GenesisConfig, - pub connection_cache: Arc, + pub connection_cache: Arc, } impl LocalCluster { @@ -322,11 +322,11 @@ impl LocalCluster { validators, genesis_config, connection_cache: match config.tpu_use_quic { - true => Arc::new(ConnectionCacheWrapper::new_quic( + true => Arc::new(ConnectionCache::new_quic( "connection_cache_local_cluster_quic", config.tpu_connection_pool_size, )), - false => Arc::new(ConnectionCacheWrapper::with_udp( + false => Arc::new(ConnectionCache::with_udp( "connection_cache_local_cluster_udp", config.tpu_connection_pool_size, )), @@ -814,8 +814,8 @@ impl LocalCluster { let rpc_url = format!("http://{}", self.entry_point_info.rpc().unwrap()); let cache = match &*self.connection_cache { - ConnectionCacheWrapper::Quic(cache) => cache, - ConnectionCacheWrapper::Udp(_) => { + ConnectionCache::Quic(cache) => cache, + ConnectionCache::Udp(_) => { return Err(Error::new( ErrorKind::Other, "Expected a Quic ConnectionCache. Got UDP",