From 3a0ed135529b23b9a36afa9c6625596589f7ac81 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:12:06 +0200 Subject: [PATCH 1/5] build(github): extract Rust toolchain version from rust-toolchain.toml --- .github/actions/rust/action.yaml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/actions/rust/action.yaml b/.github/actions/rust/action.yaml index 01239962fc1..cdfc7e11e63 100644 --- a/.github/actions/rust/action.yaml +++ b/.github/actions/rust/action.yaml @@ -3,9 +3,8 @@ name: "Rust Dependencies" description: "Install dependencies" inputs: toolchain: - description: Rust toolchain to use, stable / nightly / beta, or exact version - # The same as in /README.md - default: "1.76" + description: Rust toolchain to use, stable / nightly / beta, or exact version; uses rust-toolchain.toml if not specified + default: "" target: description: Target Rust platform required: false @@ -21,11 +20,24 @@ inputs: runs: using: composite steps: + - name: Extract Rust toolchain version from rust-toolchain.toml + shell: bash + id: rust_toolchain + run: | + TOOLCHAIN_VERSION="${{ inputs.toolchain }}" + if [[ -z "$TOOLCHAIN_VERSION" ]]; then + TOOLCHAIN_VERSION=$(grep channel rust-toolchain.toml | awk '{print $3}' | tr -d '"') + fi + + echo "TOOLCHAIN_VERSION=$TOOLCHAIN_VERSION" >> $GITHUB_ENV + echo "::set-output name=version::$TOOLCHAIN_VERSION" + # TODO: Move to AMI and build every day - uses: dtolnay/rust-toolchain@master name: Install Rust toolchain + id: install_rust with: - toolchain: ${{ inputs.toolchain }} + toolchain: ${{ steps.rust_toolchain.outputs.version }} target: ${{ inputs.target }} components: ${{ inputs.components }} From c82206cc5580226914d8e4388cf2633e825ecc4b Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:13:13 +0200 Subject: [PATCH 2/5] build(cargo.toml): inherit rust-version from workspace --- Cargo.toml | 3 ++ packages/dapi-grpc/Cargo.toml | 2 +- packages/dashpay-contract/Cargo.toml | 2 +- packages/data-contracts/Cargo.toml | 2 +- packages/dpns-contract/Cargo.toml | 2 +- packages/feature-flags-contract/Cargo.toml | 2 +- .../Cargo.toml | 2 +- packages/rs-dpp/Cargo.toml | 2 +- packages/rs-drive-abci/Cargo.toml | 2 +- packages/rs-drive-proof-verifier/Cargo.toml | 2 +- packages/rs-drive-verify-c-binding/Cargo.toml | 2 +- packages/rs-drive/Cargo.toml | 4 +-- .../Cargo.toml | 6 ++-- .../Cargo.toml | 2 +- packages/rs-platform-serialization/Cargo.toml | 2 +- .../rs-platform-value-convertible/Cargo.toml | 2 +- packages/rs-platform-value/Cargo.toml | 2 +- packages/rs-platform-version/Cargo.toml | 4 +-- packages/rs-platform-versioning/Cargo.toml | 2 +- packages/simple-signer/Cargo.toml | 4 +-- packages/strategy-tests/Cargo.toml | 2 +- packages/wasm-dpp/Cargo.toml | 2 +- packages/withdrawals-contract/Cargo.toml | 2 +- scripts/update_rust_version.sh | 34 +++++++++++++++++++ 24 files changed, 63 insertions(+), 28 deletions(-) create mode 100755 scripts/update_rust_version.sh diff --git a/Cargo.toml b/Cargo.toml index bdf98a874fa..1c533f315bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,9 @@ members = [ "packages/rs-json-schema-compatibility-validator", "packages/check-features", ] +[workspace.package] + +rust-version = "1.76" [patch.crates-io] tower-service = { git = "https://github.com/QuantumExplorer/tower", branch = "fix/indexMap2OnV0413" } diff --git a/packages/dapi-grpc/Cargo.toml b/packages/dapi-grpc/Cargo.toml index c70258a333d..9039b60b7e4 100644 --- a/packages/dapi-grpc/Cargo.toml +++ b/packages/dapi-grpc/Cargo.toml @@ -10,7 +10,7 @@ authors = [ "Ivan Shumkov ", ] edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [features] diff --git a/packages/dashpay-contract/Cargo.toml b/packages/dashpay-contract/Cargo.toml index 92ae5794cd5..996c7b10442 100644 --- a/packages/dashpay-contract/Cargo.toml +++ b/packages/dashpay-contract/Cargo.toml @@ -3,7 +3,7 @@ name = "dashpay-contract" description = "DashPay data contract schema and tools" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/data-contracts/Cargo.toml b/packages/data-contracts/Cargo.toml index 7e0b5441f9c..be84cfdc812 100644 --- a/packages/data-contracts/Cargo.toml +++ b/packages/data-contracts/Cargo.toml @@ -3,7 +3,7 @@ name = "data-contracts" description = "Dash Platform system data contracts" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/dpns-contract/Cargo.toml b/packages/dpns-contract/Cargo.toml index 73cf5273753..c9dac7b4fe1 100644 --- a/packages/dpns-contract/Cargo.toml +++ b/packages/dpns-contract/Cargo.toml @@ -3,7 +3,7 @@ name = "dpns-contract" description = "DPNS data contract schema and tools" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/feature-flags-contract/Cargo.toml b/packages/feature-flags-contract/Cargo.toml index 429fd81ea09..379778e18c7 100644 --- a/packages/feature-flags-contract/Cargo.toml +++ b/packages/feature-flags-contract/Cargo.toml @@ -3,7 +3,7 @@ name = "feature-flags-contract" description = "Feature flags data contract schema and tools" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/masternode-reward-shares-contract/Cargo.toml b/packages/masternode-reward-shares-contract/Cargo.toml index 61266726822..dc6c8d1fcc5 100644 --- a/packages/masternode-reward-shares-contract/Cargo.toml +++ b/packages/masternode-reward-shares-contract/Cargo.toml @@ -3,7 +3,7 @@ name = "masternode-reward-shares-contract" description = "Masternode reward shares data contract schema and tools" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/rs-dpp/Cargo.toml b/packages/rs-dpp/Cargo.toml index 9b916baae93..3431c7ba49a 100644 --- a/packages/rs-dpp/Cargo.toml +++ b/packages/rs-dpp/Cargo.toml @@ -2,7 +2,7 @@ name = "dpp" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true authors = [ "Anton Suprunchuk ", "Samuel Westrich ", diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 1675ee853f0..4413680a057 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -9,7 +9,7 @@ authors = [ "Igor Markin ", ] edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/rs-drive-proof-verifier/Cargo.toml b/packages/rs-drive-proof-verifier/Cargo.toml index 8630d0225c5..429610470b2 100644 --- a/packages/rs-drive-proof-verifier/Cargo.toml +++ b/packages/rs-drive-proof-verifier/Cargo.toml @@ -2,7 +2,7 @@ name = "drive-proof-verifier" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true crate-type = ["cdylib"] diff --git a/packages/rs-drive-verify-c-binding/Cargo.toml b/packages/rs-drive-verify-c-binding/Cargo.toml index 3a2ccf94a19..07bb5314be2 100644 --- a/packages/rs-drive-verify-c-binding/Cargo.toml +++ b/packages/rs-drive-verify-c-binding/Cargo.toml @@ -2,7 +2,7 @@ name = "rs-drive-verify-c-binding" version = "0.25.16-rc.3" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index 7635be94c59..f2cd1e74a46 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -9,7 +9,7 @@ authors = [ "Wisdom Ogwu ", -] +rust-version.workspace = true +authors = ["Ivan Shumkov "] [dependencies] json-patch = "1.2.0" diff --git a/packages/rs-platform-serialization-derive/Cargo.toml b/packages/rs-platform-serialization-derive/Cargo.toml index 58810354baa..77a87bf6653 100644 --- a/packages/rs-platform-serialization-derive/Cargo.toml +++ b/packages/rs-platform-serialization-derive/Cargo.toml @@ -4,7 +4,7 @@ authors = ["Samuel Westrich "] description = "Bincode serialization and deserialization derivations" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [lib] diff --git a/packages/rs-platform-serialization/Cargo.toml b/packages/rs-platform-serialization/Cargo.toml index 43739e0d9ef..f1c0b34b1df 100644 --- a/packages/rs-platform-serialization/Cargo.toml +++ b/packages/rs-platform-serialization/Cargo.toml @@ -4,7 +4,7 @@ authors = ["Samuel Westrich "] description = "Bincode based serialization and deserialization" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/rs-platform-value-convertible/Cargo.toml b/packages/rs-platform-value-convertible/Cargo.toml index 2339afce87b..36c19c2d36e 100644 --- a/packages/rs-platform-value-convertible/Cargo.toml +++ b/packages/rs-platform-value-convertible/Cargo.toml @@ -4,7 +4,7 @@ authors = ["Samuel Westrich "] description = "Convertion to and from platform values" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [lib] diff --git a/packages/rs-platform-value/Cargo.toml b/packages/rs-platform-value/Cargo.toml index dfa51e74bf5..f6f3ef5560b 100644 --- a/packages/rs-platform-value/Cargo.toml +++ b/packages/rs-platform-value/Cargo.toml @@ -4,7 +4,7 @@ authors = ["Samuel Westrich "] description = "A simple value module" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/rs-platform-version/Cargo.toml b/packages/rs-platform-version/Cargo.toml index 55e6458b23f..5e4747757fd 100644 --- a/packages/rs-platform-version/Cargo.toml +++ b/packages/rs-platform-version/Cargo.toml @@ -4,12 +4,12 @@ authors = ["Samuel Westrich "] description = "Versioning library for Platform" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] thiserror = { version = "1.0.59" } -bincode = { version = "2.0.0-rc.3"} +bincode = { version = "2.0.0-rc.3" } versioned-feature-core = { git = "https://github.com/dashpay/versioned-feature-core", version = "1.0.0" } grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "2c14841e95b4222d489f0655c85238bc05267b91" } once_cell = "1.19.0" diff --git a/packages/rs-platform-versioning/Cargo.toml b/packages/rs-platform-versioning/Cargo.toml index 7ef41ff106b..4ff37f26cdb 100644 --- a/packages/rs-platform-versioning/Cargo.toml +++ b/packages/rs-platform-versioning/Cargo.toml @@ -4,7 +4,7 @@ authors = ["Samuel Westrich "] description = "Version derivation" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [lib] diff --git a/packages/simple-signer/Cargo.toml b/packages/simple-signer/Cargo.toml index 9337d46a92a..ad63547a493 100644 --- a/packages/simple-signer/Cargo.toml +++ b/packages/simple-signer/Cargo.toml @@ -2,7 +2,7 @@ name = "simple-signer" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,4 +10,4 @@ rust-version = "1.76" bincode = { version = "2.0.0-rc.3", features = ["serde"] } dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore-rpc", tag = "v0.15.4" } dpp = { path = "../rs-dpp", features = ["abci"] } -base64 = { version = "0.22.1"} +base64 = { version = "0.22.1" } diff --git a/packages/strategy-tests/Cargo.toml b/packages/strategy-tests/Cargo.toml index 29aef67b897..16763197f15 100644 --- a/packages/strategy-tests/Cargo.toml +++ b/packages/strategy-tests/Cargo.toml @@ -7,7 +7,7 @@ authors = [ "Paul DeLucia ", ] edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/packages/wasm-dpp/Cargo.toml b/packages/wasm-dpp/Cargo.toml index cf14fc9d130..3b815a456e8 100644 --- a/packages/wasm-dpp/Cargo.toml +++ b/packages/wasm-dpp/Cargo.toml @@ -2,7 +2,7 @@ name = "wasm-dpp" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true authors = ["Anton Suprunchuk "] [lib] diff --git a/packages/withdrawals-contract/Cargo.toml b/packages/withdrawals-contract/Cargo.toml index e96a28d9595..fa5310a16c2 100644 --- a/packages/withdrawals-contract/Cargo.toml +++ b/packages/withdrawals-contract/Cargo.toml @@ -3,7 +3,7 @@ name = "withdrawals-contract" description = "Witdrawals data contract schema and tools" version = "1.1.0-dev.1" edition = "2021" -rust-version = "1.76" +rust-version.workspace = true license = "MIT" [dependencies] diff --git a/scripts/update_rust_version.sh b/scripts/update_rust_version.sh new file mode 100755 index 00000000000..d653f0ea9e1 --- /dev/null +++ b/scripts/update_rust_version.sh @@ -0,0 +1,34 @@ +#! /bin/bash -e + +# This script updates the rust version to the one provided in the first argument. +# Requires `yq` to be installed: https://github.com/mikefarah/yq +PROJECT_ROOT="$(realpath "$(dirname "$0")"/..)" + +# Check if the first argument is provided +if [ -z "${1}" ]; then + echo "Please provide the new rust version as the first argument." + exit 1 +fi + +VERSION="$1" + +function check { + for file in "$@"; do + if ! grep -q "${VERSION}" "${file}"; then + echo "The file ${file} does not contain the version ${VERSION}." + exit 1 + fi + done +} + +echo Update the rust version in the Cargo.toml file +sed -i "s/^rust-version = \".*\"/rust-version = \"${VERSION}\"/" "${PROJECT_ROOT}"/*/*/Cargo.toml +check "${PROJECT_ROOT}"/Cargo.toml + +echo Update the rust version in the README.md +sed -i "s/\(\[rust\](https.*)\) v[0-9.]\++,/\1 v$VERSION+,/" "${PROJECT_ROOT}/README.md" +check "${PROJECT_ROOT}/README.md" + +echo Update the rust version in rust-toolchain.toml +sed -i "s/^channel = \".*\"/channel = \"${VERSION}\"/" "${PROJECT_ROOT}/rust-toolchain.toml" +check "${PROJECT_ROOT}/rust-toolchain.toml" From 5dec6179a8642f5cb5c0501366af2153f0b253f7 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:16:28 +0200 Subject: [PATCH 3/5] build(Docker): take rust version from rust-toolchain.toml --- Dockerfile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 67c1c96a7e3..7d45dee9533 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,13 +68,17 @@ RUN npm config set --global audit false ARG TARGETARCH +WORKDIR /platform + + # TODO: It doesn't sharing PATH between stages, so we need "source $HOME/.cargo/env" everywhere -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ - --profile minimal \ - -y \ - # Rust version the same as in /README.md - --default-toolchain 1.76 \ - --target wasm32-unknown-unknown +COPY rust-toolchain.toml . +RUN TOOLCHAIN_VERSION="$(grep channel rust-toolchain.toml | awk '{print $3}' | tr -d '"')" && \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ + --profile minimal \ + -y \ + --default-toolchain "${TOOLCHAIN_VERSION}" \ + --target wasm32-unknown-unknown # Install protoc - protobuf compiler # The one shipped with Alpine does not work From cd9052dbb7a5a8666a77316b14fe15a6cfc4e7bb Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:18:33 +0200 Subject: [PATCH 4/5] chore: minor fix in update-rust-version.sh --- scripts/update_rust_version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_rust_version.sh b/scripts/update_rust_version.sh index d653f0ea9e1..d0868be2aa3 100755 --- a/scripts/update_rust_version.sh +++ b/scripts/update_rust_version.sh @@ -22,7 +22,7 @@ function check { } echo Update the rust version in the Cargo.toml file -sed -i "s/^rust-version = \".*\"/rust-version = \"${VERSION}\"/" "${PROJECT_ROOT}"/*/*/Cargo.toml +sed -i "s/^rust-version = \".*\"/rust-version = \"${VERSION}\"/" "${PROJECT_ROOT}"/Cargo.toml check "${PROJECT_ROOT}"/Cargo.toml echo Update the rust version in the README.md From 23fd00213afc8134d681db4966f871e740a56195 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:19:58 +0200 Subject: [PATCH 5/5] build(deps): update rust to 1.80 --- Cargo.toml | 2 +- README.md | 2 +- rust-toolchain.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1c533f315bc..ab03e80fb4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ members = [ ] [workspace.package] -rust-version = "1.76" +rust-version = "1.80" [patch.crates-io] tower-service = { git = "https://github.com/QuantumExplorer/tower", branch = "fix/indexMap2OnV0413" } diff --git a/README.md b/README.md index d4853d7f891..45689c393c5 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ this repository may be used on the following networks: - Install prerequisites: - [node.js](https://nodejs.org/) v20 - [docker](https://docs.docker.com/get-docker/) v20.10+ - - [rust](https://www.rust-lang.org/tools/install) v1.76+, with wasm32 target (`rustup target add wasm32-unknown-unknown`) + - [rust](https://www.rust-lang.org/tools/install) v1.80+, with wasm32 target (`rustup target add wasm32-unknown-unknown`) - [protoc - protobuf compiler](https://github.com/protocolbuffers/protobuf/releases) v25.2+ - if needed, set PROTOC environment variable to location of `protoc` binary - [wasm-bingen toolchain](https://rustwasm.github.io/wasm-bindgen/): diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6ff0f74bf9f..42a546e0324 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] # Rust version the same as in /README.md -channel = "1.76" +channel = "1.80" targets = ["wasm32-unknown-unknown"]