From df9d51db96f7ad4422b3b990c733d3da18b70485 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:05:34 +0200 Subject: [PATCH 01/12] feat: add fuel-core-version script --- Cargo.toml | 3 + scripts/fuel-core-version/Cargo.toml | 16 +++++ scripts/fuel-core-version/src/main.rs | 84 +++++++++++++++++++++++++++ scripts/fuel-core-version/version.rs | 1 + 4 files changed, 104 insertions(+) create mode 100644 scripts/fuel-core-version/Cargo.toml create mode 100644 scripts/fuel-core-version/src/main.rs create mode 100644 scripts/fuel-core-version/version.rs diff --git a/Cargo.toml b/Cargo.toml index 6f7315cd83..a6a5740802 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ members = [ "packages/fuels-test-helpers", "packages/wasm-tests", "scripts/check-docs", + "scripts/fuel-core-version", "scripts/versions-replacer", ] @@ -44,6 +45,8 @@ async-trait = { version = "0.1.74", default-features = false } bech32 = "0.9.1" bytes = { version = "1.5.0", default-features = false } chrono = "0.4.31" +clap = { version = "4.5.3", features = ["derive"] } +color-eyre = "0.6.2" elliptic-curve = { version = "0.13.8", default-features = false } eth-keystore = "0.5.0" fuel-abi-types = "0.4.0" diff --git a/scripts/fuel-core-version/Cargo.toml b/scripts/fuel-core-version/Cargo.toml new file mode 100644 index 0000000000..8632510a9b --- /dev/null +++ b/scripts/fuel-core-version/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "fuel-core-version" +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = false +repository = { workspace = true } +rust-version = { workspace = true } + +[dependencies] +clap = { workspace = true } +color-eyre = { workspace = true } +semver = { workspace = true } +versions-replacer = { path = "../versions-replacer" } diff --git a/scripts/fuel-core-version/src/main.rs b/scripts/fuel-core-version/src/main.rs new file mode 100644 index 0000000000..149fff74e4 --- /dev/null +++ b/scripts/fuel-core-version/src/main.rs @@ -0,0 +1,84 @@ +use std::{ + fs, + path::{Path, PathBuf}, +}; + +use clap::{Parser, Subcommand}; +use color_eyre::{ + eyre::{bail, ContextCompat}, + Result, +}; +use semver::Version; +use versions_replacer::metadata::collect_versions_from_cargo_toml; + +fn get_version_from_toml(manifest_path: impl AsRef) -> Result { + let versions = collect_versions_from_cargo_toml(manifest_path)?; + let version = versions["fuel-core"].parse::()?; + Ok(version) +} + +fn write_version_to_file(version: Version, version_file_path: impl AsRef) -> Result<()> { + let Version { + major, + minor, + patch, + .. + } = version; + let text = format!("Version::new({major}, {minor}, {patch})"); + fs::write(version_file_path, text.as_bytes())?; + Ok(()) +} + +fn get_version_file_path( + manifest_path: impl AsRef, +) -> Result { + Ok(manifest_path + .as_ref() + .parent() + .wrap_err("Invalid manifest path")? + .join("scripts/fuel-core-version/version.rs")) +} + +fn verify_version_from_file(version: Version) -> Result<()> { + let version_from_file: Version = include!("../version.rs"); + if version != version_from_file { + bail!( + "fuel_core version in version.rs ({}) doesn't match one in Cargo.toml ({})", + version_from_file, + version + ); + } + println!( + "fuel_core versions in versions.rs and Cargo.toml match ({})", + version + ); + Ok(()) +} + +#[derive(Debug, Parser)] +struct App { + #[clap(subcommand)] + command: Command, + #[clap(long)] + manifest_path: PathBuf, +} + +#[derive(Debug, Subcommand)] +enum Command { + Write, + Verify, +} + +fn main() -> Result<()> { + let App { + command, + manifest_path, + } = App::parse(); + let version = get_version_from_toml(&manifest_path)?; + let version_file_path = get_version_file_path(&manifest_path)?; + match command { + Command::Write => write_version_to_file(version, version_file_path)?, + Command::Verify => verify_version_from_file(version)?, + } + Ok(()) +} diff --git a/scripts/fuel-core-version/version.rs b/scripts/fuel-core-version/version.rs new file mode 100644 index 0000000000..6b7458d151 --- /dev/null +++ b/scripts/fuel-core-version/version.rs @@ -0,0 +1 @@ +Version::new(0, 23, 0) \ No newline at end of file From 78f7a42d6ddb0ddb70bbfaa623fbccd14ecdec3b Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:14:04 +0200 Subject: [PATCH 02/12] ci: add fuel-core-version verify to CI --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5afa9162c1..92015b3bae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -197,6 +197,8 @@ jobs: args: --skip-target-dir - command: test_wasm args: + - command: check_fuel_core_version + args: - command: check_doc_anchors_valid args: - command: check_doc_unresolved_links @@ -273,6 +275,10 @@ jobs: cd packages/wasm-tests wasm-pack test --node + - name: Check that fuel_core version.rs file is up to date + if: ${{ matrix.command == 'check_fuel_core_version' }} + run: cargo run --bin fuel-core-version --manifest-path ./Cargo.toml verify + - name: Check for invalid documentation anchors if: ${{ matrix.command == 'check_doc_anchors_valid' }} run: cargo run --bin check-docs From 8b667df10fa5a54e2f59b095b0ce1b8105d8a553 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:14:28 +0200 Subject: [PATCH 03/12] chore(fuels): remove fuel-core dev-dependency --- packages/fuels/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/fuels/Cargo.toml b/packages/fuels/Cargo.toml index 4a213e9a64..44c9ce61ee 100644 --- a/packages/fuels/Cargo.toml +++ b/packages/fuels/Cargo.toml @@ -26,7 +26,6 @@ fuels-test-helpers = { workspace = true, optional = true } [dev-dependencies] chrono = { workspace = true } -fuel-core = { workspace = true, default-features = false } fuel-core-types = { workspace = true } fuels-code-gen = { workspace = true } fuels-test-helpers = { workspace = true } From 125f3aca3f1e5d1ce9a030701b8ce444158d2db1 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:14:57 +0200 Subject: [PATCH 04/12] feat: use committed version.rs in check_version_compatibility --- .../fuels-accounts/src/provider/supported_versions.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/fuels-accounts/src/provider/supported_versions.rs b/packages/fuels-accounts/src/provider/supported_versions.rs index 478b6e894d..26413f598c 100644 --- a/packages/fuels-accounts/src/provider/supported_versions.rs +++ b/packages/fuels-accounts/src/provider/supported_versions.rs @@ -1,8 +1,7 @@ use semver::Version; -fn get_supported_fuel_core_version() -> Version { - "0.23.0".parse().expect("is valid version") -} +pub const SUPPORTED_FUEL_CORE_VERSION: Version = + include!("../../../../scripts/fuel-core-version/version.rs"); #[derive(Debug, PartialEq, Eq)] pub(crate) struct VersionCompatibility { @@ -15,8 +14,7 @@ pub(crate) struct VersionCompatibility { pub(crate) fn check_fuel_core_version_compatibility( network_version: Version, ) -> VersionCompatibility { - let supported_version = get_supported_fuel_core_version(); - check_version_compatibility(network_version, supported_version) + check_version_compatibility(network_version, SUPPORTED_FUEL_CORE_VERSION) } fn check_version_compatibility( From 3f78bf55832bc981478c2cb3a67d14a50554fa7a Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Mon, 1 Apr 2024 16:24:42 +0300 Subject: [PATCH 05/12] ci: fix task --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92015b3bae..b13aff0a5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -277,7 +277,7 @@ jobs: - name: Check that fuel_core version.rs file is up to date if: ${{ matrix.command == 'check_fuel_core_version' }} - run: cargo run --bin fuel-core-version --manifest-path ./Cargo.toml verify + run: cargo run --bin fuel-core-version -- --manifest-path ./Cargo.toml verify - name: Check for invalid documentation anchors if: ${{ matrix.command == 'check_doc_anchors_valid' }} From ab44125901c0ca84915cf5cdf01da81335058cb2 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:40:42 +0300 Subject: [PATCH 06/12] fix: use fuel-core-types for fuel-core version --- scripts/fuel-core-version/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fuel-core-version/src/main.rs b/scripts/fuel-core-version/src/main.rs index 149fff74e4..4725a0808f 100644 --- a/scripts/fuel-core-version/src/main.rs +++ b/scripts/fuel-core-version/src/main.rs @@ -13,7 +13,7 @@ use versions_replacer::metadata::collect_versions_from_cargo_toml; fn get_version_from_toml(manifest_path: impl AsRef) -> Result { let versions = collect_versions_from_cargo_toml(manifest_path)?; - let version = versions["fuel-core"].parse::()?; + let version = versions["fuel-core-types"].parse::()?; Ok(version) } From e67330bf139ebffa5d3dec902708e5521b069957 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Fri, 3 May 2024 15:40:49 +0100 Subject: [PATCH 07/12] chore: update version.rs file --- scripts/fuel-core-version/version.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fuel-core-version/version.rs b/scripts/fuel-core-version/version.rs index 6b7458d151..6ae5049340 100644 --- a/scripts/fuel-core-version/version.rs +++ b/scripts/fuel-core-version/version.rs @@ -1 +1 @@ -Version::new(0, 23, 0) \ No newline at end of file +Version::new(0, 24, 3) \ No newline at end of file From 966172ff7b8a78dec90092d701bcc046da771915 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Fri, 3 May 2024 16:11:24 +0100 Subject: [PATCH 08/12] Revert "chore(fuels): remove fuel-core dev-dependency" This reverts commit 8b667df10fa5a54e2f59b095b0ce1b8105d8a553. --- packages/fuels/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/fuels/Cargo.toml b/packages/fuels/Cargo.toml index 44c9ce61ee..4a213e9a64 100644 --- a/packages/fuels/Cargo.toml +++ b/packages/fuels/Cargo.toml @@ -26,6 +26,7 @@ fuels-test-helpers = { workspace = true, optional = true } [dev-dependencies] chrono = { workspace = true } +fuel-core = { workspace = true, default-features = false } fuel-core-types = { workspace = true } fuels-code-gen = { workspace = true } fuels-test-helpers = { workspace = true } From 6143c31626c152b3ad14ad6ab89c43667ed6acfc Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Sat, 4 May 2024 16:52:12 +0100 Subject: [PATCH 09/12] Update version.rs --- scripts/fuel-core-version/version.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fuel-core-version/version.rs b/scripts/fuel-core-version/version.rs index 6ae5049340..e41fa22a24 100644 --- a/scripts/fuel-core-version/version.rs +++ b/scripts/fuel-core-version/version.rs @@ -1 +1 @@ -Version::new(0, 24, 3) \ No newline at end of file +Version::new(0, 26, 0) From 037d1ddf5a6735d28ea5871d79eb6305005b280c Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Tue, 21 May 2024 14:22:30 +0100 Subject: [PATCH 10/12] chore: confine deps to local Cargo.toml --- Cargo.toml | 2 -- scripts/fuel-core-version/Cargo.toml | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 802ce96aaa..4dfbe28579 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,8 +46,6 @@ async-trait = { version = "0.1.74", default-features = false } bech32 = "0.9.1" bytes = { version = "1.5.0", default-features = false } chrono = "0.4.31" -clap = { version = "4.5.3", features = ["derive"] } -color-eyre = "0.6.2" elliptic-curve = { version = "0.13.8", default-features = false } eth-keystore = "0.5.0" fuel-abi-types = "0.5.0" diff --git a/scripts/fuel-core-version/Cargo.toml b/scripts/fuel-core-version/Cargo.toml index 8632510a9b..ef31d26aef 100644 --- a/scripts/fuel-core-version/Cargo.toml +++ b/scripts/fuel-core-version/Cargo.toml @@ -10,7 +10,7 @@ repository = { workspace = true } rust-version = { workspace = true } [dependencies] -clap = { workspace = true } -color-eyre = { workspace = true } +clap = { version = "4.5.3", features = ["derive"] } +color-eyre = "0.6.2" semver = { workspace = true } versions-replacer = { path = "../versions-replacer" } From 108cba3620e4931619fb57658cc0784e838048de Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Tue, 21 May 2024 18:31:57 +0100 Subject: [PATCH 11/12] chore(Cargo.toml): use workspace for versions-replacer --- scripts/fuel-core-version/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fuel-core-version/Cargo.toml b/scripts/fuel-core-version/Cargo.toml index ef31d26aef..af158ca4e7 100644 --- a/scripts/fuel-core-version/Cargo.toml +++ b/scripts/fuel-core-version/Cargo.toml @@ -13,4 +13,4 @@ rust-version = { workspace = true } clap = { version = "4.5.3", features = ["derive"] } color-eyre = "0.6.2" semver = { workspace = true } -versions-replacer = { path = "../versions-replacer" } +versions-replacer = { workspace = true } From 1482c9d978884eb30b05301662ddcf3120f06060 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko <12615679+Br1ght0ne@users.noreply.github.com> Date: Tue, 21 May 2024 18:34:30 +0100 Subject: [PATCH 12/12] fix: add versions-replacer to workspace Cargo.toml --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 4dfbe28579..089d3c85a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,3 +101,4 @@ fuels-core = { version = "0.62.0", path = "./packages/fuels-core", default-featu fuels-macros = { version = "0.62.0", path = "./packages/fuels-macros", default-features = false } fuels-programs = { version = "0.62.0", path = "./packages/fuels-programs", default-features = false } fuels-test-helpers = { version = "0.62.0", path = "./packages/fuels-test-helpers", default-features = false } +versions-replacer = { version = "0.62.0", path = "./scripts/versions-replacer", default-features = false }