solana_sdk/
quic.rs

1#![cfg(feature = "full")]
2//! Definitions related to Solana over QUIC.
3use {crate::signer::keypair::Keypair, std::time::Duration};
4
5pub const QUIC_PORT_OFFSET: u16 = 6;
6// Empirically found max number of concurrent streams
7// that seems to maximize TPS on GCE (higher values don't seem to
8// give significant improvement or seem to impact stability)
9pub const QUIC_MAX_UNSTAKED_CONCURRENT_STREAMS: usize = 128;
10pub const QUIC_MIN_STAKED_CONCURRENT_STREAMS: usize = 128;
11
12pub const QUIC_TOTAL_STAKED_CONCURRENT_STREAMS: usize = 100_000;
13
14// Set the maximum concurrent stream numbers to avoid excessive streams.
15// The value was lowered from 2048 to reduce contention of the limited
16// receive_window among the streams which is observed in CI bench-tests with
17// forwarded packets from staked nodes.
18pub const QUIC_MAX_STAKED_CONCURRENT_STREAMS: usize = 512;
19
20pub const QUIC_MAX_TIMEOUT: Duration = Duration::from_secs(2);
21pub const QUIC_KEEP_ALIVE: Duration = Duration::from_secs(1);
22
23// Disable Quic send fairness.
24// When set to false, streams are still scheduled based on priority,
25// but once a chunk of a stream has been written out, quinn tries to complete
26// the stream instead of trying to round-robin balance it among the streams
27// with the same priority.
28// See https://github.com/quinn-rs/quinn/pull/2002.
29pub const QUIC_SEND_FAIRNESS: bool = false;
30
31// Based on commonly-used handshake timeouts for various TCP
32// applications. Different applications vary, but most seem to
33// be in the 30-60 second range
34pub const QUIC_CONNECTION_HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(60);
35
36/// The receive window for QUIC connection from unstaked nodes is
37/// set to this ratio times [`solana_sdk::packet::PACKET_DATA_SIZE`]
38pub const QUIC_UNSTAKED_RECEIVE_WINDOW_RATIO: u64 = 128;
39
40/// The receive window for QUIC connection from minimum staked nodes is
41/// set to this ratio times [`solana_sdk::packet::PACKET_DATA_SIZE`]
42pub const QUIC_MIN_STAKED_RECEIVE_WINDOW_RATIO: u64 = 128;
43
44/// The receive window for QUIC connection from maximum staked nodes is
45/// set to this ratio times [`solana_sdk::packet::PACKET_DATA_SIZE`]
46pub const QUIC_MAX_STAKED_RECEIVE_WINDOW_RATIO: u64 = 512;
47
48pub trait NotifyKeyUpdate {
49    fn update_key(&self, key: &Keypair) -> Result<(), Box<dyn std::error::Error>>;
50}