clone_solana_quic_definitions/
lib.rs

1//! Definitions related to Solana over QUIC.
2use {clone_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.
25/// For upgrade purpose, we keep the original one. Once the network is upgraded
26/// to the one having higher QUIC_MAX_TIMEOUT, this value can be increased.
27pub const QUIC_KEEP_ALIVE: Duration = Duration::from_secs(1);
28
29// Disable Quic send fairness.
30// When set to false, streams are still scheduled based on priority,
31// but once a chunk of a stream has been written out, quinn tries to complete
32// the stream instead of trying to round-robin balance it among the streams
33// with the same priority.
34// See https://github.com/quinn-rs/quinn/pull/2002.
35pub const QUIC_SEND_FAIRNESS: bool = false;
36
37// Based on commonly-used handshake timeouts for various TCP
38// applications. Different applications vary, but most seem to
39// be in the 30-60 second range
40pub const QUIC_CONNECTION_HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(60);
41
42/// The receive window for QUIC connection from unstaked nodes is
43/// set to this ratio times [`clone_solana_packet::PACKET_DATA_SIZE`]
44///
45/// [`clone_solana_packet::PACKET_DATA_SIZE`]: https://docs.rs/solana-packet/latest/clone_solana_packet/constant.PACKET_DATA_SIZE.html
46pub const QUIC_UNSTAKED_RECEIVE_WINDOW_RATIO: u64 = 128;
47
48/// The receive window for QUIC connection from minimum staked nodes is
49/// set to this ratio times [`clone_solana_packet::PACKET_DATA_SIZE`]
50///
51/// [`clone_solana_packet::PACKET_DATA_SIZE`]: https://docs.rs/solana-packet/latest/clone_solana_packet/constant.PACKET_DATA_SIZE.html
52pub const QUIC_MIN_STAKED_RECEIVE_WINDOW_RATIO: u64 = 128;
53
54/// The receive window for QUIC connection from maximum staked nodes is
55/// set to this ratio times [`clone_solana_packet::PACKET_DATA_SIZE`]
56///
57/// [`clone_solana_packet::PACKET_DATA_SIZE`]: https://docs.rs/solana-packet/latest/clone_solana_packet/constant.PACKET_DATA_SIZE.html
58pub const QUIC_MAX_STAKED_RECEIVE_WINDOW_RATIO: u64 = 512;
59
60pub trait NotifyKeyUpdate {
61    fn update_key(&self, key: &Keypair) -> Result<(), Box<dyn std::error::Error>>;
62}