fuel_vm/
consts.rs

1//! VM parameters
2
3use fuel_types::{
4    AssetId,
5    Bytes32,
6    Word,
7};
8
9use core::mem;
10
11/// Register count for checking constraints
12pub const VM_REGISTER_COUNT: usize = 64;
13
14/// The number of readable registers.
15pub const VM_REGISTER_SYSTEM_COUNT: usize = 16;
16
17/// The number of writable registers.
18pub const VM_REGISTER_PROGRAM_COUNT: usize = VM_REGISTER_COUNT - VM_REGISTER_SYSTEM_COUNT;
19
20// MEMORY TYPES
21
22/// Length of a word, in bytes
23pub const WORD_SIZE: usize = mem::size_of::<Word>();
24
25/// Maximum memory in MiB
26pub const FUEL_MAX_MEMORY_SIZE: u64 = 64;
27
28/// Maximum VM RAM, in bytes.
29pub const VM_MAX_RAM: u64 = 1024 * 1024 * FUEL_MAX_MEMORY_SIZE;
30
31/// Size of the VM memory, in bytes.
32#[allow(clippy::cast_possible_truncation)]
33pub const MEM_SIZE: usize = VM_MAX_RAM as usize;
34
35static_assertions::const_assert!(VM_MAX_RAM < usize::MAX as u64);
36
37// no limits to heap for now.
38
39/// Offset for the assets balances in VM memory
40pub const VM_MEMORY_BASE_ASSET_ID_OFFSET: usize = Bytes32::LEN;
41
42/// Offset for the assets balances in VM memory
43pub const VM_MEMORY_BALANCES_OFFSET: usize =
44    VM_MEMORY_BASE_ASSET_ID_OFFSET + AssetId::LEN;
45
46/// Encoded len of a register id in an instruction (unused)
47pub const VM_REGISTER_WIDTH: u8 = 6;
48
49/// Empty merkle root for receipts tree
50pub const EMPTY_RECEIPTS_MERKLE_ROOT: [u8; 32] = [
51    0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f,
52    0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b,
53    0x78, 0x52, 0xb8, 0x55,
54];