miden_objects/
constants.rs

1use miden_processor::ExecutionOptions;
2
3/// Depth of the account database tree.
4pub const ACCOUNT_TREE_DEPTH: u8 = 64;
5
6/// The maximum allowed size of an account update is 256 KiB.
7pub const ACCOUNT_UPDATE_MAX_SIZE: u32 = 2u32.pow(18);
8
9/// The maximum number of assets that can be stored in a single note.
10pub const MAX_ASSETS_PER_NOTE: usize = 255;
11
12/// The maximum number of inputs that can accompany a single note.
13///
14/// The value is set to 128 so that it can be represented using as a single byte while being
15/// evenly divisible by 8.
16pub const MAX_INPUTS_PER_NOTE: usize = 128;
17
18/// The maximum number of notes that can be consumed by a single transaction.
19pub const MAX_INPUT_NOTES_PER_TX: usize = 1024;
20
21/// The maximum number of new notes created by a single transaction.
22pub const MAX_OUTPUT_NOTES_PER_TX: usize = MAX_INPUT_NOTES_PER_TX;
23
24/// The minimum proof security level used by the Miden prover & verifier.
25pub const MIN_PROOF_SECURITY_LEVEL: u32 = 96;
26
27/// The maximum number of VM cycles a transaction is allowed to take.
28pub const MAX_TX_EXECUTION_CYCLES: u32 = ExecutionOptions::MAX_CYCLES;
29
30/// The minimum number of VM cycles a transaction needs to execute.
31pub const MIN_TX_EXECUTION_CYCLES: u32 = 1 << 12;
32
33/// Maximum number of the foreign accounts that can be loaded.
34pub const MAX_NUM_FOREIGN_ACCOUNTS: u8 = 64;
35
36// TRANSACTION BATCH
37// ================================================================================================
38
39/// The depth of the Sparse Merkle Tree used to store output notes in a single batch.
40pub const BATCH_NOTE_TREE_DEPTH: u8 = 10;
41
42/// The maximum number of notes that can be created in a single batch.
43pub const MAX_OUTPUT_NOTES_PER_BATCH: usize = 1 << BATCH_NOTE_TREE_DEPTH;
44const _: () = assert!(MAX_OUTPUT_NOTES_PER_BATCH >= MAX_OUTPUT_NOTES_PER_TX);
45
46/// The maximum number of input notes that can be consumed in a single batch.
47pub const MAX_INPUT_NOTES_PER_BATCH: usize = MAX_OUTPUT_NOTES_PER_BATCH;
48const _: () = assert!(MAX_INPUT_NOTES_PER_BATCH >= MAX_INPUT_NOTES_PER_TX);
49
50/// The maximum number of accounts that can be updated in a single batch.
51pub const MAX_ACCOUNTS_PER_BATCH: usize = 1024;
52
53// BLOCK
54// ================================================================================================
55
56/// The final depth of the Sparse Merkle Tree used to store all notes created in a block.
57pub const BLOCK_NOTE_TREE_DEPTH: u8 = 16;
58
59/// Maximum number of batches that can be inserted into a single block.
60pub const MAX_BATCHES_PER_BLOCK: usize = 1 << (BLOCK_NOTE_TREE_DEPTH - BATCH_NOTE_TREE_DEPTH);
61
62/// Maximum number of output notes that can be created in a single block.
63pub const MAX_OUTPUT_NOTES_PER_BLOCK: usize = MAX_OUTPUT_NOTES_PER_BATCH * MAX_BATCHES_PER_BLOCK;
64const _: () = assert!(MAX_OUTPUT_NOTES_PER_BLOCK >= MAX_OUTPUT_NOTES_PER_BATCH);
65
66/// Maximum number of input notes that can be consumed in a single block.
67pub const MAX_INPUT_NOTES_PER_BLOCK: usize = MAX_OUTPUT_NOTES_PER_BLOCK;
68
69/// The maximum number of accounts that can be updated in a single block.
70pub const MAX_ACCOUNTS_PER_BLOCK: usize = MAX_ACCOUNTS_PER_BATCH * MAX_BATCHES_PER_BLOCK;
71const _: () = assert!(MAX_ACCOUNTS_PER_BLOCK >= MAX_ACCOUNTS_PER_BATCH);
72const _: () = assert!(MAX_ACCOUNTS_PER_BLOCK >= MAX_BATCHES_PER_BLOCK);