Skip to content

Commit

Permalink
switch over to solana-tpu-client for bench-tps, dos, gossip, local-cl…
Browse files Browse the repository at this point in the history
…uster
  • Loading branch information
gregcusack committed Mar 20, 2024
1 parent 8df80d9 commit 8de91f3
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 35 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bench-tps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ solana-logger = { workspace = true }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-net-utils = { workspace = true }
solana-quic-client = { workspace = true }
solana-rpc = { workspace = true }
solana-rpc-client = { workspace = true }
solana-rpc-client-api = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/bench_tps_client/tpu_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use {
crate::bench_tps_client::{BenchTpsClient, BenchTpsError, Result},
solana_client::tpu_client::TpuClient,
solana_connection_cache::connection_cache::{
ConnectionManager, ConnectionPool, NewConnectionConfig,
},
Expand All @@ -10,6 +9,7 @@ use {
message::Message, pubkey::Pubkey, signature::Signature, slot_history::Slot,
transaction::Transaction,
},
solana_tpu_client::tpu_client::TpuClient,
solana_transaction_status::UiConfirmedBlock,
};

Expand Down
6 changes: 2 additions & 4 deletions bench-tps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use {
keypairs::get_keypairs,
send_batch::{generate_durable_nonce_accounts, generate_keypairs},
},
solana_client::{
connection_cache::ConnectionCache,
tpu_client::{TpuClient, TpuClientConfig},
},
solana_client::connection_cache::ConnectionCache,
solana_genesis::Base64Account,
solana_rpc_client::rpc_client::RpcClient,
solana_sdk::{
Expand All @@ -22,6 +19,7 @@ use {
system_program,
},
solana_streamer::streamer::StakedNodes,
solana_tpu_client::tpu_client::{TpuClient, TpuClientConfig},
std::{
collections::HashMap,
fs::File,
Expand Down
17 changes: 14 additions & 3 deletions bench-tps/tests/bench_tps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ use {
cli::{Config, InstructionPaddingConfig},
send_batch::generate_durable_nonce_accounts,
},
solana_client::tpu_client::{TpuClient, TpuClientConfig},
solana_connection_cache::connection_cache::NewConnectionConfig,
solana_core::validator::ValidatorConfig,
solana_faucet::faucet::run_local_faucet,
solana_local_cluster::{
cluster::Cluster,
local_cluster::{ClusterConfig, LocalCluster},
validator_configs::make_identical_validator_configs,
},
solana_quic_client::{QuicConfig, QuicConnectionManager},
solana_rpc::rpc::JsonRpcConfig,
solana_rpc_client::rpc_client::RpcClient,
solana_sdk::{
Expand All @@ -26,6 +27,7 @@ use {
},
solana_streamer::socket::SocketAddrSpace,
solana_test_validator::TestValidatorGenesis,
solana_tpu_client::tpu_client::{TpuClient, TpuClientConfig},
std::{sync::Arc, time::Duration},
};

Expand Down Expand Up @@ -124,8 +126,17 @@ fn test_bench_tps_test_validator(config: Config) {
CommitmentConfig::processed(),
));
let websocket_url = test_validator.rpc_pubsub_url();
let client =
Arc::new(TpuClient::new(rpc_client, &websocket_url, TpuClientConfig::default()).unwrap());

let client = Arc::new(
TpuClient::new(
"tpu_client_quic_bench_tps",
rpc_client,
&websocket_url,
TpuClientConfig::default(),
QuicConnectionManager::new_with_connection_config(QuicConfig::new().unwrap()),
)
.expect("Should build Quic Tpu Client."),
);

let lamports_per_account = 1000;

Expand Down
8 changes: 0 additions & 8 deletions client/src/tpu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,13 @@ use {
transport::Result as TransportResult,
},
solana_tpu_client::tpu_client::{Result, TpuClient as BackendTpuClient},
solana_udp_client::{UdpConfig, UdpConnectionManager, UdpPool},
std::sync::Arc,
};
pub use {
crate::nonblocking::tpu_client::TpuSenderError,
solana_tpu_client::tpu_client::{TpuClientConfig, DEFAULT_FANOUT_SLOTS, MAX_FANOUT_SLOTS},
};

pub type QuicTpuClient = TpuClient<QuicPool, QuicConnectionManager, QuicConfig>;

pub enum TpuClientWrapper {
Quic(TpuClient<QuicPool, QuicConnectionManager, QuicConfig>),
Udp(TpuClient<UdpPool, UdpConnectionManager, UdpConfig>),
}

