From 4cd9e12388414801ef98eb36eb9335b707fe21aa Mon Sep 17 00:00:00 2001 From: Cameron Carstens Date: Fri, 31 Jan 2025 11:06:57 +0100 Subject: [PATCH] Update to forc `v0.66.6` (#323) ## Type of change - Improvement (refactoring, restructuring repository, cleaning tech debt, ...) ## Changes The following changes have been made: - Updates the repository to forc `v0.66.6` ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. - [ ] I have updated the changelog to reflect the changes on this PR. --- .github/workflows/ci.yml | 2 +- .github/workflows/gh-pages.yml | 2 +- README.md | 8 ++--- docs/book/src/getting_started/index.md | 2 +- docs/contributing-book/src/code/Forc.lock | 23 ++++++++++++++ .../src/code/connect_four/src/main.sw | 4 +-- examples/Forc.lock | 4 +-- libs/Forc.lock | 4 +-- libs/src/admin.sw | 2 +- libs/src/bytecode/utils.sw | 2 +- libs/src/signed_integers/i128.sw | 4 +-- libs/src/signed_integers/i16.sw | 4 +-- libs/src/signed_integers/i256.sw | 4 +-- libs/src/signed_integers/i32.sw | 4 +-- libs/src/signed_integers/i64.sw | 4 +-- libs/src/signed_integers/i8.sw | 4 +-- tests/Forc.lock | 4 +-- .../complex_contract/src/main.sw | 2 +- tests/src/bytecode/tests/utils/mod.rs | 31 ++++++++++++++++--- .../reentrancy_attacker_contract/src/main.sw | 2 +- 20 files changed, 80 insertions(+), 36 deletions(-) create mode 100644 docs/contributing-book/src/code/Forc.lock diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c194f418..ccee8729 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ env: CARGO_TERM_COLOR: always REGISTRY: ghcr.io RUST_VERSION: 1.83.0 - FORC_VERSION: 0.66.2 + FORC_VERSION: 0.66.6 CORE_VERSION: 0.40.0 jobs: diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 0b594e78..375b4d2f 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -9,7 +9,7 @@ on: env: RUST_VERSION: 1.83.0 - FORC_VERSION: 0.66.2 + FORC_VERSION: 0.66.6 CORE_VERSION: 0.40.0 jobs: diff --git a/README.md b/README.md index 26802f06..5868887d 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ - - + + @@ -97,7 +97,7 @@ For more information about implementation please refer to the [Sway Libs Docs Hu ## Running Tests -There are two sets of tests that should be run: inline tests and sdk-harness tests. Please make sure you are using `forc v0.66.2` and `fuel-core v0.40.0`. You can check what version you are using by running the `fuelup show` command. +There are two sets of tests that should be run: inline tests and sdk-harness tests. Please make sure you are using `forc v0.66.6` and `fuel-core v0.40.0`. You can check what version you are using by running the `fuelup show` command. Make sure you are in the source directory of this repository `sway-libs/`. @@ -119,7 +119,7 @@ forc test --path tests --release --locked && cargo test --manifest-path tests/Ca Any instructions related to using a specific library should be found within the README.md of that library. > **NOTE:** -> All projects currently use `forc v0.66.2`, `fuels-rs v0.66.9` and `fuel-core v0.40.0`. +> All projects currently use `forc v0.66.6`, `fuels-rs v0.66.9` and `fuel-core v0.40.0`. ## Contributing diff --git a/docs/book/src/getting_started/index.md b/docs/book/src/getting_started/index.md index 7e6c306f..d8be9529 100644 --- a/docs/book/src/getting_started/index.md +++ b/docs/book/src/getting_started/index.md @@ -38,7 +38,7 @@ use sway_libs::ownership::only_owner; ``` > **NOTE:** -> All projects currently use `forc 0.63.3`, `fuels-rs v0.66.2` and `fuel-core 0.34.0`. +> All projects currently use `forc 0.66.6`, `fuels-rs v0.66.6` and `fuel-core 0.40.0`. ## Using Sway Libs diff --git a/docs/contributing-book/src/code/Forc.lock b/docs/contributing-book/src/code/Forc.lock new file mode 100644 index 00000000..be133dbb --- /dev/null +++ b/docs/contributing-book/src/code/Forc.lock @@ -0,0 +1,23 @@ +[[package]] +name = "bad_documentation" +source = "member" +dependencies = ["std"] + +[[package]] +name = "connect_four" +source = "member" +dependencies = ["std"] + +[[package]] +name = "core" +source = "path+from-root-2E654A91A5A21ADE" + +[[package]] +name = "std" +source = "git+https://github.com/fuellabs/sway?tag=v0.66.6#986aee2c1e34c9cd958c81e7fd6b84638b26619b" +dependencies = ["core"] + +[[package]] +name = "style_guide" +source = "member" +dependencies = ["std"] diff --git a/docs/contributing-book/src/code/connect_four/src/main.sw b/docs/contributing-book/src/code/connect_four/src/main.sw index e4bb5e24..c97d5132 100644 --- a/docs/contributing-book/src/code/connect_four/src/main.sw +++ b/docs/contributing-book/src/code/connect_four/src/main.sw @@ -1,7 +1,7 @@ contract; -mod data_structures; -mod interface; +pub mod data_structures; +pub mod interface; use data_structures::{Game, Player}; use interface::ConnectFour; diff --git a/examples/Forc.lock b/examples/Forc.lock index b02db3b9..c897ae72 100644 --- a/examples/Forc.lock +++ b/examples/Forc.lock @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "core" -source = "path+from-root-7053AAA90CC5E690" +source = "path+from-root-2E654A91A5A21ADE" [[package]] name = "merkle_examples" @@ -146,7 +146,7 @@ dependencies = ["std"] [[package]] name = "std" -source = "git+https://github.com/fuellabs/sway?tag=v0.66.2#31486c0b47669612acb7c64d66ecb50aea281282" +source = "git+https://github.com/fuellabs/sway?tag=v0.66.6#986aee2c1e34c9cd958c81e7fd6b84638b26619b" dependencies = ["core"] [[package]] diff --git a/libs/Forc.lock b/libs/Forc.lock index 7ac14885..77203d00 100644 --- a/libs/Forc.lock +++ b/libs/Forc.lock @@ -1,6 +1,6 @@ [[package]] name = "core" -source = "path+from-root-7053AAA90CC5E690" +source = "path+from-root-2E654A91A5A21ADE" [[package]] name = "standards" @@ -9,7 +9,7 @@ dependencies = ["std"] [[package]] name = "std" -source = "git+https://github.com/fuellabs/sway?tag=v0.66.2#31486c0b47669612acb7c64d66ecb50aea281282" +source = "git+https://github.com/fuellabs/sway?tag=v0.66.6#986aee2c1e34c9cd958c81e7fd6b84638b26619b" dependencies = ["core"] [[package]] diff --git a/libs/src/admin.sw b/libs/src/admin.sw index 3e6b401e..d7a2a506 100644 --- a/libs/src/admin.sw +++ b/libs/src/admin.sw @@ -5,7 +5,7 @@ pub mod errors; use ::admin::errors::AdminError; use ::ownership::{_owner, only_owner}; use standards::src5::State; -use std::{auth::msg_sender, hash::{Hash, sha256}, storage::storage_api::clear,}; +use std::{auth::msg_sender, hash::{Hash, sha256}, storage::storage_api::clear}; // Sets a new administrator. /// diff --git a/libs/src/bytecode/utils.sw b/libs/src/bytecode/utils.sw index ddb84191..fae3ebd3 100644 --- a/libs/src/bytecode/utils.sw +++ b/libs/src/bytecode/utils.sw @@ -1,6 +1,6 @@ library; -use std::{alloc::{alloc, alloc_bytes, realloc_bytes}, bytes::Bytes,}; +use std::{alloc::{alloc, alloc_bytes, realloc_bytes}, bytes::Bytes}; /// Pre-defined number of bytes of a leaf in a bytecode merkle tree. const LEAF_SIZE = 16 * 1024; diff --git a/libs/src/signed_integers/i128.sw b/libs/src/signed_integers/i128.sw index fddcfbe3..6e93c481 100644 --- a/libs/src/signed_integers/i128.sw +++ b/libs/src/signed_integers/i128.sw @@ -395,8 +395,8 @@ impl core::ops::Subtract for I128 { impl WrappingNeg for I128 { fn wrapping_neg(self) -> Self { - if self == self::min() { - return self::min() + if self == Self::min() { + return Self::min() } self * Self::neg_try_from(U128::from((0, 1))).unwrap() } diff --git a/libs/src/signed_integers/i16.sw b/libs/src/signed_integers/i16.sw index b3da7430..5282fa87 100644 --- a/libs/src/signed_integers/i16.sw +++ b/libs/src/signed_integers/i16.sw @@ -383,8 +383,8 @@ impl core::ops::Subtract for I16 { impl WrappingNeg for I16 { fn wrapping_neg(self) -> Self { - if self == self::min() { - return self::min() + if self == Self::min() { + return Self::min() } self * Self::neg_try_from(1u16).unwrap() } diff --git a/libs/src/signed_integers/i256.sw b/libs/src/signed_integers/i256.sw index 92d35bbc..70720a11 100644 --- a/libs/src/signed_integers/i256.sw +++ b/libs/src/signed_integers/i256.sw @@ -374,8 +374,8 @@ impl core::ops::Subtract for I256 { impl WrappingNeg for I256 { fn wrapping_neg(self) -> Self { - if self == self::min() { - return self::min() + if self == Self::min() { + return Self::min() } self * Self::neg_try_from(0x0000000000000000000000000000000000000000000000000000000000000001u256).unwrap() } diff --git a/libs/src/signed_integers/i32.sw b/libs/src/signed_integers/i32.sw index 1e94e8ee..8ce3da8f 100644 --- a/libs/src/signed_integers/i32.sw +++ b/libs/src/signed_integers/i32.sw @@ -383,8 +383,8 @@ impl core::ops::Divide for I32 { impl WrappingNeg for I32 { fn wrapping_neg(self) -> Self { - if self == self::min() { - return self::min() + if self == Self::min() { + return Self::min() } self * Self::neg_try_from(1u32).unwrap() } diff --git a/libs/src/signed_integers/i64.sw b/libs/src/signed_integers/i64.sw index 3b8c24c4..93e1ce2f 100644 --- a/libs/src/signed_integers/i64.sw +++ b/libs/src/signed_integers/i64.sw @@ -384,8 +384,8 @@ impl core::ops::Divide for I64 { impl WrappingNeg for I64 { fn wrapping_neg(self) -> Self { - if self == self::min() { - return self::min() + if self == Self::min() { + return Self::min() } self * Self::neg_try_from(1).unwrap() } diff --git a/libs/src/signed_integers/i8.sw b/libs/src/signed_integers/i8.sw index 37b9938a..e19a288b 100644 --- a/libs/src/signed_integers/i8.sw +++ b/libs/src/signed_integers/i8.sw @@ -383,8 +383,8 @@ impl core::ops::Subtract for I8 { impl WrappingNeg for I8 { fn wrapping_neg(self) -> Self { - if self == self::min() { - return self::min() + if self == Self::min() { + return Self::min() } self * Self::neg_try_from(1u8).unwrap() } diff --git a/tests/Forc.lock b/tests/Forc.lock index 7ce10f0c..3f8e27fc 100644 --- a/tests/Forc.lock +++ b/tests/Forc.lock @@ -22,7 +22,7 @@ dependencies = ["std"] [[package]] name = "core" -source = "path+from-root-7053AAA90CC5E690" +source = "path+from-root-2E654A91A5A21ADE" [[package]] name = "i128_test" @@ -244,7 +244,7 @@ dependencies = ["std"] [[package]] name = "std" -source = "git+https://github.com/fuellabs/sway?tag=v0.66.2#31486c0b47669612acb7c64d66ecb50aea281282" +source = "git+https://github.com/fuellabs/sway?tag=v0.66.6#986aee2c1e34c9cd958c81e7fd6b84638b26619b" dependencies = ["core"] [[package]] diff --git a/tests/src/bytecode/test_artifacts/complex_contract/src/main.sw b/tests/src/bytecode/test_artifacts/complex_contract/src/main.sw index 74e4c25c..ef7d3f62 100644 --- a/tests/src/bytecode/test_artifacts/complex_contract/src/main.sw +++ b/tests/src/bytecode/test_artifacts/complex_contract/src/main.sw @@ -1,6 +1,6 @@ contract; -use std::{hash::*, math::*, storage::storage_vec::*,}; +use std::{hash::*, math::*, storage::storage_vec::*}; struct SimpleStruct { x: u32, diff --git a/tests/src/bytecode/tests/utils/mod.rs b/tests/src/bytecode/tests/utils/mod.rs index 91f7f026..e50908f7 100644 --- a/tests/src/bytecode/tests/utils/mod.rs +++ b/tests/src/bytecode/tests/utils/mod.rs @@ -40,11 +40,32 @@ const DEFAULT_PREDICATE_BALANCE: u64 = 512; const HEX_STR_1: &str = "0xb4ca495f61ac3433e9a78cbf3adfb0e4486913bb548029cef99d1de2cf606d52"; const HEX_STR_2: &str = "0x5d617010b482b54332741fab0dfd1b15dfad07e8895360af0fb9f3e3a04b0c74"; const HEX_STR_3: &str = "0xfebf0fdda20de46a0f2261a69556b0f9fdeea85759af1edb322831cf7d0dc8d5"; -const SIMPLE_PREDICATE_OFFSET: u64 = 376; -const SIMPLE_CONTRACT_OFFSET: u64 = 1384; -const COMPLEX_CONTRACT_OFFSET_1: u64 = 22584; -const COMPLEX_CONTRACT_OFFSET_2: u64 = 22544; -const COMPLEX_CONTRACT_OFFSET_3: u64 = 22472; +// For bytecode test failures, these offsets need to be updated with the new configurable values +// in the .json files in `bytecode/test_artifacts/*/out/*-abi.json`. +// For example: in `bytecode/test_artifacts/complex_contract/out/contract_contract-abi.json` we have the following: +// "configurables": [ +// { +// "name": "VALUE", +// "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", +// "offset": 20800 +// }, +// { +// "name": "STRUCT", +// "concreteTypeId": "75f7f7a06026cab5d7a70984d1fde56001e83505e3a091ff9722b92d7f56d8be", +// "offset": 20760 +// }, +// { +// "name": "ENUM", +// "concreteTypeId": "8dfea60c80d5eb43188e38922a715225450c499b19fd0dacc673c13ff708cdb2", +// "offset": 20688 +// } +// ] +// You would use 20800, 20760, and 20688 for 1, 2, 3 respectively +const SIMPLE_PREDICATE_OFFSET: u64 = 384; +const SIMPLE_CONTRACT_OFFSET: u64 = 1280; +const COMPLEX_CONTRACT_OFFSET_1: u64 = 20800; +const COMPLEX_CONTRACT_OFFSET_2: u64 = 20760; +const COMPLEX_CONTRACT_OFFSET_3: u64 = 20688; pub mod abi_calls { diff --git a/tests/src/reentrancy/reentrancy_attacker_contract/src/main.sw b/tests/src/reentrancy/reentrancy_attacker_contract/src/main.sw index 2c00f1e9..1e18dc38 100644 --- a/tests/src/reentrancy/reentrancy_attacker_contract/src/main.sw +++ b/tests/src/reentrancy/reentrancy_attacker_contract/src/main.sw @@ -1,6 +1,6 @@ contract; -use std::{auth::*, call_frames::*,}; +use std::{auth::*, call_frames::*}; use reentrancy_target_abi::Target; use reentrancy_attacker_abi::Attacker;