-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use chopsticks for runtime upgrade testing (#1356)
* 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
1 parent
5c17cfa
commit fddc081
Showing
8 changed files
with
110 additions
and
0 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
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,4 @@ | ||
POLKADOT_BLOCK_NUMBER= | ||
MANTA_BLOCK_NUMBER= | ||
# LOG_LEVEL="debug" | ||
# VERBOSE_LOG=true |
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,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. |
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,21 @@ | ||
endpoint: wss://ws.manta.systems | ||
mock-signature-host: true | ||
block: ${env.MANTA_BLOCK_NUMBER} | ||
db: ./db.sqlite | ||
|
||
import-storage: | ||
Sudo: | ||
Key: dfbMFtQXqiKHH4d2y4CFcVQCpopqKcaEiYv2DCUpVCphoz8kB # Alice | ||
System: | ||
Account: | ||
- | ||
- | ||
- dfbMFtQXqiKHH4d2y4CFcVQCpopqKcaEiYv2DCUpVCphoz8kB # Alice | ||
- 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] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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 | ||
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,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); | ||
|