Skip to content

Commit

Permalink
new chopsticks upgrade support (#389)
Browse files Browse the repository at this point in the history
* new chopsticks upgrade support

* zombietest workaround

* remove nohup

* zombie

* fix

* fmt

* update zombie versions
  • Loading branch information
timbrinded authored Mar 4, 2024
1 parent 5883f01 commit dad03aa
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 141 deletions.
6 changes: 6 additions & 0 deletions .changeset/purple-flowers-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@moonwall/cli": patch
"@moonwall/tests": patch
---

Support new 1.7.0 upgrade
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ jobs:
bun moonwall download moonbeam latest ./tmp
# Change these to latest once MB is compatible with 1.2.0
bun moonwall download polkadot 1.1.0 ./tmp
bun moonwall download polkadot-execute-worker 1.1.0 ./tmp
bun moonwall download polkadot-prepare-worker 1.1.0 ./tmp
bun moonwall download polkadot 1.8.0 ./tmp
bun moonwall download polkadot-execute-worker 1.8.0 ./tmp
bun moonwall download polkadot-prepare-worker 1.8.0 ./tmp
- name: Run ${{matrix.suite}}
run: |
cd test
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/cmds/runNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ let lastSelected = 0;
export async function runNetworkCmd(args: RunCommandArgs) {
await cacheConfig();
process.env.MOON_TEST_ENV = args.envName;
process.env.MOON_SUBDIR = args.subDirectory;
if (args.subDirectory) {
process.env.MOON_SUBDIR = args.subDirectory;
}
const globalConfig = await importAsyncConfig();
const env = globalConfig.environments.find(({ name }) => name === args.envName);

Expand Down
30 changes: 21 additions & 9 deletions packages/cli/src/lib/upgradeProcedures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,30 @@ export async function upgradeRuntimeChopsticks(
const rtWasm = readFileSync(path);
const rtHex = `0x${rtWasm.toString("hex")}`;
const rtHash = blake2AsHex(rtHex);
await context.setStorage({
providerName,
module: "parachainSystem",
method: "authorizedUpgrade",
methodParams: `${rtHash}01`, // 01 is for the RT ver check = true
});
await context.createBlock({ providerName });

const api = context.polkadotJs(providerName);
const signer = context.keyring.alice;

await api.tx.parachainSystem.enactAuthorizedUpgrade(rtHex).signAndSend(signer);
if ("authorizedUpgrade" in api.query.system) {
await context.setStorage({
providerName,
module: "system",
method: "authorizedUpgrade",
methodParams: `${rtHash}01`, // 01 is for the RT ver check = true
});
await context.createBlock({ providerName });

await api.tx.system.enactAuthorizedUpgrade(rtHex).signAndSend(signer);
} else {
await context.setStorage({
providerName,
module: "parachainSystem",
method: "authorizedUpgrade",
methodParams: `${rtHash}01`, // 01 is for the RT ver check = true
});
await context.createBlock({ providerName });

await api.tx.parachainSystem.enactAuthorizedUpgrade(rtHex).signAndSend(signer);
}

await context.createBlock({ providerName, count: 3 });
}
Expand Down
74 changes: 35 additions & 39 deletions test/configs/kubernetesMB.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
{
"parachains": [
{
"id": 1282,
"chain": "moonbase-local",
"chain_spec_path": "/tmp/zombie-5934ea727785d7b7cfb05d04dc91027d_-1678604-EepQT32GXviB/moonbase-local-1282-rococo-local.json",
"collator": {
"args": [
"-lparachain=debug"
],
"command": "/moonbeam/moonbeam",
"image": "moonbeamfoundation/moonbeam:latest",
"name": "alith"
}
}
],
"relaychain": {
"chain": "rococo-local",
"default_image": "docker.io/parity/polkadot:latest",
"node_groups": [
{
"args": [
"-lparachain=debug"
],
"count": 3,
"name": "alice"
}
]
},
"settings": {
"timeout": 1000
},
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
}
}
}
"parachains": [
{
"id": 1282,
"chain": "moonbase-local",
"chain_spec_path": "/tmp/zombie-5934ea727785d7b7cfb05d04dc91027d_-1678604-EepQT32GXviB/moonbase-local-1282-rococo-local.json",
"collator": {
"args": ["-lparachain=debug"],
"command": "/moonbeam/moonbeam",
"image": "moonbeamfoundation/moonbeam:latest",
"name": "alith"
}
}
],
"relaychain": {
"chain": "rococo-local",
"default_image": "docker.io/parity/polkadot:latest",
"node_groups": [
{
"args": ["-lparachain=debug"],
"count": 3,
"name": "alice"
}
]
},
"settings": {
"timeout": 1000
},
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
}
}
}
128 changes: 62 additions & 66 deletions test/configs/relaytest.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,63 @@
{
"parachains": [
{
"cumulus_based": true,
"id": 2001,
"collator": {
"args": [
"-lparachain=debug"
],
"command": "polkadot-parachain",
"image": "parity/polkadot-parachain:1.3.0",
"name": "collator02"
}
}
],
"relaychain": {
"chain": "rococo-local",
"default_image": "docker.io/parity/polkadot:v1.3.0",
"node_groups": [
{
"args": [
"-lparachain=debug"
],
"count": 3,
"name": "alice"
}
],
"default_resources": {
"limits": {
"cpu": "2",
"memory": "4G"
},
"requests": {
"cpu": "1",
"memory": "2G"
}
},
"genesis": {
"runtimeGenesis": {
"patch": {
"configuration": {
"config": {
"group_rotation_frequency": 4,
"needed_approvals": 1,
"relay_vrf_modulo_samples": 6,
"scheduling_lookahead": 3,
"async_backing_params": {
"allowed_ancestry_len": 3,
"max_candidate_depth": 4
}
}
}
}
}
}
},
"settings": {
"timeout": 1000
},
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
}
}
}
"parachains": [
{
"cumulus_based": true,
"id": 2001,
"collator": {
"args": ["-lparachain=debug"],
"command": "polkadot-parachain",
"image": "parity/polkadot-parachain:1.3.0",
"name": "collator02"
}
}
],
"relaychain": {
"chain": "rococo-local",
"default_image": "docker.io/parity/polkadot:v1.3.0",
"node_groups": [
{
"args": ["-lparachain=debug"],
"count": 3,
"name": "alice"
}
],
"default_resources": {
"limits": {
"cpu": "2",
"memory": "4G"
},
"requests": {
"cpu": "1",
"memory": "2G"
}
},
"genesis": {
"runtimeGenesis": {
"patch": {
"configuration": {
"config": {
"group_rotation_frequency": 4,
"needed_approvals": 1,
"relay_vrf_modulo_samples": 6,
"scheduling_lookahead": 3,
"async_backing_params": {
"allowed_ancestry_len": 3,
"max_candidate_depth": 4
}
}
}
}
}
}
},
"settings": {
"timeout": 1000
},
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
}
}
}
2 changes: 1 addition & 1 deletion test/moonwall.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"testFileDir": ["suites/zombie"],
"timeout": 300000,
"envVars": ["DEBUG_COLORS=1"],
"reporters": ["basic"],
"reporters": ["default"],
"foundation": {
"type": "zombie",
"rtUpgradePath": "./tmp/moonbase-runtime-2401.wasm",
Expand Down
2 changes: 1 addition & 1 deletion test/suites/chopsticks/test-chopsticks-state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "@moonbeam-network/api-augment"
import "@moonbeam-network/api-augment";
import { describeSuite, expect, beforeAll } from "@moonwall/cli";
import { alith } from "@moonwall/util";
import { parseEther } from "ethers";
Expand Down
10 changes: 4 additions & 6 deletions test/suites/dev_tests/test1/test_dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
describeSuite,
expect,
fetchCompiledContract,
whiteListedTrack
whiteListedTrack,
} from "@moonwall/cli";
import {
ALITH_ADDRESS,
Expand All @@ -16,7 +16,7 @@ import {
GLMR,
alith,
baltathar,
deployViemContract
deployViemContract,
} from "@moonwall/util";
import { BN } from "@polkadot/util";
import { Wallet, parseEther } from "ethers";
Expand Down Expand Up @@ -618,14 +618,14 @@ describeSuite({
log(`Previous block #${block}, new block #${block2}`);
log(`Previous round #${round}, new round #${round2}`);
expect(round2).toBe(round + 1);

},
});

