From 8d8debda49f3c83f37740cd22e269a91a8cd55d3 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Mon, 4 Mar 2024 15:10:45 -0500 Subject: [PATCH 01/13] Add rust-toolchain.toml to pin the project to the same rust version as casper-node Signed-off-by: Zach Showalter --- rust-toolchain.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..f4ec842f --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.73.0" \ No newline at end of file From ba468937d2c4d0bcb64da9b7af3629b2a5bce0f0 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Mon, 15 Apr 2024 13:58:22 -0400 Subject: [PATCH 02/13] pin clap dependencies to allow project to be compiled with Rust 1.73 Signed-off-by: Zach Showalter --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c6a4cfa9..6d1430a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ readme = "README.md" homepage = "https://casperlabs.io" repository = "https://github.com/casper-ecosystem/casper-client-rs" license = "Apache-2.0" +build = "build.rs" [lib] crate-type = ["cdylib", "rlib"] @@ -30,8 +31,8 @@ async-trait = { version = "0.1.74", optional = true } base16 = "0.2.1" casper-hashing = "3.0.0" casper-types = { version = "4.0.1", features = ["std"] } -clap = { version = "4.4.10", optional = true, features = ["cargo", "deprecated", "wrap_help"] } -clap_complete = { version = "4.4.4", optional = true } +clap = { version = "=4.4.10", optional = true, features = ["cargo", "deprecated", "wrap_help"] } +clap_complete = { version = "=4.4.4", optional = true } hex-buffer-serde = "0.4.0" humantime = "2.1.0" itertools = "0.12.0" @@ -39,7 +40,7 @@ jsonrpc-lite = "0.6.0" num-traits = "0.2.15" once_cell = "1.18.0" rand = "0.8.5" -reqwest = { version = "0.11.22", features = ["json"] } +reqwest = { version = "0.12.3", features = ["json"] } schemars = "=0.8.5" serde = { version = "1.0.193", default-features = false, features = ["derive"] } serde_json = { version = "1.0.108", features = ["preserve_order"] } @@ -51,7 +52,6 @@ uint = "0.9.5" tempfile = "3.8.1" [build-dependencies] -vergen = { version = "7", default-features = false, features = ["git"] } [patch.crates-io] casper-hashing = { git = "https://github.com/casper-network/casper-node", branch = "dev" } From ea97e125cb36456a336c8d4ad8f3ca150c820cb8 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Mon, 15 Apr 2024 14:03:00 -0400 Subject: [PATCH 03/13] Remove build field from package section of Cargo.toml Signed-off-by: Zach Showalter --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6d1430a7..c1c1c0f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ readme = "README.md" homepage = "https://casperlabs.io" repository = "https://github.com/casper-ecosystem/casper-client-rs" license = "Apache-2.0" -build = "build.rs" [lib] crate-type = ["cdylib", "rlib"] From c11b33da0f6d9347e48c0f073ad6821bee1471a6 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Mon, 15 Apr 2024 14:04:16 -0400 Subject: [PATCH 04/13] Update `build.rs` script and version string in `main.rs` to add the short git commit hash to the clients version string Signed-off-by: Zach Showalter --- build.rs | 25 +++++++++++++++++++++---- src/main.rs | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index c8dd712c..0b5b1302 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,24 @@ -use vergen::{Config, ShaKind}; +use std::{ + env::set_var, + process::Command +}; +const GIT_HASH_ENV_VAR: &str = "GIT_SHA_SHORT"; fn main() { - let mut config = Config::default(); - *config.git_mut().sha_kind_mut() = ShaKind::Short; - let _ = vergen::vergen(config); + //Build command to retrieve the short git commit hash + let git_process_output = Command::new("git") + .arg("rev-parse") + .arg("--short") + .arg("HEAD") + .output() + .expect("Failed to retrieve short git commit hash"); + + //Parse the raw output into a string, we still need to remove the newline character + let git_hash_raw = String::from_utf8(git_process_output.stdout).expect("Failed to convert git hash to string"); + //Remove the newline character from the short git commit hash + let git_hash = git_hash_raw.trim_end_matches('\n'); + + println!("test: {}", git_hash); + + set_var(GIT_HASH_ENV_VAR, git_hash); } diff --git a/src/main.rs b/src/main.rs index d67770b9..d087797d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,7 +54,7 @@ const APP_NAME: &str = "Casper client"; static VERSION: Lazy = Lazy::new( - || match option_env!("VERGEN_GIT_SHA_SHORT").map(|sha| sha.to_lowercase()) { + || match option_env!("GIT_SHA_SHORT").map(|sha| sha.to_lowercase()) { None => crate_version!().to_string(), Some(git_sha_short) => { if git_sha_short.to_lowercase() == "unknown" { From 61327a629f8305156a69475aef8ae3f81b9787f1 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Mon, 15 Apr 2024 14:14:58 -0400 Subject: [PATCH 05/13] change build.rs to use `println!()` to communicate with rustc. this sets the `GIT_SHA_SHORT` env var during compile time so the client may use `env!` macros to populate the version string with a short git commit hash. Signed-off-by: Zach Showalter --- build.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 0b5b1302..87c59a07 100644 --- a/build.rs +++ b/build.rs @@ -18,7 +18,5 @@ fn main() { //Remove the newline character from the short git commit hash let git_hash = git_hash_raw.trim_end_matches('\n'); - println!("test: {}", git_hash); - - set_var(GIT_HASH_ENV_VAR, git_hash); + println!("cargo::rustc-env={}={}", GIT_HASH_ENV_VAR, git_hash); } From f31e2b9b616d16e800b5e63ee758c739bd4c596b Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Mon, 15 Apr 2024 14:16:32 -0400 Subject: [PATCH 06/13] remove unused import and communicate with cargo via historical method. (Using only one colon vs two for `cargo:rustc-env`) Signed-off-by: Zach Showalter --- build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 87c59a07..9814f34b 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,4 @@ use std::{ - env::set_var, process::Command }; @@ -18,5 +17,5 @@ fn main() { //Remove the newline character from the short git commit hash let git_hash = git_hash_raw.trim_end_matches('\n'); - println!("cargo::rustc-env={}={}", GIT_HASH_ENV_VAR, git_hash); + println!("cargo:rustc-env={}={}", GIT_HASH_ENV_VAR, git_hash); } From 5a50ef8edd38fda57367906a2a069dabc0f7f110 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Mon, 15 Apr 2024 14:35:39 -0400 Subject: [PATCH 07/13] run cargo fmt Signed-off-by: Zach Showalter --- build.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 9814f34b..60e68891 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,4 @@ -use std::{ - process::Command -}; +use std::process::Command; const GIT_HASH_ENV_VAR: &str = "GIT_SHA_SHORT"; fn main() { @@ -13,7 +11,8 @@ fn main() { .expect("Failed to retrieve short git commit hash"); //Parse the raw output into a string, we still need to remove the newline character - let git_hash_raw = String::from_utf8(git_process_output.stdout).expect("Failed to convert git hash to string"); + let git_hash_raw = + String::from_utf8(git_process_output.stdout).expect("Failed to convert git hash to string"); //Remove the newline character from the short git commit hash let git_hash = git_hash_raw.trim_end_matches('\n'); From 787ecc78fe77b7f2031237ed551877b23eecec38 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Mon, 15 Apr 2024 16:21:09 -0400 Subject: [PATCH 08/13] Change CI file to fix `wasm32-unknown-unknown` issue Signed-off-by: Zach Showalter --- .github/workflows/ci-casper-client-rs.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-casper-client-rs.yml b/.github/workflows/ci-casper-client-rs.yml index 05bab790..076b4245 100644 --- a/.github/workflows/ci-casper-client-rs.yml +++ b/.github/workflows/ci-casper-client-rs.yml @@ -22,10 +22,16 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + + - name: Get stable from rust-toolchain.toml + id: stable-toolchain + run: echo "::set-output name=version::$(sed -nr 's/channel\s+=\s+\"(.*)\"/\1/p' rust-toolchain.toml)" + + - name: Install Toolchain - Stable + uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #tag v1.0.7 with: - toolchain: stable profile: minimal + toolchain: ${{ steps.stable-toolchain.outputs.version }} components: rustfmt, clippy target: wasm32-unknown-unknown @@ -73,4 +79,5 @@ jobs: uses: actions-rs/cargo@v1 with: command: build - args: --lib --target wasm32-unknown-unknown --no-default-features + target: wasm32-unknown-unknown + args: --lib --target wasm32-unknown-unknown --no-default-features \ No newline at end of file From 4fc1c45095a335bcffbc86a6a78315e2c9c84839 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Wed, 17 Apr 2024 13:33:48 -0400 Subject: [PATCH 09/13] Reduce the rigidity of clap dependencies in Cargo.toml Signed-off-by: Zach Showalter --- Cargo.toml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c1c1c0f4..54ef0b71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,8 @@ async-trait = { version = "0.1.74", optional = true } base16 = "0.2.1" casper-hashing = "3.0.0" casper-types = { version = "4.0.1", features = ["std"] } -clap = { version = "=4.4.10", optional = true, features = ["cargo", "deprecated", "wrap_help"] } -clap_complete = { version = "=4.4.4", optional = true } +clap = { version = "~4.4", optional = true, features = ["cargo", "deprecated", "wrap_help"] } +clap_complete = { version = "<4.5.0", optional = true } hex-buffer-serde = "0.4.0" humantime = "2.1.0" itertools = "0.12.0" @@ -50,8 +50,6 @@ uint = "0.9.5" [dev-dependencies] tempfile = "3.8.1" -[build-dependencies] - [patch.crates-io] casper-hashing = { git = "https://github.com/casper-network/casper-node", branch = "dev" } casper-types = { git = "https://github.com/casper-network/casper-node", branch = "dev" } From c272d053c397fbdb259b97d10fe3984c88592edc Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Wed, 17 Apr 2024 13:34:15 -0400 Subject: [PATCH 10/13] Added a newline for readability in build.rs Signed-off-by: Zach Showalter --- build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/build.rs b/build.rs index 60e68891..039bc4a0 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,7 @@ use std::process::Command; const GIT_HASH_ENV_VAR: &str = "GIT_SHA_SHORT"; + fn main() { //Build command to retrieve the short git commit hash let git_process_output = Command::new("git") From e09085a06e9ac112547bbce87b91836a770d3a51 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Fri, 19 Apr 2024 11:24:01 -0400 Subject: [PATCH 11/13] remove deprecated `actions-rs` in client CI. Signed-off-by: Zach Showalter --- .github/workflows/ci-casper-client-rs.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-casper-client-rs.yml b/.github/workflows/ci-casper-client-rs.yml index 076b4245..7e68dccf 100644 --- a/.github/workflows/ci-casper-client-rs.yml +++ b/.github/workflows/ci-casper-client-rs.yml @@ -25,15 +25,15 @@ jobs: - name: Get stable from rust-toolchain.toml id: stable-toolchain - run: echo "::set-output name=version::$(sed -nr 's/channel\s+=\s+\"(.*)\"/\1/p' rust-toolchain.toml)" + run: | + VER=$(sed -nr 's/channel\s+=\s+\"(.*)\"/\1/p' rust-toolchain.toml) + echo "RUST_CHANNEL=$VER" >> $GITHUB_ENV - name: Install Toolchain - Stable - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #tag v1.0.7 - with: - profile: minimal - toolchain: ${{ steps.stable-toolchain.outputs.version }} - components: rustfmt, clippy - target: wasm32-unknown-unknown + run: | + rustup update --no-self-update ${{ env.RUST_CHANNEL }} + rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src + rustup default ${{ env.RUST_CHANNEL }} - name: Fmt uses: actions-rs/cargo@v1 From 9e22082110cd761449175e47d58fc43208458427 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Fri, 19 Apr 2024 12:38:18 -0400 Subject: [PATCH 12/13] Add clippy component to toolchainn for CI Signed-off-by: Zach Showalter --- .github/workflows/ci-casper-client-rs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-casper-client-rs.yml b/.github/workflows/ci-casper-client-rs.yml index 7e68dccf..399aaeb7 100644 --- a/.github/workflows/ci-casper-client-rs.yml +++ b/.github/workflows/ci-casper-client-rs.yml @@ -32,7 +32,7 @@ jobs: - name: Install Toolchain - Stable run: | rustup update --no-self-update ${{ env.RUST_CHANNEL }} - rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src + rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src clippy rustup default ${{ env.RUST_CHANNEL }} - name: Fmt From a52b6b1e7d6242a4106981ee661a9092c44873e4 Mon Sep 17 00:00:00 2001 From: Zach Showalter Date: Fri, 19 Apr 2024 12:50:14 -0400 Subject: [PATCH 13/13] add wasm32-unknown-unknown target to rustup in CI Signed-off-by: Zach Showalter --- .github/workflows/ci-casper-client-rs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-casper-client-rs.yml b/.github/workflows/ci-casper-client-rs.yml index 399aaeb7..89eecef8 100644 --- a/.github/workflows/ci-casper-client-rs.yml +++ b/.github/workflows/ci-casper-client-rs.yml @@ -34,7 +34,7 @@ jobs: rustup update --no-self-update ${{ env.RUST_CHANNEL }} rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src clippy rustup default ${{ env.RUST_CHANNEL }} - + rustup target add wasm32-unknown-unknown - name: Fmt uses: actions-rs/cargo@v1 with: