From 718814d989865236a96ebce72e7a9cd0ccf511b5 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 27 May 2025 16:26:36 +0200 Subject: [PATCH 1/6] fix ci --- .github/workflows/check-code.yml | 11 + .../peregrine/src/xcm_components/trader.rs | 257 ++++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 runtimes/peregrine/src/xcm_components/trader.rs diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index fe03041c8..1cae20243 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -360,6 +360,17 @@ jobs: ~/.cargo/git/db/ key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} + - name: Install frame-omni-bencher + run: | + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/workspace" \ + -v "${HOME}/.cargo/registry/index:${{ env.CARGO_HOME }}/registry/index" \ + -v "${HOME}/.cargo/registry/cache:${{ env.CARGO_HOME }}/registry/cache" \ + -v "${HOME}/.cargo/git/db:${{ env.CARGO_HOME }}/git/db" \ + -w /workspace \ + paritytech/ci-unified:bullseye-1.81.0 \ + bash -c "cargo install frame-omni-bencher --locked" + - name: Run runtime benchmarks run: | docker run --rm \ diff --git a/runtimes/peregrine/src/xcm_components/trader.rs b/runtimes/peregrine/src/xcm_components/trader.rs new file mode 100644 index 000000000..bd47b3a2b --- /dev/null +++ b/runtimes/peregrine/src/xcm_components/trader.rs @@ -0,0 +1,257 @@ +// KILT Blockchain – +// Copyright (C) 2025, KILT Foundation + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at + +use frame_support::{ + ensure, + traits::{fungible::Mutate, tokens::Preservation}, + weights::WeightToFee as WeightToFeeT, +}; +use sp_core::Get; +use sp_runtime::traits::Zero; +use sp_std::marker::PhantomData; +use xcm::v4::{Asset, AssetId, Error, Location, Weight, XcmContext, XcmHash}; +use xcm_executor::{traits::WeightTrader, AssetsInHolding}; + +const LOG_TARGET: &str = "xcm::bKILT::UsingComponentsForBKILT"; + +/// Type implementing [WeightTrader] that allows paying for XCM fees when +/// reserve transferring the remote asset of the on-chain switch pair. +/// +/// This trader is required in case there is no other mechanism to pay for +/// fees when transferring such an asset to this chain. +/// +/// Any unused fee is transferred from the switch pair pool account to the +/// specified account. +#[derive(Default, Debug, Clone)] +pub struct UsingComponentsForSwitchPairRemoteAsset +where + T: Config, + I: 'static, + FeeDestinationAccount: Get, +{ + remaining_weight: Weight, + remaining_fungible_balance: u128, + consumed_xcm_hash: Option, + remote_asset_id: AssetId, + remote_location: Location, + _phantom: PhantomData<(WeightToFee, I, FeeDestinationAccount)>, +} + +impl PartialEq + for UsingComponentsForSwitchPairRemoteAsset +where + T: Config, + I: 'static, + FeeDestinationAccount: Get, +{ + fn eq(&self, other: &Self) -> bool { + self.remaining_weight == other.remaining_weight + && self.remaining_fungible_balance == other.remaining_fungible_balance + && self.consumed_xcm_hash == other.consumed_xcm_hash + && self.remote_asset_id == other.remote_asset_id + && self.remote_location == other.remote_location + } +} + +impl WeightTrader + for UsingComponentsForSwitchPairRemoteAsset +where + T: Config, + I: 'static, + FeeDestinationAccount: Get, + WeightToFee: WeightToFeeT, +{ + fn new() -> Self { + let switch_pair = SwitchPair::::get(); + Self { + consumed_xcm_hash: None, + remaining_fungible_balance: Zero::zero(), + remaining_weight: Zero::zero(), + _phantom: PhantomData, + } + } + + fn buy_weight( + &mut self, + weight: Weight, + payment: AssetsInHolding, + context: &XcmContext, + ) -> Result { + log::info!( + target: LOG_TARGET, + "buy_weight {:?}, {:?}, {:?}", + weight, + payment, + context + ); + + // Prevent re-using the same trader more than once. + ensure!(self.consumed_xcm_hash.is_none(), Error::NotWithdrawable); + // Asset not relevant if no switch pair is set or if not enabled. + let switch_pair = self.switch_pair.as_ref().ok_or(Error::AssetNotFound)?; + ensure!(switch_pair.is_enabled(), Error::AssetNotFound); + + let amount = WeightToFee::weight_to_fee(&weight); + + let switch_pair_remote_asset_v4: AssetId = switch_pair.remote_asset_id.clone().try_into().map_err(|e| { + log::error!( + target: LOG_TARGET, + "Failed to convert stored asset ID {:?} into v4 AssetId with error {:?}", + switch_pair.remote_asset_id, + e + ); + Error::FailedToTransactAsset("Failed to convert switch pair asset ID into required version.") + })?; + + let required: Asset = (switch_pair_remote_asset_v4, amount).into(); + let unused = payment.checked_sub(required.clone()).map_err(|_| Error::TooExpensive)?; + + // Set link to XCM message ID only if this is the trader used. + log::trace!(target: LOG_TARGET, "Required {:?} - unused {:?}", required, unused); + self.consumed_xcm_hash = Some(context.message_id); + self.remaining_fungible_balance = self.remaining_fungible_balance.saturating_add(amount); + self.remaining_weight = self.remaining_weight.saturating_add(weight); + + Ok(unused) + } + + fn refund_weight(&mut self, weight: Weight, context: &XcmContext) -> Option { + log::trace!( + target: LOG_TARGET, + "UsingComponents::refund_weight weight: {:?}, context: {:?}", + weight, + context + ); + + // Ensure we refund in the same trader we took fees from. + if Some(context.message_id) != self.consumed_xcm_hash { + return None; + }; + + let Some(switch_pair) = &self.switch_pair else { + log::error!(target: LOG_TARGET, "Stored switch pair should not be None, but it is."); + return None; + }; + if !switch_pair.is_enabled() { + return None; + } + + let switch_pair_remote_asset_v4: AssetId = switch_pair + .remote_asset_id + .clone() + .try_into() + .map_err(|e| { + log::error!( + target: LOG_TARGET, + "Failed to convert stored asset ID {:?} into v4 AssetId with error {:?}", + switch_pair.remote_asset_id, + e + ); + Error::FailedToTransactAsset("Failed to convert switch pair asset ID into required version.") + }) + .ok()?; + + let weight_to_refund = weight.min(self.remaining_weight); + let amount_for_weight_to_refund = WeightToFee::weight_to_fee(&weight_to_refund); + // We can only refund up to the remaining balance of this weigher. + let amount_to_refund = amount_for_weight_to_refund.min(self.remaining_fungible_balance); + + self.consumed_xcm_hash = None; + self.remaining_fungible_balance = self.remaining_fungible_balance.saturating_sub(amount_to_refund); + self.remaining_weight = self.remaining_weight.saturating_sub(weight_to_refund); + + if amount_to_refund > 0 { + log::trace!( + target: LOG_TARGET, + "Refund amount {:?}", + (switch_pair_remote_asset_v4.clone(), amount_to_refund) + ); + Some((switch_pair_remote_asset_v4, amount_to_refund).into()) + } else { + log::trace!(target: LOG_TARGET, "No refund"); + None + } + } +} + +// Move any unused asset from the switch pool account to the specified account, +// and update the remote balance with the difference since we know we control +// the full amount on the remote location. +impl Drop + for UsingComponentsForSwitchPairRemoteAsset +where + T: Config, + I: 'static, + FeeDestinationAccount: Get, +{ + fn drop(&mut self) { + log::trace!( + target: LOG_TARGET, + "Drop with remaining {:?}", + ( + self.consumed_xcm_hash, + self.remaining_fungible_balance, + self.remaining_weight, + &self.switch_pair + ) + ); + + // Nothing to refund if this trader was not called or if the leftover balance is + // zero. + if let Some(switch_pair) = &self.switch_pair { + // We don't care if the pool is enabled, since we're sending all non-refunded + // weight to the configured destination account (e.g., treasury). + if self.remaining_fungible_balance > Zero::zero() { + let Ok(remaining_balance_as_local_currency) = LocalCurrencyBalanceOf::::try_from(self.remaining_fungible_balance).inspect_err(|_| { + log::error!(target: LOG_TARGET, "Failed to convert remaining balance {:?} to local currency balance", self.remaining_fungible_balance); + }) else { return; }; + + // No error should ever be thrown from inside this block. + let transfer_result = >::transfer( + &switch_pair.pool_account, + &FeeDestinationAccount::get(), + remaining_balance_as_local_currency, + Preservation::Preserve, + ).inspect_err(|_| { + log::error!(target: LOG_TARGET, "Failed to transfer unused balance {:?} from switch pair pool account {:?} to specified account {:?}", remaining_balance_as_local_currency, switch_pair.pool_account, FeeDestinationAccount::get()); + }); + + debug_assert!( + transfer_result.is_ok(), + "Transferring from pool account to fee destination failed." + ); + + // No error should ever be thrown from inside this block. + SwitchPair::::mutate(|entry| { + let Some(existing_switch_pair) = entry.as_mut() else { + log::error!(target: LOG_TARGET, "Stored switch pair should not be None but it is."); + return; + }; + existing_switch_pair + .try_process_incoming_switch(self.remaining_fungible_balance) + .unwrap_or_else(|_| { + log::error!( + target: LOG_TARGET, + "Failed to increase balance of remote sovereign account due to overflow." + ); + }); + }); + } + } + } +} From 9d20a1b959ef5845c2dcdc2f9fbc98f9deb16c80 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 27 May 2025 16:28:25 +0200 Subject: [PATCH 2/6] fix ci --- .github/workflows/check-code.yml | 587 ++++++++++++++++--------------- 1 file changed, 294 insertions(+), 293 deletions(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index 1cae20243..f864ff2d0 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -1,6 +1,7 @@ name: Check codebase on: + workflow_dispatch: pull_request: push: branches: @@ -31,298 +32,298 @@ jobs: id: get-head-commit-message run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" - cargo-clippy: - name: Run Clippy checks - runs-on: ubuntu-latest - container: - image: paritytech/ci-unified:bullseye-1.81.0 - env: - # Configured by the Docker image. We can't change this unless the image does it. - CARGO_HOME: /usr/local/cargo - SKIP_WASM_BUILD: 1 - needs: get-commit-head - if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} - - strategy: - matrix: - cargo-flags: - # Generic clippy checks for all features - - --all-targets --all-features - # Generic clippy checks for no features (catches some missing `no_std`-only lints) - - --all-targets - # Clippy lints specifically for all runtime code, excluding all test and binary crates - - --target wasm32-unknown-unknown --no-default-features --workspace --exclude kilt-parachain --exclude standalone-node --exclude xcm-integration-tests --exclude 'dip-provider*' --exclude 'dip-consumer*' - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - path: | - ${{ env.CARGO_HOME }}/bin/ - ${{ env.CARGO_HOME }}/registry/index/ - ${{ env.CARGO_HOME }}/registry/cache/ - ${{ env.CARGO_HOME }}/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ matrix.cargo-flags }}-${{ hashFiles('**/Cargo.lock') }} - save-always: true - - - name: Run `cargo clippy` - run: cargo clippy --locked --no-deps ${{ matrix.cargo-flags }} - - cargo-fmt: - name: Check formatting - runs-on: ubuntu-latest - container: - image: paritytech/ci-unified:bullseye-1.81.0 - env: - # Configured by the Docker image. We can't change this unless the image does it. - CARGO_HOME: /usr/local/cargo - # Latest nightly version matching the base rustc version (1.18.0). - RUSTUP_NIGHTLY_VERSION: nightly-2023-10-02 - needs: get-commit-head - if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - path: | - ${{ env.CARGO_HOME }}/bin/ - ${{ env.CARGO_HOME }}/registry/index/ - ${{ env.CARGO_HOME }}/registry/cache/ - ${{ env.CARGO_HOME }}/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} - save-always: true - - - name: Install nightly toolchain - run: rustup toolchain add ${{ env.RUSTUP_NIGHTLY_VERSION }} - - - name: Run `cargo fmt` - run: cargo +${{ env.RUSTUP_NIGHTLY_VERSION }} fmt -- --check - - - name: Run `taplo` - run: taplo fmt --check - - cargo-deny: - name: Check cargo-deny rules - runs-on: ubuntu-latest - needs: get-commit-head - if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Run `cargo deny` - uses: EmbarkStudios/cargo-deny-action@v2 - with: - # All is set in the config file - arguments: - command-arguments: "--hide-inclusion-graph -c .cargo-deny.toml --show-stats -D warnings" - - integration-tests: - name: Run Chopsticks tests - runs-on: ubuntu-latest - env: - working-dir: ./integration-tests/chopsticks - CI: true - SPIRITNET_BLOCK_NUMBER: 7850499 - HYDRATION_BLOCK_NUMBER: 5235787 - POLKADOT_BLOCK_NUMBER: 21010819 - ASSETHUB_BLOCK_NUMBER: 7934113 - SPIRITNET_WASM_OVERRIDE: ../../target/wasm32-unknown-unknown/debug/wbuild/spiritnet-runtime/spiritnet_runtime.wasm - PEREGRINE_WASM_OVERRIDE: ../../target/wasm32-unknown-unknown/debug/wbuild/peregrine-runtime/peregrine_runtime.wasm - - defaults: - run: - working-directory: ${{ env.working-dir }} - needs: get-commit-head - if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Free Disk Space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - # These paths are mounted inside the Docker container. - # We cannot mount the `.cargo/bin` folder since the container already contains binaries, and overriding with an empty one breaks compilation. - path: | - ~/.cargo/registry/index - ~/.cargo/registry/cache - ~/.cargo/git/db - key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} - save-always: true - - - name: Setup environment - uses: actions/setup-node@v4 - with: - node-version-file: "${{ env.working-dir }}/.nvmrc" - - - name: Install dependencies - run: yarn --immutable - - - name: Check TS - run: yarn ts-check - - - name: Check lints - run: yarn lint - - - name: Build runtime wasms - run: cargo build -p peregrine-runtime -p spiritnet-runtime --no-default-features --target wasm32-unknown-unknown - - - name: Run Chopsticks tests - run: yarn test - - cargo-test: - name: Run Cargo tests - runs-on: ubuntu-latest - env: - # Configured by the Docker image. We can't change this unless the image does it. - CARGO_HOME: /usr/local/cargo - needs: cargo-clippy - - strategy: - matrix: - features: - - - - --all-features - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Free Disk Space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - # These paths are mounted inside the Docker container. - # We cannot mount the `.cargo/bin` folder since the container already contains binaries, and overriding with an empty one breaks compilation. - path: | - ~/.cargo/registry/index - ~/.cargo/registry/cache - ~/.cargo/git/db - key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} - save-always: true - - - name: Run `cargo test` - # We cannot use the default `container:` component because it runs out of memory, so we resort to using this solution instead. - # Maybe re-evaluate this job if anything changes GH side. - run: | - docker run --rm \ - -v "${GITHUB_WORKSPACE}:/workspace" \ - -v "${HOME}/.cargo/registry/index:${{ env.CARGO_HOME }}/registry/index" \ - -v "${HOME}/.cargo/registry/cache:${{ env.CARGO_HOME }}/registry/cache" \ - -v "${HOME}/.cargo/git/db:${{ env.CARGO_HOME }}/git/db" \ - -w /workspace \ - paritytech/ci-unified:bullseye-1.81.0 \ - bash -c "cargo test --all-targets --locked ${{ matrix.features }}" - - cargo-doc: - name: Check Rustdoc - runs-on: ubuntu-latest - container: - image: paritytech/ci-unified:bullseye-1.81.0 - env: - # Configured by the Docker image. We can't change this unless the image does it. - CARGO_HOME: /usr/local/cargo - SKIP_WASM_BUILD: 1 - RUSTDOCFLAGS: -D warnings - needs: cargo-clippy - - strategy: - matrix: - features: - - - - --all-features - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - path: | - ${{ env.CARGO_HOME }}/bin/ - ${{ env.CARGO_HOME }}/registry/index/ - ${{ env.CARGO_HOME }}/registry/cache/ - ${{ env.CARGO_HOME }}/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} - save-always: true - - - name: Run `cargo doc` - run: cargo doc --no-deps --locked ${{ matrix.features }} - - try-runtime: - name: Run try-runtime - runs-on: ubuntu-latest - container: - image: paritytech/ci-unified:bullseye-1.81.0 - env: - # Configured by the Docker image. We can't change this unless the image does it. - CARGO_HOME: /usr/local/cargo - TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 - needs: cargo-clippy - - strategy: - matrix: - runtime: - - peregrine - - spiritnet - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Cargo cache - uses: actions/cache@v4 - with: - path: | - ${{ env.CARGO_HOME }}/bin/ - ${{ env.CARGO_HOME }}/registry/index/ - ${{ env.CARGO_HOME }}/registry/cache/ - ${{ env.CARGO_HOME }}/git/db/ - key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} - save-always: true - - - name: Install try-runtime - run: | - curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime - chmod +x ./try-runtime - ./try-runtime --version - - - name: Build runtime - run: cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime - - - name: Run `try-runtime` - run: | - ./try-runtime \ - --runtime=./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \ - on-runtime-upgrade \ - --disable-spec-version-check \ - --checks=all \ - live \ - --uri=wss://${{ matrix.runtime }}.kilt.io + # cargo-clippy: + # name: Run Clippy checks + # runs-on: ubuntu-latest + # container: + # image: paritytech/ci-unified:bullseye-1.81.0 + # env: + # # Configured by the Docker image. We can't change this unless the image does it. + # CARGO_HOME: /usr/local/cargo + # SKIP_WASM_BUILD: 1 + # needs: get-commit-head + # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} + + # strategy: + # matrix: + # cargo-flags: + # # Generic clippy checks for all features + # - --all-targets --all-features + # # Generic clippy checks for no features (catches some missing `no_std`-only lints) + # - --all-targets + # # Clippy lints specifically for all runtime code, excluding all test and binary crates + # - --target wasm32-unknown-unknown --no-default-features --workspace --exclude kilt-parachain --exclude standalone-node --exclude xcm-integration-tests --exclude 'dip-provider*' --exclude 'dip-consumer*' + # fail-fast: false + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ${{ env.CARGO_HOME }}/bin/ + # ${{ env.CARGO_HOME }}/registry/index/ + # ${{ env.CARGO_HOME }}/registry/cache/ + # ${{ env.CARGO_HOME }}/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.cargo-flags }}-${{ hashFiles('**/Cargo.lock') }} + # save-always: true + + # - name: Run `cargo clippy` + # run: cargo clippy --locked --no-deps ${{ matrix.cargo-flags }} + + # cargo-fmt: + # name: Check formatting + # runs-on: ubuntu-latest + # container: + # image: paritytech/ci-unified:bullseye-1.81.0 + # env: + # # Configured by the Docker image. We can't change this unless the image does it. + # CARGO_HOME: /usr/local/cargo + # # Latest nightly version matching the base rustc version (1.18.0). + # RUSTUP_NIGHTLY_VERSION: nightly-2023-10-02 + # needs: get-commit-head + # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ${{ env.CARGO_HOME }}/bin/ + # ${{ env.CARGO_HOME }}/registry/index/ + # ${{ env.CARGO_HOME }}/registry/cache/ + # ${{ env.CARGO_HOME }}/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} + # save-always: true + + # - name: Install nightly toolchain + # run: rustup toolchain add ${{ env.RUSTUP_NIGHTLY_VERSION }} + + # - name: Run `cargo fmt` + # run: cargo +${{ env.RUSTUP_NIGHTLY_VERSION }} fmt -- --check + + # - name: Run `taplo` + # run: taplo fmt --check + + # cargo-deny: + # name: Check cargo-deny rules + # runs-on: ubuntu-latest + # needs: get-commit-head + # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Run `cargo deny` + # uses: EmbarkStudios/cargo-deny-action@v2 + # with: + # # All is set in the config file + # arguments: + # command-arguments: "--hide-inclusion-graph -c .cargo-deny.toml --show-stats -D warnings" + + # integration-tests: + # name: Run Chopsticks tests + # runs-on: ubuntu-latest + # env: + # working-dir: ./integration-tests/chopsticks + # CI: true + # SPIRITNET_BLOCK_NUMBER: 7850499 + # HYDRATION_BLOCK_NUMBER: 5235787 + # POLKADOT_BLOCK_NUMBER: 21010819 + # ASSETHUB_BLOCK_NUMBER: 7934113 + # SPIRITNET_WASM_OVERRIDE: ../../target/wasm32-unknown-unknown/debug/wbuild/spiritnet-runtime/spiritnet_runtime.wasm + # PEREGRINE_WASM_OVERRIDE: ../../target/wasm32-unknown-unknown/debug/wbuild/peregrine-runtime/peregrine_runtime.wasm + + # defaults: + # run: + # working-directory: ${{ env.working-dir }} + # needs: get-commit-head + # if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }} + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Free Disk Space + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # # These paths are mounted inside the Docker container. + # # We cannot mount the `.cargo/bin` folder since the container already contains binaries, and overriding with an empty one breaks compilation. + # path: | + # ~/.cargo/registry/index + # ~/.cargo/registry/cache + # ~/.cargo/git/db + # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} + # save-always: true + + # - name: Setup environment + # uses: actions/setup-node@v4 + # with: + # node-version-file: "${{ env.working-dir }}/.nvmrc" + + # - name: Install dependencies + # run: yarn --immutable + + # - name: Check TS + # run: yarn ts-check + + # - name: Check lints + # run: yarn lint + + # - name: Build runtime wasms + # run: cargo build -p peregrine-runtime -p spiritnet-runtime --no-default-features --target wasm32-unknown-unknown + + # - name: Run Chopsticks tests + # run: yarn test + + # cargo-test: + # name: Run Cargo tests + # runs-on: ubuntu-latest + # env: + # # Configured by the Docker image. We can't change this unless the image does it. + # CARGO_HOME: /usr/local/cargo + # needs: cargo-clippy + + # strategy: + # matrix: + # features: + # - + # - --all-features + # fail-fast: false + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Free Disk Space + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # # These paths are mounted inside the Docker container. + # # We cannot mount the `.cargo/bin` folder since the container already contains binaries, and overriding with an empty one breaks compilation. + # path: | + # ~/.cargo/registry/index + # ~/.cargo/registry/cache + # ~/.cargo/git/db + # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} + # save-always: true + + # - name: Run `cargo test` + # # We cannot use the default `container:` component because it runs out of memory, so we resort to using this solution instead. + # # Maybe re-evaluate this job if anything changes GH side. + # run: | + # docker run --rm \ + # -v "${GITHUB_WORKSPACE}:/workspace" \ + # -v "${HOME}/.cargo/registry/index:${{ env.CARGO_HOME }}/registry/index" \ + # -v "${HOME}/.cargo/registry/cache:${{ env.CARGO_HOME }}/registry/cache" \ + # -v "${HOME}/.cargo/git/db:${{ env.CARGO_HOME }}/git/db" \ + # -w /workspace \ + # paritytech/ci-unified:bullseye-1.81.0 \ + # bash -c "cargo test --all-targets --locked ${{ matrix.features }}" + + # cargo-doc: + # name: Check Rustdoc + # runs-on: ubuntu-latest + # container: + # image: paritytech/ci-unified:bullseye-1.81.0 + # env: + # # Configured by the Docker image. We can't change this unless the image does it. + # CARGO_HOME: /usr/local/cargo + # SKIP_WASM_BUILD: 1 + # RUSTDOCFLAGS: -D warnings + # needs: cargo-clippy + + # strategy: + # matrix: + # features: + # - + # - --all-features + # fail-fast: false + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ${{ env.CARGO_HOME }}/bin/ + # ${{ env.CARGO_HOME }}/registry/index/ + # ${{ env.CARGO_HOME }}/registry/cache/ + # ${{ env.CARGO_HOME }}/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} + # save-always: true + + # - name: Run `cargo doc` + # run: cargo doc --no-deps --locked ${{ matrix.features }} + + # try-runtime: + # name: Run try-runtime + # runs-on: ubuntu-latest + # container: + # image: paritytech/ci-unified:bullseye-1.81.0 + # env: + # # Configured by the Docker image. We can't change this unless the image does it. + # CARGO_HOME: /usr/local/cargo + # TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 + # needs: cargo-clippy + + # strategy: + # matrix: + # runtime: + # - peregrine + # - spiritnet + # fail-fast: false + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Set up Cargo cache + # uses: actions/cache@v4 + # with: + # path: | + # ${{ env.CARGO_HOME }}/bin/ + # ${{ env.CARGO_HOME }}/registry/index/ + # ${{ env.CARGO_HOME }}/registry/cache/ + # ${{ env.CARGO_HOME }}/git/db/ + # key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} + # save-always: true + + # - name: Install try-runtime + # run: | + # curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime + # chmod +x ./try-runtime + # ./try-runtime --version + + # - name: Build runtime + # run: cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime + + # - name: Run `try-runtime` + # run: | + # ./try-runtime \ + # --runtime=./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \ + # on-runtime-upgrade \ + # --disable-spec-version-check \ + # --checks=all \ + # live \ + # --uri=wss://${{ matrix.runtime }}.kilt.io test-runtime-benchmarks: name: Test runtime benchmarks @@ -331,7 +332,7 @@ jobs: # Configured by the Docker image. We can't change this unless the image does it. CARGO_HOME: /usr/local/cargo needs: cargo-clippy - if: ${{ github.event_name == 'push'}} + #if: ${{ github.event_name == 'push'}} strategy: matrix: From 8e86882ffb0ad698caab5d2b77a1b6707432e537 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 27 May 2025 16:46:55 +0200 Subject: [PATCH 3/6] fix ci --- .github/workflows/check-code.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index f864ff2d0..a995278d5 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -7,6 +7,7 @@ on: branches: - develop - master + - ag_fix_ci_bencher tags: - '[0-9]+.[0-9]+.[0-9]+*' @@ -331,7 +332,7 @@ jobs: env: # Configured by the Docker image. We can't change this unless the image does it. CARGO_HOME: /usr/local/cargo - needs: cargo-clippy + #needs: cargo-clippy #if: ${{ github.event_name == 'push'}} strategy: From 80e4a68f3987a5e91e96b5cfb86a8089f48bd3eb Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 27 May 2025 16:49:26 +0200 Subject: [PATCH 4/6] fix ci --- .github/workflows/validate-pr-title.yml | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml index 7cddc225a..f5baa0880 100644 --- a/.github/workflows/validate-pr-title.yml +++ b/.github/workflows/validate-pr-title.yml @@ -21,3 +21,61 @@ jobs: uses: amannn/action-semantic-pull-request@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + test-runtime-benchmarks: + name: Test runtime benchmarks + runs-on: ubuntu-latest + env: + # Configured by the Docker image. We can't change this unless the image does it. + CARGO_HOME: /usr/local/cargo + #needs: cargo-clippy + #if: ${{ github.event_name == 'push'}} + + strategy: + matrix: + runtime: + - peregrine + - spiritnet + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + + - name: Set up Cargo cache + uses: actions/cache@v4 + with: + # These paths are mounted inside the Docker container. + # We cannot mount the `.cargo/bin` folder since the container already contains binaries, and overriding with an empty one breaks compilation. + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Install frame-omni-bencher + run: | + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/workspace" \ + -v "${HOME}/.cargo/registry/index:${{ env.CARGO_HOME }}/registry/index" \ + -v "${HOME}/.cargo/registry/cache:${{ env.CARGO_HOME }}/registry/cache" \ + -v "${HOME}/.cargo/git/db:${{ env.CARGO_HOME }}/git/db" \ + -w /workspace \ + paritytech/ci-unified:bullseye-1.81.0 \ + bash -c "cargo install frame-omni-bencher --locked" + + - name: Run runtime benchmarks + run: | + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/workspace" \ + -v "${HOME}/.cargo/registry/index:${{ env.CARGO_HOME }}/registry/index" \ + -v "${HOME}/.cargo/registry/cache:${{ env.CARGO_HOME }}/registry/cache" \ + -v "${HOME}/.cargo/git/db:${{ env.CARGO_HOME }}/git/db" \ + -w /workspace \ + paritytech/ci-unified:bullseye-1.81.0 \ + bash -c "bash -x scripts/run_benches_for_runtime.sh ${{ matrix.runtime }} dev" From 701638eca45134aa99ea041ceb4e7340bcdf86bd Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 27 May 2025 16:50:59 +0200 Subject: [PATCH 5/6] fix ci --- .github/workflows/validate-pr-title.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml index f5baa0880..78ba45e82 100644 --- a/.github/workflows/validate-pr-title.yml +++ b/.github/workflows/validate-pr-title.yml @@ -12,15 +12,15 @@ on: - synchronize jobs: - validate-pr-title: - name: Validate PR title - runs-on: ubuntu-latest + # validate-pr-title: + # name: Validate PR title + # runs-on: ubuntu-latest - steps: - - name: Check title - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # steps: + # - name: Check title + # uses: amannn/action-semantic-pull-request@v5 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} test-runtime-benchmarks: name: Test runtime benchmarks From a10c442e802da92ddcdeb3a1dd7bbcf8bbadf7b7 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 27 May 2025 16:51:57 +0200 Subject: [PATCH 6/6] fix ci --- .github/workflows/validate-pr-title.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml index 78ba45e82..ddea00901 100644 --- a/.github/workflows/validate-pr-title.yml +++ b/.github/workflows/validate-pr-title.yml @@ -6,6 +6,7 @@ on: - develop - master - 'refs/tags/[0-9]+.[0-9]+.[0-9]+*' + - ag_fix_ci_bencher types: - opened - edited