solana_quic_definitions/
lib.rs

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