/// Client which sends transactions directly to the current leader's TPU port over UDP.
/// The client uses RPC to determine the current leader and fetch node contact info
/// This is just a thin wrapper over the "BackendTpuClient", use that directly for more efficiency.
Expand Down
13 changes: 6 additions & 7 deletions dos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ use {
log::*,
rand::{thread_rng, Rng},
solana_bench_tps::{bench::generate_and_fund_keypairs, bench_tps_client::BenchTpsClient},
solana_client::{
connection_cache::ConnectionCache, tpu_client::TpuClientWrapper,
tpu_connection::TpuConnection,
},
solana_client::{connection_cache::ConnectionCache, tpu_connection::TpuConnection},
solana_core::repair::serve_repair::{RepairProtocol, RepairRequestHeader, ServeRepair},
solana_dos::cli::*,
solana_gossip::{
Expand All @@ -72,7 +69,7 @@ use {
transaction::Transaction,
},
solana_streamer::socket::SocketAddrSpace,
solana_tpu_client::tpu_client::DEFAULT_TPU_CONNECTION_POOL_SIZE,
solana_tpu_client::tpu_client::{TpuClientWrapper, DEFAULT_TPU_CONNECTION_POOL_SIZE},
std::{
net::{SocketAddr, UdpSocket},
process::exit,
Expand Down Expand Up @@ -795,6 +792,7 @@ fn main() {
DEFAULT_TPU_CONNECTION_POOL_SIZE,
),
};

let client = get_client(&validators, Arc::new(connection_cache));
(gossip_nodes, Some(client))
} else {
Expand All @@ -818,7 +816,6 @@ fn main() {
pub mod test {
use {
super::*,
solana_client::tpu_client::QuicTpuClient,
solana_core::validator::ValidatorConfig,
solana_faucet::faucet::run_local_faucet,
solana_gossip::contact_info::LegacyContactInfo,
Expand All @@ -836,7 +833,9 @@ pub mod test {
// thin wrapper for the run_dos function
// to avoid specifying everywhere generic parameters
fn run_dos_no_client(nodes: &[ContactInfo], iterations: usize, params: DosClientParameters) {
run_dos::<QuicTpuClient>(nodes, iterations, None, params);
run_dos::<TpuClient<QuicPool, QuicConnectionManager, QuicConfig>>(
nodes, iterations, None, params,
);
}

#[test]
Expand Down
7 changes: 2 additions & 5 deletions gossip/src/gossip_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +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::ConnectionCache,
rpc_client::RpcClient,
tpu_client::{TpuClient, TpuClientConfig, TpuClientWrapper},
},
solana_client::{connection_cache::ConnectionCache, rpc_client::RpcClient},
solana_perf::recycler::Recycler,
solana_runtime::bank_forks::BankForks,
solana_sdk::{
Expand All @@ -19,6 +15,7 @@ use {
socket::SocketAddrSpace,
streamer::{self, StreamerReceiveStats},
},
solana_tpu_client::tpu_client::{TpuClient, TpuClientConfig, TpuClientWrapper},
std::{
collections::HashSet,
net::{SocketAddr, TcpListener, UdpSocket},
Expand Down
4 changes: 3 additions & 1 deletion local-cluster/src/cluster.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
solana_client::{thin_client::ThinClient, tpu_client::QuicTpuClient},
solana_client::thin_client::ThinClient,
solana_core::validator::{Validator, ValidatorConfig},
solana_gossip::{cluster_info::Node, contact_info::ContactInfo},
solana_ledger::shred::Shred,
Expand All @@ -8,6 +8,8 @@ use {
std::{io::Result, path::PathBuf, sync::Arc},
};

pub type QuicTpuClient = TpuClient<QuicPool, QuicConnectionManager, QuicConfig>;

pub struct ValidatorInfo {
pub keypair: Arc<Keypair>,
pub voting_keypair: Arc<Keypair>,
Expand Down
10 changes: 4 additions & 6 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
use {
crate::{
cluster::{Cluster, ClusterValidatorInfo, ValidatorInfo},
cluster::{Cluster, ClusterValidatorInfo, QuicTpuClient, ValidatorInfo},
cluster_tests,
validator_configs::*,
},
itertools::izip,
log::*,
solana_accounts_db::utils::create_accounts_run_and_snapshot_dirs,
solana_client::{
connection_cache::ConnectionCache,
rpc_client::RpcClient,
thin_client::ThinClient,
tpu_client::{QuicTpuClient, TpuClient, TpuClientConfig},
connection_cache::ConnectionCache, rpc_client::RpcClient, thin_client::ThinClient,
},
solana_core::{
consensus::tower_storage::FileTowerStorage,
Expand Down Expand Up @@ -52,7 +49,8 @@ use {
solana_stake_program::stake_state,
solana_streamer::socket::SocketAddrSpace,
solana_tpu_client::tpu_client::{
DEFAULT_TPU_CONNECTION_POOL_SIZE, DEFAULT_TPU_ENABLE_UDP, DEFAULT_TPU_USE_QUIC,
TpuClient, TpuClientConfig, DEFAULT_TPU_CONNECTION_POOL_SIZE, DEFAULT_TPU_ENABLE_UDP,
DEFAULT_TPU_USE_QUIC,
},
solana_vote_program::{
vote_instruction,
Expand Down
2 changes: 2 additions & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tpu-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ solana-connection-cache = { workspace = true }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-pubsub-client = { workspace = true }
solana-quic-client = { workspace = true }
solana-rpc-client = { workspace = true }
solana-rpc-client-api = { workspace = true }
solana-sdk = { workspace = true }
solana-udp-client = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["full"] }

Expand Down
7 changes: 7 additions & 0 deletions tpu-client/src/tpu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ use {
solana_connection_cache::connection_cache::{
ConnectionCache, ConnectionManager, ConnectionPool, NewConnectionConfig,
},
solana_quic_client::{QuicConfig, QuicConnectionManager, QuicPool},
solana_rpc_client::rpc_client::RpcClient,
solana_sdk::{clock::Slot, transaction::Transaction, transport::Result as TransportResult},
solana_udp_client::{UdpConfig, UdpConnectionManager, UdpPool},
std::{
collections::VecDeque,
net::UdpSocket,
Expand All @@ -25,6 +27,11 @@ pub const DEFAULT_TPU_CONNECTION_POOL_SIZE: usize = 4;

pub type Result<T> = std::result::Result<T, TpuSenderError>;

pub enum TpuClientWrapper {
Quic(TpuClient<QuicPool, QuicConnectionManager, QuicConfig>),
Udp(TpuClient<UdpPool, UdpConnectionManager, UdpConfig>),
}

/// Send at ~100 TPS
#[cfg(feature = "spinner")]
pub(crate) const SEND_TRANSACTION_INTERVAL: Duration = Duration::from_millis(10);
Expand Down

0 comments on commit 8de91f3

Please sign in to comment.