From 0ab81c907f0043ef606c2ac4ad1cad7d36995c52 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 16 Nov 2020 14:41:57 +0100 Subject: [PATCH] Add CI job to verify extrinsic ordering (#1950) * WIP: add initial check_extrinsics_ordering.sh script * iterate through runtimes, add gitlab job * move job to publish * temp force build-linux-release to run * update check_extrinsics_ordering.sh * maybe we have to fetch release * use node docker image * revert before opening pr: force bad extrinsic ordering * revert commits to prepare for PR * move job to build stage, use bin from test-linux-release * remove FIXME * fix PR nags --- polkadot/.gitlab-ci.yml | 13 ++++ .../gitlab/check_extrinsics_ordering.sh | 59 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100755 polkadot/scripts/gitlab/check_extrinsics_ordering.sh diff --git a/polkadot/.gitlab-ci.yml b/polkadot/.gitlab-ci.yml index 913c9e43c8..07438a8c8f 100644 --- a/polkadot/.gitlab-ci.yml +++ b/polkadot/.gitlab-ci.yml @@ -116,6 +116,9 @@ test-linux-stable: &test # but still want to have debug assertions. RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" TARGET: native + artifacts: + paths: + - ./target/release/polkadot script: - ./scripts/gitlab/test_linux_stable.sh - sccache -s @@ -141,6 +144,16 @@ check-runtime-benchmarks: &test - ./scripts/gitlab/check_runtime_benchmarks.sh - sccache -s +check-transaction-versions: + image: node:15 + stage: build + needs: + - job: test-linux-stable + before_script: + - npm install -g @polkadot/metadata-cmp + - git fetch origin release + script: "scripts/gitlab/check_extrinsics_ordering.sh" + build-wasm-release: stage: build <<: *collect-artifacts diff --git a/polkadot/scripts/gitlab/check_extrinsics_ordering.sh b/polkadot/scripts/gitlab/check_extrinsics_ordering.sh new file mode 100755 index 0000000000..cfdad63691 --- /dev/null +++ b/polkadot/scripts/gitlab/check_extrinsics_ordering.sh @@ -0,0 +1,59 @@ +#!/bin/bash +BIN=./target/release/polkadot +LIVE_WS=wss://rpc.polkadot.io +LOCAL_WS=ws://localhost:9944 + +# Kill the polkadot client before exiting +trap 'kill "$(jobs -p)"' EXIT + +runtimes=( + "westend" + "kusama" + "polkadot" +) + +for RUNTIME in "${runtimes[@]}"; do + echo "[+] Checking runtime: ${RUNTIME}" + + release_transaction_version=$( + git show "origin/release:runtime/${RUNTIME}/src/lib.rs" | \ + grep 'transaction_version' + ) + + current_transaction_version=$( + grep 'transaction_version' "./runtime/${RUNTIME}/src/lib.rs" + ) + + echo "[+] Release: ${release_transaction_version}" + echo "[+] Ours: ${current_transaction_version}" + + if [ ! "$release_transaction_version" = "$current_transaction_version" ]; then + echo "[+] Transaction version for ${RUNTIME} has been bumped since last release." + exit 0 + fi + + if [ "$RUNTIME" = 'polkadot' ]; then + LIVE_WS="wss://rpc.polkadot.io" + else + LIVE_WS="wss://${RUNTIME}-rpc.polkadot.io" + fi + + # Start running the local polkadot node in the background + $BIN --chain="$RUNTIME-local" & + jobs + + changed_extrinsics=$( + polkadot-js-metadata-cmp "$LIVE_WS" "$LOCAL_WS" \ + | sed 's/^ \+//g' | grep -e 'idx: [0-9]\+ -> [0-9]\+' + ) + + if [ -n "$changed_extrinsics" ]; then + echo "[!] Extrinsics indexing/ordering has changed in the ${RUNTIME} runtime! If this change is intentional, please bump transaction_version in lib.rs. Changed extrinsics:" + echo "$changed_extrinsics" + exit 1 + fi + + echo "[+] No change in extrinsics ordering for the ${RUNTIME} runtime" + kill "$(jobs -p)"; sleep 5 +done +