-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add first job for testing starliht ugrade through zombie (#731)
* add first job for testing relay ugrade through zombie * add to CI * fix * try to fix * use current node * and workers * add script correctly
- Loading branch information
Showing
8 changed files
with
280 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -827,6 +827,57 @@ jobs: | |
pnpm install | ||
pnpm moonwall test zombie_${{ matrix.chains.chain }}_upgrade | ||
zombienet-test-upgrade-starlight: | ||
runs-on: self-hosted | ||
needs: ["set-tags", "build"] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
chains: [ | ||
{ chain: "dancelight", runtime: "dancelight" } | ||
] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ needs.set-tags.outputs.git_ref }} | ||
|
||
- name: Pnpm | ||
uses: pnpm/[email protected] | ||
with: | ||
version: 9 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.x | ||
cache: "pnpm" | ||
|
||
- name: Create local folders | ||
run: | | ||
mkdir -p target/release/wbuild/${{ matrix.chains.runtime }}-runtime/ | ||
mkdir -p test/tmp | ||
- name: "Download binaries" | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: binaries | ||
path: target/release | ||
- name: "Download runtime" | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: runtimes | ||
path: target/release/wbuild/${{ matrix.chains.runtime }}-runtime/ | ||
|
||
- name: "Install and run upgrade test" | ||
run: | | ||
chmod uog+x target/release/container-chain-simple-node | ||
chmod uog+x target/release/tanssi-relay | ||
chmod uog+x target/release/tanssi-relay-execute-worker | ||
chmod uog+x target/release/tanssi-relay-prepare-worker | ||
cd test | ||
pnpm install | ||
pnpm moonwall test zombie_${{ matrix.chains.chain }}_upgrade | ||
docker-tanssi: | ||
runs-on: ubuntu-latest | ||
needs: ["set-tags", "build"] | ||
|
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,66 @@ | ||
{ | ||
"settings": { | ||
"timeout": 1000, | ||
"provider": "native" | ||
}, | ||
"relaychain": { | ||
"chain_spec_path": "specs/tanssi-relay.json", | ||
"default_command": "../target/release/tanssi-relay", | ||
"default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy"], | ||
"genesis": { | ||
"runtimeGenesis": { | ||
"patch": { | ||
"configuration": { | ||
"config": { | ||
"async_backing_params": { | ||
"allowed_ancestry_len": 2, | ||
"max_candidate_depth": 3 | ||
}, | ||
"scheduler_params": { | ||
"scheduling_lookahead": 2, | ||
"num_cores": 4 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"nodes": [ | ||
{ | ||
"name": "alice", | ||
"ws_port": "9947", | ||
"validator": true | ||
}, | ||
{ | ||
"name": "bob", | ||
"validator": true | ||
} | ||
] | ||
}, | ||
"parachains": [ | ||
{ | ||
"id": 2000, | ||
"chain": "dev", | ||
"add_to_genesis": false, | ||
"register_para": false, | ||
"onboard_as_parachain": false, | ||
"collators": [ | ||
{ | ||
"name": "FullNode-2000", | ||
"validator": false, | ||
"chain": "dev", | ||
"command": "../target/release/container-chain-simple-node", | ||
"ws_port": 9948, | ||
"p2p_port": 33051 | ||
} | ||
] | ||
} | ||
], | ||
"types": { | ||
"Header": { | ||
"number": "u64", | ||
"parent_hash": "Hash", | ||
"post_state": "Hash" | ||
} | ||
} | ||
} |
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,16 @@ | ||
#!/bin/bash | ||
|
||
# Exit on any error | ||
set -e | ||
|
||
# Always run the commands from the "test" dir | ||
cd $(dirname $0)/.. | ||
|
||
if [[ -z "${1}" || ${1} == "undefined" ]]; then | ||
BINARY_FOLDER="../target/release" | ||
else | ||
BINARY_FOLDER="${1}" | ||
fi | ||
|
||
mkdir -p specs | ||
$BINARY_FOLDER/tanssi-relay build-spec --chain dancelight-local > specs/tanssi-relay.json |
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,33 @@ | ||
#!/bin/bash | ||
|
||
# Exit on any error | ||
set -e | ||
|
||
# Always run the commands from the "test" dir | ||
cd $(dirname $0)/.. | ||
|
||
LATEST_RUNTIME_RELEASE=$(curl -s https://api.github.com/repos/moondance-labs/tanssi/releases | jq -r '.[] | select(.name | test("runtime";"i") and (test("starlight";"i"))) | .tag_name' | head -n 1 | tr -d '[:blank:]') && [[ ! -z "${LATEST_RUNTIME_RELEASE}" ]] | ||
ENDPOINT="https://api.github.com/repos/moondance-labs/tanssi/git/refs/tags/$LATEST_RUNTIME_RELEASE" | ||
RESPONSE=$(curl -s -H "Accept: application/vnd.github.v3+json" $ENDPOINT) | ||
TYPE=$(echo $RESPONSE | jq -r '.object.type') | ||
if [[ $TYPE == "commit" ]] | ||
then | ||
LATEST_RT_SHA8=$(echo $RESPONSE | jq -r '.object.sha' | cut -c -8) | ||
elif [[ $TYPE == "tag" ]] | ||
then | ||
URL=$(echo $RESPONSE | jq -r '.object.url') | ||
TAG_RESPONSE=$(curl -s -H "Accept: application/vnd.github.v3+json" $URL) | ||
TAG_RESPONSE_CLEAN=$(echo $TAG_RESPONSE | tr -d '\000-\037') | ||
LATEST_RT_SHA8=$(echo $TAG_RESPONSE_CLEAN | jq -r '.object.sha' | cut -c -8) | ||
fi | ||
|
||
DOCKER_TAG_STARLIGHT="moondancelabs/starlight:sha-$LATEST_RT_SHA8-fast-runtime" | ||
|
||
docker rm -f starlight_container 2> /dev/null | true | ||
docker create --name starlight_container $DOCKER_TAG_STARLIGHT bash | ||
docker cp starlight_container:tanssi-relay/tanssi-relay tmp/tanssi-relay | ||
docker cp starlight_container:tanssi-relay/tanssi-relay-execute-worker tmp/tanssi-relay-execute-worker | ||
docker cp starlight_container:tanssi-relay/tanssi-relay-prepare-worker tmp/tanssi-relay-prepare-worker | ||
docker rm -f starlight_container | ||
chmod uog+x ../target/release/tanssi-relay | ||
chmod uog+x tmp/tanssi-relay |
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
File renamed without changes.
69 changes: 69 additions & 0 deletions
69
test/suites/rt-upgrade-relay-zombienet/test-upgrade-chain.ts
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,69 @@ | ||
import { MoonwallContext, beforeAll, describeSuite, expect } from "@moonwall/cli"; | ||
import { KeyringPair } from "@moonwall/util"; | ||
import { ApiPromise, Keyring } from "@polkadot/api"; | ||
import fs from "node:fs"; | ||
|
||
describeSuite({ | ||
id: "R01", | ||
title: "Zombie Dancelight Upgrade Test", | ||
foundationMethods: "zombie", | ||
testCases: function ({ it, context, log }) { | ||
let relayApi: ApiPromise; | ||
let alice: KeyringPair; | ||
|
||
beforeAll(async () => { | ||
const keyring = new Keyring({ type: "sr25519" }); | ||
alice = keyring.addFromUri("//Alice", { name: "Alice default" }); | ||
relayApi = context.polkadotJs("parachain"); | ||
|
||
const relayNetwork = relayApi.consts.system.version.specName.toString(); | ||
expect(relayNetwork, "Relay API incorrect").to.contain("dancelight"); | ||
|
||
const currentBlock = (await relayApi.rpc.chain.getBlock()).block.header.number.toNumber(); | ||
expect(currentBlock, "Parachain not producing blocks").to.be.greaterThan(0); | ||
}, 120000); | ||
|
||
it({ | ||
id: "T01", | ||
title: "Blocks are being produced on parachain", | ||
test: async function () { | ||
const blockNum = (await relayApi.rpc.chain.getBlock()).block.header.number.toNumber(); | ||
expect(blockNum).to.be.greaterThan(0); | ||
}, | ||
}); | ||
|
||
it({ | ||
id: "T02", | ||
title: "Chain can be upgraded", | ||
timeout: 600000, | ||
test: async function () { | ||
const blockNumberBefore = (await relayApi.rpc.chain.getBlock()).block.header.number.toNumber(); | ||
const currentCode = await relayApi.rpc.state.getStorage(":code"); | ||
const codeString = currentCode.toString(); | ||
|
||
const wasm = fs.readFileSync((await MoonwallContext.getContext()).rtUpgradePath); | ||
const rtHex = `0x${wasm.toString("hex")}`; | ||
const rtBefore = relayApi.consts.system.version.specVersion.toNumber(); | ||
|
||
if (rtHex === codeString) { | ||
log("Runtime already upgraded, skipping test"); | ||
return; | ||
} else { | ||
log("Runtime not upgraded, proceeding with test"); | ||
log("Current runtime hash: " + rtHex.slice(0, 10) + "..." + rtHex.slice(-10)); | ||
log("New runtime hash: " + codeString.slice(0, 10) + "..." + codeString.slice(-10)); | ||
} | ||
|
||
await context.upgradeRuntime({ from: alice, logger: log }); | ||
await context.waitBlock(2); | ||
const rtafter = relayApi.consts.system.version.specVersion.toNumber(); | ||
if (rtBefore === rtafter) { | ||
throw new Error("Runtime upgrade failed"); | ||
} | ||
const blockNumberAfter = (await relayApi.rpc.chain.getBlock()).block.header.number.toNumber(); | ||
log(`Before: #${blockNumberBefore}, After: #${blockNumberAfter}`); | ||
expect(blockNumberAfter, "Block number did not increase").to.be.greaterThan(blockNumberBefore); | ||
}, | ||
}); | ||
}, | ||
}); |