it({
id: "T26",
title: "it can fast execute an openGov proposal",
test: async () => {
// change this to system.authorizedupgrade after sdk 1.7
const value = (await context.pjsApi.query.parachainSystem.authorizedUpgrade()).isNone;
expect(value, "parachainSystem.authorizedUpgrade should be empty to begin with").toBe(true);

Expand All @@ -640,9 +640,7 @@ describeSuite({
expect(postStatus).toBe(false);

expect(
(await context.pjsApi.query.parachainSystem.authorizedUpgrade())
.unwrap()
.codeHash.toHex()
(await context.pjsApi.query.parachainSystem.authorizedUpgrade()).unwrap().codeHash.toHex()
).toBe("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
},
});
Expand Down
2 changes: 1 addition & 1 deletion test/suites/dev_tests/test2/test_dev2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "@moonbeam-network/api-augment";
import { describeSuite, expect, beforeAll} from "@moonwall/cli";
import { describeSuite, expect, beforeAll } from "@moonwall/cli";
import { CHARLETH_ADDRESS, BALTATHAR_ADDRESS, alith } from "@moonwall/util";
import { parseEther, Wallet } from "ethers";
import { BN } from "@polkadot/util";
Expand Down
34 changes: 20 additions & 14 deletions test/suites/zombie/test_basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describeSuite({
title: "Check parachain api correctly connected (2)",
timeout: 120000,
test: async () => {
await context.waitBlock(5, "parachain", "height");
await context.waitBlock(2, "parachain", "height");
},
});

Expand All @@ -58,20 +58,26 @@ describeSuite({

log("Please wait, this will take at least 30s for transaction to complete");

await new Promise((resolve) => {
paraApi.tx.balances
.transferAllowDeath(ALITH_ADDRESS, 2n * GLMR)
.signAndSend(baltathar, ({ status, events }) => {
if (status.isInBlock) {
log("Transaction is in block");
}
if (status.isFinalized) {
log("Transaction is finalized!");
resolve(events);
}
});
});
// Uncomment when we upgrade to polkadot 1.7
// await new Promise((resolve) => {
// paraApi.tx.balances
// .transferAllowDeath(ALITH_ADDRESS, 2n * GLMR)
// .signAndSend(baltathar, ({ status, events }) => {
// if (status.isInBlock) {
// log("Transaction is in block");
// }
// if (status.isFinalized) {
// log("Transaction is finalized!");
// resolve(events);
// }
// });
// });

await paraApi.tx.balances
.transferAllowDeath(ALITH_ADDRESS, 2n * GLMR)
.signAndSend(baltathar);

await context.waitBlock(4, "parachain", "quantity");
const balAfter = (await paraApi.query.system.account(ALITH_ADDRESS)).data.free;
expect(balBefore.lt(balAfter)).to.be.true;
},
Expand Down

0 comments on commit dad03aa

Please sign in to comment.