From 9fa9909ee1cf5b20c11e5a3cf0a53c859218c382 Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Sat, 2 Nov 2024 20:54:29 +0400 Subject: [PATCH] remove solana-sdk from solana-streamer --- Cargo.lock | 8 ++++++ programs/sbf/Cargo.lock | 9 ++++++- streamer/Cargo.toml | 12 +++++++-- streamer/src/nonblocking/quic.rs | 25 ++++++++++--------- streamer/src/nonblocking/sendmmsg.rs | 2 +- streamer/src/nonblocking/testing_utilities.rs | 8 +++--- streamer/src/packet.rs | 2 +- streamer/src/quic.rs | 16 ++++++++---- streamer/src/sendmmsg.rs | 4 +-- streamer/src/streamer.rs | 4 ++- streamer/src/tls_certificates.rs | 6 +++-- 11 files changed, 64 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d391046a3330f..64ff3cdf4a977e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8611,12 +8611,20 @@ dependencies = [ "rustls 0.23.16", "smallvec", "socket2 0.5.7", + "solana-keypair", "solana-logger", "solana-measure", "solana-metrics", + "solana-packet", "solana-perf", + "solana-pubkey", + "solana-quic-definitions", "solana-sdk", + "solana-signature", + "solana-signer", "solana-streamer", + "solana-time-utils", + "solana-transaction-error", "solana-transaction-metrics-tracker", "thiserror", "tokio", diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index bace687a7029af..68df7588c2a7fa 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -7284,10 +7284,17 @@ dependencies = [ "rustls 0.23.16", "smallvec", "socket2 0.5.7", + "solana-keypair", "solana-measure", "solana-metrics", + "solana-packet", "solana-perf", - "solana-sdk", + "solana-pubkey", + "solana-quic-definitions", + "solana-signature", + "solana-signer", + "solana-time-utils", + "solana-transaction-error", "solana-transaction-metrics-tracker", "thiserror", "tokio", diff --git a/streamer/Cargo.toml b/streamer/Cargo.toml index f44e99771c0783..7acbd62dfc8462 100644 --- a/streamer/Cargo.toml +++ b/streamer/Cargo.toml @@ -31,10 +31,18 @@ rand = { workspace = true } rustls = { workspace = true } smallvec = { workspace = true } socket2 = { workspace = true } +solana-keypair = { workspace = true } solana-measure = { workspace = true } solana-metrics = { workspace = true } +solana-packet = { workspace = true } solana-perf = { workspace = true } -solana-sdk = { workspace = true } +solana-pubkey = { workspace = true } +solana-quic-definitions = { workspace = true } +solana-sdk = { workspace = true, optional = true } +solana-signature = { workspace = true } +solana-signer = { workspace = true } +solana-time-utils = { workspace = true } +solana-transaction-error = { workspace = true } solana-transaction-metrics-tracker = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } @@ -47,7 +55,7 @@ solana-logger = { workspace = true } solana-streamer = { path = ".", features = ["dev-context-only-utils"] } [features] -dev-context-only-utils = [] +dev-context-only-utils = ["dep:solana-sdk"] [lib] crate-type = ["lib"] diff --git a/streamer/src/nonblocking/quic.rs b/streamer/src/nonblocking/quic.rs index acc04c11c768ce..b1753280caaeb9 100644 --- a/streamer/src/nonblocking/quic.rs +++ b/streamer/src/nonblocking/quic.rs @@ -24,19 +24,18 @@ use { rand::{thread_rng, Rng}, smallvec::SmallVec, solana_measure::measure::Measure, + solana_packet::{Meta, PACKET_DATA_SIZE}, solana_perf::packet::{PacketBatch, PACKETS_PER_BATCH}, - solana_sdk::{ - packet::{Meta, PACKET_DATA_SIZE}, - pubkey::Pubkey, - quic::{ - QUIC_CONNECTION_HANDSHAKE_TIMEOUT, QUIC_MAX_STAKED_CONCURRENT_STREAMS, - QUIC_MAX_STAKED_RECEIVE_WINDOW_RATIO, QUIC_MAX_UNSTAKED_CONCURRENT_STREAMS, - QUIC_MIN_STAKED_CONCURRENT_STREAMS, QUIC_MIN_STAKED_RECEIVE_WINDOW_RATIO, - QUIC_TOTAL_STAKED_CONCURRENT_STREAMS, QUIC_UNSTAKED_RECEIVE_WINDOW_RATIO, - }, - signature::{Keypair, Signature}, - timing, + solana_pubkey::Pubkey, + solana_quic_definitions::{ + QUIC_CONNECTION_HANDSHAKE_TIMEOUT, QUIC_MAX_STAKED_CONCURRENT_STREAMS, + QUIC_MAX_STAKED_RECEIVE_WINDOW_RATIO, QUIC_MAX_UNSTAKED_CONCURRENT_STREAMS, + QUIC_MIN_STAKED_CONCURRENT_STREAMS, QUIC_MIN_STAKED_RECEIVE_WINDOW_RATIO, + QUIC_TOTAL_STAKED_CONCURRENT_STREAMS, QUIC_UNSTAKED_RECEIVE_WINDOW_RATIO, }, + solana_signature::Signature, + solana_keypair::Keypair, + solana_time_utils as timing, solana_transaction_metrics_tracker::signature_if_should_track_packet, std::{ array, @@ -1533,7 +1532,9 @@ pub mod test { async_channel::unbounded as async_unbounded, crossbeam_channel::{unbounded, Receiver}, quinn::{ApplicationClose, ConnectionError}, - solana_sdk::{net::DEFAULT_TPU_COALESCE, signature::Keypair, signer::Signer}, + solana_keypair::Keypair, + solana_sdk::net::DEFAULT_TPU_COALESCE, + solana_signer::Signer, std::collections::HashMap, tokio::time::sleep, }; diff --git a/streamer/src/nonblocking/sendmmsg.rs b/streamer/src/nonblocking/sendmmsg.rs index 15217b906eb5da..352651d1d61c90 100644 --- a/streamer/src/nonblocking/sendmmsg.rs +++ b/streamer/src/nonblocking/sendmmsg.rs @@ -61,7 +61,7 @@ mod tests { sendmmsg::SendPktsError, }, assert_matches::assert_matches, - solana_sdk::packet::PACKET_DATA_SIZE, + solana_packet::PACKET_DATA_SIZE, std::{ io::ErrorKind, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, diff --git a/streamer/src/nonblocking/testing_utilities.rs b/streamer/src/nonblocking/testing_utilities.rs index e1a13c23fb2e69..695cc5a805ab43 100644 --- a/streamer/src/nonblocking/testing_utilities.rs +++ b/streamer/src/nonblocking/testing_utilities.rs @@ -16,11 +16,9 @@ use { TokioRuntime, TransportConfig, }, solana_perf::packet::PacketBatch, - solana_sdk::{ - net::DEFAULT_TPU_COALESCE, - quic::{QUIC_KEEP_ALIVE, QUIC_MAX_TIMEOUT}, - signer::keypair::Keypair, - }, + solana_quic_definitions::{QUIC_KEEP_ALIVE, QUIC_MAX_TIMEOUT}, + solana_sdk::net::DEFAULT_TPU_COALESCE, + solana_signer::keypair::Keypair, std::{ net::{SocketAddr, UdpSocket}, sync::{atomic::AtomicBool, Arc, RwLock}, diff --git a/streamer/src/packet.rs b/streamer/src/packet.rs index fdab5eba14ffea..5b89c939eaf2fa 100644 --- a/streamer/src/packet.rs +++ b/streamer/src/packet.rs @@ -11,10 +11,10 @@ use { }, }; pub use { + solana_packet::{Meta, Packet, PACKET_DATA_SIZE}, solana_perf::packet::{ to_packet_batches, PacketBatch, PacketBatchRecycler, NUM_PACKETS, PACKETS_PER_BATCH, }, - solana_sdk::packet::{Meta, Packet, PACKET_DATA_SIZE}, }; pub fn recv_from(batch: &mut PacketBatch, socket: &UdpSocket, max_wait: Duration) -> Result { diff --git a/streamer/src/quic.rs b/streamer/src/quic.rs index 21f173475ebf7b..70359b69ef24ba 100644 --- a/streamer/src/quic.rs +++ b/streamer/src/quic.rs @@ -18,12 +18,11 @@ use { server::danger::ClientCertVerified, DistinguishedName, KeyLogFile, }, + solana_keypair::Keypair, + solana_packet::PACKET_DATA_SIZE, solana_perf::packet::PacketBatch, - solana_sdk::{ - net::DEFAULT_TPU_COALESCE, - packet::PACKET_DATA_SIZE, - quic::{NotifyKeyUpdate, QUIC_MAX_TIMEOUT, QUIC_MAX_UNSTAKED_CONCURRENT_STREAMS}, - signature::Keypair, + solana_quic_definitions::{ + NotifyKeyUpdate, QUIC_MAX_TIMEOUT, QUIC_MAX_UNSTAKED_CONCURRENT_STREAMS, }, std::{ net::UdpSocket, @@ -42,6 +41,8 @@ pub const MAX_UNSTAKED_CONNECTIONS: usize = 500; // This will be adjusted and parameterized in follow-on PRs. pub const DEFAULT_QUIC_ENDPOINTS: usize = 1; +// inlined to avoid solana-sdk dep +const DEFAULT_TPU_COALESCE: Duration = Duration::from_millis(5); #[derive(Debug)] pub struct SkipClientVerification(Arc); @@ -840,4 +841,9 @@ mod test { exit.store(true, Ordering::Relaxed); t.join().unwrap(); } + + #[test] + fn test_inline_tpu_coalesce() { + assert_eq!(DEFAULT_TPU_COALESCE, solana_sdk::net::DEFAULT_TPU_COALESCE); + } } diff --git a/streamer/src/sendmmsg.rs b/streamer/src/sendmmsg.rs index f3d3e8419def99..b1c8e58125a2a5 100644 --- a/streamer/src/sendmmsg.rs +++ b/streamer/src/sendmmsg.rs @@ -11,7 +11,7 @@ use { }, }; use { - solana_sdk::transport::TransportError, + solana_transaction_error::TransportError, std::{ borrow::Borrow, io, @@ -189,7 +189,7 @@ mod tests { sendmmsg::{batch_send, multi_target_send, SendPktsError}, }, assert_matches::assert_matches, - solana_sdk::packet::PACKET_DATA_SIZE, + solana_packet::PACKET_DATA_SIZE, std::{ io::ErrorKind, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}, diff --git a/streamer/src/streamer.rs b/streamer/src/streamer.rs index a79445c3b8e7ac..b4f1e54429fc07 100644 --- a/streamer/src/streamer.rs +++ b/streamer/src/streamer.rs @@ -10,7 +10,9 @@ use { crossbeam_channel::{Receiver, RecvTimeoutError, SendError, Sender}, histogram::Histogram, itertools::Itertools, - solana_sdk::{packet::Packet, pubkey::Pubkey, timing::timestamp}, + solana_packet::Packet, + solana_pubkey::Pubkey, + solana_time_utils::timestamp, std::{ cmp::Reverse, collections::HashMap, diff --git a/streamer/src/tls_certificates.rs b/streamer/src/tls_certificates.rs index fba1441de88a86..d046d770e3ac09 100644 --- a/streamer/src/tls_certificates.rs +++ b/streamer/src/tls_certificates.rs @@ -1,5 +1,7 @@ use { - solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}, + solana_pubkey::Pubkey, + solana_keypair::Keypair, + solana_signer::Signer, x509_parser::{prelude::*, public_key::PublicKey}, }; @@ -113,7 +115,7 @@ pub fn get_pubkey_from_tls_certificate( #[cfg(test)] mod tests { - use {super::*, solana_sdk::signer::Signer}; + use {super::*, solana_signer::Signer}; #[test] fn test_generate_tls_certificate() {