Skip to main content

solana_transaction_context/
lib.rs

1#![cfg(feature = "agave-unstable-api")]
2//! Data shared between program runtime and built-in programs as well as SBF programs.
3#![deny(clippy::indexing_slicing)]
4#![cfg_attr(docsrs, feature(doc_cfg))]
5
6pub mod instruction;
7pub mod instruction_accounts;
8pub mod transaction_accounts;
9mod vm_addresses;
10pub mod vm_slice;
11
12pub mod transaction;
13
14pub const MAX_ACCOUNTS_PER_TRANSACTION: usize = 256;
15// This is one less than MAX_ACCOUNTS_PER_TRANSACTION because
16// one index is used as NON_DUP_MARKER in ABI v0 and v1.
17pub const MAX_ACCOUNTS_PER_INSTRUCTION: usize = 255;
18pub const MAX_INSTRUCTION_DATA_LEN: usize = 10 * 1024;
19pub const MAX_ACCOUNT_DATA_LEN: u64 = 10 * 1024 * 1024;
20// Note: With virtual_address_space_adjustments programs can grow accounts
21// faster than they intend to, because the AccessViolationHandler might grow
22// an account up to MAX_ACCOUNT_DATA_GROWTH_PER_INSTRUCTION at once.
23pub const MAX_ACCOUNT_DATA_GROWTH_PER_TRANSACTION: i64 = MAX_ACCOUNT_DATA_LEN as i64 * 2;
24pub const MAX_ACCOUNT_DATA_GROWTH_PER_INSTRUCTION: usize = 10 * 1_024;
25// Maximum cross-program invocation and instructions per transaction
26pub const MAX_INSTRUCTION_TRACE_LENGTH: usize = 64;
27pub const DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT: u32 = 200_000;
28
29#[cfg(test)]
30static_assertions::const_assert_eq!(
31    MAX_ACCOUNTS_PER_INSTRUCTION,
32    solana_program_entrypoint::NON_DUP_MARKER as usize,
33);
34#[cfg(test)]
35static_assertions::const_assert_eq!(
36    MAX_ACCOUNT_DATA_LEN,
37    solana_system_interface::MAX_PERMITTED_DATA_LENGTH,
38);
39#[cfg(test)]
40static_assertions::const_assert_eq!(
41    MAX_ACCOUNT_DATA_GROWTH_PER_TRANSACTION,
42    solana_system_interface::MAX_PERMITTED_ACCOUNTS_DATA_ALLOCATIONS_PER_TRANSACTION,
43);
44#[cfg(test)]
45static_assertions::const_assert_eq!(
46    MAX_ACCOUNT_DATA_GROWTH_PER_INSTRUCTION,
47    solana_account_info::MAX_PERMITTED_DATA_INCREASE,
48);
49
50/// Index of an account inside of the transaction or an instruction.
51pub type IndexOfAccount = u16;
52
53/// Selects if transactions can be discarded entirely
54#[derive(Clone, Copy, Debug)]
55pub enum DropOnBailOut {
56    /// As follower, in replay: Transactions failing with InstructionError::BailOut are part of consensus
57    Disabled,
58    /// As leader, in block production: Transactions failing with InstructionError::BailOut are dropped
59    Enabled,
60}