|
1 | 1 | use { |
| 2 | + crate::core::{DEFAULT_UNUSED_CONNECTION_TTL, QUIC_MAX_TIMEOUT}, |
2 | 3 | serde::{Deserialize, Deserializer, de}, |
3 | 4 | solana_net_utils::{PortRange, VALIDATOR_PORT_RANGE}, |
4 | 5 | solana_pubkey::Pubkey, |
5 | | - solana_quic_definitions::QUIC_MAX_TIMEOUT, |
6 | 6 | std::{net::SocketAddr, num::NonZeroUsize, ops::Range, time::Duration}, |
7 | 7 | }; |
8 | 8 |
|
@@ -191,9 +191,59 @@ pub struct TpuSenderConfig { |
191 | 191 | /// |
192 | 192 | #[serde(default)] |
193 | 193 | pub tpu_info_override: Vec<TpuOverrideInfo>, |
| 194 | + |
| 195 | + /// |
| 196 | + /// Duration after which an orphan connection is evicted. |
| 197 | + /// |
| 198 | + /// # Note |
| 199 | + /// |
| 200 | + /// An orphan connection is a connection that is established but have no sender tasks referencing it. |
| 201 | + /// Each remote peer identity multiplexed over a connection gets 1:1 mapping to a sender task. |
| 202 | + /// |
| 203 | + /// When all sender tasks for a connection are dropped, the connection becomes an orphan. |
| 204 | + /// |
| 205 | + #[serde( |
| 206 | + default = "TpuSenderConfig::default_unused_connection_ttl", |
| 207 | + with = "humantime_serde" |
| 208 | + )] |
| 209 | + pub orphan_connection_ttl: Duration, |
| 210 | + |
| 211 | + /// |
| 212 | + /// NO DOCUMENTATION! |
| 213 | + /// |
| 214 | + /// IF YOU USE THIS FEATURE YOU SHOULD FEEL BAD. |
| 215 | + #[serde( |
| 216 | + skip_deserializing, |
| 217 | + default = "TpuSenderConfig::default_allow_arbitrary_txn_size" |
| 218 | + )] |
| 219 | + pub unsafe_allow_arbitrary_txn_size: bool, |
194 | 220 | } |
195 | 221 |
|
196 | 222 | impl TpuSenderConfig { |
| 223 | + /// |
| 224 | + /// # Safety |
| 225 | + /// |
| 226 | + /// This function enables sending transactions of arbitrary size, which may lead to unexpected behavior or security vulnerabilities. |
| 227 | + /// It should only be used in controlled testing environments. |
| 228 | + /// |
| 229 | + pub unsafe fn allow_arbitrary_txn_size(&mut self) { |
| 230 | + #[cfg(not(feature = "intg-testing"))] |
| 231 | + { |
| 232 | + panic!( |
| 233 | + "TpuSenderConfig::allow_arbitrary_txn_size can only be set to true in integration testing builds." |
| 234 | + ); |
| 235 | + } |
| 236 | + self.unsafe_allow_arbitrary_txn_size = true; |
| 237 | + } |
| 238 | + |
| 239 | + pub const fn default_allow_arbitrary_txn_size() -> bool { |
| 240 | + false |
| 241 | + } |
| 242 | + |
| 243 | + pub const fn default_unused_connection_ttl() -> Duration { |
| 244 | + DEFAULT_UNUSED_CONNECTION_TTL |
| 245 | + } |
| 246 | + |
197 | 247 | pub const fn default_connection_timeout() -> Duration { |
198 | 248 | DEFAULT_CONNECTION_TIMEOUT |
199 | 249 | } |
@@ -257,7 +307,7 @@ impl TpuSenderConfig { |
257 | 307 | /// Talking with Anza, we should not open more than 5 endpoints to host QUIC connections. |
258 | 308 | pub const DEFAULT_QUIC_DRIVER_ENDPOINT_COUNT: NonZeroUsize = |
259 | 309 | NonZeroUsize::new(5).expect("default endpoint count must be non-zero"); |
260 | | -pub const DEFAULT_CONNECTION_TIMEOUT: Duration = Duration::from_secs(2); |
| 310 | +pub const DEFAULT_CONNECTION_TIMEOUT: Duration = Duration::from_secs(4); |
261 | 311 | pub const DEFAULT_MAX_CONSECUTIVE_CONNECTION_ATTEMPT: usize = 3; |
262 | 312 | pub const DEFAULT_PER_PEER_TRANSACTION_QUEUE_SIZE: usize = 10_000; |
263 | 313 | pub const DEFAULT_MAX_CONCURRENT_CONNECTIONS: usize = 1024; |
@@ -285,6 +335,8 @@ impl Default for TpuSenderConfig { |
285 | 335 | send_timeout: DEFAULT_TX_SEND_TIMEOUT, |
286 | 336 | leader_prediction_lookahead: Some(DEFAULT_LEADER_PREDICTION_LOOKAHEAD), |
287 | 337 | tpu_info_override: Vec::new(), |
| 338 | + orphan_connection_ttl: DEFAULT_UNUSED_CONNECTION_TTL, |
| 339 | + unsafe_allow_arbitrary_txn_size: false, |
288 | 340 | } |
289 | 341 | } |
290 | 342 | } |
|
0 commit comments