Skip to content

Commit 6403901

Browse files
authored
Limit the number of receipts to u16::MAX (#535)
Increases the receipt limit from `u8::MAX` to `u16::MAX`, leaving space for panic and script result. The old limit was not enforced, but FuelLabs/fuel-vm#633 is going to enforce the new rules defined here. The number of receipts is limited separtely from gas, since adding more receipts slows down all instructions that operate on them. Moreover, this change makes the upper bound for memory use clear.
1 parent 1b3b772 commit 6403901

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/fuel-vm/instruction-set.md

+8
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ This page provides a description of all instructions for the FuelVM. Encoding is
125125
- The syntax `MEM[x, y]` used in this page means the memory range starting at byte `x`, of length `y` bytes.
126126
- The syntax `STATE[x, y]` used in this page means the sequence of storage slots starting at key `x` and spanning `y` bytes.
127127

128+
### Panics
129+
128130
Some instructions may _panic_, i.e. enter an unrecoverable state. Additionally, attempting to execute an instruction not in this list causes a panic and consumes no gas. How a panic is handled depends on [context](./index.md#contexts):
129131

130132
- In a predicate context, cease VM execution and return `false`.
@@ -147,6 +149,12 @@ then append an additional receipt to the list of receipts, again modifying `tx.r
147149
| `result` | `uint64` | `1` |
148150
| `gas_used` | `uint64` | Gas consumed by the script. |
149151

152+
### Receipts
153+
154+
The number of receipts is limited to 2<sup>16</sup>, with the last two reserved to panic and script result receipts. Trying to add any other receipts after 2<sup>16</sup>-2 will panic.
155+
156+
### Effects
157+
150158
A few instructions are annotated with the _effects_ they produce, the table below explains each effect:
151159

152160
| effect name | description |

src/identifiers/utxo-id.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The ID of a message is computed as the [hash](../protocol/cryptographic-primitiv
1818

1919
### Message Nonce
2020

21-
The nonce value for `InputMessage` is determined by the sending system and is published at the time the message is sent. The nonce value for `OutputMessage` is computed as the [hash](../protocol/cryptographic-primitives.md#hashing) of the [Transaction ID](./transaction-id.md) that emitted the message and the index of the message receipt `uint8`: `hash(byte[32] ++ uint8)`.
21+
The nonce value for `InputMessage` is determined by the sending system and is published at the time the message is sent. The nonce value for `OutputMessage` is computed as the [hash](../protocol/cryptographic-primitives.md#hashing) of the [Transaction ID](./transaction-id.md) that emitted the message and the index of the message receipt `uint16` (with canonical encoding): `hash(byte[32] ++ canonical(uint16))`.
2222

2323
## Fee ID
2424

0 commit comments

Comments
 (0)