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#[cfg_attr(feature = "wincode", derive(wincode::SchemaRead, wincode::SchemaWrite))]
15#[cfg_attr(feature = "wincode", wincode(assert_zero_copy))]
16#[repr(C)]
17pub struct WireInstructionHeader {
18    pub program_id_index: u8,
19    pub num_accounts: u8,
20    pub data_len: [u8; 2],
21}
22
23/// Version byte for V1 messages (decimal 129).
24pub const V1_PREFIX: u8 = MESSAGE_VERSION_PREFIX | 1;
25
26/// Maximum transaction size for V1 format in bytes.
27pub const MAX_TRANSACTION_SIZE: usize = 4096;
28
29/// Maximum number of account addresses in a V1 message.
30pub const MAX_ADDRESSES: u8 = 64;
31
32/// Maximum number of instructions in a V1 message.
33pub const MAX_INSTRUCTIONS: u8 = 64;
34
35/// Maximum number of signatures in a V1 transaction.
36pub const MAX_SIGNATURES: u8 = 12;
37
38/// Default heap size in bytes when not specified.
39///
40/// This is the same as the minimum heap size.
41pub const DEFAULT_HEAP_SIZE: u32 = MIN_HEAP_SIZE;
42
43/// Minimum heap size in bytes (32KB).
44pub const MIN_HEAP_SIZE: u32 = 32 * 1024;
45
46/// Maximum heap size in bytes (256KB).
47pub const MAX_HEAP_SIZE: u32 = 256 * 1024;
48
49/// Size of the fixed header portion of a serialized V1 message.
50pub const FIXED_HEADER_SIZE: usize = size_of::<MessageHeader>() // legacy header
51    + size_of::<TransactionConfigMask>() // config mask
52    + size_of::<Hash>() // lifetime specifier
53    + size_of::<u8>() // number of instructions
54    + size_of::<u8>(); // number of addresses
55
56/// Size of a single Ed25519 signature (64 bytes).
57pub const SIGNATURE_SIZE: usize = 64;