Skip to content

Commit

Permalink
seems to be working....need to test more
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcusack committed Mar 18, 2024
1 parent f9e2e69 commit 76ec779
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 34 deletions.
16 changes: 8 additions & 8 deletions bench-tps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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,
);
Expand All @@ -108,7 +108,7 @@ fn create_connection_cache(
Arc::new(stakes),
HashMap::<Pubkey, u64>::default(), // overrides
)));
ConnectionCacheWrapper::new_with_client_options(
ConnectionCache::new_with_client_options(
"bench-tps-connection_cache_quic",
tpu_connection_pool_size,
None,
Expand All @@ -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<dyn BenchTpsClient + Send + Sync> {
match external_client_type {
Expand All @@ -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,
Expand All @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions client/src/connection_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BackendConnectionCache<QuicPool, QuicConnectionManager, QuicConfig>>),
Udp(Arc<BackendConnectionCache<UdpPool, UdpConnectionManager, UdpConfig>>),
}
Expand All @@ -46,7 +46,7 @@ pub enum NonblockingClientConnection {
Udp(Arc<<UdpBaseClientConnection as BaseClientConnection>::NonblockingClientConnection>),
}

impl NotifyKeyUpdate for ConnectionCacheWrapper {
impl NotifyKeyUpdate for ConnectionCache {
fn update_key(&self, key: &Keypair) -> Result<(), Box<dyn std::error::Error>> {
match self {
Self::Udp(_) => Ok(()),
Expand All @@ -55,19 +55,19 @@ 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
Some(cert_info),
None, // stake_info
)
} else {
ConnectionCacheWrapper::with_udp(name, DEFAULT_CONNECTION_POOL_SIZE)
ConnectionCache::with_udp(name, DEFAULT_CONNECTION_POOL_SIZE)
}
}

Expand Down Expand Up @@ -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::{
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions client/src/nonblocking/tpu_client.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions client/src/thin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion client/src/tpu_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
// crate::connection_cache::ConnectionCache,
crate::connection_cache::ConnectionCache,
solana_connection_cache::connection_cache::{
ConnectionCache as BackendConnectionCache, ConnectionManager, ConnectionPool,
NewConnectionConfig,
Expand Down
7 changes: 3 additions & 4 deletions dos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions gossip/src/gossip_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -197,15 +197,15 @@ pub fn discover(
/// Creates a TpuClient by selecting a valid node at random
pub fn get_client(
nodes: &[ContactInfo],
connection_cache: Arc<ConnectionCacheWrapper>,
connection_cache: Arc<ConnectionCache>,
) -> TpuClientWrapper {
let select = thread_rng().gen_range(0..nodes.len());

let rpc_pubsub_url = format!("ws://{}/", nodes[select].rpc_pubsub().unwrap());
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(),
Expand All @@ -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(),
Expand Down
12 changes: 6 additions & 6 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -145,7 +145,7 @@ pub struct LocalCluster {
pub entry_point_info: ContactInfo,
pub validators: HashMap<Pubkey, ClusterValidatorInfo>,
pub genesis_config: GenesisConfig,
pub connection_cache: Arc<ConnectionCacheWrapper>,
pub connection_cache: Arc<ConnectionCache>,
}

impl LocalCluster {
Expand Down Expand Up @@ -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,
)),
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 76ec779

Please sign in to comment.