Skip to main content

solana_message/versions/v1/
mod.rs

1use crate::{MessageHeader, MESSAGE_VERSION_PREFIX};
2
3#[cfg(feature = "std")]
4mod cached;
5mod config;
6mod error;
7mod message;
8
9#[cfg(feature = "std")]
10pub use cached::*;
11use solana_hash::Hash;
12pub use {config::*, error::*, message::*};
13
14/// A type definition for an  instruction header:
15///  - program_id_index
16///  - num_accounts
17///  - data_len
18///
19/// This is used to parse the instruction portion of a V1 message.
20pub type InstructionHeader = (u8, u8, [u8; 2]);
21
22/// Version byte for V1 messages (decimal 129).
23pub const V1_PREFIX: u8 = MESSAGE_VERSION_PREFIX | 1;
24
25/// Maximum transaction size for V1 format in bytes.
26pub const MAX_TRANSACTION_SIZE: usize = 4096;
27
28/// Maximum number of account addresses in a V1 message.
29pub const MAX_ADDRESSES: u8 = 64;
30
31/// Maximum number of instructions in a V1 message.
32pub const MAX_INSTRUCTIONS: u8 = 64;
33
34/// Maximum number of signatures in a V1 transaction.
35pub const MAX_SIGNATURES: u8 = 12;
36
37/// Default heap size in bytes when not specified.
38///
39/// This is the same as the minimum heap size.
40pub const DEFAULT_HEAP_SIZE: u32 = MIN_HEAP_SIZE;
41
42/// Minimum heap size in bytes (32KB).
43pub const MIN_HEAP_SIZE: u32 = 32 * 1024;
44
45/// Maximum heap size in bytes (256KB).
46pub const MAX_HEAP_SIZE: u32 = 256 * 1024;
47
48/// Size of the fixed header portion of a serialized V1 message.
49pub const FIXED_HEADER_SIZE: usize = size_of::<MessageHeader>() // legacy header
50    + size_of::<TransactionConfigMask>() // config mask
51    + size_of::<Hash>() // lifetime specifier
52    + size_of::<u8>() // number of instructions
53    + size_of::<u8>(); // number of addresses
54
55/// Size of a single Ed25519 signature (64 bytes).
56pub const SIGNATURE_SIZE: usize = 64;