diff --git a/CHANGELOG.md b/CHANGELOG.md index f158f070fdf..6b29b586b2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,40 +8,69 @@ and this project adheres to [Semantic Versioning](http://semver.org/). Description of the upcoming release here. +## [Version 0.21.0] + +This release focuses on preparing `fuel-core` for the mainnet environment: +- Most of the changes improved the security and stability of the node. +- The gas model was reworked to cover all aspects of execution. +- The benchmarking system was significantly enhanced, covering worst scenarios. +- A new set of benchmarks was added to track the accuracy of gas prices. +- Optimized heavy operations and removed/replaced exploitable functionality. + +Besides that, there are more concrete changes: +- Unified naming conventions for all CLI arguments. Added dependencies between related fields to avoid misconfiguration in case of missing arguments. Added `--debug` flag that enables additional functionality like a debugger. +- Improved telemetry to cover the internal work of services and added support for the Pyroscope, allowing it to generate real-time flamegraphs to track performance. +- Improved stability of the P2P layer and adjusted the updating of reputation. The speed of block synchronization was significantly increased. +- The node is more stable and resilient. Improved DoS resistance and resource management. Fixed critical bugs during state transition. +- Reworked the `Mint` transaction to accumulate the fee from block production inside the contract defined by the block producer. + +FuelVM received a lot of safety and stability improvements: +- The audit helped identify some bugs and errors that have been successfully fixed. +- Updated the gas price model to charge for resources used during the transaction lifecycle. +- Added `no_std` and 32 bit system support. This opens doors for fraud proving in the future. +- Removed the `ChainId` from the `PredicateId` calculation, allowing the use of predicates cross-chain. +- Improvements in the performance of some storage-related opcodes. +- Support the `ECAL` instruction that allows adding custom functionality to the VM. It can be used to create unique rollups or advanced indexers in the future. +- Support of [transaction policies](https://github.com/FuelLabs/fuel-vm/blob/master/CHANGELOG.md#version-0420) provides additional safety for the user. + It also allows the implementation of a multi-dimensional price model in the future, making the transaction execution cheaper and allowing more transactions that don't affect storage. +- Refactored errors, returning more detailed errors to the user, simplifying debugging. + ### Added - [#1503](https://github.com/FuelLabs/fuel-core/pull/1503): Add `gtf` opcode sanity check. - [#1502](https://github.com/FuelLabs/fuel-core/pull/1502): Added price benchmark for `vm_initialization`. +- [#1501](https://github.com/FuelLabs/fuel-core/pull/1501): Add a CLI command for generating a fee collection contract. - [#1492](https://github.com/FuelLabs/fuel-core/pull/1492): Support backward iteration in the RocksDB. It allows backward queries that were not allowed before. - [#1490](https://github.com/FuelLabs/fuel-core/pull/1490): Add push and pop benchmarks. - [#1485](https://github.com/FuelLabs/fuel-core/pull/1485): Prepare rc release of fuel core v0.21 - [#1476](https://github.com/FuelLabs/fuel-core/pull/1453): Add the majority of the "other" benchmarks for contract opcodes. -- [#1453](https://github.com/FuelLabs/fuel-core/pull/1453): Add the majority of the "sanity" benchmarks for contract opcodes. - [#1473](https://github.com/FuelLabs/fuel-core/pull/1473): Expose fuel-core version as a constant - [#1469](https://github.com/FuelLabs/fuel-core/pull/1469): Added support of bloom filter for RocksDB tables and increased the block cache. -- [#1642](https://github.com/FuelLabs/fuel-core/pull/1462): Added benchmark to measure the performance of contract state and contract ID calculation; use for gas costing. - [#1465](https://github.com/FuelLabs/fuel-core/pull/1465): Improvements for keygen cli and crates +- [#1642](https://github.com/FuelLabs/fuel-core/pull/1462): Added benchmark to measure the performance of contract state and contract ID calculation; use for gas costing. - [#1457](https://github.com/FuelLabs/fuel-core/pull/1457): Fixing incorrect measurement for fast(µs) opcodes. - [#1456](https://github.com/FuelLabs/fuel-core/pull/1456): Added flushing of the RocksDB during a graceful shutdown. - [#1456](https://github.com/FuelLabs/fuel-core/pull/1456): Added more logs to track the service lifecycle. +- [#1453](https://github.com/FuelLabs/fuel-core/pull/1453): Add the majority of the "sanity" benchmarks for contract opcodes. +- [#1452](https://github.com/FuelLabs/fuel-core/pull/1452): Added benchmark to measure the performance of contract root calculation when utilizing the maximum contract size; used for gas costing of contract root during predicate owner validation. - [#1449](https://github.com/FuelLabs/fuel-core/pull/1449): Fix coin pagination in e2e test client. -- [#1452](https://github.com/FuelLabs/fuel-core/pull/1452): Added benchmark to measure the performance of contract root calculation when utilizing the maximum contract size; used for gas costing of contract root during predicate owner validation. - [#1447](https://github.com/FuelLabs/fuel-core/pull/1447): Add timeout for continuous e2e tests - [#1444](https://github.com/FuelLabs/fuel-core/pull/1444): Add "sanity" benchmarks for memory opcodes. - [#1437](https://github.com/FuelLabs/fuel-core/pull/1437): Add some transaction throughput tests for basic transfers. - [#1436](https://github.com/FuelLabs/fuel-core/pull/1436): Add a github action to continuously test beta-4. - [#1433](https://github.com/FuelLabs/fuel-core/pull/1433): Add "sanity" benchmarks for flow opcodes. -- [#1430](https://github.com/FuelLabs/fuel-core/pull/1430): Add "sanity" benchmarks for crypto opcodes. - [#1432](https://github.com/FuelLabs/fuel-core/pull/1432): Add a new `--api-request-timeout` argument to control TTL for GraphQL requests. -- [#1426](https://github.com/FuelLabs/fuel-core/pull/1426) Split keygen into a create and a binary +- [#1430](https://github.com/FuelLabs/fuel-core/pull/1430): Add "sanity" benchmarks for crypto opcodes. +- [#1426](https://github.com/FuelLabs/fuel-core/pull/1426) Split keygen into a create and a binary. - [#1419](https://github.com/FuelLabs/fuel-core/pull/1419): Add additional "sanity" benchmarks for arithmetic op code instructions. - [#1411](https://github.com/FuelLabs/fuel-core/pull/1411): Added WASM and `no_std` compatibility. +- [#1405](https://github.com/FuelLabs/fuel-core/pull/1405): Use correct names for service metrics. - [#1400](https://github.com/FuelLabs/fuel-core/pull/1400): Add releasy beta to fuel-core so that new commits to fuel-core master triggers fuels-rs. -- [#1371](https://github.com/FuelLabs/fuel-core/pull/1371): Add new client function for querying the `MessageStatus` for a specific message (by `Nonce`) -- [#1356](https://github.com/FuelLabs/fuel-core/pull/1356): Add peer reputation reporting to heartbeat code -- [#1355](https://github.com/FuelLabs/fuel-core/pull/1355): Added new metrics related to block importing, such as tps, sync delays etc +- [#1371](https://github.com/FuelLabs/fuel-core/pull/1371): Add new client function for querying the `MessageStatus` for a specific message (by `Nonce`). +- [#1356](https://github.com/FuelLabs/fuel-core/pull/1356): Add peer reputation reporting to heartbeat code. +- [#1355](https://github.com/FuelLabs/fuel-core/pull/1355): Added new metrics related to block importing, such as tps, sync delays etc. - [#1339](https://github.com/FuelLabs/fuel-core/pull/1339): Adds `baseAssetId` to `FeeParameters` in the GraphQL API. -- [#1331](https://github.com/FuelLabs/fuel-core/pull/1331): Add peer reputation reporting to block import code +- [#1331](https://github.com/FuelLabs/fuel-core/pull/1331): Add peer reputation reporting to block import code. - [#1324](https://github.com/FuelLabs/fuel-core/pull/1324): Added pyroscope profiling to fuel-core, intended to be used by a secondary docker image that has debug symbols enabled. - [#1309](https://github.com/FuelLabs/fuel-core/pull/1309): Add documentation for running debug builds with CLion and Visual Studio Code. - [#1308](https://github.com/FuelLabs/fuel-core/pull/1308): Add support for loading .env files when compiling with the `env` feature. This allows users to conveniently supply CLI arguments in a secure and IDE-agnostic way. @@ -49,43 +78,40 @@ Description of the upcoming release here. - [#1286](https://github.com/FuelLabs/fuel-core/pull/1286): Include readable names for test cases where missing. - [#1274](https://github.com/FuelLabs/fuel-core/pull/1274): Added tests to benchmark block synchronization. - [#1263](https://github.com/FuelLabs/fuel-core/pull/1263): Add gas benchmarks for `ED19` and `ECR1` instructions. -- [#1331](https://github.com/FuelLabs/fuel-core/pull/1331): Add peer reputation reporting to block import code -- [#1405](https://github.com/FuelLabs/fuel-core/pull/1405): Use correct names for service metrics. -- [#1501](https://github.com/FuelLabs/fuel-core/pull/1501): Add a CLI command for generating a fee collection contract. ### Changed +- [#1512](https://github.com/FuelLabs/fuel-core/pull/1512): Internally simplify merkle_contract_state_range. - [#1507](https://github.com/FuelLabs/fuel-core/pull/1507): Updated chain configuration to be ready for beta 5 network. It includes opcode prices from the latest benchmark and contract for the block producer. - [#1477](https://github.com/FuelLabs/fuel-core/pull/1477): Upgraded the Rust version used in CI and containers to 1.73.0. Also includes associated Clippy changes. - [#1469](https://github.com/FuelLabs/fuel-core/pull/1469): Replaced usage of `MemoryTransactionView` by `Checkpoint` database in the benchmarks. -- [#1466](https://github.com/FuelLabs/fuel-core/pull/1466): Handling overflows during arithmetic operations. - [#1468](https://github.com/FuelLabs/fuel-core/pull/1468): Bumped version of the `fuel-vm` to `v0.40.0`. It brings some breaking changes into consensus parameters API because of changes in the underlying types. +- [#1466](https://github.com/FuelLabs/fuel-core/pull/1466): Handling overflows during arithmetic operations. - [#1460](https://github.com/FuelLabs/fuel-core/pull/1460): Change tracking branch from main to master for releasy tests. +- [#1454](https://github.com/FuelLabs/fuel-core/pull/1454): Update gas benchmarks for opcodes that append receipts. - [#1440](https://github.com/FuelLabs/fuel-core/pull/1440): Don't report reserved nodes that send invalid transactions. - [#1439](https://github.com/FuelLabs/fuel-core/pull/1439): Reduced memory BMT consumption during creation of the header. - [#1434](https://github.com/FuelLabs/fuel-core/pull/1434): Continue gossiping transactions to reserved peers regardless of gossiping reputation score. +- [#1408](https://github.com/FuelLabs/fuel-core/pull/1408): Update gas benchmarks for storage opcodes to use a pre-populated database to get more accurate worst-case costs. - [#1399](https://github.com/FuelLabs/fuel-core/pull/1399): The Relayer now queries Ethereum for its latest finalized block instead of using a configurable "finalization period" to presume finality. - [#1397](https://github.com/FuelLabs/fuel-core/pull/1397): Improved keygen. Created a crate to be included from forc plugins and upgraded internal library to drop requirement of protoc to build -- [#1349](https://github.com/FuelLabs/fuel-core/pull/1349): Updated peer-to-peer transactions API to support multiple blocks in a single request, and updated block synchronization to request multiple blocks based on the configured range of headers. +- [#1395](https://github.com/FuelLabs/fuel-core/pull/1395): Add DependentCost benchmarks for `k256`, `s256` and `mcpi` instructions. +- [#1393](https://github.com/FuelLabs/fuel-core/pull/1393): Increase heartbeat timeout from `2` to `60` seconds, as suggested in [this issue](https://github.com/FuelLabs/fuel-core/issues/1330). +- [#1392](https://github.com/FuelLabs/fuel-core/pull/1392): Fixed an overflow in `message_proof`. +- [#1390](https://github.com/FuelLabs/fuel-core/pull/1390): Up the `ethers` version to `2` to fix an issue with `tungstenite`. +- [#1383](https://github.com/FuelLabs/fuel-core/pull/1383): Disallow usage of `log` crate internally in favor of `tracing` crate. - [#1380](https://github.com/FuelLabs/fuel-core/pull/1380): Add preliminary, hard-coded config values for heartbeat peer reputation, removing `todo`. - [#1377](https://github.com/FuelLabs/fuel-core/pull/1377): Remove `DiscoveryEvent` and use `KademliaEvent` directly in `DiscoveryBehavior`. - [#1366](https://github.com/FuelLabs/fuel-core/pull/1366): Improve caching during docker builds in CI by replacing gha - [#1358](https://github.com/FuelLabs/fuel-core/pull/1358): Upgraded the Rust version used in CI to 1.72.0. Also includes associated Clippy changes. +- [#1349](https://github.com/FuelLabs/fuel-core/pull/1349): Updated peer-to-peer transactions API to support multiple blocks in a single request, and updated block synchronization to request multiple blocks based on the configured range of headers. +- [#1342](https://github.com/FuelLabs/fuel-core/pull/1342): Add error handling for P2P requests to return `None` to requester and log error. - [#1318](https://github.com/FuelLabs/fuel-core/pull/1318): Modified block synchronization to use asynchronous task execution when retrieving block headers. - [#1314](https://github.com/FuelLabs/fuel-core/pull/1314): Removed `types::ConsensusParameters` in favour of `fuel_tx:ConsensusParameters`. - [#1302](https://github.com/FuelLabs/fuel-core/pull/1302): Removed the usage of flake and building of the bridge contract ABI. It simplifies the maintenance and updating of the events, requiring only putting the event definition into the codebase of the relayer. - [#1293](https://github.com/FuelLabs/fuel-core/issues/1293): Parallelized the `estimate_predicates` endpoint to utilize all available threads. - [#1270](https://github.com/FuelLabs/fuel-core/pull/1270): Modify the way block headers are retrieved from peers to be done in batches. -- [#1342](https://github.com/FuelLabs/fuel-core/pull/1342): Add error handling for P2P requests to return `None` to requester and log error. -- [#1383](https://github.com/FuelLabs/fuel-core/pull/1383): Disallow usage of `log` crate internally in favor of `tracing` crate. -- [#1390](https://github.com/FuelLabs/fuel-core/pull/1390): Up the `ethers` version to `2` to fix an issue with `tungstenite`. -- [#1392](https://github.com/FuelLabs/fuel-core/pull/1392): Fixed an overflow in `message_proof`. -- [#1393](https://github.com/FuelLabs/fuel-core/pull/1393): Increase heartbeat timeout from `2` to `60` seconds, as suggested in [this issue](https://github.com/FuelLabs/fuel-core/issues/1330). -- [#1395](https://github.com/FuelLabs/fuel-core/pull/1395): Add DependentCost benchmarks for `k256`, `s256` and `mcpi` instructions. -- [#1408](https://github.com/FuelLabs/fuel-core/pull/1408): Update gas benchmarks for storage opcodes to use a pre-populated database to get more accurate worst-case costs. -- [#1454](https://github.com/FuelLabs/fuel-core/pull/1454): Update gas benchmarks for opcodes that append receipts. -- [#1512](https://github.com/FuelLabs/fuel-core/pull/1512): Internally simplify merkle_contract_state_range. #### Breaking - [#1506](https://github.com/FuelLabs/fuel-core/pull/1506): Added validation of the coin's fields during block production and validation. Before, it was possible to submit a transaction that didn't match the coin's values in the database, allowing printing/using unavailable assets. @@ -98,9 +124,10 @@ Description of the upcoming release here. - [#1407](https://github.com/FuelLabs/fuel-core/pull/1407): The `Mint` transaction is reworked with new fields to support the account-base model. It affects serialization and deserialization of the transaction and also affects GraphQL schema. - [#1407](https://github.com/FuelLabs/fuel-core/pull/1407): The `Mint` transaction is the last transaction in the block instead of the first. - [#1374](https://github.com/FuelLabs/fuel-core/pull/1374): Renamed `base_chain_height` to `da_height` and return current relayer height instead of latest Fuel block height. +- [#1367](https://github.com/FuelLabs/fuel-core/pull/1367): Update to the latest version of fuel-vm. - [#1363](https://github.com/FuelLabs/fuel-core/pull/1363): Change message_proof api to take `nonce` instead of `message_id` -- [#1339](https://github.com/FuelLabs/fuel-core/pull/1339): Added a new required field called `base_asset_id` to the `FeeParameters` definition in `ConsensusParameters`, as well as default values for `base_asset_id` in the `beta` and `dev` chainspecs. - [#1355](https://github.com/FuelLabs/fuel-core/pull/1355): Removed the `metrics` feature flag from the fuel-core crate, and metrics are now included by default. +- [#1339](https://github.com/FuelLabs/fuel-core/pull/1339): Added a new required field called `base_asset_id` to the `FeeParameters` definition in `ConsensusParameters`, as well as default values for `base_asset_id` in the `beta` and `dev` chain specifications. - [#1322](https://github.com/FuelLabs/fuel-core/pull/1322): The `debug` flag is added to the CLI. The flag should be used for local development only. Enabling debug mode: - Allows GraphQL Endpoints to arbitrarily advance blocks. @@ -110,7 +137,6 @@ Description of the upcoming release here. - [#1290](https://github.com/FuelLabs/fuel-core/pull/1290): Standardize CLI args to use `-` instead of `_`. - [#1279](https://github.com/FuelLabs/fuel-core/pull/1279): Added a new CLI flag to enable the Relayer service `--enable-relayer`, and disabled the Relayer service by default. When supplying the `--enable-relayer` flag, the `--relayer` argument becomes mandatory, and omitting it is an error. Similarly, providing a `--relayer` argument without the `--enable-relayer` flag is an error. Lastly, providing the `--keypair` or `--network` arguments will also produce an error if the `--enable-p2p` flag is not set. - [#1262](https://github.com/FuelLabs/fuel-core/pull/1262): The `ConsensusParameters` aggregates all configuration data related to the consensus. It contains many fields that are segregated by the usage. The API of some functions was affected to use lesser types instead the whole `ConsensusParameters`. It is a huge breaking change requiring repetitively monotonically updating all places that use the `ConsensusParameters`. But during updating, consider that maybe you can use lesser types. Usage of them may simplify signatures of methods and make them more user-friendly and transparent. -- [#1367](https://github.com/FuelLabs/fuel-core/pull/1367): Update to the latest version of fuel-vm. ### Removed diff --git a/Cargo.lock b/Cargo.lock index 622fea1135c..2832860f52e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -444,31 +444,33 @@ dependencies = [ [[package]] name = "async-io" -version = "1.13.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ "async-lock", - "autocfg", "cfg-if", "concurrent-queue", + "futures-io", "futures-lite", - "log", "parking", "polling", - "rustix 0.37.27", + "rustix", "slab", - "socket2 0.4.10", + "tracing", "waker-fn", + "windows-sys 0.48.0", ] [[package]] name = "async-lock" -version = "2.8.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" dependencies = [ "event-listener", + "event-listener-strategy", + "pin-project-lite 0.2.13", ] [[package]] @@ -1746,15 +1748,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "data-encoding-macro" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" +checksum = "20c01c06f5f429efdf2bae21eb67c28b3df3cf85b7dd2d8ef09c0838dac5d33e" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -1762,9 +1764,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" +checksum = "0047d07f2c89b17dd631c80450d69841a6b5d7fb17278cbc43d7e4cfcf2576f3" dependencies = [ "data-encoding", "syn 1.0.109", @@ -1776,7 +1778,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" dependencies = [ - "uuid 1.5.0", + "uuid 1.6.1", ] [[package]] @@ -2048,7 +2050,7 @@ checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der 0.7.8", "digest 0.10.7", - "elliptic-curve 0.13.7", + "elliptic-curve 0.13.8", "rfc6979 0.4.0", "signature 2.2.0", "spki 0.7.2", @@ -2132,9 +2134,9 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.7" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9775b22bc152ad86a0cf23f0f348b884b26add12bf741e7ffc4d4ab2ab4d205" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct 0.2.0", "crypto-bigint 0.5.5", @@ -2413,7 +2415,7 @@ dependencies = [ "cargo_metadata", "chrono", "const-hex", - "elliptic-curve 0.13.7", + "elliptic-curve 0.13.8", "ethabi", "generic-array", "k256", @@ -2523,7 +2525,7 @@ dependencies = [ "coins-bip32", "coins-bip39", "const-hex", - "elliptic-curve 0.13.7", + "elliptic-curve 0.13.8", "eth-keystore", "ethers-core", "rand 0.8.5", @@ -2572,9 +2574,24 @@ checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" [[package]] name = "event-listener" -version = "2.5.3" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite 0.2.13", +] + +[[package]] +name = "event-listener-strategy" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +dependencies = [ + "event-listener", + "pin-project-lite 0.2.13", +] [[package]] name = "eventsource-client" @@ -2601,15 +2618,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "fastrand" version = "2.0.1" @@ -2700,9 +2708,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -2737,7 +2745,7 @@ dependencies = [ [[package]] name = "fuel-core" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "assert_matches", @@ -2786,7 +2794,7 @@ dependencies = [ "tokio-stream", "tower-http", "tracing", - "uuid 1.5.0", + "uuid 1.6.1", ] [[package]] @@ -2821,11 +2829,11 @@ dependencies = [ [[package]] name = "fuel-core-bft" -version = "0.21.0-rc.1" +version = "0.21.0" [[package]] name = "fuel-core-bin" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "clap 4.4.8", @@ -2851,12 +2859,10 @@ dependencies = [ [[package]] name = "fuel-core-chain-config" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "bech32", - "fuel-core", - "fuel-core-client", "fuel-core-storage", "fuel-core-types", "hex", @@ -2867,13 +2873,12 @@ dependencies = [ "serde", "serde_json", "serde_with", - "tokio", "tracing", ] [[package]] name = "fuel-core-client" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "cynic", @@ -2896,7 +2901,7 @@ dependencies = [ [[package]] name = "fuel-core-client-bin" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "clap 4.4.8", "fuel-core-client", @@ -2907,7 +2912,7 @@ dependencies = [ [[package]] name = "fuel-core-consensus-module" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "fuel-core-chain-config", @@ -2919,7 +2924,7 @@ dependencies = [ [[package]] name = "fuel-core-database" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "derive_more", @@ -2930,7 +2935,7 @@ dependencies = [ [[package]] name = "fuel-core-e2e-client" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "assert_cmd", @@ -2955,7 +2960,7 @@ dependencies = [ [[package]] name = "fuel-core-executor" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "fuel-core-chain-config", @@ -2966,7 +2971,7 @@ dependencies = [ [[package]] name = "fuel-core-importer" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "derive_more", @@ -2982,7 +2987,7 @@ dependencies = [ [[package]] name = "fuel-core-keygen" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "clap 4.4.8", @@ -2993,7 +2998,7 @@ dependencies = [ [[package]] name = "fuel-core-keygen-bin" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "atty", @@ -3006,7 +3011,7 @@ dependencies = [ [[package]] name = "fuel-core-metrics" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "axum", "once_cell", @@ -3020,7 +3025,7 @@ dependencies = [ [[package]] name = "fuel-core-p2p" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "async-trait", @@ -3064,7 +3069,7 @@ dependencies = [ [[package]] name = "fuel-core-poa" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "async-trait", @@ -3082,7 +3087,7 @@ dependencies = [ [[package]] name = "fuel-core-producer" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "async-trait", @@ -3099,7 +3104,7 @@ dependencies = [ [[package]] name = "fuel-core-relayer" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "async-trait", @@ -3127,7 +3132,7 @@ dependencies = [ [[package]] name = "fuel-core-services" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "async-trait", @@ -3141,7 +3146,7 @@ dependencies = [ [[package]] name = "fuel-core-storage" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "derive_more", @@ -3152,7 +3157,7 @@ dependencies = [ [[package]] name = "fuel-core-sync" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "async-trait", @@ -3202,7 +3207,7 @@ dependencies = [ [[package]] name = "fuel-core-trace" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "ctor", "tracing", @@ -3212,7 +3217,7 @@ dependencies = [ [[package]] name = "fuel-core-txpool" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "async-trait", @@ -3238,7 +3243,7 @@ dependencies = [ [[package]] name = "fuel-core-types" -version = "0.21.0-rc.1" +version = "0.21.0" dependencies = [ "anyhow", "derive_more", @@ -3428,17 +3433,12 @@ checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" -version = "1.13.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" dependencies = [ - "fastrand 1.9.0", "futures-core", - "futures-io", - "memchr", - "parking", "pin-project-lite 0.2.13", - "waker-fn", ] [[package]] @@ -3933,7 +3933,7 @@ dependencies = [ "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", - "webpki-roots 0.25.2", + "webpki-roots 0.25.3", ] [[package]] @@ -3977,9 +3977,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -3987,19 +3987,19 @@ dependencies = [ [[package]] name = "if-addrs" -version = "0.7.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" +checksum = "cabb0019d51a643781ff15c9c8a3e5dedc365c47211270f4e8f82812fedd8f0a" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "if-watch" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb892e5777fe09e16f3d44de7802f4daa7267ecbe8c466f19d94e25bb0c303e" +checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ "async-io", "core-foundation", @@ -4129,17 +4129,6 @@ dependencies = [ "webrtc-util", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.3", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "ip_network" version = "0.4.1" @@ -4171,7 +4160,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.24", + "rustix", "windows-sys 0.48.0", ] @@ -4245,7 +4234,7 @@ checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" dependencies = [ "cfg-if", "ecdsa 0.16.9", - "elliptic-curve 0.13.7", + "elliptic-curve 0.13.8", "once_cell", "sha2 0.10.8", "signature 2.2.0", @@ -4951,12 +4940,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.11" @@ -5610,7 +5593,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" dependencies = [ "ecdsa 0.16.9", - "elliptic-curve 0.13.7", + "elliptic-curve 0.13.8", "primeorder", "sha2 0.10.8", ] @@ -5777,9 +5760,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" @@ -5963,17 +5946,15 @@ dependencies = [ [[package]] name = "polling" -version = "2.8.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" dependencies = [ - "autocfg", - "bitflags 1.3.2", "cfg-if", "concurrent-queue", - "libc", - "log", "pin-project-lite 0.2.13", + "rustix", + "tracing", "windows-sys 0.48.0", ] @@ -6130,7 +6111,7 @@ version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" dependencies = [ - "elliptic-curve 0.13.7", + "elliptic-curve 0.13.8", ] [[package]] @@ -6723,7 +6704,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.2", + "webpki-roots 0.25.3", "winreg", ] @@ -6937,28 +6918,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.27" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.11", + "linux-raw-sys", "windows-sys 0.48.0", ] @@ -7306,18 +7273,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -7816,7 +7783,7 @@ dependencies = [ "debugid", "memmap2", "stable_deref_trait", - "uuid 1.5.0", + "uuid 1.6.1", ] [[package]] @@ -7925,9 +7892,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", - "fastrand 2.0.1", + "fastrand", "redox_syscall 0.4.1", - "rustix 0.38.24", + "rustix", "windows-sys 0.48.0", ] @@ -8243,7 +8210,7 @@ dependencies = [ "tokio", "tokio-rustls 0.24.1", "tungstenite", - "webpki-roots 0.25.2", + "webpki-roots 0.25.3", ] [[package]] @@ -8672,12 +8639,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", - "idna 0.4.0", + "idna 0.5.0", "percent-encoding", ] @@ -8705,9 +8672,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ "getrandom 0.2.11", ] @@ -8913,9 +8880,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] name = "webrtc" @@ -9031,7 +8998,7 @@ dependencies = [ "tokio", "turn", "url", - "uuid 1.5.0", + "uuid 1.6.1", "waitgroup", "webrtc-mdns", "webrtc-util", @@ -9134,7 +9101,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.24", + "rustix", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5677557a413..660a25138c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,33 +46,33 @@ homepage = "https://fuel.network/" keywords = ["blockchain", "cryptocurrencies", "fuel-vm", "vm"] license = "BUSL-1.1" repository = "https://github.com/FuelLabs/fuel-core" -version = "0.21.0-rc.1" +version = "0.21.0" [workspace.dependencies] # Workspace members -fuel-core = { version = "0.21.0-rc.1", path = "./crates/fuel-core", default-features = false } -fuel-core-client-bin = { version = "0.21.0-rc.1", path = "./bin/client" } -fuel-core-bin = { version = "0.21.0-rc.1", path = "./bin/fuel-core" } -fuel-core-keygen = { version = "0.21.0-rc.1", path = "./crates/keygen" } -fuel-core-keygen-bin = { version = "0.21.0-rc.1", path = "./bin/keygen" } -fuel-core-chain-config = { version = "0.21.0-rc.1", path = "./crates/chain-config" } -fuel-core-client = { version = "0.21.0-rc.1", path = "./crates/client" } -fuel-core-database = { version = "0.21.0-rc.1", path = "./crates/database" } -fuel-core-metrics = { version = "0.21.0-rc.1", path = "./crates/metrics" } -fuel-core-services = { version = "0.21.0-rc.1", path = "./crates/services" } -fuel-core-consensus-module = { version = "0.21.0-rc.1", path = "./crates/services/consensus_module" } -fuel-core-bft = { version = "0.21.0-rc.1", path = "./crates/services/consensus_module/bft" } -fuel-core-poa = { version = "0.21.0-rc.1", path = "./crates/services/consensus_module/poa" } -fuel-core-executor = { version = "0.21.0-rc.1", path = "./crates/services/executor" } -fuel-core-importer = { version = "0.21.0-rc.1", path = "./crates/services/importer" } -fuel-core-p2p = { version = "0.21.0-rc.1", path = "./crates/services/p2p" } -fuel-core-producer = { version = "0.21.0-rc.1", path = "./crates/services/producer" } -fuel-core-relayer = { version = "0.21.0-rc.1", path = "./crates/services/relayer" } -fuel-core-sync = { version = "0.21.0-rc.1", path = "./crates/services/sync" } -fuel-core-txpool = { version = "0.21.0-rc.1", path = "./crates/services/txpool" } -fuel-core-storage = { version = "0.21.0-rc.1", path = "./crates/storage" } -fuel-core-trace = { version = "0.21.0-rc.1", path = "./crates/trace" } -fuel-core-types = { version = "0.21.0-rc.1", path = "./crates/types", default-features = false } +fuel-core = { version = "0.21.0", path = "./crates/fuel-core", default-features = false } +fuel-core-client-bin = { version = "0.21.0", path = "./bin/client" } +fuel-core-bin = { version = "0.21.0", path = "./bin/fuel-core" } +fuel-core-keygen = { version = "0.21.0", path = "./crates/keygen" } +fuel-core-keygen-bin = { version = "0.21.0", path = "./bin/keygen" } +fuel-core-chain-config = { version = "0.21.0", path = "./crates/chain-config" } +fuel-core-client = { version = "0.21.0", path = "./crates/client" } +fuel-core-database = { version = "0.21.0", path = "./crates/database" } +fuel-core-metrics = { version = "0.21.0", path = "./crates/metrics" } +fuel-core-services = { version = "0.21.0", path = "./crates/services" } +fuel-core-consensus-module = { version = "0.21.0", path = "./crates/services/consensus_module" } +fuel-core-bft = { version = "0.21.0", path = "./crates/services/consensus_module/bft" } +fuel-core-poa = { version = "0.21.0", path = "./crates/services/consensus_module/poa" } +fuel-core-executor = { version = "0.21.0", path = "./crates/services/executor" } +fuel-core-importer = { version = "0.21.0", path = "./crates/services/importer" } +fuel-core-p2p = { version = "0.21.0", path = "./crates/services/p2p" } +fuel-core-producer = { version = "0.21.0", path = "./crates/services/producer" } +fuel-core-relayer = { version = "0.21.0", path = "./crates/services/relayer" } +fuel-core-sync = { version = "0.21.0", path = "./crates/services/sync" } +fuel-core-txpool = { version = "0.21.0", path = "./crates/services/txpool" } +fuel-core-storage = { version = "0.21.0", path = "./crates/storage" } +fuel-core-trace = { version = "0.21.0", path = "./crates/trace" } +fuel-core-types = { version = "0.21.0", path = "./crates/types", default-features = false } fuel-core-tests = { version = "0.0.0", path = "./tests" } fuel-core-xtask = { version = "0.0.0", path = "./xtask" } diff --git a/crates/chain-config/Cargo.toml b/crates/chain-config/Cargo.toml index 05f99311a3d..2f1ba39147c 100644 --- a/crates/chain-config/Cargo.toml +++ b/crates/chain-config/Cargo.toml @@ -25,13 +25,10 @@ serde_with = "1.11" tracing = "0.1" [dev-dependencies] -fuel-core = { workspace = true } -fuel-core-client = { workspace = true } fuel-core-types = { workspace = true, default-features = false, features = ["random", "serde"] } insta = { workspace = true } rand = { workspace = true } serde_json = { version = "1.0", features = ["raw_value"] } -tokio = { workspace = true, features = ["full"] } [features] default = ["std"] diff --git a/crates/chain-config/src/fee_collection_contract.rs b/crates/chain-config/src/fee_collection_contract.rs index 780ebe16174..46fe5793b9e 100644 --- a/crates/chain-config/src/fee_collection_contract.rs +++ b/crates/chain-config/src/fee_collection_contract.rs @@ -65,327 +65,3 @@ pub fn generate(address: Address) -> Vec { asm_bytes } - -#[cfg(test)] -#[allow(clippy::cast_possible_truncation)] -#[allow(clippy::arithmetic_side_effects)] -mod tests { - use super::*; - use crate::SecretKey; - - use rand::{ - rngs::StdRng, - Rng, - SeedableRng, - }; - - use fuel_core::service::{ - Config, - FuelService, - }; - use fuel_core_client::client::{ - types::TransactionStatus, - FuelClient, - }; - use fuel_core_types::{ - fuel_asm::GTFArgs, - fuel_tx::{ - Cacheable, - Finalizable, - Input, - Output, - TransactionBuilder, - Witness, - }, - fuel_types::{ - canonical::Serialize, - AssetId, - BlockHeight, - ChainId, - ContractId, - Salt, - }, - }; - - struct TestContext { - address: Address, - contract_id: ContractId, - _node: FuelService, - client: FuelClient, - } - - async fn setup(rng: &mut StdRng) -> TestContext { - // Make contract that coinbase fees are collected into - let address: Address = rng.gen(); - let salt: Salt = rng.gen(); - let contract = generate(address); - let witness: Witness = contract.into(); - let mut create_tx = TransactionBuilder::create(witness.clone(), salt, vec![]) - .add_random_fee_input() - .finalize(); - create_tx - .precompute(&ChainId::default()) - .expect("tx should be valid"); - let contract_id = create_tx.metadata().as_ref().unwrap().contract_id; - - // Start up a node - let mut config = Config::local_node(); - config.debug = true; - config.block_producer.coinbase_recipient = Some(contract_id); - let node = FuelService::new_node(config).await.unwrap(); - let client = FuelClient::from(node.bound_address); - - // Submit contract creation tx - let tx_status = client - .submit_and_await_commit(&create_tx.into()) - .await - .unwrap(); - assert!(matches!(tx_status, TransactionStatus::Success { .. })); - let bh = client.produce_blocks(1, None).await.unwrap(); - assert_eq!(bh, BlockHeight::new(2)); - - // No fees should have been collected yet - let contract_balance = - client.contract_balance(&(contract_id), None).await.unwrap(); - assert_eq!(contract_balance, 0); - - TestContext { - address, - contract_id, - _node: node, - client, - } - } - - /// This makes a block with a single transaction that has a fee, - /// so that the coinbase fee is collected into the contract - async fn make_block_with_fee(rng: &mut StdRng, ctx: &TestContext) { - let old_balance = ctx - .client - .contract_balance(&ctx.contract_id, None) - .await - .unwrap(); - - // Run a script that does nothing, but will cause fee collection - let tx = TransactionBuilder::script( - [op::ret(RegId::ONE)].into_iter().collect(), - vec![], - ) - .add_unsigned_coin_input( - SecretKey::random(rng), - rng.gen(), - 1000, - Default::default(), - Default::default(), - Default::default(), - ) - .gas_price(1) - .script_gas_limit(1_000_000) - .finalize_as_transaction(); - let tx_status = ctx.client.submit_and_await_commit(&tx).await.unwrap(); - assert!(matches!(tx_status, TransactionStatus::Success { .. })); - - // Now the coinbase fee should be reflected in the contract balance - let new_balance = ctx - .client - .contract_balance(&ctx.contract_id, None) - .await - .unwrap(); - assert!(new_balance > old_balance); - } - - async fn collect_fees(ctx: &TestContext) { - let TestContext { - client, - contract_id, - .. - } = ctx; - - let asset_id = AssetId::BASE; - let output_index = 1u64; - let call_struct_register = 0x10; - // Now call the fee collection contract to withdraw the fees - let script = vec![ - // Point to the call structure - op::gtf_args(call_struct_register, 0x00, GTFArgs::ScriptData), - op::addi( - call_struct_register, - call_struct_register, - (asset_id.size() + output_index.size()) as u16, - ), - op::call(call_struct_register, RegId::ZERO, RegId::ZERO, RegId::CGAS), - op::ret(RegId::ONE), - ]; - - let tx = TransactionBuilder::script( - script.into_iter().collect(),asset_id.to_bytes().into_iter() - .chain(output_index.to_bytes().into_iter()) - .chain(contract_id - .to_bytes().into_iter()) - .chain(0u64.to_bytes().into_iter()) - .chain(0u64.to_bytes().into_iter()) - .collect(), - ) - .add_random_fee_input() // No coinbase fee for this block - .gas_price(0) - .script_gas_limit(1_000_000) - .add_input(Input::contract( - Default::default(), - Default::default(), - Default::default(), - Default::default(), - *contract_id, - )) - .add_output(Output::contract(1, Default::default(), Default::default())) - .add_output(Output::variable( - Default::default(), - Default::default(), - Default::default(), - )) - .finalize_as_transaction(); - - let tx_status = client.submit_and_await_commit(&tx).await.unwrap(); - assert!( - matches!(tx_status, TransactionStatus::Success { .. }), - "{tx_status:?}" - ); - } - - #[tokio::test] - async fn happy_path() { - let rng = &mut StdRng::seed_from_u64(0); - - let ctx = setup(rng).await; - - for _ in 0..10 { - make_block_with_fee(rng, &ctx).await; - } - - // When - // Before withdrawal, the recipient's balance should be zero, - // and the contract balance should be non-zero. - let contract_balance_before_collect = ctx - .client - .contract_balance(&ctx.contract_id, None) - .await - .unwrap(); - assert_ne!(contract_balance_before_collect, 0); - assert_eq!(ctx.client.balance(&ctx.address, None).await.unwrap(), 0); - - // When - collect_fees(&ctx).await; - - // Then - - // Make sure that the full balance was been withdrawn - let contract_balance_after_collect = ctx - .client - .contract_balance(&ctx.contract_id, None) - .await - .unwrap(); - assert_eq!(contract_balance_after_collect, 0); - - // Make sure that the full balance was been withdrawn - assert_eq!( - ctx.client.balance(&ctx.address, None).await.unwrap(), - contract_balance_before_collect - ); - } - - /// Attempts fee collection when no balance has accumulated yet - #[tokio::test] - async fn no_fees_collected_yet() { - let rng = &mut StdRng::seed_from_u64(0); - - let ctx = setup(rng).await; - - // Given - let contract_balance_before_collect = ctx - .client - .contract_balance(&ctx.contract_id, None) - .await - .unwrap(); - assert_eq!(contract_balance_before_collect, 0); - assert_eq!(ctx.client.balance(&ctx.address, None).await.unwrap(), 0); - - // When - collect_fees(&ctx).await; - - // Then - - // Make sure that the balance is still zero - let contract_balance = ctx - .client - .contract_balance(&ctx.contract_id, None) - .await - .unwrap(); - assert_eq!(contract_balance, 0); - - // There were no coins to withdraw - assert_eq!(ctx.client.balance(&ctx.address, None).await.unwrap(), 0); - } - - #[tokio::test] - async fn missing_variable_output() { - let rng = &mut StdRng::seed_from_u64(0); - - let ctx = setup(rng).await; - make_block_with_fee(rng, &ctx).await; - - let asset_id = AssetId::BASE; - let output_index = 1u64; - let call_struct_register = 0x10; - - // Now call the fee collection contract to withdraw the fees, - // but unlike in the happy path, we don't add the variable output to the transaction. - let script = vec![ - // Point to the call structure - op::gtf_args(call_struct_register, 0x00, GTFArgs::ScriptData), - op::addi( - call_struct_register, - call_struct_register, - (asset_id.size() + output_index.size()) as u16, - ), - op::call(call_struct_register, RegId::ZERO, RegId::ZERO, RegId::CGAS), - op::ret(RegId::ONE), - ]; - let tx = TransactionBuilder::script( - script.into_iter().collect(), - asset_id.to_bytes().into_iter() - .chain(output_index.to_bytes().into_iter()) - .chain(ctx.contract_id - .to_bytes().into_iter()) - .chain(0u64.to_bytes().into_iter()) - .chain(0u64.to_bytes().into_iter()) - .collect(), - ) - .add_random_fee_input() // No coinbase fee for this block - .gas_price(0) - .script_gas_limit(1_000_000) - .add_input(Input::contract( - Default::default(), - Default::default(), - Default::default(), - Default::default(), - ctx.contract_id, - )) - .add_output(Output::contract(1, Default::default(), Default::default())) - .finalize_as_transaction(); - - let tx_status = ctx.client.submit_and_await_commit(&tx).await.unwrap(); - let TransactionStatus::Failure { reason, .. } = tx_status else { - panic!("Expected failure"); - }; - assert_eq!(reason, "OutputNotFound"); - - // Make sure that nothing was withdrawn - let contract_balance = ctx - .client - .contract_balance(&ctx.contract_id, None) - .await - .unwrap(); - assert_eq!(contract_balance, 1); - let asset_balance = ctx.client.balance(&ctx.address, None).await.unwrap(); - assert_eq!(asset_balance, 0); - } -} diff --git a/deployment/charts/Chart.yaml b/deployment/charts/Chart.yaml index 0f278f33eb4..9a79b278ca4 100644 --- a/deployment/charts/Chart.yaml +++ b/deployment/charts/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: ${fuel_core_service_name} description: ${fuel_core_service_name} Helm Chart type: application -appVersion: "0.21.0-rc.1" +appVersion: "0.21.0" version: 0.1.0 diff --git a/tests/tests/fee_collection_contract.rs b/tests/tests/fee_collection_contract.rs new file mode 100644 index 00000000000..c92893652a6 --- /dev/null +++ b/tests/tests/fee_collection_contract.rs @@ -0,0 +1,321 @@ +#![allow(clippy::cast_possible_truncation)] +#![allow(clippy::arithmetic_side_effects)] + +use rand::{ + rngs::StdRng, + Rng, + SeedableRng, +}; + +use fuel_core::service::{ + Config, + FuelService, +}; +use fuel_core_client::client::{ + types::TransactionStatus, + FuelClient, +}; +use fuel_core_types::{ + fuel_asm::{ + op, + GTFArgs, + RegId, + }, + fuel_crypto::SecretKey, + fuel_tx::{ + Cacheable, + Finalizable, + Input, + Output, + TransactionBuilder, + Witness, + }, + fuel_types::{ + canonical::Serialize, + Address, + AssetId, + BlockHeight, + ChainId, + ContractId, + Salt, + }, +}; + +struct TestContext { + address: Address, + contract_id: ContractId, + _node: FuelService, + client: FuelClient, +} + +async fn setup(rng: &mut StdRng) -> TestContext { + // Make contract that coinbase fees are collected into + let address: Address = rng.gen(); + let salt: Salt = rng.gen(); + let contract = fuel_core::chain_config::fee_collection_contract::generate(address); + let witness: Witness = contract.into(); + let mut create_tx = TransactionBuilder::create(witness.clone(), salt, vec![]) + .add_random_fee_input() + .finalize(); + create_tx + .precompute(&ChainId::default()) + .expect("tx should be valid"); + let contract_id = create_tx.metadata().as_ref().unwrap().contract_id; + + // Start up a node + let mut config = Config::local_node(); + config.debug = true; + config.block_producer.coinbase_recipient = Some(contract_id); + let node = FuelService::new_node(config).await.unwrap(); + let client = FuelClient::from(node.bound_address); + + // Submit contract creation tx + let tx_status = client + .submit_and_await_commit(&create_tx.into()) + .await + .unwrap(); + assert!(matches!(tx_status, TransactionStatus::Success { .. })); + let bh = client.produce_blocks(1, None).await.unwrap(); + assert_eq!(bh, BlockHeight::new(2)); + + // No fees should have been collected yet + let contract_balance = client.contract_balance(&(contract_id), None).await.unwrap(); + assert_eq!(contract_balance, 0); + + TestContext { + address, + contract_id, + _node: node, + client, + } +} + +/// This makes a block with a single transaction that has a fee, +/// so that the coinbase fee is collected into the contract +async fn make_block_with_fee(rng: &mut StdRng, ctx: &TestContext) { + let old_balance = ctx + .client + .contract_balance(&ctx.contract_id, None) + .await + .unwrap(); + + // Run a script that does nothing, but will cause fee collection + let tx = + TransactionBuilder::script([op::ret(RegId::ONE)].into_iter().collect(), vec![]) + .add_unsigned_coin_input( + SecretKey::random(rng), + rng.gen(), + 1000, + Default::default(), + Default::default(), + Default::default(), + ) + .gas_price(1) + .script_gas_limit(1_000_000) + .finalize_as_transaction(); + let tx_status = ctx.client.submit_and_await_commit(&tx).await.unwrap(); + assert!(matches!(tx_status, TransactionStatus::Success { .. })); + + // Now the coinbase fee should be reflected in the contract balance + let new_balance = ctx + .client + .contract_balance(&ctx.contract_id, None) + .await + .unwrap(); + assert!(new_balance > old_balance); +} + +async fn collect_fees(ctx: &TestContext) { + let TestContext { + client, + contract_id, + .. + } = ctx; + + let asset_id = AssetId::BASE; + let output_index = 1u64; + let call_struct_register = 0x10; + // Now call the fee collection contract to withdraw the fees + let script = vec![ + // Point to the call structure + op::gtf_args(call_struct_register, 0x00, GTFArgs::ScriptData), + op::addi( + call_struct_register, + call_struct_register, + (asset_id.size() + output_index.size()) as u16, + ), + op::call(call_struct_register, RegId::ZERO, RegId::ZERO, RegId::CGAS), + op::ret(RegId::ONE), + ]; + + let tx = TransactionBuilder::script( + script.into_iter().collect(),asset_id.to_bytes().into_iter() + .chain(output_index.to_bytes().into_iter()) + .chain(contract_id + .to_bytes().into_iter()) + .chain(0u64.to_bytes().into_iter()) + .chain(0u64.to_bytes().into_iter()) + .collect(), + ) + .add_random_fee_input() // No coinbase fee for this block + .gas_price(0) + .script_gas_limit(1_000_000) + .add_input(Input::contract( + Default::default(), + Default::default(), + Default::default(), + Default::default(), + *contract_id, + )) + .add_output(Output::contract(1, Default::default(), Default::default())) + .add_output(Output::variable( + Default::default(), + Default::default(), + Default::default(), + )) + .finalize_as_transaction(); + + let tx_status = client.submit_and_await_commit(&tx).await.unwrap(); + assert!( + matches!(tx_status, TransactionStatus::Success { .. }), + "{tx_status:?}" + ); +} + +#[tokio::test] +async fn happy_path() { + let rng = &mut StdRng::seed_from_u64(0); + + let ctx = setup(rng).await; + + for _ in 0..10 { + make_block_with_fee(rng, &ctx).await; + } + + // When + // Before withdrawal, the recipient's balance should be zero, + // and the contract balance should be non-zero. + let contract_balance_before_collect = ctx + .client + .contract_balance(&ctx.contract_id, None) + .await + .unwrap(); + assert_ne!(contract_balance_before_collect, 0); + assert_eq!(ctx.client.balance(&ctx.address, None).await.unwrap(), 0); + + // When + collect_fees(&ctx).await; + + // Then + + // Make sure that the full balance was been withdrawn + let contract_balance_after_collect = ctx + .client + .contract_balance(&ctx.contract_id, None) + .await + .unwrap(); + assert_eq!(contract_balance_after_collect, 0); + + // Make sure that the full balance was been withdrawn + assert_eq!( + ctx.client.balance(&ctx.address, None).await.unwrap(), + contract_balance_before_collect + ); +} + +/// Attempts fee collection when no balance has accumulated yet +#[tokio::test] +async fn no_fees_collected_yet() { + let rng = &mut StdRng::seed_from_u64(0); + + let ctx = setup(rng).await; + + // Given + let contract_balance_before_collect = ctx + .client + .contract_balance(&ctx.contract_id, None) + .await + .unwrap(); + assert_eq!(contract_balance_before_collect, 0); + assert_eq!(ctx.client.balance(&ctx.address, None).await.unwrap(), 0); + + // When + collect_fees(&ctx).await; + + // Then + + // Make sure that the balance is still zero + let contract_balance = ctx + .client + .contract_balance(&ctx.contract_id, None) + .await + .unwrap(); + assert_eq!(contract_balance, 0); + + // There were no coins to withdraw + assert_eq!(ctx.client.balance(&ctx.address, None).await.unwrap(), 0); +} + +#[tokio::test] +async fn missing_variable_output() { + let rng = &mut StdRng::seed_from_u64(0); + + let ctx = setup(rng).await; + make_block_with_fee(rng, &ctx).await; + + let asset_id = AssetId::BASE; + let output_index = 1u64; + let call_struct_register = 0x10; + + // Now call the fee collection contract to withdraw the fees, + // but unlike in the happy path, we don't add the variable output to the transaction. + let script = vec![ + // Point to the call structure + op::gtf_args(call_struct_register, 0x00, GTFArgs::ScriptData), + op::addi( + call_struct_register, + call_struct_register, + (asset_id.size() + output_index.size()) as u16, + ), + op::call(call_struct_register, RegId::ZERO, RegId::ZERO, RegId::CGAS), + op::ret(RegId::ONE), + ]; + let tx = TransactionBuilder::script( + script.into_iter().collect(), + asset_id.to_bytes().into_iter() + .chain(output_index.to_bytes().into_iter()) + .chain(ctx.contract_id + .to_bytes().into_iter()) + .chain(0u64.to_bytes().into_iter()) + .chain(0u64.to_bytes().into_iter()) + .collect(), + ) + .add_random_fee_input() // No coinbase fee for this block + .gas_price(0) + .script_gas_limit(1_000_000) + .add_input(Input::contract( + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ctx.contract_id, + )) + .add_output(Output::contract(1, Default::default(), Default::default())) + .finalize_as_transaction(); + + let tx_status = ctx.client.submit_and_await_commit(&tx).await.unwrap(); + let TransactionStatus::Failure { reason, .. } = tx_status else { + panic!("Expected failure"); + }; + assert_eq!(reason, "OutputNotFound"); + + // Make sure that nothing was withdrawn + let contract_balance = ctx + .client + .contract_balance(&ctx.contract_id, None) + .await + .unwrap(); + assert_eq!(contract_balance, 1); + let asset_balance = ctx.client.balance(&ctx.address, None).await.unwrap(); + assert_eq!(asset_balance, 0); +} diff --git a/tests/tests/lib.rs b/tests/tests/lib.rs index 9932f39ab2b..5c8eda28465 100644 --- a/tests/tests/lib.rs +++ b/tests/tests/lib.rs @@ -10,6 +10,7 @@ mod contract; mod dap; mod debugger; mod deployment; +mod fee_collection_contract; mod health; mod helpers; mod messages;