From 7e9a1c28b49adc1a6e089b867f145d69bc7d1190 Mon Sep 17 00:00:00 2001 From: brenzi Date: Tue, 4 Jun 2024 07:48:56 +0200 Subject: [PATCH] bump version, rustc stable, fmt with nightly, clippy (#292) * bump stable, fmt with nightly * separate fmt and clippy ymls * add github env file * explicit name for clippy runtime * bump 1.10.0-v52 * fix clippy CI --- .github/env | 1 + .github/workflows/ci.yml | 52 +++++++++---------- .github/workflows/clippy-runtime.yml | 39 ++++++++++++++ .github/workflows/fmt.yml | 34 ++++++++++++ Cargo.lock | 6 +-- polkadot-parachains/Cargo.toml | 4 +- polkadot-parachains/common/src/xcm_config.rs | 4 +- .../integritee-runtime/Cargo.toml | 4 +- .../integritee-runtime/src/helpers.rs | 2 +- .../integritee-runtime/src/lib.rs | 18 +++---- .../integritee-runtime/src/migrations.rs | 4 +- polkadot-parachains/shell-runtime/Cargo.toml | 4 +- polkadot-parachains/shell-runtime/src/lib.rs | 2 +- .../shell-runtime/src/xcm_config.rs | 5 +- rust-toolchain.toml | 18 +++---- 15 files changed, 134 insertions(+), 63 deletions(-) create mode 100644 .github/env create mode 100644 .github/workflows/clippy-runtime.yml create mode 100644 .github/workflows/fmt.yml diff --git a/.github/env b/.github/env new file mode 100644 index 00000000..859c1af2 --- /dev/null +++ b/.github/env @@ -0,0 +1 @@ +RUST_NIGHTLY_VERSION=2024-04-14 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58a826d6..fa71fca6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: - '[0-9]+.[0-9]+.[0-9]+' - '[0-9]+.[0-9]+.[0-9]+-dev*' pull_request: - branches: [master] + branches: [ master ] workflow_dispatch: inputs: verbose: @@ -49,9 +49,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04] - rust: [stable] - binary: [release] + os: [ ubuntu-22.04 ] + rust: [ stable ] + binary: [ release ] env: RUST_BACKTRACE: full RUSTV: ${{ matrix.rust }} @@ -76,8 +76,8 @@ jobs: - name: Install protobuf run: | - sudo apt update - sudo apt install --assume-yes protobuf-compiler + sudo apt update + sudo apt install --assume-yes protobuf-compiler - name: Release if: ${{ matrix.binary == 'release' }} @@ -104,9 +104,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04] - rust: [stable] - binary: [release] + os: [ ubuntu-22.04 ] + rust: [ stable ] + binary: [ release ] env: RUST_BACKTRACE: full RUSTV: ${{ matrix.rust }} @@ -162,11 +162,11 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest] - rust: [stable] - rust-target: [x86_64-unknown-linux-gnu] -# check: [fmt --all -- --check, clippy -- -D warnings] - check: [fmt --all -- --check, check --features runtime-benchmarks] # skip clippy for now + os: [ ubuntu-latest ] + rust: [ nightly-2024-04-14 ] + rust-target: [ x86_64-unknown-linux-gnu ] + # check: [fmt --all -- --check, clippy -- -D warnings] + check: [ check --features runtime-benchmarks ] # skip clippy for now env: RUST_BACKTRACE: full RUSTV: ${{ matrix.rust }} @@ -231,7 +231,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - runtime: ["shell", "integritee"] + runtime: [ "shell", "integritee" ] steps: - uses: actions/checkout@v3 @@ -285,12 +285,12 @@ jobs: subwasm meta ${{ steps.srtool_build.outputs.wasm }} subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.runtime }}-metadata.json -# This is unsupported it wants to diff the metadata with a running chain. i.e. wss://kusama--rpc.parity.io -# - name: Check the metadata diff -# shell: bash -# run: | -# subwasm diff ${{ steps.srtool_build.outputs.wasm }} --chain-b ${{ matrix.chain }} > ${{ matrix.chain }}-diff.txt -# cat ${{ matrix.chain }}-diff.txt + # This is unsupported it wants to diff the metadata with a running chain. i.e. wss://kusama--rpc.parity.io + # - name: Check the metadata diff + # shell: bash + # run: | + # subwasm diff ${{ steps.srtool_build.outputs.wasm }} --chain-b ${{ matrix.chain }} > ${{ matrix.chain }}-diff.txt + # cat ${{ matrix.chain }}-diff.txt - name: Archive Subwasm results uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 @@ -320,8 +320,8 @@ jobs: strategy: fail-fast: false matrix: - chain: [integritee] - config: [rococo, westend, kusama, polkadot, moonbase, paseo] + chain: [ integritee ] + config: [ rococo, westend, kusama, polkadot, moonbase, paseo ] include: - chain: shell config: kusama-lease2 @@ -368,7 +368,7 @@ jobs: name: Draft Release if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest - needs: [create_artifacts, build_primary_binaries, check] + needs: [ create_artifacts, build_primary_binaries, check ] outputs: release_url: ${{ steps.create-release.outputs.html_url }} asset_upload_url: ${{ steps.create-release.outputs.upload_url }} @@ -415,10 +415,10 @@ jobs: publish-runtimes: name: Publish Runtimes runs-on: ubuntu-latest - needs: ["release"] + needs: [ "release" ] strategy: matrix: - runtime: ["shell", "integritee"] + runtime: [ "shell", "integritee" ] steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 diff --git a/.github/workflows/clippy-runtime.yml b/.github/workflows/clippy-runtime.yml new file mode 100644 index 00000000..150045b4 --- /dev/null +++ b/.github/workflows/clippy-runtime.yml @@ -0,0 +1,39 @@ +name: Clippy-Runtime + +on: + pull_request: + branches: [ master ] + paths: + - 'polkadot-parachains/integritee-runtime/**' + +# cancel previous runs +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + clippy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set rust version via common env file + run: cat .github/env >> $GITHUB_ENV + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Fetch cache + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 + with: + shared-key: "parachain-cache-clippy" + - name: Run clippy + uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --manifest-path polkadot-parachains/integritee-runtime/Cargo.toml + env: + # RUSTFLAGS: "-D warnings" # FAIL-CI + SKIP_WASM_BUILD: 1 diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 00000000..f14a18e9 --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,34 @@ +name: "Rustfmt (check)" + +on: + push: + branches: + - master + tags: + - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+-dev*' + pull_request: + branches: [ master ] + workflow_dispatch: + inputs: + verbose: + description: "Set --verbose to get verbose build output" + required: false + default: 'true' + +jobs: + rustfmt: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set rust version via common env file + run: cat .github/env >> $GITHUB_ENV + + - name: Install nightly toolchain + run: rustup toolchain install "nightly-$RUST_NIGHTLY_VERSION" --profile minimal --component rustfmt + + - name: Rustfmt (check) + run: cargo +nightly-$RUST_NIGHTLY_VERSION fmt --all -- --check diff --git a/Cargo.lock b/Cargo.lock index d35a1721..ad2deedc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4259,7 +4259,7 @@ dependencies = [ [[package]] name = "integritee-collator" -version = "1.9.5" +version = "1.10.0" dependencies = [ "assert_cmd", "async-trait", @@ -4366,7 +4366,7 @@ dependencies = [ [[package]] name = "integritee-runtime" -version = "1.9.51" +version = "1.10.52" dependencies = [ "assets-common", "cumulus-pallet-aura-ext", @@ -11989,7 +11989,7 @@ dependencies = [ [[package]] name = "shell-runtime" -version = "1.9.16" +version = "1.10.17" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/polkadot-parachains/Cargo.toml b/polkadot-parachains/Cargo.toml index 415c0474..68796803 100644 --- a/polkadot-parachains/Cargo.toml +++ b/polkadot-parachains/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "integritee-collator" description = "The Integritee parachain collator binary" -# align major.minor revision with the runtimes. bump patch revision ad lib. make this the github release tag -version = "1.9.5" +# align major.minor revision with polkadot SDK. bump patch revision ad lib. make this the github release tag +version = "1.10.0" authors = ["Integritee AG "] homepage = "https://integritee.network/" repository = "https://github.com/integritee-network/parachain" diff --git a/polkadot-parachains/common/src/xcm_config.rs b/polkadot-parachains/common/src/xcm_config.rs index 136556ca..4e020d3f 100644 --- a/polkadot-parachains/common/src/xcm_config.rs +++ b/polkadot-parachains/common/src/xcm_config.rs @@ -40,7 +40,7 @@ where fn contains(asset: &Asset, origin: &Location) -> bool { if let Some(ref reserve) = ReserveProvider::reserve(asset) { if reserve == origin { - return true; + return true } } false @@ -61,7 +61,7 @@ where fn matches_fungible(a: &Asset) -> Option { if let (Fungible(ref amount), AssetId(location)) = (&a.fun, &a.id) { if CurrencyIdConvert::convert(location.clone()).is_some() { - return CheckedConversion::checked_from(*amount); + return CheckedConversion::checked_from(*amount) } } None diff --git a/polkadot-parachains/integritee-runtime/Cargo.toml b/polkadot-parachains/integritee-runtime/Cargo.toml index c58c6fbf..a4dfeedc 100644 --- a/polkadot-parachains/integritee-runtime/Cargo.toml +++ b/polkadot-parachains/integritee-runtime/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "integritee-runtime" description = "The Integritee parachain runtime" -# patch revision must match runtime spec_version -version = "1.9.51" +# align major.minor revision with polkadot SDK. patch revision must match runtime spec_version +version = "1.10.52" authors = ["Integritee AG "] homepage = "https://integritee.network/" repository = "https://github.com/integritee-network/parachain" diff --git a/polkadot-parachains/integritee-runtime/src/helpers.rs b/polkadot-parachains/integritee-runtime/src/helpers.rs index c7f91209..65e992a0 100644 --- a/polkadot-parachains/integritee-runtime/src/helpers.rs +++ b/polkadot-parachains/integritee-runtime/src/helpers.rs @@ -26,7 +26,7 @@ /// Usage: /// ```Rust /// parameter_types! { -/// pub const VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES); +/// pub const VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES); /// } #[macro_export] macro_rules! prod_or_fast { diff --git a/polkadot-parachains/integritee-runtime/src/lib.rs b/polkadot-parachains/integritee-runtime/src/lib.rs index fadc69b3..90d7bfa9 100644 --- a/polkadot-parachains/integritee-runtime/src/lib.rs +++ b/polkadot-parachains/integritee-runtime/src/lib.rs @@ -68,7 +68,7 @@ pub use integritee_parachains_common::{ use pallet_asset_conversion::{Ascending, Chain, WithFirstAsset}; pub use pallet_balances::Call as BalancesCall; pub use pallet_claims; -use pallet_collective; +pub use pallet_collective; pub use pallet_enclave_bridge; pub use pallet_sidechain; pub use pallet_teeracle; @@ -120,7 +120,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("integritee-parachain"), impl_name: create_runtime_str!("integritee-full"), authoring_version: 2, - spec_version: 51, + spec_version: 52, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 7, @@ -385,7 +385,7 @@ impl pallet_proxy::Config for Runtime { } parameter_types! { - pub const MinVestedTransfer: Balance = 1 * TEER; + pub const MinVestedTransfer: Balance = TEER; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } @@ -429,7 +429,7 @@ impl pallet_utility::Config for Runtime { } parameter_types! { - pub const PreimageBaseDeposit: Balance = 1 * TEER; + pub const PreimageBaseDeposit: Balance = TEER; pub const PreimageByteDeposit: Balance = deposit(0, 1); pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage); @@ -595,7 +595,7 @@ pub struct NoConversion; impl ConversionFromAssetBalance for NoConversion { type Error = (); fn from_asset_balance(balance: Balance, _asset_id: ()) -> Result { - return Ok(balance); + Ok(balance) } #[cfg(feature = "runtime-benchmarks")] fn ensure_successful(_: ()) {} @@ -629,12 +629,12 @@ impl pallet_treasury::Config for Runtime { } parameter_types! { - pub const BountyDepositBase: Balance = 1 * TEER; + pub const BountyDepositBase: Balance = TEER; pub const BountyDepositPayoutDelay: BlockNumber = prod_or_fast!(4 * DAYS, 4 * MINUTES); pub const BountyUpdatePeriod: BlockNumber = prod_or_fast!(90 * DAYS, 15 * MINUTES); pub const MaximumReasonLength: u32 = 16384; pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50); - pub const CuratorDepositMin: Balance = 1 * TEER; + pub const CuratorDepositMin: Balance = TEER; pub const CuratorDepositMax: Balance = 100 * TEER; pub const BountyValueMinimum: Balance = 100 * TEER; } @@ -740,7 +740,7 @@ parameter_types! { pub FastTrackVotingPeriod: BlockNumber = prod_or_fast!(3 * HOURS, 2 * MINUTES); pub const MinimumDeposit: Balance = 100 * TEER; pub EnactmentPeriod: BlockNumber = prod_or_fast!(2 * DAYS, 1); - pub const CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES); + pub const CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, MINUTES); pub const InstantAllowed: bool = true; pub const MaxVotes: u32 = 100; pub const MaxProposals: u32 = 100; @@ -808,7 +808,7 @@ impl EnsureOriginWithArg for NoAsset o: RuntimeOrigin, _a: &AssetIdForTrustBackedAssets, ) -> sp_std::result::Result { - return Err(o); + Err(o) } #[cfg(feature = "runtime-benchmarks")] diff --git a/polkadot-parachains/integritee-runtime/src/migrations.rs b/polkadot-parachains/integritee-runtime/src/migrations.rs index dfc2f955..dc783bcf 100644 --- a/polkadot-parachains/integritee-runtime/src/migrations.rs +++ b/polkadot-parachains/integritee-runtime/src/migrations.rs @@ -10,7 +10,7 @@ pub mod scheduler { use sp_runtime::TryRuntimeError; /// The log target. - const TARGET: &'static str = "runtime::fix::scheduler::migration"; + const TARGET: &str = "runtime::fix::scheduler::migration"; pub mod v1 { use super::*; @@ -102,7 +102,7 @@ pub mod scheduler { Expected version == 4, found {:?}", onchain_version, ); - return T::DbWeight::get().reads(1); + return T::DbWeight::get().reads(1) } log::info!(target: TARGET, "migrating from {:?} to 4, purging agenda", onchain_version); let purged_agendas = v1::Agenda::::clear(u32::MAX, None).unique as u64; diff --git a/polkadot-parachains/shell-runtime/Cargo.toml b/polkadot-parachains/shell-runtime/Cargo.toml index 82922cf2..84a8da58 100644 --- a/polkadot-parachains/shell-runtime/Cargo.toml +++ b/polkadot-parachains/shell-runtime/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "shell-runtime" description = "The Integritee shell parachain runtime" -# major.minor revision must match collator node. patch should match spec_version -version = "1.9.16" +# align major.minor revision with polkadot SDK. patch should match spec_version +version = "1.10.17" authors = ["Integritee AG "] homepage = "https://integritee.network/" repository = "https://github.com/integritee-network/parachain" diff --git a/polkadot-parachains/shell-runtime/src/lib.rs b/polkadot-parachains/shell-runtime/src/lib.rs index a84ff7b5..a2e00d00 100644 --- a/polkadot-parachains/shell-runtime/src/lib.rs +++ b/polkadot-parachains/shell-runtime/src/lib.rs @@ -96,7 +96,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("integritee-parachain"), impl_name: create_runtime_str!("integritee-shell"), authoring_version: 0, - spec_version: 16, + spec_version: 17, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/polkadot-parachains/shell-runtime/src/xcm_config.rs b/polkadot-parachains/shell-runtime/src/xcm_config.rs index 43c038af..94a4b84e 100644 --- a/polkadot-parachains/shell-runtime/src/xcm_config.rs +++ b/polkadot-parachains/shell-runtime/src/xcm_config.rs @@ -125,10 +125,7 @@ impl Convert> for CurrencyIdConvert { [Parachain(id), TEER_GENERAL_KEY] if *id == self_para_id => Some(CurrencyId::TEER), _ => None, }, - (0, interior) => match interior { - [TEER_GENERAL_KEY] => Some(CurrencyId::TEER), - _ => None, - }, + (0, [TEER_GENERAL_KEY]) => Some(CurrencyId::TEER), _ => None, } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 077aeba9..3c5b1312 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,14 +1,14 @@ [toolchain] -channel = "nightly-2023-11-01" +channel = "1.77.0" components = [ - "cargo", - "clippy", - "rust-analyzer", - "rust-src", - "rust-std", - "rustc", - "rustc-dev", - "rustfmt", + "cargo", + "clippy", + "rust-analyzer", + "rust-src", + "rust-std", + "rustc", + "rustc-dev", + "rustfmt", ] targets = ["wasm32-unknown-unknown"] profile = "default" # include rustfmt, clippy