diff --git a/src/fuel-vm/index.md b/src/fuel-vm/index.md index cea85fec..533e8442 100644 --- a/src/fuel-vm/index.md +++ b/src/fuel-vm/index.md @@ -149,7 +149,7 @@ If script bytecode is present, transaction validation requires execution. The VM is [initialized](#vm-initialization), then: 1. `$pc` and `$is` are set to the start of the transaction's script bytecode. -1. `$ggas` and `$cgas` are set to `tx.gasLimit`. +1. `$ggas` and `$cgas` are set to `tx.scriptGasLimit`. Following initialization, execution begins. diff --git a/src/fuel-vm/instruction-set.md b/src/fuel-vm/instruction-set.md index eafcfed1..dec89c09 100644 --- a/src/fuel-vm/instruction-set.md +++ b/src/fuel-vm/instruction-set.md @@ -2442,7 +2442,7 @@ Get [fields from the transaction](../tx-format/transaction.md). | name | `imm` | set `$rA` to | |-------------------------------------------|---------|-------------------------------------------------------------------| | `GTF_TYPE` | `0x001` | `tx.type` | -| `GTF_SCRIPT_GAS_LIMIT` | `0x002` | `tx.gasLimit` | +| `GTF_SCRIPT_GAS_LIMIT` | `0x002` | `tx.scriptGasLimit` | | `GTF_SCRIPT_SCRIPT_LENGTH` | `0x003` | `tx.scriptLength` | | `GTF_SCRIPT_SCRIPT_DATA_LENGTH` | `0x004` | `tx.scriptDataLength` | | `GTF_SCRIPT_INPUTS_COUNT` | `0x005` | `tx.inputsCount` | diff --git a/src/protocol/tx-validity.md b/src/protocol/tx-validity.md index 2ca48fab..0bacccd4 100644 --- a/src/protocol/tx-validity.md +++ b/src/protocol/tx-validity.md @@ -144,7 +144,7 @@ def unavailable_balance(tx, asset_id) -> int: return sentBalance def fee_balance(tx, asset_id) -> int: - gas = tx.gasLimit + sum_predicate_gas_used(tx) + gas = tx.scriptGasLimit + sum_predicate_gas_used(tx) gasBalance = gasPrice * gas / GAS_PRICE_FACTOR bytesBalance = size(tx) * GAS_PER_BYTE * gasPrice / GAS_PRICE_FACTOR # Total fee balance @@ -205,7 +205,7 @@ Once the free balances are computed, the [script is executed](../fuel-vm/index.m 1. The unspent free balance `unspentBalance` for each asset ID. 1. The unspent gas `unspentGas` from the `$ggas` register. -The fees incurred for a transaction are `ceiling(((size(tx) * GAS_PER_BYTE) + (tx.gasLimit - unspentGas) + sum(tx.inputs[i].predicateGasUsed)) * tx.gasPrice / GAS_PRICE_FACTOR)`. +The fees incurred for a transaction are `ceiling(((size(tx) * GAS_PER_BYTE) + (tx.scriptGasLimit - unspentGas) + sum(tx.inputs[i].predicateGasUsed)) * tx.gasPrice / GAS_PRICE_FACTOR)`. `size(tx)` includes the entire transaction serialized according to the transaction format, including witness data. This ensures every byte of block space either on Fuel or corresponding DA layer can be accounted for. diff --git a/src/tx-format/transaction.md b/src/tx-format/transaction.md index 8dbfc617..abca7225 100644 --- a/src/tx-format/transaction.md +++ b/src/tx-format/transaction.md @@ -55,22 +55,22 @@ enum ReceiptType : uint8 { } ``` -| name | type | description | -|--------------------|-----------------------------|------------------------------------------------------| -| `gasLimit` | `uint64` | Gas limit for transaction (including predicate gas). | -| `scriptLength` | `uint16` | Script length, in instructions. | -| `scriptDataLength` | `uint16` | Length of script input data, in bytes. | -| `policyTypes` | `uint32` | Bitfield of used policy types. | -| `inputsCount` | `uint8` | Number of inputs. | -| `outputsCount` | `uint8` | Number of outputs. | -| `witnessesCount` | `uint8` | Number of witnesses. | -| `receiptsRoot` | `byte[32]` | Merkle root of receipts. | -| `script` | `byte[]` | Script to execute. | -| `scriptData` | `byte[]` | Script input data (parameters). | -| `policies` | [Policy](./policy.md)`[]` | List of policies, sorted by PolicyType. | -| `inputs` | [Input](./input.md)`[]` | List of inputs. | -| `outputs` | [Output](./output.md)`[]` | List of outputs. | -| `witnesses` | [Witness](./witness.md)`[]` | List of witnesses. | +| name | type | description | +|--------------------|-----------------------------|-----------------------------------------| +| `scriptGasLimit` | `uint64` | Gas limits the script execution. | +| `scriptLength` | `uint16` | Script length, in instructions. | +| `scriptDataLength` | `uint16` | Length of script input data, in bytes. | +| `policyTypes` | `uint32` | Bitfield of used policy types. | +| `inputsCount` | `uint8` | Number of inputs. | +| `outputsCount` | `uint8` | Number of outputs. | +| `witnessesCount` | `uint8` | Number of witnesses. | +| `receiptsRoot` | `byte[32]` | Merkle root of receipts. | +| `script` | `byte[]` | Script to execute. | +| `scriptData` | `byte[]` | Script input data (parameters). | +| `policies` | [Policy](./policy.md)`[]` | List of policies, sorted by PolicyType. | +| `inputs` | [Input](./input.md)`[]` | List of inputs. | +| `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 `len()` that returns the number of bytes of a field.