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