-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CW-53: Added a runtime metadata check (#1762)
# Description This PR adds a runtime metadata check, which consists of two phases: 1. Build `subxt` using large self-hosted runner (1 minute) 2. Run `subxt codegen` on runtime built from main (used in e2e tests - short session) (1 minute) This check fails if someone forgets to regenerate the `aleph-runtime` static metadata file. There's no if condition when this check is supposed to run as if practically it does not make sense to check, e.g., if runtime code changed or aleph pallet code changed in git, as then we'd need to check every `aleph-runtime` dependency, etc. This check is lightweight (2-3 minutes, and runs in parallel with the longest check excluded packages). Also, this PR consists of changes to the `Aleph::NextAuthorities` hash. This hash is what `subtext` thinks the hash of `NextAuthorities` metadata is. Normally, this hash does not include any of what is stored as a storage value, but only data such as pallet name, storage function name, storage value type (`Option<T>` or `T`), etc. Also, maybe a bit surprisingly, it includes _default_ value of given type into that `subxt` hash. Now, `NextAuthorities` storage value type is `Vec<AccountId>`, and normally default is `vec![]`. However, we do have a default initializer `DefaultNextAuthorities` which, turns out, is used by `subxt codegen` when generating hash for `NextAuthorities`. When `DefaultNextAuthorities`, static runtime metadata generated by `subxt` is always the same in CI. `DefaultNextAuthorities` is not required in pallet aleph, as initialization of `NextAuthorities` is done in `on_genesis_session`. ## Type of change Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) # Testing * [Runtime changed but no metadata regenerated - fail](https://github.com/Cardinal-Cryptography/aleph-node/actions/runs/9516243551/job/26232450103) - OK * [Runtime changed and metadata regenerated - pass](https://github.com/Cardinal-Cryptography/aleph-node/actions/runs/9577643942/job/26406625666?pr=1762) - OK
- Loading branch information
1 parent
d004433
commit 2b195a0
Showing
9 changed files
with
136 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
# This workflow builds subxt-cli, starts local one-node consensus chain and | ||
# uses subxt codegen to compare live chain data with what is versioned in git | ||
name: Check runtime metadata | ||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: "git ref: hash, branch, tag or 'mainnet' or 'testnet'" | ||
type: string | ||
required: true | ||
artifact-aleph-node-image: | ||
description: 'Name of aleph-node image stored in GH Artifacts' | ||
type: string | ||
required: true | ||
artifact-chain-bootstrapper-image: | ||
description: 'chain-bootstrapper image name in GH artifacts' | ||
type: string | ||
required: true | ||
jobs: | ||
build-subxt: | ||
name: Build subxt | ||
runs-on: [self-hosted, Linux, X64, large] | ||
env: | ||
RUST_BACKTRACE: full | ||
RUSTC_WRAPPER: sccache | ||
steps: | ||
- name: Checkout aleph-node source code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Call action get-ref-properties | ||
id: get-ref-properties | ||
uses: Cardinal-Cryptography/github-actions/get-ref-properties@v7 | ||
|
||
- name: Install Rust toolchain | ||
uses: Cardinal-Cryptography/github-actions/install-rust-toolchain@v7 | ||
with: | ||
targets: wasm32-unknown-unknown | ||
|
||
- name: Build subxt-cli | ||
shell: bash | ||
run: | | ||
# same version as in aleph-client's Cargo.toml | ||
cargo install subxt-cli --version 0.30.1 | ||
- name: Get subxt-cli path | ||
id: get-subxt-path | ||
shell: bash | ||
run: | | ||
subxt_path=$(which subxt) | ||
echo "path=${subxt_path}" >> $GITHUB_OUTPUT | ||
- name: Upload subxt binary to GH artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: subxt-binary | ||
path: ${{ steps.get-subxt-path.outputs.path }} | ||
if-no-files-found: error | ||
retention-days: 7 | ||
|
||
check-metadata: | ||
name: Check runtime metadata | ||
needs: [build-subxt] | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout aleph-node source code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Download node docker image | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: subxt-binary | ||
|
||
- name: Download node docker image | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.artifact-aleph-node-image }} | ||
|
||
- name: Load node docker image | ||
shell: bash | ||
run: docker load -i aleph-node.tar | ||
|
||
- name: Download chain-bootstrapper image | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.artifact-chain-bootstrapper-image }} | ||
|
||
- name: Load chain-bootstrapper image | ||
shell: bash | ||
run: docker load -i chain-bootstrapper.tar | ||
|
||
- name: Run consensus party | ||
shell: bash | ||
run: | | ||
./.github/scripts/run_consensus.sh -n 1 | ||
sleep 30 | ||
- name: Check metadata | ||
shell: bash | ||
run: | | ||
chmod +x subxt | ||
cd aleph-client | ||
SUBXT_BINARY=../subxt ./check-runtime-metadata.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
9 changes: 6 additions & 3 deletions
9
...nt/docker/subxt-integration-entrypoint.sh → aleph-client/check-runtime-metadata.sh
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters