Skip to content

Commit

Permalink
Use chopsticks for runtime upgrade testing (#1356)
Browse files Browse the repository at this point in the history
* Use chopsticks for runtime upgrade testing

Signed-off-by: Jamie <[email protected]>

* Fix yaml lint

Signed-off-by: Jamie <[email protected]>

---------

Signed-off-by: Jamie <[email protected]>
  • Loading branch information
Dengjianping authored Nov 12, 2024
1 parent 5c17cfa commit fddc081
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ These checks should be performed on the codebase prior to freezing our release c
- [ ] Check that build artifacts have been added to the draft-release
- [ ] Promote the draft to a Pre-Release on github
- [ ] If there's any new extrinsic or pallet introduced, please add it to [runtime/calamari/src/diff_tx_fees.rs](../../runtime/calamari/src/diff_tx_fees.rs), then follow [tx-fees-data/README](../../runtime/calamari/tx-fees-data/README.md) to generate a new tx fees sheet.
- [ ] Do runtime upgrade by [chopstick](../../chop/).

# Deploy to internal testnets ( fast runtime )

Expand Down
4 changes: 4 additions & 0 deletions chop/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POLKADOT_BLOCK_NUMBER=
MANTA_BLOCK_NUMBER=
# LOG_LEVEL="debug"
# VERBOSE_LOG=true
30 changes: 30 additions & 0 deletions chop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Do runtime upgrade by chopsticks

- chopsticks: https://github.com/AcalaNetwork/chopsticks
- manta config: [manta](./manta.yml), which configure Alice as sudo account.
- polkadot config: [polkadot](./polkadot.yml)

1. Update the recent block number for polkadot and manta.
```
POLKADOT_BLOCK_NUMBER=
MANTA_BLOCK_NUMBER=
```

2. Start both forked chains with chopsticks
```
npx @acala-network/chopsticks@latest xcm --r=polkadot.yml --p=manta.yml
```
manta will take port `8000`, and ``8001` for polkadot by default.

3. Please authorize runtime upgrade first on manta chain.
![authorize](./pics/authorize.png)

4. Then enact runtime upgrade
![enact](./pics/enact.png)

5. Advance some blocks on manta and polkadot chain by this scripts
```
cd tests
yarn advance-blocks
```
Ideally, you will see runtime upgraded event, that means the upgrade will have been finished.
21 changes: 21 additions & 0 deletions chop/manta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
endpoint: wss://ws.manta.systems
mock-signature-host: true
block: ${env.MANTA_BLOCK_NUMBER}
db: ./db.sqlite

import-storage:
Sudo:
Key: dfbMFtQXqiKHH4d2y4CFcVQCpopqKcaEiYv2DCUpVCphoz8kB # Alice

Check warning on line 8 in chop/manta.yml

View workflow job for this annotation

GitHub Actions / lint-checks

8:60 [comments] too few spaces before comment
System:
Account:
-
-
- dfbMFtQXqiKHH4d2y4CFcVQCpopqKcaEiYv2DCUpVCphoz8kB # Alice

Check warning on line 13 in chop/manta.yml

View workflow job for this annotation

GitHub Actions / lint-checks

13:63 [comments] too few spaces before comment
- data:
free: "100000000000000000000000"
ParachainStaking:
# NOTE: MANTA_BLOCK_NUMBER should set to 2170792 in .env file.
# If you change the block number, you need to also change here.
# The value should be `authorInherent.author` storage \
# correspond to your block number.
SelectedCandidates: [dfbE3LfJAvdnNWBQmNv9bBUW3ieAjwijWZYRXx26uK3o2gTJZ]
Binary file added chop/pics/authorize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chop/pics/enact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions chop/polkadot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
endpoint:
- wss://rpc.ibp.network/polkadot
- wss://polkadot-rpc.dwellir.com
mock-signature-host: true
block: ${env.POLKADOT_BLOCK_NUMBER}
db: ./db.sqlite
# wasm-override: polkadot_runtime.compact.compressed.wasm

import-storage:
System:
Account:
-
-
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
- providers: 1
data:
free: '10000000000000000000'
ParasDisputes:
$removePrefix: ['disputes'] # those can makes block building super slow

Check warning on line 19 in chop/polkadot.yml

View workflow job for this annotation

GitHub Actions / lint-checks

19:33 [comments] too few spaces before comment
35 changes: 35 additions & 0 deletions tests/advance-blocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ApiPromise, WsProvider } from '@polkadot/api';
import '@polkadot/api-augment';

async function createPromiseApi(nodeAddress: string) {
const wsProvider = new WsProvider(nodeAddress);

const api = new ApiPromise({
provider: wsProvider,
});
await api.isReady;
console.log(`${nodeAddress} has been started`);
return api;
}

async function delay(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

async function advance() {
const mantaEndpoint = 'ws://127.0.0.1:8000';
const dotEndpoint = 'ws://127.0.0.1:8001';
const mantaApi = await createPromiseApi(mantaEndpoint);
const dotApi = await createPromiseApi(dotEndpoint);
await mantaApi.rpc('dev_newBlock', { count: 30 });
await dotApi.rpc('dev_newBlock', { count: 60 });
await mantaApi.disconnect();
await dotApi.disconnect();
}

async function main() {
await advance();
}

main().catch(console.error);

0 comments on commit fddc081

Please sign in to comment.