1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! VM parameters
use *;
use ;
use mem;
/* FLAG AND REGISTER TYPES */
/// Register count for checking constraints
pub const VM_REGISTER_COUNT: usize = 64;
/// Contains zero (0), for convenience.
pub const REG_ZERO: usize = 0x00;
/// Contains one (1), for convenience.
pub const REG_ONE: usize = 0x01;
/// Contains overflow/underflow of addition, subtraction, and multiplication.
pub const REG_OF: usize = 0x02;
/// The program counter. Memory address of the current instruction.
pub const REG_PC: usize = 0x03;
/// Memory address of bottom of current writable stack area.
pub const REG_SSP: usize = 0x04;
/// Memory address on top of current writable stack area (points to free
/// memory).
pub const REG_SP: usize = 0x05;
/// Memory address of beginning of current call frame.
pub const REG_FP: usize = 0x06;
/// Memory address below the current bottom of the heap (points to free memory).
pub const REG_HP: usize = 0x07;
/// Error codes for particular operations.
pub const REG_ERR: usize = 0x08;
/// Remaining gas globally.
pub const REG_GGAS: usize = 0x09;
/// Remaining gas in the context.
pub const REG_CGAS: usize = 0x0a;
/// Received balance for this context.
pub const REG_BAL: usize = 0x0b;
/// Pointer to the start of the currently-executing code.
pub const REG_IS: usize = 0x0c;
/// Return value or pointer.
pub const REG_RET: usize = 0x0d;
/// Return value length in bytes.
pub const REG_RETL: usize = 0x0e;
/// Flags register.
pub const REG_FLAG: usize = 0x0f;
/// Smallest writable register
pub const REG_WRITABLE: usize = 0x10;
/* END */
/* MEMORY TYPES */
/// Length of a word, in bytes
pub const WORD_SIZE: usize = ;
/// Maximum memory word count
pub const FUEL_MAX_MEMORY_SIZE: u64 = 64;
/// Maximum VM RAM, in bytes.
pub const VM_MAX_RAM: u64 = 16 * 1024 * FUEL_MAX_MEMORY_SIZE * WORD_SIZE as u64;
/// Maximum memory access size, in bytes.
pub const MEM_MAX_ACCESS_SIZE: u64 = VM_MAX_RAM;
/// Maximum size of a fuel program (unused)
pub const FUEL_MAX_PROGRAM_SIZE: usize = 16 * /* KB */ 1024;
// no limits to heap for now.
/// Encoded len of a register id in an instruction (unused)
pub const VM_REGISTER_WIDTH: u8 = 6;
/// Transaction offset in the VM memory
pub const VM_TX_MEMORY: usize = LEN // Tx ID
+ WORD_SIZE // Tx size
+ MAX_INPUTS as usize * ; // Color/Balance coin input pairs
/// Empty merkle root for receipts tree
pub const EMPTY_RECEIPTS_MERKLE_ROOT: = ;