From 13dbcaf6bd40b6a5ac889327e87b42aae3c56887 Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Mon, 12 Feb 2024 23:36:45 +0900 Subject: [PATCH] Add CI job for checking missing migrations and fix the missing `PolkadotXcm` migration for ajuna (#397) * add runtime-migration check (untested) * [CI] use ajuna as endpoint * [CI] add pallet-xcm (aka PolkadotXcm) migration * [para] add deprecation notice for the try runtime command * Readme.md add try-runtime explanation. * [solo-node] fix try-runtime feature flag, and make it compile with solo-node (although it seems it can't be used with the solo node. * remove obsolete try-runtime-cli from dependencies * [para] fix cherry-pick merge * run ci on branch and prs to ajuna-stable * [ajuna-solo] remove try-runtime feature * [CI] disable spec-version-check and idempotency check --- .github/workflows/check-migration.yml | 76 ++++++++++++++++++++++++ .github/workflows/check-pull-request.yml | 2 + .github/workflows/runtimes-matrix.json | 8 +++ Cargo.lock | 1 - README.md | 16 +++++ node/cli/Cargo.toml | 13 ++-- node/cli/src/para/cli.rs | 9 +-- node/cli/src/para/command.rs | 43 +------------- node/service/Cargo.toml | 10 ++-- runtime/ajuna/src/lib.rs | 3 + 10 files changed, 123 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/check-migration.yml create mode 100644 .github/workflows/runtimes-matrix.json diff --git a/.github/workflows/check-migration.yml b/.github/workflows/check-migration.yml new file mode 100644 index 00000000..304a0247 --- /dev/null +++ b/.github/workflows/check-migration.yml @@ -0,0 +1,76 @@ +name: Check Migrations + +on: + push: + branches: ["develop", "ajuna-stable" ] + pull_request: + branches: ["develop", "ajuna-stable"] + workflow_dispatch: + +# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is +# triggered (ref https://stackoverflow.com/a/72408109) +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + runtime-matrix: + runs-on: ubuntu-latest + outputs: + runtime: ${{ steps.runtime.outputs.runtime }} + name: Extract tasks from matrix + steps: + - uses: actions/checkout@v3 + - id: runtime + run: | + # Filter out runtimes that don't have a URI + TASKS=$(jq '[.[] | select(.uri != null)]' .github/workflows/runtimes-matrix.json) + SKIPPED_TASKS=$(jq '[.[] | select(.uri == null)]' .github/workflows/runtimes-matrix.json) + echo --- Running the following tasks --- + echo $TASKS + echo --- Skipping the following tasks due to not having a uri field --- + echo $SKIPPED_TASKS + # Strip whitespace from Tasks now that we've logged it + TASKS=$(echo $TASKS | jq -c .) + echo "runtime=$TASKS" >> $GITHUB_OUTPUT + + check-migrations: + needs: [runtime-matrix] + continue-on-error: true + runs-on: ubuntu-latest + strategy: + matrix: + runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }} + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Download try-runtime-cli + run: | + curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.5.2/try-runtime-x86_64-unknown-linux-musl -o try-runtime + chmod +x ./try-runtime + + - name: Install Protoc + uses: arduino/setup-protoc@v1 + with: + version: "3.6.1" + + - name: Add wasm32-unknown-unknown target + run: rustup target add wasm32-unknown-unknown + + - name: Build ${{ matrix.runtime.name }} + run: | + cargo build --release -p ${{ matrix.runtime.package }} --features try-runtime -q --locked + + - name: Check migrations + # Todo: enable spec-version-check dynamically if we are releasing + run: | + PACKAGE_NAME=${{ matrix.runtime.package }} + RUNTIME_BLOB_NAME=$(echo $PACKAGE_NAME | sed 's/-/_/g').compact.compressed.wasm + RUNTIME_BLOB_PATH=./target/release/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME + + ./try-runtime \ + --runtime $RUNTIME_BLOB_PATH \ + on-runtime-upgrade --checks=pre-and-post \ + --disable-spec-version-check --disable-idempotency-checks \ + live --uri ${{ matrix.runtime.uri }} diff --git a/.github/workflows/check-pull-request.yml b/.github/workflows/check-pull-request.yml index 2339a0d8..52529f08 100644 --- a/.github/workflows/check-pull-request.yml +++ b/.github/workflows/check-pull-request.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - develop + - ajuna-stable paths: - "**/*.rs" - "**/Cargo.toml" @@ -14,6 +15,7 @@ on: push: branches: - develop + - ajuna-stable # Ensures only one build is run per branch, unless pushing to develop concurrency: diff --git a/.github/workflows/runtimes-matrix.json b/.github/workflows/runtimes-matrix.json new file mode 100644 index 00000000..c1111ff8 --- /dev/null +++ b/.github/workflows/runtimes-matrix.json @@ -0,0 +1,8 @@ +[ + { + "name": "ajuna", + "package": "ajuna-runtime", + "path": "runtime/ajuna-runtime", + "uri": "wss://rpc-parachain.ajuna.network:443" + } +] \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e52d93f0..8436f1c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -217,7 +217,6 @@ dependencies = [ "sp-runtime", "sp-timestamp", "substrate-build-script-utils", - "try-runtime-cli", ] [[package]] diff --git a/README.md b/README.md index 17afd603..82869ac7 100644 --- a/README.md +++ b/README.md @@ -64,3 +64,19 @@ A game platform [parachain](https://wiki.polkadot.network/docs/learn-parachains) # parachain with rococo-local relay chain docker-compose -f docker/parachain.yml up ``` + + +## Check state migrations + +```bash +curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.5.2/try-runtime-x86_64-unknown-linux-musl -o try-runtime +chmod +x ./try-runtime + +# check state migrations with state fetched from the remote chain. +../bin/try-runtime \ + --runtime ./target/release/wbuild/ajuna-solo-runtime/ajuna_solo_runtime.wasm \ + on-runtime-upgrade --checks=pre-and-post \ + live --uri wss://rpc-parachain.bajun.network:443 +``` + +This is also executed in the check-migration.yml CI. \ No newline at end of file diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml index 4c7b4f31..7428133f 100644 --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -44,8 +44,6 @@ sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polk sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", optional = true } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", optional = true } -try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", optional = true } - # Polkadot polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42", optional = true } polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42", optional = true } @@ -81,8 +79,13 @@ rococo-native = [ "polkadot-cli/rococo-native" ] runtime-benchmarks = [ "ajuna-service/runtime-benchmarks", - "polkadot-cli/runtime-benchmarks", + "polkadot-cli?/runtime-benchmarks", ] -cli = [ "try-runtime-cli" ] -try-runtime = [ "try-runtime-cli/try-runtime", "sc-executor", "sp-io" ] +cli = [ ] +try-runtime = [ + "ajuna-service/try-runtime", + "polkadot-cli?/try-runtime", + "sc-executor", + "sp-io", +] diff --git a/node/cli/src/para/cli.rs b/node/cli/src/para/cli.rs index 981d233c..1bafbe8d 100644 --- a/node/cli/src/para/cli.rs +++ b/node/cli/src/para/cli.rs @@ -52,12 +52,9 @@ pub enum Subcommand { #[clap(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), - /// Try some testing command against a specified runtime state. - #[cfg(feature = "try-runtime")] - TryRuntime(try_runtime_cli::TryRuntimeCmd), - - /// Errors since the binary was not build with `--features try-runtime`. - #[cfg(not(feature = "try-runtime"))] + /// Try-runtime has migrated to a standalone + /// [CLI](). The subcommand exists as a stub and + /// deprecation notice. It will be removed entirely some time after Janurary 2024. TryRuntime, } diff --git a/node/cli/src/para/command.rs b/node/cli/src/para/command.rs index fe16a547..943cc512 100644 --- a/node/cli/src/para/command.rs +++ b/node/cli/src/para/command.rs @@ -308,48 +308,7 @@ pub fn run() -> Result<()> { _ => Err("Benchmarking sub-command unsupported".into()), } }, - #[cfg(feature = "try-runtime")] - Some(Subcommand::TryRuntime(cmd)) => { - use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch}; - use try_runtime_cli::block_building_info::timestamp_with_aura_info; - - let runner = cli.create_runner(cmd)?; - type HostFunctionsOf = ExtendedHostFunctions< - sp_io::SubstrateHostFunctions, - ::ExtendHostFunctions, - >; - - // grab the task manager. - let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry) - .map_err(|e| format!("Error: {:?}", e))?; - - #[cfg(feature = "ajuna")] - if cfg!(feature = "ajuna") { - return runner.async_run(|_| { - Ok(( - cmd.run::, _>(Some( - timestamp_with_aura_info::(6000), - )), - task_manager, - )) - }) - } - #[cfg(feature = "bajun")] - runner.async_run(|_| { - Ok(( - cmd.run::, _>(Some( - timestamp_with_aura_info::(6000), - )), - task_manager, - )) - }) - }, - #[cfg(not(feature = "try-runtime"))] - Some(Subcommand::TryRuntime) => Err("Try-runtime was not enabled when building the node. \ - You can enable it with `--features try-runtime`." - .into()), + Some(Subcommand::TryRuntime) => Err("The `try-runtime` subcommand has been migrated to a standalone CLI (https://github.com/paritytech/try-runtime-cli). It is no longer being maintained here and will be removed entirely some time after January 2024. Please remove this subcommand from your runtime and use the standalone CLI.".into()), None => { let runner = cli.create_runner(&cli.run.normalize())?; let collator_options = cli.run.collator_options(); diff --git a/node/service/Cargo.toml b/node/service/Cargo.toml index 28f7aa83..dc9f0bee 100644 --- a/node/service/Cargo.toml +++ b/node/service/Cargo.toml @@ -112,11 +112,13 @@ polkadot-native = [ "polkadot-service/polkadot-native" ] rococo-native = [ "polkadot-service/rococo-native" ] runtime-benchmarks = [ - "ajuna-solo-runtime/runtime-benchmarks", - "bajun-runtime/runtime-benchmarks", - "ajuna-runtime/runtime-benchmarks", + "ajuna-solo-runtime?/runtime-benchmarks", + "bajun-runtime?/runtime-benchmarks", + "ajuna-runtime?/runtime-benchmarks", ] try-runtime = [ - "bajun-runtime/try-runtime", + "bajun-runtime?/try-runtime", + "polkadot-service?/try-runtime", + "sp-runtime/try-runtime" ] diff --git a/runtime/ajuna/src/lib.rs b/runtime/ajuna/src/lib.rs index 456ed10e..30576bf5 100644 --- a/runtime/ajuna/src/lib.rs +++ b/runtime/ajuna/src/lib.rs @@ -114,8 +114,11 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + Migrations, >; +type Migrations = (pallet_xcm::migration::v1::MigrateToV1,); + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the /// node's balance type. ///