Skip to main content

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