rialo_limits/
lib.rs

1// Copyright (c) Subzero Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4mod oracle_update_size;
5pub use oracle_update_size::*;
6use rialo_s_pubkey::Pubkey;
7
8/// The number of bytes in a kilobyte.
9const KIB: u64 = 1024;
10
11/// The number of bytes in a megabyte.
12const MIB: u64 = 1024 * KIB;
13
14/// The maximum size of a program instruction payload in bytes.
15pub const MAX_INSTRUCTION_DATA_SIZE: u64 = 65 * KIB;
16
17/// The maximum size of a consensus block in bytes.
18pub const MAX_CONSENSUS_BLOCK_SIZE: u64 = 512 * KIB;
19
20/// The maximum size of a single transaction in bytes.
21pub const MAX_TRANSACTION_SIZE: u64 = 128 * KIB;
22
23/// The maximum size for a payload received from a remote backend in bytes.
24pub const MAX_RESPONSE_SIZE: usize = (10 * MIB) as usize;
25
26#[cfg(test)]
27static_assertions::const_assert_eq!(PACKET_DATA_SIZE, 1232);
28/// Maximum over-the-wire size of a Transaction
29///   1280 is IPv6 minimum MTU
30///   40 bytes is the size of the IPv6 header
31///   8 bytes is the size of the fragment header
32///
33/// # Notes
34///
35/// Inherited from our Runtime fork of Solana.
36pub const PACKET_DATA_SIZE: usize = 1280 - 40 - 8;
37
38// The packet has a maximum length of 1232 bytes.
39// This means the maximum number of 32 byte keys is 38.
40// 38 as an min-sized encoded u16 is 1 byte.
41// We can simply read this byte, if it's >38 we can return None.
42pub const MAX_STATIC_ACCOUNTS_PER_PACKET: u8 =
43    (PACKET_DATA_SIZE / core::mem::size_of::<Pubkey>()) as u8;