-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: - `TxParameters` are replaced with `TxPolicies` - `GasPrice` and `Maturity` fields are optional - `TxPolicies` introduced new fields: - `WitnessLimit` - allows the limitation of the maximum size of witnesses in bytes. - `MaxFee` - allows the upper bound for the maximum fee that users agree to pay for the transaction. - The `ScriptGasLimit` only limits the script execution. Previously, the `ScriptGasLimit` also limited the predicate execution time, but it is not valid anymore. So, it is not possible to use the `ScriptGasLimit` for transaction cost limitations. A new `MaxFee` policy is a way to do that. The `GasLimit` field was removed from the `Create` transaction because it only relates to the script execution(which the `Create` transaction doesn't have). - The new `WhitnessLimit` also impacts the `max_gas` and `max_fee` calculation along with the `ScriptGasLimit`(in the case of `Create` transaction only `WitnessLimit` affects the `max_gas` and `max_fee`). - The minimal gas also charges the user for transaction ID calculation. - Each transaction requires setting the `GasPrice` policy. - Previously, `GasLimit` should be less than the `MAX_GAS_PER_TX` constant. After removing this field from the `Create` transaction, it is impossible to require it. Instead, it requires that `max_gas <= MAX_GAS_PER_TX` for any transaction. Consequently, any `Script` transaction that uses `MAX_GAS_PER_TX` as a `GasLimit` will always fail because of a new rule. Setting the estimated gas usage instead solves the problem. - If the `max_fee > policies.max_fee`, then transaction will be rejected. - If the `witnessses_size > policies.witness_limit`, then transaction will be rejected. - `get_message_proof` not uses `Nonce` instead of the message_id - predicates do not use `ChainId` for address calculation - `manual_blocks_enabled` is replaced with `debug` in local chain config - `fee_checked_from_tx` uses `FeeParameters` - `fuel_tx::ConsensusParameters` were refactored - this also affects us - when building a transaction_builder the `BuildableTransacion` trait needs to be in scope - `utxo_validation` and `manual_blocks` are enabled by default for test providers - node config does not have `local_node` anymore use `default` - `let node_config = Config::default();` Thanks @MujkicA for updating the documentation. Co-authored-by: MujkicA <[email protected]> Co-authored-by: Ahmed Sagdati <[email protected]>
- Loading branch information
1 parent
d8704e1
commit b9cac99
Showing
58 changed files
with
1,143 additions
and
858 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Transaction policies | ||
|
||
<!-- This section should explain what tx policies are and how to configure them --> | ||
<!-- tx_policies:example:start --> | ||
Transaction policies are defined as follows: | ||
|
||
```rust,ignore | ||
{{#include ../../../packages/fuels-core/src/types/wrappers/transaction.rs:tx_policies_struct}} | ||
``` | ||
|
||
Where: | ||
|
||
1. **Gas Price** - Maximum gas price for transaction. | ||
2. **Witness Limit** - The maximum amount of witness data allowed for the transaction. | ||
3. **Maturity** - Block until which the transaction cannot be included. | ||
4. **Max Fee** - The maximum fee payable by this transaction. | ||
5. **Script Gas Limit** - The maximum amount of gas the transaction may consume for executing its script code. | ||
|
||
When the **Script Gas Limit** is not set, the Rust SDK will estimate the consumed gas in the background and set it as the limit. Similarly, if no **Gas Price** is defined, the Rust SDK defaults to the network's minimum gas price. | ||
|
||
**Witness Limit** makes use of the following default values for script and create transactions: | ||
|
||
```rust,ignore | ||
{{#include ../../../packages/fuels-core/src/utils/constants.rs:witness_default}} | ||
``` | ||
|
||
You can configure these parameters by creating an instance of `TxPolicies` and passing it to a chain method called `with_tx_policies`: | ||
<!-- tx_policies:example:end--> | ||
|
||
```rust,ignore | ||
{{#include ../../../examples/contracts/src/lib.rs:tx_policies}} | ||
``` | ||
|
||
<!-- This section should explain how to use the default tx policy --> | ||
<!-- tx_policies_default:example:start --> | ||
You can also use `TxPolicies::default()` to use the default values. | ||
<!-- tx_policies_default:example:end --> | ||
|
||
This way: | ||
|
||
```rust,ignore | ||
{{#include ../../../examples/contracts/src/lib.rs:tx_policies_default}} | ||
``` | ||
|
||
As you might have noticed, `TxPolicies` can also be specified when deploying contracts or transferring assets by passing it to the respective methods. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.