Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Add CI job for checking missing migrations and fix the missing `Polka…
Browse files Browse the repository at this point in the history
…dotXcm` 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
  • Loading branch information
clangenb authored Feb 12, 2024
1 parent fa67958 commit 13dbcaf
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 58 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/check-migration.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- develop
- ajuna-stable
paths:
- "**/*.rs"
- "**/Cargo.toml"
Expand All @@ -14,6 +15,7 @@ on:
push:
branches:
- develop
- ajuna-stable

# Ensures only one build is run per branch, unless pushing to develop
concurrency:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/runtimes-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"name": "ajuna",
"package": "ajuna-runtime",
"path": "runtime/ajuna-runtime",
"uri": "wss://rpc-parachain.ajuna.network:443"
}
]
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
13 changes: 8 additions & 5 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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",
]
9 changes: 3 additions & 6 deletions node/cli/src/para/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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](<https://github.com/paritytech/try-runtime-cli>). The subcommand exists as a stub and
/// deprecation notice. It will be removed entirely some time after Janurary 2024.
TryRuntime,
}

Expand Down
43 changes: 1 addition & 42 deletions node/cli/src/para/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<E> = ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<E as NativeExecutionDispatch>::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::<AjunaBlock, HostFunctionsOf<AjunaRuntimeExecutor>, _>(Some(
timestamp_with_aura_info::<AjunaBlock>(6000),
)),
task_manager,
))
})
}
#[cfg(feature = "bajun")]
runner.async_run(|_| {
Ok((
cmd.run::<BajunBlock, HostFunctionsOf<BajunRuntimeExecutor>, _>(Some(
timestamp_with_aura_info::<BajunBlock>(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();
Expand Down
10 changes: 6 additions & 4 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
3 changes: 3 additions & 0 deletions runtime/ajuna/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
Migrations,
>;

type Migrations = (pallet_xcm::migration::v1::MigrateToV1<Runtime>,);

/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
/// node's balance type.
///
Expand Down

0 comments on commit 13dbcaf

Please sign in to comment.