Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some clarification after implementation #533

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/fuel-vm/instruction-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -2508,8 +2508,7 @@ Get [fields from the transaction](../tx-format/transaction.md).
| `GTF_OUTPUT_CONTRACT_CREATED_STATE_ROOT` | `0x308` | Memory address of `tx.outputs[$rB].stateRoot` |
| `GTF_WITNESS_DATA_LENGTH` | `0x400` | `tx.witnesses[$rB].dataLength` |
| `GTF_WITNESS_DATA` | `0x401` | Memory address of `tx.witnesses[$rB].data` |
| `GTF_POLICY_COUNT` | `0x500` | `count_ones(tx.policyTypes)` |
| `GTF_POLICY_TYPE` | `0x501` | `tx.policies[$rB].type` |
| `GTF_POLICY_TYPES` | `0x501` | `tx.policies.policyTypes` |
| `GTF_POLICY_GAS_PRICE` | `0x502` | `tx.policies[0x00].gasPrice` |
| `GTF_POLICY_WITNESS_LIMIT` | `0x504` | `tx.policies[count_ones(0b11 & tx.policyTypes) - 1].witnessLimit` |
| `GTF_POLICY_MATURITY` | `0x505` | `tx.policies[count_ones(0b111 & tx.policyTypes) - 1].maturity` |
Expand Down
5 changes: 4 additions & 1 deletion src/tx-format/transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ enum ReceiptType : uint8 {
| `outputs` | [Output](./output.md)`[]` | List of outputs. |
| `witnesses` | [Witness](./witness.md)`[]` | List of witnesses. |

Given helper `max_gas()` returns the maximum gas that the transaction can use.
Copy link
Member

@Voxelot Voxelot Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we define max_gas() anywhere? It might be confusing without more context. i.e in tx-validity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is what you've started in the #529 =D I decided not to describe it here because we have another PR dedicated to the gas model description.

Given helper `len()` that returns the number of bytes of a field.
Given helper `count_ones()` that returns the number of ones in the binary representation of a field.
Given helper `count_variants()` that returns the number of variants in an enum.
Expand All @@ -84,7 +85,7 @@ Transaction is invalid if:
- `scriptDataLength > MAX_SCRIPT_DATA_LENGTH`
- `scriptLength * 4 != len(script)`
- `scriptDataLength != len(scriptData)`
- `gasLimit > MAX_GAS_PER_TX`
- `max_gas(tx) > MAX_GAS_PER_TX`
- No policy of type `PolicyType.GasPrice`
- `count_ones(policyTypes) > count_variants(PolicyType)`
- `policyTypes > sum_variants(PolicyType)`
Expand Down Expand Up @@ -116,6 +117,7 @@ The receipts root `receiptsRoot` is the root of the [binary Merkle tree](../prot
| `outputs` | [Output](./output.md)`[]` | List of outputs. |
| `witnesses` | [Witness](./witness.md)`[]` | List of witnesses. |

Given helper `max_gas()` returns the maximum gas that the transaction can use.
Given helper `count_ones()` that returns the number of ones in the binary representation of a field.
Given helper `count_variants()` that returns the number of variants in an enum.
Given helper `sum_variants()` that sums all variants of an enum.
Expand All @@ -133,6 +135,7 @@ Transaction is invalid if:
- The keys of `storageSlots` are not in ascending lexicographic order
- The computed contract ID (see below) is not equal to the `contractID` of the one `OutputType.ContractCreated` output
- `storageSlotsCount > MAX_STORAGE_SLOTS`
- `max_gas(tx) > MAX_GAS_PER_TX`
- The [Sparse Merkle tree](../protocol/cryptographic-primitives.md#sparse-merkle-tree) root of `storageSlots` is not equal to the `stateRoot` of the one `OutputType.ContractCreated` output
- No policy of type `PolicyType.GasPrice`
- `count_ones(policyTypes) > count_variants(PolicyType)`
Expand Down