From f32f5dd391199edcafe229619376ac72ea1c7209 Mon Sep 17 00:00:00 2001 From: John Adler Date: Mon, 6 Jun 2022 15:31:14 -0400 Subject: [PATCH] Fix `balanceOfStart` usage. (#327) * Fix balanceOfStart usage. * Fix helper wording. --- specs/vm/opcodes.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/specs/vm/opcodes.md b/specs/vm/opcodes.md index 5ffbf4f6..bed87242 100644 --- a/specs/vm/opcodes.md +++ b/specs/vm/opcodes.md @@ -1084,6 +1084,8 @@ This modifies the `balanceRoot` field of the appropriate output. | Encoding | `0x00 rA rB rC rD` | | Notes | | +Given helper `balanceOfStart(asset_id: byte[32]) -> uint32` which returns the memory address of the remaining free balance of `asset_id`, or panics if `asset_id` has no free balance remaining. + Panic if: - `$rA + 32` overflows @@ -1495,7 +1497,7 @@ Panic if: | Encoding | `0x00 rA rB rC -` | | Notes | | -Given helper `balanceOfStart(asset_id: byte[32]) -> uint32` which returns the memory address of `asset_id` balance, or `0` if `asset_id` has no balance. +Given helper `balanceOfStart(asset_id: byte[32]) -> uint32` which returns the memory address of the remaining free balance of `asset_id`, or panics if `asset_id` has no free balance remaining. Panic if: @@ -1504,7 +1506,7 @@ Panic if: - `$rA + 32 > VM_MAX_RAM` - `$rC + 32 > VM_MAX_RAM` - Contract with ID `MEM[$rA, 32]` is not in `tx.inputs` -- In an external context, if `$rB > MEM[balanceOf(MEM[$rC, 32]), 8]` +- In an external context, if `$rB > MEM[balanceOfStart(MEM[$rC, 32]), 8]` - In an internal context, if `$rB` is greater than the balance of asset ID `MEM[$rC, 32]` of output with contract ID `MEM[$fp, 32]` - `$rB == 0` @@ -1534,7 +1536,7 @@ This modifies the `balanceRoot` field of the appropriate output(s). | Encoding | `0x00 rA rB rC rD` | | Notes | | -Given helper `balanceOfStart(asset_id: byte[32]) -> uint32` which returns the memory address of `asset_id` balance, or `0` if `asset_id` has no balance. +Given helper `balanceOfStart(asset_id: byte[32]) -> uint32` which returns the memory address of the remaining free balance of `asset_id`, or panics if `asset_id` has no free balance remaining. Panic if: @@ -1543,7 +1545,7 @@ Panic if: - `$rA + 32 > VM_MAX_RAM` - `$rD + 32 > VM_MAX_RAM` - `$rB > tx.outputsCount` -- In an external context, if `$rC > MEM[balanceOf(MEM[$rD, 32]), 8]` +- In an external context, if `$rC > MEM[balanceOfStart(MEM[$rD, 32]), 8]` - In an internal context, if `$rC` is greater than the balance of asset ID `MEM[$rD, 32]` of output with contract ID `MEM[$fp, 32]` - `$rC == 0` - `tx.outputs[$rB].type != OutputType.Variable`