From 5b45319d80b53270a7d558c5ae2924fb5d6fb66a Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 30 May 2023 03:31:29 -0700 Subject: [PATCH 01/18] Update instruction_set.md --- src/vm/instruction_set.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vm/instruction_set.md b/src/vm/instruction_set.md index 2bc5ebdc..d5a9c86d 100644 --- a/src/vm/instruction_set.md +++ b/src/vm/instruction_set.md @@ -1802,14 +1802,16 @@ Panics if: | | | |-------------|------------------------------------------------------| -| Description | Mint `$rA` coins of the current contract's asset ID. | -| Operation | ```mint($rA);``` | -| Syntax | `mint $rA` | -| Encoding | `0x00 rA - - -` | -| Notes | | +| Description | Mint `$rA` coins of the `$rB` ID from the current contract. | +| Operation | ```mint($rA, $rB);``` | +| Syntax | `mint $rA $rB` | +| Encoding | `0x00 rA rB - -` | +| Notes | `$rB` is a pointer to a 256 bit ID in memory | Panic if: +- The asset ID will be constructed using the coin ID construction method. + - Balance of asset ID `MEM[$fp, 32]` of output with contract ID `MEM[$fp, 32]` plus `$rA` overflows - `$fp == 0` (in the script context) From 062375e6a9872870034e49ddb73e162fda2cdb74 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 30 May 2023 03:37:28 -0700 Subject: [PATCH 02/18] Update instruction_set.md --- src/vm/instruction_set.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/vm/instruction_set.md b/src/vm/instruction_set.md index d5a9c86d..aa28c6a7 100644 --- a/src/vm/instruction_set.md +++ b/src/vm/instruction_set.md @@ -1567,11 +1567,13 @@ Block header hashes for blocks with height greater than or equal to current bloc | | | |-------------|------------------------------------------------------| -| Description | Burn `$rA` coins of the current contract's asset ID. | -| Operation | ```burn($rA);``` | -| Syntax | `burn $rA` | -| Encoding | `0x00 rA - - -` | -| Notes | | +| Description | Burn `$rA` coins of the `$rB` ID from the current contract. | +| Operation | ```burn($rA, $rB);``` | +| Syntax | `burn $rA $rB` | +| Encoding | `0x00 rA rB - -` | +| Notes | `$rB` is a pointer to a 256-bit ID in memory. | + +The asset ID is constructed using the coin ID construction method. Panic if: @@ -1808,9 +1810,9 @@ Panics if: | Encoding | `0x00 rA rB - -` | | Notes | `$rB` is a pointer to a 256 bit ID in memory | -Panic if: +The asset ID will be constructed using the coin ID construction method. -- The asset ID will be constructed using the coin ID construction method. +Panic if: - Balance of asset ID `MEM[$fp, 32]` of output with contract ID `MEM[$fp, 32]` plus `$rA` overflows - `$fp == 0` (in the script context) From d3c6e874aff36671c5d12a25794e3bee6dedd503 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 30 May 2023 03:40:43 -0700 Subject: [PATCH 03/18] Update instruction_set.md --- src/vm/instruction_set.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm/instruction_set.md b/src/vm/instruction_set.md index aa28c6a7..6e0dd982 100644 --- a/src/vm/instruction_set.md +++ b/src/vm/instruction_set.md @@ -1808,7 +1808,7 @@ Panics if: | Operation | ```mint($rA, $rB);``` | | Syntax | `mint $rA $rB` | | Encoding | `0x00 rA rB - -` | -| Notes | `$rB` is a pointer to a 256 bit ID in memory | +| Notes | `$rB` is a pointer to a 256-bit ID in memory | The asset ID will be constructed using the coin ID construction method. From 27f7e6982bea61f98073fdfcddfc03db89fade5f Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 30 May 2023 03:45:30 -0700 Subject: [PATCH 04/18] Create asset.md --- src/protocol/id/asset.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/protocol/id/asset.md diff --git a/src/protocol/id/asset.md b/src/protocol/id/asset.md new file mode 100644 index 00000000..54d8d5e0 --- /dev/null +++ b/src/protocol/id/asset.md @@ -0,0 +1,8 @@ +# Asset ID + +The _asset ID_ (also called _asset hash_) of a asset is computed as +the [hash](../cryptographic_primitives.md#hashing) of the `CONTRACT_ID` and a 256-bit `IDENTIFIER`. + +```python +sha256(CONTRACT_ID ++ IDENTIFIER) +``` From 045bbc389b9aeab8e123b8d877b310a379097157 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 30 May 2023 03:46:04 -0700 Subject: [PATCH 05/18] Update index.md --- src/protocol/id/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/protocol/id/index.md b/src/protocol/id/index.md index 3b485a6b..f46402ee 100644 --- a/src/protocol/id/index.md +++ b/src/protocol/id/index.md @@ -4,6 +4,7 @@ This chapter defines how to compute unique identifiers. - [Transaction ID](./transaction.md) - [Contract ID](./contract.md) +- [Asset ID](./asset.md) - [Predicate ID](./predicate.md) - [UTXO ID](./utxo.md) - [Coin ID](./utxo.md#coin-id) From e886b3469a25ac4a44ae36fca34f56313c6c34cf Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 31 May 2023 04:06:11 -0700 Subject: [PATCH 06/18] Update instruction_set.md --- src/vm/instruction_set.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vm/instruction_set.md b/src/vm/instruction_set.md index 6e0dd982..3b90429f 100644 --- a/src/vm/instruction_set.md +++ b/src/vm/instruction_set.md @@ -1797,7 +1797,7 @@ Logs the memory range `MEM[$rC, $rD]`. Panics if: - `$rC + $rD` overflows -- `$rA + $rD > VM_MAX_RAN` +- `$rA + $rD > VM_MAX_RAM` - `$rD > MEM_MAX_ACCESS_SIZE` ### MINT: Mint new coins @@ -1814,6 +1814,8 @@ The asset ID will be constructed using the coin ID construction method. Panic if: +- If asset ID has already been instantiated by another contract. +- `$rD > VM_MAX_RAM` - Balance of asset ID `MEM[$fp, 32]` of output with contract ID `MEM[$fp, 32]` plus `$rA` overflows - `$fp == 0` (in the script context) From 2698ee66b15fb5c277bd2d0fb2bf11ad24544b51 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 31 May 2023 04:35:19 -0700 Subject: [PATCH 07/18] Update receipts.md --- src/protocol/abi/receipts.md | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/protocol/abi/receipts.md b/src/protocol/abi/receipts.md index 5125f7e0..41a9972d 100644 --- a/src/protocol/abi/receipts.md +++ b/src/protocol/abi/receipts.md @@ -23,6 +23,8 @@ All receipts will have a `type` property: - [Panic](#panic-receipt) - [Revert](#revert-receipt) - [Log](#log-receipt) + - [Mint](#mint-receipt) + - [Burn](#burn-receipt) - [LogData](#logdata-receipt) - [Transfer](#transfer-receipt) - [TransferOut](#transferout-receipt) @@ -124,6 +126,46 @@ _Important note:_ For the JSON representation of receipts, we represent 64-bit u } ``` +## Mint Receipt + +- `type`: `Mint`. +- `id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID. +- `contract_id`: Hexadecimal string representation of the 256-bit (32-byte) contract ID of the current context. +- `val`: Decimal string representation of a 64-bit unsigned integer; value of register `$rA`. +- `pc`: Hexadecimal string representation of a 64-bit unsigned integer; value of register `$pc`. +- `is`: Hexadecimal string representation of a 64-bit unsigned integer; value of register `$is`. + +```json +{ + "type": "Mint", + "id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", + "contract_id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", + "val": "18446744073709551613", + "pc": "0xffffffffffffffff", + "is": "0xfffffffffffffffe" +} +``` + +## Burn Receipt + +- `type`: `Burn`. +- `id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID. +- `contract_id`: Hexadecimal string representation of the 256-bit (32-byte) contract ID of the current context. +- `val`: Decimal string representation of a 64-bit unsigned integer; value of register `$rA`. +- `pc`: Hexadecimal string representation of a 64-bit unsigned integer; value of register `$pc`. +- `is`: Hexadecimal string representation of a 64-bit unsigned integer; value of register `$is`. + +```json +{ + "type": "Burn", + "id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", + "contract_id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", + "val": "18446744073709551613", + "pc": "0xffffffffffffffff", + "is": "0xfffffffffffffffe" +} +``` + ## LogData Receipt - `type`: `LogData`. From 816362be784f38338b5cbee7e8dd46c850f62ae8 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 5 Jun 2023 05:38:51 -0700 Subject: [PATCH 08/18] Update instruction_set.md --- src/vm/instruction_set.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/vm/instruction_set.md b/src/vm/instruction_set.md index 3b90429f..b3af97d9 100644 --- a/src/vm/instruction_set.md +++ b/src/vm/instruction_set.md @@ -1584,6 +1584,17 @@ For output with contract ID `MEM[$fp, 32]`, decrease balance of asset ID `MEM[$f This modifies the `balanceRoot` field of the appropriate output. +Append a receipt to the list of receipts, modifying tx.receiptsRoot: + +| name | type | description | +|----------|---------------|---------------------------------------------------------------------------| +| `type` | `ReceiptType` | `ReceiptType.Burn` | +| `id` | `byte[32]` | Asset sub identifier `MEM[$rB, $rB + 32]`. | +| `contract_id` | `byte[32]` | Contract ID of the current context. | +| `val` | `uint64` | Value of register `$rA`. | +| `pc` | `uint64` | Value of register `$pc`. | +| `is` | `uint64` | Value of register `$is`. | + ### CALL: Call contract | | | @@ -1823,6 +1834,17 @@ For output with contract ID `MEM[$fp, 32]`, increase balance of asset ID `MEM[$f This modifies the `balanceRoot` field of the appropriate output. +Append a receipt to the list of receipts, modifying tx.receiptsRoot: + +| name | type | description | +|----------|---------------|---------------------------------------------------------------------------| +| `type` | `ReceiptType` | `ReceiptType.Mint` | +| `id` | `byte[32]` | Asset sub identifier `MEM[$rB, $rB + 32]`. | +| `contract_id` | `byte[32]` | Contract ID of the current context. | +| `val` | `uint64` | Value of register `$rA`. | +| `pc` | `uint64` | Value of register `$pc`. | +| `is` | `uint64` | Value of register `$is`. | + ### RETD: Return from context with data | | | From c4aab7af5e80efb33925ad2b76dc75e8e1b72736 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 6 Jun 2023 05:48:00 -0700 Subject: [PATCH 09/18] Update SUB_IDENTIFIER --- src/protocol/id/asset.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocol/id/asset.md b/src/protocol/id/asset.md index 54d8d5e0..df294af3 100644 --- a/src/protocol/id/asset.md +++ b/src/protocol/id/asset.md @@ -1,8 +1,8 @@ # Asset ID The _asset ID_ (also called _asset hash_) of a asset is computed as -the [hash](../cryptographic_primitives.md#hashing) of the `CONTRACT_ID` and a 256-bit `IDENTIFIER`. +the [hash](../cryptographic_primitives.md#hashing) of the `CONTRACT_ID` and a 256-bit `SUB_IDENTIFIER`. ```python -sha256(CONTRACT_ID ++ IDENTIFIER) +sha256(CONTRACT_ID ++ SUB_IDENTIFIER) ``` From 3e9fdfd7397fdf502244aafdc8f32d58db8cc81a Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 6 Jun 2023 05:59:13 -0700 Subject: [PATCH 10/18] Small nits. --- src/vm/instruction_set.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/vm/instruction_set.md b/src/vm/instruction_set.md index b3af97d9..b34925ec 100644 --- a/src/vm/instruction_set.md +++ b/src/vm/instruction_set.md @@ -1571,9 +1571,9 @@ Block header hashes for blocks with height greater than or equal to current bloc | Operation | ```burn($rA, $rB);``` | | Syntax | `burn $rA $rB` | | Encoding | `0x00 rA rB - -` | -| Notes | `$rB` is a pointer to a 256-bit ID in memory. | +| Notes | `$rB` is a pointer to a 32 byte ID in memory. | -The asset ID is constructed using the coin ID construction method. +The asset ID is constructed using the asset ID construction method. Panic if: @@ -1819,14 +1819,13 @@ Panics if: | Operation | ```mint($rA, $rB);``` | | Syntax | `mint $rA $rB` | | Encoding | `0x00 rA rB - -` | -| Notes | `$rB` is a pointer to a 256-bit ID in memory | +| Notes | `$rB` is a pointer to a 32 byte ID in memory | -The asset ID will be constructed using the coin ID construction method. +The asset ID will be constructed using the asset ID construction method. Panic if: -- If asset ID has already been instantiated by another contract. -- `$rD > VM_MAX_RAM` +- `$rB + 32 > VM_MAX_RAM` - Balance of asset ID `MEM[$fp, 32]` of output with contract ID `MEM[$fp, 32]` plus `$rA` overflows - `$fp == 0` (in the script context) From c7610c6b5fac8da3f5317782a3304363f6ef831d Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 6 Jun 2023 06:00:09 -0700 Subject: [PATCH 11/18] Small nits. --- src/vm/instruction_set.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vm/instruction_set.md b/src/vm/instruction_set.md index b34925ec..bf1f0f2c 100644 --- a/src/vm/instruction_set.md +++ b/src/vm/instruction_set.md @@ -1577,6 +1577,7 @@ The asset ID is constructed using the asset ID construction method. Panic if: +- `$rB + 32 > VM_MAX_RAM` - Balance of asset ID `MEM[$fp, 32]` of output with contract ID `MEM[$fp, 32]` minus `$rA` underflows - `$fp == 0` (in the script context) From b48cdd6a853e094c4cfbbdc0697cf4f6fd019970 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 6 Jun 2023 06:01:34 -0700 Subject: [PATCH 12/18] sub_id --- src/vm/instruction_set.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vm/instruction_set.md b/src/vm/instruction_set.md index bf1f0f2c..ed3409ae 100644 --- a/src/vm/instruction_set.md +++ b/src/vm/instruction_set.md @@ -1590,7 +1590,7 @@ Append a receipt to the list of receipts, modifying tx.receiptsRoot: | name | type | description | |----------|---------------|---------------------------------------------------------------------------| | `type` | `ReceiptType` | `ReceiptType.Burn` | -| `id` | `byte[32]` | Asset sub identifier `MEM[$rB, $rB + 32]`. | +| `sub_id` | `byte[32]` | Asset sub identifier `MEM[$rB, $rB + 32]`. | | `contract_id` | `byte[32]` | Contract ID of the current context. | | `val` | `uint64` | Value of register `$rA`. | | `pc` | `uint64` | Value of register `$pc`. | @@ -1839,7 +1839,7 @@ Append a receipt to the list of receipts, modifying tx.receiptsRoot: | name | type | description | |----------|---------------|---------------------------------------------------------------------------| | `type` | `ReceiptType` | `ReceiptType.Mint` | -| `id` | `byte[32]` | Asset sub identifier `MEM[$rB, $rB + 32]`. | +| `sub_id` | `byte[32]` | Asset sub identifier `MEM[$rB, $rB + 32]`. | | `contract_id` | `byte[32]` | Contract ID of the current context. | | `val` | `uint64` | Value of register `$rA`. | | `pc` | `uint64` | Value of register `$pc`. | From 62e613f7460a933dfe08a4b8de1505ab19adb961 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 6 Jun 2023 06:03:37 -0700 Subject: [PATCH 13/18] sub_id in receipts. --- src/protocol/abi/receipts.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/protocol/abi/receipts.md b/src/protocol/abi/receipts.md index 41a9972d..0c79c18e 100644 --- a/src/protocol/abi/receipts.md +++ b/src/protocol/abi/receipts.md @@ -129,7 +129,7 @@ _Important note:_ For the JSON representation of receipts, we represent 64-bit u ## Mint Receipt - `type`: `Mint`. -- `id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID. +- `sub_id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID. - `contract_id`: Hexadecimal string representation of the 256-bit (32-byte) contract ID of the current context. - `val`: Decimal string representation of a 64-bit unsigned integer; value of register `$rA`. - `pc`: Hexadecimal string representation of a 64-bit unsigned integer; value of register `$pc`. @@ -138,7 +138,7 @@ _Important note:_ For the JSON representation of receipts, we represent 64-bit u ```json { "type": "Mint", - "id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", + "sub_id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", "contract_id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", "val": "18446744073709551613", "pc": "0xffffffffffffffff", @@ -149,7 +149,7 @@ _Important note:_ For the JSON representation of receipts, we represent 64-bit u ## Burn Receipt - `type`: `Burn`. -- `id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID. +- `sub_id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID. - `contract_id`: Hexadecimal string representation of the 256-bit (32-byte) contract ID of the current context. - `val`: Decimal string representation of a 64-bit unsigned integer; value of register `$rA`. - `pc`: Hexadecimal string representation of a 64-bit unsigned integer; value of register `$pc`. @@ -158,7 +158,7 @@ _Important note:_ For the JSON representation of receipts, we represent 64-bit u ```json { "type": "Burn", - "id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", + "sub_id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", "contract_id": "0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051", "val": "18446744073709551613", "pc": "0xffffffffffffffff", From 65b03c7edcf8bcd724ecbd200a66f25c7f5d7c3a Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 20 Jun 2023 04:46:44 -0700 Subject: [PATCH 14/18] Update transaction.md --- src/protocol/tx_format/transaction.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/protocol/tx_format/transaction.md b/src/protocol/tx_format/transaction.md index 6dbd3c85..c5e65a4a 100644 --- a/src/protocol/tx_format/transaction.md +++ b/src/protocol/tx_format/transaction.md @@ -51,6 +51,8 @@ enum ReceiptType : uint8 { TransferOut = 8, ScriptResult = 9, MessageOut = 10, + Mint = 11 + Burn = 12 } ``` From 1a421c947f938ee13103364bba15b7f4b4927bc9 Mon Sep 17 00:00:00 2001 From: Brandon Kite Date: Mon, 10 Jul 2023 16:20:24 -0700 Subject: [PATCH 15/18] merge conflicts --- src/identifiers/index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/identifiers/index.md b/src/identifiers/index.md index 4cd66523..0cff02bb 100644 --- a/src/identifiers/index.md +++ b/src/identifiers/index.md @@ -2,9 +2,10 @@ This chapter defines how to compute unique identifiers. -- [Transaction ID](./transaction-id.md) +- [Asset ID](./asset.md) - [Contract ID](./contract-id.md) - [Predicate ID](./predicate-id.md) +- [Transaction ID](./transaction-id.md) - [UTXO ID](./utxo-id.md) - [Coin ID](./utxo-id.md#coin-id) - [Message ID](./utxo-id.md#message-id) From 7cd030ca22e6fb41ee57889307b923e3069f5d40 Mon Sep 17 00:00:00 2001 From: Brandon Kite Date: Mon, 10 Jul 2023 16:23:01 -0700 Subject: [PATCH 16/18] fix links --- src/identifiers/asset.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/identifiers/asset.md b/src/identifiers/asset.md index df294af3..7f51fb51 100644 --- a/src/identifiers/asset.md +++ b/src/identifiers/asset.md @@ -1,7 +1,7 @@ # Asset ID The _asset ID_ (also called _asset hash_) of a asset is computed as -the [hash](../cryptographic_primitives.md#hashing) of the `CONTRACT_ID` and a 256-bit `SUB_IDENTIFIER`. +the [hash](../protocol/cryptographic-primitives.md#hashing) of the `CONTRACT_ID` and a 256-bit `SUB_IDENTIFIER`. ```python sha256(CONTRACT_ID ++ SUB_IDENTIFIER) From 351eff19c846e9c3de6d7bb791f4ad10391fee9c Mon Sep 17 00:00:00 2001 From: Brandon Kite Date: Mon, 10 Jul 2023 16:34:25 -0700 Subject: [PATCH 17/18] fix asset id construction --- src/fuel-vm/instruction-set.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/fuel-vm/instruction-set.md b/src/fuel-vm/instruction-set.md index c8f67e50..844e1968 100644 --- a/src/fuel-vm/instruction-set.md +++ b/src/fuel-vm/instruction-set.md @@ -1565,23 +1565,23 @@ Block header hashes for blocks with height greater than or equal to current bloc ### BURN: Burn existing coins -| | | -|-------------|------------------------------------------------------| +| | | +|-------------|-------------------------------------------------------------| | Description | Burn `$rA` coins of the `$rB` ID from the current contract. | -| Operation | ```burn($rA, $rB);``` | -| Syntax | `burn $rA $rB` | -| Encoding | `0x00 rA rB - -` | -| Notes | `$rB` is a pointer to a 32 byte ID in memory. | +| Operation | ```burn($rA, $rB);``` | +| Syntax | `burn $rA $rB` | +| Encoding | `0x00 rA rB - -` | +| Notes | `$rB` is a pointer to a 32 byte ID in memory. | The asset ID is constructed using the asset ID construction method. Panic if: - `$rB + 32 > VM_MAX_RAM` -- Balance of asset ID `MEM[$fp, 32]` of output with contract ID `MEM[$fp, 32]` minus `$rA` underflows +- Balance of asset ID from `constructAssetID(MEM[$fp, 32], MEM[$rB, 32])` of output with contract ID `MEM[$fp, 32]` minus `$rA` underflows - `$fp == 0` (in the script context) -For output with contract ID `MEM[$fp, 32]`, decrease balance of asset ID `MEM[$fp, 32]` by `$rA`. +For output with contract ID `MEM[$fp, 32]`, decrease balance of asset ID `constructAssetID(MEM[$fp, 32], MEM[$rB, 32])` by `$rA`. This modifies the `balanceRoot` field of the appropriate output. @@ -1814,23 +1814,23 @@ Panics if: ### MINT: Mint new coins -| | | -|-------------|------------------------------------------------------| +| | | +|-------------|-------------------------------------------------------------| | Description | Mint `$rA` coins of the `$rB` ID from the current contract. | -| Operation | ```mint($rA, $rB);``` | -| Syntax | `mint $rA $rB` | -| Encoding | `0x00 rA rB - -` | -| Notes | `$rB` is a pointer to a 32 byte ID in memory | +| Operation | ```mint($rA, $rB);``` | +| Syntax | `mint $rA $rB` | +| Encoding | `0x00 rA rB - -` | +| Notes | `$rB` is a pointer to a 32 byte ID in memory | The asset ID will be constructed using the asset ID construction method. Panic if: - `$rB + 32 > VM_MAX_RAM` -- Balance of asset ID `MEM[$fp, 32]` of output with contract ID `MEM[$fp, 32]` plus `$rA` overflows +- Balance of asset ID `constructAssetID(MEM[$fp, 32], MEM[$rB])` of output with contract ID `MEM[$fp, 32]` plus `$rA` overflows - `$fp == 0` (in the script context) -For output with contract ID `MEM[$fp, 32]`, increase balance of asset ID `MEM[$fp, 32]` by `$rA`. +For output with contract ID `MEM[$fp, 32]`, increase balance of asset ID `constructAssetID(MEM[$fp, 32], MEM[$rB])` by `$rA`. This modifies the `balanceRoot` field of the appropriate output. From 4c88a94f3e79f0a9f6c92f546202b164fc8dbe5f Mon Sep 17 00:00:00 2001 From: Brandon Kite Date: Mon, 7 Aug 2023 14:39:05 -0700 Subject: [PATCH 18/18] Apply suggestions from code review Co-authored-by: Green Baneling --- src/abi/receipts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/abi/receipts.md b/src/abi/receipts.md index 32adef7c..1fbfdf7c 100644 --- a/src/abi/receipts.md +++ b/src/abi/receipts.md @@ -129,7 +129,7 @@ _Important note:_ For the JSON representation of receipts, we represent 64-bit u ## Mint Receipt - `type`: `Mint`. -- `sub_id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID. +- `sub_id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID; derived from register `$rB`. - `contract_id`: Hexadecimal string representation of the 256-bit (32-byte) contract ID of the current context. - `val`: Decimal string representation of a 64-bit unsigned integer; value of register `$rA`. - `pc`: Hexadecimal string representation of a 64-bit unsigned integer; value of register `$pc`. @@ -149,7 +149,7 @@ _Important note:_ For the JSON representation of receipts, we represent 64-bit u ## Burn Receipt - `type`: `Burn`. -- `sub_id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID. +- `sub_id`: Hexadecimal string representation of the 256-bit (32-byte) asset sub identifier ID; derived from register `$rB`. - `contract_id`: Hexadecimal string representation of the 256-bit (32-byte) contract ID of the current context. - `val`: Decimal string representation of a 64-bit unsigned integer; value of register `$rA`. - `pc`: Hexadecimal string representation of a 64-bit unsigned integer; value of register `$pc`.