-
Notifications
You must be signed in to change notification settings - Fork 18
113 lines (98 loc) · 4.77 KB
/
Copy pathtry-runtime.yml
File metadata and controls
113 lines (98 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Check try-runtime
# Runs `try-runtime on-runtime-upgrade --checks=all` for each runtime against live chain state,
# exercising the runtime's migration `pre_upgrade`/`on_runtime_upgrade`/`post_upgrade` hooks and the
# `try_state` checks of every pallet. This is the canonical pre-merge check that a runtime upgrade
# (and any storage migration it carries) applies cleanly, is idempotent, and preserves invariants.
#
# NOTE: this repo's cargo workspace lives under `parachain/`, so we build and run try-runtime
# ourselves (the `paritytech/try-runtime-gha` action assumes a repo-root manifest and cannot find
# `parachain/Cargo.toml`). The build/run steps mirror the `try-runtime` job in
# `check-runtime-upgrade.yml`.
# Manual trigger only: try-runtime compiles both runtimes from scratch and scrapes full live chain
# state (~10+ min), which is too heavy to run on every PR. Dispatch it on a feature branch when a
# runtime change carries a migration or otherwise warrants pre-merge migration testing.
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# try-runtime CLI version. Must support `on-runtime-upgrade --blocktime`.
TRYRUNTIME_VERSION: 0.10.1
# subwasm is used to read the block time out of the built runtime (see the run step).
SUBWASM_VERSION: 0.21.3
jobs:
runtime-matrix:
runs-on: ubuntu-22.04
outputs:
runtime: ${{ steps.runtime.outputs.runtime }}
name: Parse runtime matrix
steps:
- uses: actions/checkout@v7
- id: runtime
run: |
TASKS=$(jq '[.[] | select(.uri != null)]' .github/runtime.json)
SKIPPED_TASKS=$(jq '[.[] | select(.uri == null)]' .github/runtime.json)
echo --- Running the following tasks ---
echo $TASKS
echo --- Skipping the following tasks due to not having a uri field ---
echo $SKIPPED_TASKS
TASKS=$(echo $TASKS | jq -c .)
echo "runtime=$TASKS" >> $GITHUB_OUTPUT
try-runtime:
needs: [runtime-matrix]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
name: ${{ matrix.runtime.name }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install rust toolchain
run: rustup show
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -yq protobuf-compiler
- name: Download try-runtime-cli
run: |
curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v${{ env.TRYRUNTIME_VERSION }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime
chmod +x ./try-runtime
mv try-runtime parachain
- name: Build ${{ matrix.runtime.name }} runtime
run: |
cd parachain
cargo build --profile production -p ${{ matrix.runtime.package }} --features try-runtime -q --locked
- name: Install subwasm ${{ env.SUBWASM_VERSION }}
run: |
wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb
sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb
subwasm --version
- name: Run ${{ matrix.runtime.name }} try-runtime check
run: |
cd parachain
PACKAGE_NAME=${{ matrix.runtime.package }}
RUNTIME_BLOB_NAME=$(echo $PACKAGE_NAME | sed 's/-/_/g').compact.compressed.wasm
RUNTIME_BLOB_PATH=./target/production/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME
# Derive the block time from the runtime *being tested*, not a hard-coded value, so this
# works for any runtime (the current 6s, the old 12s, or a future elastic-scaling target).
# Aura's slot duration is twice `Timestamp::MinimumPeriod`; subwasm reads that constant
# (a little-endian u64, in ms) straight from the built wasm's metadata.
MIN_PERIOD=$(subwasm metadata "$RUNTIME_BLOB_PATH" --format json \
| jq -r '[.. | objects | select(.name=="MinimumPeriod") | .value][0]
| to_entries | map(.value * pow(256; .key)) | add')
if ! [[ "$MIN_PERIOD" =~ ^[0-9]+$ ]] || [ "$MIN_PERIOD" -le 0 ]; then
echo "Failed to read Timestamp::MinimumPeriod from runtime metadata (got '$MIN_PERIOD')"
exit 1
fi
BLOCKTIME=$((MIN_PERIOD * 2))
echo "Derived block time: ${BLOCKTIME}ms (MinimumPeriod=${MIN_PERIOD}ms)"
export RUST_LOG=remote-ext=info,runtime=info
./try-runtime \
--runtime "$RUNTIME_BLOB_PATH" \
on-runtime-upgrade --checks=all --blocktime "$BLOCKTIME" \
live --uri ${{ matrix.runtime.uri }}
shell: bash