diff --git a/Cargo.lock b/Cargo.lock index 2614844..bf922ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -328,62 +328,12 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" -[[package]] -name = "asn1-rs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" -dependencies = [ - "asn1-rs-derive", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "assert_matches" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - [[package]] name = "async-compression" version = "0.4.10" @@ -481,12 +431,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -724,16 +668,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" -[[package]] -name = "caps" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190baaad529bcfbde9e1a19022c42781bdb6ff9de25721abdb8fd98c0807730b" -dependencies = [ - "libc", - "thiserror", -] - [[package]] name = "cargo-lock" version = "9.0.0" @@ -787,22 +721,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "clap" -version = "3.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" -dependencies = [ - "atty", - "bitflags 1.3.2", - "clap_lex 0.2.4", - "indexmap 1.9.3", - "once_cell", - "strsim", - "termcolor", - "textwrap", -] - [[package]] name = "clap" version = "4.2.4" @@ -823,7 +741,7 @@ dependencies = [ "anstream", "anstyle", "bitflags 1.3.2", - "clap_lex 0.4.1", + "clap_lex", "strsim", ] @@ -839,15 +757,6 @@ dependencies = [ "syn 2.0.63", ] -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clap_lex" version = "0.4.1" @@ -873,15 +782,6 @@ dependencies = [ "unreachable", ] -[[package]] -name = "concurrent-queue" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "console" version = "0.15.8" @@ -1079,12 +979,6 @@ dependencies = [ "syn 2.0.63", ] -[[package]] -name = "data-encoding" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" - [[package]] name = "der" version = "0.5.1" @@ -1094,20 +988,6 @@ dependencies = [ "const-oid", ] -[[package]] -name = "der-parser" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" -dependencies = [ - "asn1-rs", - "displaydoc", - "nom", - "num-bigint 0.4.5", - "num-traits", - "rusticata-macros", -] - [[package]] name = "deranged" version = "0.3.11" @@ -1154,40 +1034,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.63", -] - -[[package]] -name = "dlopen2" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b4f5f101177ff01b8ec4ecc81eead416a8aa42819a2869311b3420fa114ffa" -dependencies = [ - "dlopen2_derive", - "libc", - "once_cell", - "winapi", -] - -[[package]] -name = "dlopen2_derive" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cbae11b3de8fce2a456e8ea3dada226b35fe791f0dc1d360c0941f0bb681f3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.63", -] - [[package]] name = "eager" version = "0.1.0" @@ -1289,12 +1135,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - [[package]] name = "feature-probe" version = "0.1.1" @@ -1468,7 +1308,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bincode", - "clap 4.2.4", + "clap", "futures", "log", "quic-geyser-client", @@ -1530,7 +1370,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.6", + "indexmap", "slab", "tokio", "tokio-util", @@ -1555,12 +1395,6 @@ dependencies = [ "ahash 0.7.8", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.13.2" @@ -1597,12 +1431,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "histogram" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cb882ccb290b8646e554b157ab0b71e64e8d5bef775cd66b6531e52d302669" - [[package]] name = "hmac" version = "0.8.1" @@ -1766,16 +1594,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.2.6" @@ -2005,15 +1823,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.9.1" @@ -2041,12 +1850,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.7.2" @@ -2067,29 +1870,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.7.1", - "pin-utils", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "num" version = "0.2.1" @@ -2280,15 +2060,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "oid-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" -dependencies = [ - "asn1-rs", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -2307,12 +2078,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - [[package]] name = "parking_lot" version = "0.12.2" @@ -2404,7 +2169,6 @@ checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ "der", "spki", - "zeroize", ] [[package]] @@ -2528,13 +2292,12 @@ dependencies = [ "bincode", "log", "lz4", - "pem", + "pkcs8", "quinn", + "rcgen", "rustls", "serde", - "solana-net-utils", "solana-sdk", - "solana-streamer", "solana-transaction-status", "thiserror", "tokio", @@ -2547,7 +2310,7 @@ dependencies = [ "agave-geyser-plugin-interface", "anyhow", "cargo-lock", - "clap 4.2.4", + "clap", "git-version", "log", "quic-geyser-common", @@ -2862,15 +2625,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - [[package]] name = "rustls" version = "0.21.7" @@ -3299,57 +3053,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "solana-net-utils" -version = "1.17.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafd5178a38a039e12c14780f1b6a74f1e672d62357343e0aee6d0fc7e5bd18" -dependencies = [ - "bincode", - "clap 3.2.25", - "crossbeam-channel", - "log", - "nix", - "rand 0.8.5", - "serde", - "serde_derive", - "socket2", - "solana-logger", - "solana-sdk", - "solana-version", - "tokio", - "url", -] - -[[package]] -name = "solana-perf" -version = "1.17.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d6293cddcc98ae092d00f43f741405da30aa083acb96666606130810b064f3" -dependencies = [ - "ahash 0.8.5", - "bincode", - "bv", - "caps", - "curve25519-dalek", - "dlopen2", - "fnv", - "lazy_static", - "libc", - "log", - "nix", - "rand 0.8.5", - "rayon", - "rustc_version", - "serde", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-metrics", - "solana-rayon-threadlimit", - "solana-sdk", - "solana-vote-program", -] - [[package]] name = "solana-program" version = "1.17.31" @@ -3381,7 +3084,7 @@ dependencies = [ "libsecp256k1", "light-poseidon", "log", - "memoffset 0.9.1", + "memoffset", "num-bigint 0.4.5", "num-derive 0.3.3", "num-traits", @@ -3432,16 +3135,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "solana-rayon-threadlimit" -version = "1.17.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f100d0c3214d67bb847a1eefc7079f6bb755534266423f4c994ad3b40c685ed" -dependencies = [ - "lazy_static", - "num_cpus", -] - [[package]] name = "solana-rpc-client" version = "1.17.31" @@ -3563,39 +3256,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "468aa43b7edb1f9b7b7b686d5c3aeb6630dc1708e86e31343499dd5c4d775183" -[[package]] -name = "solana-streamer" -version = "1.17.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f02b475fc20c55ebbcfa5638ff93f9b780414cc6185e3a6d0992bca0ae81ee" -dependencies = [ - "async-channel", - "bytes", - "crossbeam-channel", - "futures-util", - "histogram", - "indexmap 2.2.6", - "itertools", - "libc", - "log", - "nix", - "pem", - "percentage", - "pkcs8", - "quinn", - "quinn-proto", - "rand 0.8.5", - "rcgen", - "rustls", - "smallvec", - "solana-metrics", - "solana-perf", - "solana-sdk", - "thiserror", - "tokio", - "x509-parser", -] - [[package]] name = "solana-transaction-status" version = "1.17.31" @@ -3725,7 +3385,6 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ - "base64ct", "der", ] @@ -3976,18 +3635,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "system-configuration" version = "0.5.1" @@ -4018,12 +3665,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" - [[package]] name = "thiserror" version = "1.0.60" @@ -4200,7 +3841,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -4213,7 +3854,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.6", + "indexmap", "toml_datetime", "winnow", ] @@ -4295,12 +3936,6 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - [[package]] name = "universal-hash" version = "0.4.1" @@ -4684,24 +4319,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "x509-parser" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" -dependencies = [ - "asn1-rs", - "base64 0.13.1", - "data-encoding", - "der-parser", - "lazy_static", - "nom", - "oid-registry", - "rusticata-macros", - "thiserror", - "time", -] - [[package]] name = "yasna" version = "0.5.2" diff --git a/Cargo.toml b/Cargo.toml index cd8f254..7f60249 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,6 @@ edition = "2021" tokio = "1.37.0" solana-sdk = "=1.17.31" agave-geyser-plugin-interface = "=1.17.31" -solana-net-utils = "=1.17.31" -solana-streamer = "=1.17.31" solana-transaction-status = "=1.17.31" solana-logger = "=1.17.31" @@ -45,7 +43,6 @@ quinn = "0.10.2" rustls = "=0.21.7" rcgen = "0.10.0" pkcs8 = "0.8.0" -pem = "1.1.1" lz4 = "1.24.0" async-stream = "0.3.5" diff --git a/client/src/client.rs b/client/src/client.rs index 9ee5bc8..872b78e 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -8,7 +8,6 @@ use quic_geyser_common::quic::quinn_reciever::recv_message; use quic_geyser_common::quic::quinn_sender::send_message; use quic_geyser_common::{filters::Filter, types::connections_parameters::ConnectionParameters}; use quinn::{Connection, ConnectionError}; -use solana_sdk::signature::Keypair; pub struct Client { pub address: String, @@ -18,11 +17,9 @@ pub struct Client { impl Client { pub async fn new( server_address: String, - identity: &Keypair, connection_parameters: ConnectionParameters, ) -> anyhow::Result { - let endpoint = - configure_client(identity, connection_parameters.max_number_of_streams).await?; + let endpoint = configure_client(connection_parameters.max_number_of_streams).await?; let socket_addr = SocketAddr::from_str(&server_address)?; let connecting = endpoint.connect(socket_addr, "quic_geyser_client")?; let connection = connecting.await?; @@ -45,7 +42,7 @@ impl Client { Ok(()) } - pub fn get_stream(&self) -> impl Stream { + pub fn create_stream(&self) -> impl Stream { let connection = self.connection.clone(); let (sender, mut reciever) = tokio::sync::mpsc::unbounded_channel::(); tokio::spawn(async move { @@ -89,10 +86,7 @@ impl Client { #[cfg(test)] mod tests { - use std::{ - net::{IpAddr, Ipv4Addr, UdpSocket}, - sync::Arc, - }; + use std::{net::UdpSocket, sync::Arc}; use futures::StreamExt; use quic_geyser_common::{ @@ -102,21 +96,14 @@ mod tests { types::{account::Account, connections_parameters::ConnectionParameters}, }; use quinn::{Endpoint, EndpointConfig, TokioRuntime}; - use solana_sdk::{pubkey::Pubkey, signature::Keypair}; + use solana_sdk::pubkey::Pubkey; use tokio::{pin, sync::Notify}; use crate::client::Client; #[tokio::test] pub async fn test_client() { - let (config, _) = configure_server( - &Keypair::new(), - IpAddr::V4(Ipv4Addr::LOCALHOST), - 1, - 100000, - 1, - ) - .unwrap(); + let config = configure_server(1, 100000, 1).unwrap(); let sock = UdpSocket::bind("0.0.0.0:0").unwrap(); let port = sock.local_addr().unwrap().port(); @@ -158,7 +145,6 @@ mod tests { let client = Client::new( url, - &Keypair::new(), ConnectionParameters { max_number_of_streams: 3, streams_for_slot_data: 1, @@ -177,7 +163,7 @@ mod tests { notify_subscription.notify_one(); - let stream = client.get_stream(); + let stream = client.create_stream(); pin!(stream); for _ in 0..5 { let msg = stream.next().await.unwrap(); diff --git a/common/Cargo.toml b/common/Cargo.toml index 2c121af..87b6751 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -5,8 +5,6 @@ edition = "2021" [dependencies] solana-sdk = { workspace = true } -solana-streamer = { workspace = true } -solana-net-utils = { workspace = true } solana-transaction-status = { workspace = true } serde = { workspace = true } @@ -14,7 +12,8 @@ bincode = { workspace = true } lz4 = { workspace = true } quinn = { workspace = true } rustls = { workspace = true, default-features = false } -pem = { workspace = true } +rcgen = { workspace = true } +pkcs8 = { workspace = true } anyhow = { workspace = true } tokio = { workspace = true } log = { workspace = true } diff --git a/common/src/quic/configure_client.rs b/common/src/quic/configure_client.rs index fb2d4aa..05e07f9 100644 --- a/common/src/quic/configure_client.rs +++ b/common/src/quic/configure_client.rs @@ -1,40 +1,27 @@ -use std::{ - net::{IpAddr, Ipv4Addr}, - sync::Arc, - time::Duration, -}; +use std::{net::UdpSocket, sync::Arc, time::Duration}; use quinn::{ ClientConfig, Endpoint, EndpointConfig, IdleTimeout, TokioRuntime, TransportConfig, VarInt, }; -use solana_sdk::signature::Keypair; -use solana_streamer::tls_certificates::new_self_signed_tls_certificate; use crate::quic::{ configure_server::ALPN_GEYSER_PROTOCOL_ID, skip_verification::ClientSkipServerVerification, }; -pub const DEFAULT_MAX_STREAMS: u32 = 16384; -pub const DEFAULT_MAX_SLOT_BLOCKMETA_STREAMS: u32 = 24; -pub const DEFAULT_MAX_TRANSACTION_STREAMS: u32 = 1000; +pub const DEFAULT_MAX_STREAMS: u32 = 32768; +pub const DEFAULT_MAX_SLOT_BLOCKMETA_STREAMS: u32 = 128; +pub const DEFAULT_MAX_TRANSACTION_STREAMS: u32 = 8192; pub const DEFAULT_MAX_ACCOUNT_STREAMS: u32 = DEFAULT_MAX_STREAMS - DEFAULT_MAX_SLOT_BLOCKMETA_STREAMS - DEFAULT_MAX_TRANSACTION_STREAMS; -pub fn create_client_endpoint( - certificate: rustls::Certificate, - key: rustls::PrivateKey, - maximum_streams: u32, -) -> Endpoint { +pub fn create_client_endpoint(maximum_streams: u32) -> Endpoint { const DATAGRAM_RECEIVE_BUFFER_SIZE: usize = 64 * 1024 * 1024; const DATAGRAM_SEND_BUFFER_SIZE: usize = 64 * 1024 * 1024; const INITIAL_MAXIMUM_TRANSMISSION_UNIT: u16 = MINIMUM_MAXIMUM_TRANSMISSION_UNIT; const MINIMUM_MAXIMUM_TRANSMISSION_UNIT: u16 = 2000; let mut endpoint = { - let client_socket = - solana_net_utils::bind_in_range(IpAddr::V4(Ipv4Addr::UNSPECIFIED), (8000, 10000)) - .expect("create_endpoint bind_in_range") - .1; + let client_socket = UdpSocket::bind("0.0.0.0:0").expect("Client socket should be binded"); let mut config = EndpointConfig::default(); config .max_udp_payload_size(MINIMUM_MAXIMUM_TRANSMISSION_UNIT) @@ -43,11 +30,16 @@ pub fn create_client_endpoint( .expect("create_endpoint quinn::Endpoint::new") }; + let cert = rcgen::generate_simple_self_signed(vec!["quic_geyser_client".into()]).unwrap(); + let key = rustls::PrivateKey(cert.serialize_private_key_der()); + let cert = rustls::Certificate(cert.serialize_der().unwrap()); + let mut crypto = rustls::ClientConfig::builder() .with_safe_defaults() .with_custom_certificate_verifier(Arc::new(ClientSkipServerVerification {})) - .with_client_auth_cert(vec![certificate], key) - .unwrap(); + .with_client_auth_cert(vec![cert], key) + .expect("Should create client config"); + crypto.enable_early_data = true; crypto.alpn_protocols = vec![ALPN_GEYSER_PROTOCOL_ID.to_vec()]; @@ -72,15 +64,6 @@ pub fn create_client_endpoint( endpoint } -pub async fn configure_client( - identity: &Keypair, - maximum_concurrent_streams: u32, -) -> anyhow::Result { - let (certificate, key) = - new_self_signed_tls_certificate(identity, IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))?; - Ok(create_client_endpoint( - certificate, - key, - maximum_concurrent_streams, - )) +pub async fn configure_client(maximum_concurrent_streams: u32) -> anyhow::Result { + Ok(create_client_endpoint(maximum_concurrent_streams)) } diff --git a/common/src/quic/configure_server.rs b/common/src/quic/configure_server.rs index d945764..9593655 100644 --- a/common/src/quic/configure_server.rs +++ b/common/src/quic/configure_server.rs @@ -1,36 +1,24 @@ -use std::{net::IpAddr, sync::Arc, time::Duration}; +use std::{sync::Arc, time::Duration}; -use pem::Pem; use quinn::{IdleTimeout, ServerConfig}; -use solana_sdk::{pubkey::Pubkey, signature::Keypair}; -use solana_streamer::{ - quic::QuicServerError, - tls_certificates::{get_pubkey_from_tls_certificate, new_self_signed_tls_certificate}, -}; use super::skip_verification::ServerSkipClientVerification; pub const ALPN_GEYSER_PROTOCOL_ID: &[u8] = b"quic_geyser_plugin"; pub fn configure_server( - identity_keypair: &Keypair, - host: IpAddr, max_concurrent_streams: u32, recieve_window_size: u32, connection_timeout: u64, -) -> Result<(ServerConfig, String), QuicServerError> { - let (cert, priv_key) = new_self_signed_tls_certificate(identity_keypair, host)?; - let cert_chain_pem_parts = vec![Pem { - tag: "CERTIFICATE".to_string(), - contents: cert.0.clone(), - }]; - - let cert_chain_pem = pem::encode_many(&cert_chain_pem_parts); +) -> anyhow::Result { + let cert = rcgen::generate_simple_self_signed(vec!["quic_geyser_server".into()]).unwrap(); + let key = rustls::PrivateKey(cert.serialize_private_key_der()); + let cert = rustls::Certificate(cert.serialize_der().unwrap()); let mut server_tls_config = rustls::ServerConfig::builder() .with_safe_defaults() .with_client_cert_verifier(ServerSkipClientVerification::new()) - .with_single_cert(vec![cert], priv_key)?; + .with_single_cert(vec![cert], key)?; server_tls_config.alpn_protocols = vec![ALPN_GEYSER_PROTOCOL_ID.to_vec()]; let mut server_config = ServerConfig::with_crypto(Arc::new(server_tls_config)); @@ -50,16 +38,5 @@ pub fn configure_server( config.max_concurrent_bidi_streams(0u32.into()); config.datagram_receive_buffer_size(None); - Ok((server_config, cert_chain_pem)) -} - -pub fn get_remote_pubkey(connection: &quinn::Connection) -> Option { - // Use the client cert only if it is self signed and the chain length is 1. - connection - .peer_identity()? - .downcast::>() - .ok() - .filter(|certs| certs.len() == 1)? - .first() - .and_then(get_pubkey_from_tls_certificate) + Ok(server_config) } diff --git a/common/src/quic/quic_server.rs b/common/src/quic/quic_server.rs index 207d840..6cb4457 100644 --- a/common/src/quic/quic_server.rs +++ b/common/src/quic/quic_server.rs @@ -1,7 +1,4 @@ -use std::{ - net::{IpAddr, Ipv4Addr, UdpSocket}, - sync::Arc, -}; +use std::{net::UdpSocket, sync::Arc}; use crate::{ compression::CompressionType, @@ -19,7 +16,6 @@ use crate::{ use quinn::{Endpoint, EndpointConfig, TokioRuntime}; use solana_sdk::{ account::Account, clock::Slot, commitment_config::CommitmentLevel, pubkey::Pubkey, - signature::Keypair, }; use tokio::{runtime::Runtime, sync::mpsc::UnboundedSender}; @@ -43,14 +39,8 @@ pub struct QuicServer { } impl QuicServer { - pub fn new( - runtime: Runtime, - identity: Keypair, - config: ConfigQuicPlugin, - ) -> anyhow::Result { - let (server_config, _) = configure_server( - &identity, - IpAddr::V4(Ipv4Addr::LOCALHOST), + pub fn new(runtime: Runtime, config: ConfigQuicPlugin) -> anyhow::Result { + let server_config = configure_server( config.quic_parameters.max_number_of_streams_per_client, config.quic_parameters.recieve_window_size, config.quic_parameters.connection_timeout as u64, diff --git a/common/src/quic/quinn_reciever.rs b/common/src/quic/quinn_reciever.rs index 8bb8738..0530d21 100644 --- a/common/src/quic/quinn_reciever.rs +++ b/common/src/quic/quinn_reciever.rs @@ -27,7 +27,10 @@ pub async fn recv_message( let size_bytes: [u8; 8] = size_bytes.try_into().unwrap(); let size = u64::from_le_bytes(size_bytes) as usize; let mut buffer: Vec = vec![0; size]; - while let Some(data) = tokio::time::timeout(Duration::from_secs(1), recv_stream.read_chunk(size, false)).await?? { + while let Some(data) = + tokio::time::timeout(Duration::from_secs(1), recv_stream.read_chunk(size, false)) + .await?? + { let bytes = data.bytes.to_vec(); let offset = data.offset - 8; let begin_offset = offset as usize; @@ -52,9 +55,6 @@ mod tests { sync::Arc, }; - use quinn::{Endpoint, EndpointConfig, TokioRuntime, VarInt}; - use solana_sdk::signature::Keypair; - use crate::{ message::Message, quic::{ @@ -63,17 +63,11 @@ mod tests { }, types::account::Account, }; + use quinn::{Endpoint, EndpointConfig, TokioRuntime, VarInt}; #[tokio::test] pub async fn test_send_and_recieve_of_small_account() { - let (config, _) = configure_server( - &Keypair::new(), - IpAddr::V4(Ipv4Addr::LOCALHOST), - 1, - 100000, - 1, - ) - .unwrap(); + let config = configure_server(1, 100000, 1).unwrap(); let sock = UdpSocket::bind("0.0.0.0:0").unwrap(); let port = sock.local_addr().unwrap().port(); @@ -93,7 +87,7 @@ mod tests { let sent_message = message.clone(); tokio::spawn(async move { - let endpoint = configure_client(&Keypair::new(), 1).await.unwrap(); + let endpoint = configure_client(1).await.unwrap(); let connecting = endpoint .connect( @@ -119,14 +113,7 @@ mod tests { #[tokio::test] pub async fn test_send_and_recieve_of_large_account() { - let (config, _) = configure_server( - &Keypair::new(), - IpAddr::V4(Ipv4Addr::LOCALHOST), - 1, - 100000, - 60, - ) - .unwrap(); + let config = configure_server(1, 100000, 60).unwrap(); let sock = UdpSocket::bind("0.0.0.0:0").unwrap(); let port = sock.local_addr().unwrap().port(); @@ -146,7 +133,7 @@ mod tests { let sent_message = message.clone(); tokio::spawn(async move { - let endpoint = configure_client(&Keypair::new(), 0).await.unwrap(); + let endpoint = configure_client(0).await.unwrap(); let connecting = endpoint .connect( diff --git a/plugin/src/quic_plugin.rs b/plugin/src/quic_plugin.rs index 644caec..103f153 100644 --- a/plugin/src/quic_plugin.rs +++ b/plugin/src/quic_plugin.rs @@ -15,7 +15,7 @@ use quic_geyser_common::{ }; use solana_sdk::{ account::Account, clock::Slot, commitment_config::CommitmentLevel, message::v0::Message, - pubkey::Pubkey, signature::Keypair, + pubkey::Pubkey, }; use tokio::runtime::Builder; @@ -50,10 +50,9 @@ impl GeyserPlugin for QuicGeyserPlugin { GeyserPluginError::Custom(Box::new(QuicGeyserError::ErrorConfiguringServer)) })?; - let quic_server = - QuicServer::new(runtime, Keypair::new(), config.quic_plugin).map_err(|_| { - GeyserPluginError::Custom(Box::new(QuicGeyserError::ErrorConfiguringServer)) - })?; + let quic_server = QuicServer::new(runtime, config.quic_plugin).map_err(|_| { + GeyserPluginError::Custom(Box::new(QuicGeyserError::ErrorConfiguringServer)) + })?; self.quic_server = Some(quic_server); Ok(()) diff --git a/tester/src/main.rs b/tester/src/main.rs index a47d59a..7560187 100644 --- a/tester/src/main.rs +++ b/tester/src/main.rs @@ -12,11 +12,7 @@ use quic_geyser_common::{ types::connections_parameters::ConnectionParameters, }; use solana_rpc_client::nonblocking::rpc_client::RpcClient; -use solana_sdk::{ - commitment_config::CommitmentConfig, - pubkey::Pubkey, - signature::{Keypair, Signature}, -}; +use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey, signature::Signature}; use tokio::pin; pub mod cli; @@ -47,7 +43,7 @@ pub mod cli; async fn main() { let args = Args::parse(); println!("Connecting"); - let client = Client::new(args.url, &Keypair::new(), ConnectionParameters::default()) + let client = Client::new(args.url, ConnectionParameters::default()) .await .unwrap(); println!("Connected"); @@ -133,7 +129,7 @@ async fn main() { .unwrap(); println!("Subscribed"); - let stream = client.get_stream(); + let stream = client.create_stream(); pin!(stream); while let Some(message) = stream.next().await {