mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 03:01:02 +00:00
Add example zombienet network file and instructions (#1839)
* Add simple example on how to spin up network. * Update readme * Remove unnecessary prefix * Improve folder structure * Add link to file * Fix paths in readme * Update README.md Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
Description: Sync blocks from tip without connected collator test
|
||||
Network: ./0001-sync_blocks_from_tip_without_connected_collator.toml
|
||||
Creds: config
|
||||
|
||||
|
||||
alice: is up
|
||||
bob: is up
|
||||
charlie: is up
|
||||
dave: is up
|
||||
|
||||
alice: parachain 2000 is registered within 225 seconds
|
||||
alice: parachain 2000 block height is at least 10 within 250 seconds
|
||||
|
||||
ferdie: reports block height is at least 12 within 250 seconds
|
||||
eve: reports block height is at least 12 within 250 seconds
|
||||
@@ -0,0 +1,50 @@
|
||||
[relaychain]
|
||||
default_image = "{{RELAY_IMAGE}}"
|
||||
default_command = "polkadot"
|
||||
default_args = [ "-lparachain=debug" ]
|
||||
|
||||
chain = "rococo-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
cumulus_based = true
|
||||
|
||||
# run charlie as parachain collator
|
||||
[[parachains.collators]]
|
||||
name = "charlie"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
|
||||
# run dave as parachain full node
|
||||
[[parachains.collators]]
|
||||
name = "dave"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
|
||||
# run eve as parachain full node that is only connected to dave
|
||||
[[parachains.collators]]
|
||||
name = "eve"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["--reserved-only", "--reserved-nodes {{'dave'|zombie('multiAddress')}}"]
|
||||
|
||||
# run ferdie as parachain full node that is only connected to dave
|
||||
[[parachains.collators]]
|
||||
name = "ferdie"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["--reserved-only", "--reserved-nodes {{'dave'|zombie('multiAddress')}}", "--relay-chain-rpc-url {{'alice'|zombie('wsUri')}}"]
|
||||
@@ -0,0 +1,26 @@
|
||||
Description: PoV recovery test
|
||||
Network: ./0002-pov_recovery.toml
|
||||
Creds: config
|
||||
|
||||
|
||||
validator-0: is up
|
||||
validator-1: is up
|
||||
validator-2: is up
|
||||
validator-3: is up
|
||||
alice: is up within 60 seconds
|
||||
bob: is up within 60 seconds
|
||||
charlie: is up within 60 seconds
|
||||
one: is up within 60 seconds
|
||||
two: is up within 60 seconds
|
||||
|
||||
# wait 30 blocks and register parachain
|
||||
validator-3: reports block height is at least 30 within 250 seconds
|
||||
validator-0: js-script ./register-para.js with "2000" within 240 seconds
|
||||
validator-0: parachain 2000 is registered within 300 seconds
|
||||
|
||||
# check block production
|
||||
bob: reports block height is at least 20 within 600 seconds
|
||||
alice: reports block height is at least 20 within 600 seconds
|
||||
charlie: reports block height is at least 20 within 600 seconds
|
||||
one: reports block height is at least 20 within 600 seconds
|
||||
two: reports block height is at least 20 within 600 seconds
|
||||
@@ -0,0 +1,67 @@
|
||||
[relaychain]
|
||||
default_image = "{{RELAY_IMAGE}}"
|
||||
default_command = "polkadot"
|
||||
|
||||
chain = "rococo-local"
|
||||
|
||||
[relaychain.genesis.runtime.runtime_genesis_config.configuration.config]
|
||||
# set parameters such that collators only connect to 1 validator as a backing group
|
||||
max_validators_per_core = 1
|
||||
group_rotation_frequency = 100 # 10 mins
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "ferdie" # bootnode fullnode
|
||||
validator = false
|
||||
|
||||
[[relaychain.node_groups]]
|
||||
name = "validator"
|
||||
count = 13
|
||||
args = ["-lparachain::availability=trace,sync=debug,parachain=debug", "--reserved-only", "--reserved-nodes {{'ferdie'|zombie('multiAddress')}}"]
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
cumulus_based = true
|
||||
register_para = false
|
||||
add_to_genesis = false
|
||||
|
||||
# run bob as a parachain collator who is the only one producing blocks
|
||||
# alice and charlie will need to recover the pov blocks through availability recovery
|
||||
[[parachains.collators]]
|
||||
name = "bob"
|
||||
validator = true # collator
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["--disable-block-announcements"]
|
||||
|
||||
# run alice as a parachain collator who does not produce blocks
|
||||
# alice is a bootnode for bob and charlie
|
||||
[[parachains.collators]]
|
||||
name = "alice"
|
||||
validator = true # collator
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain::availability=trace,sync=debug,parachain=debug,cumulus-pov-recovery=debug", "--use-null-consensus", "--disable-block-announcements", "--bootnodes {{'bob'|zombie('multiAddress')}}", "--", "--reserved-only", "--reserved-nodes {{'ferdie'|zombie('multiAddress')}}"]
|
||||
|
||||
# run eve as a parachain full node
|
||||
[[parachains.collators]]
|
||||
name = "charlie"
|
||||
validator = false # full node
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain::availability=trace,sync=debug,parachain=debug,cumulus-pov-recovery=debug", "--disable-block-announcements", "--bootnodes {{'bob'|zombie('multiAddress')}}","--", "--reserved-only", "--reserved-nodes {{'ferdie'|zombie('multiAddress')}}"]
|
||||
|
||||
# run one as a RPC collator who does not produce blocks
|
||||
[[parachains.collators]]
|
||||
name = "one"
|
||||
validator = true # collator
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain::availability=trace,sync=debug,parachain=debug,cumulus-pov-recovery=debug", "--use-null-consensus", "--disable-block-announcements", "--bootnodes {{'bob'|zombie('multiAddress')}}", "--relay-chain-rpc-url {{'ferdie'|zombie('wsUri')}}", "--", "--reserved-only", "--reserved-nodes {{'ferdie'|zombie('multiAddress')}}"]
|
||||
|
||||
# run two as a RPC parachain full node
|
||||
[[parachains.collators]]
|
||||
name = "two"
|
||||
validator = false # full node
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain::availability=trace,sync=debug,parachain=debug,cumulus-pov-recovery=debug", "--disable-block-announcements", "--bootnodes {{'bob'|zombie('multiAddress')}}", "--relay-chain-rpc-url {{'ferdie'|zombie('wsUri')}}", "--", "--reserved-only", "--reserved-nodes {{'ferdie'|zombie('multiAddress')}}"]
|
||||
@@ -0,0 +1,12 @@
|
||||
Description: Full node catching up test
|
||||
Network: ./0003-full_node_catching_up.toml
|
||||
Creds: config
|
||||
|
||||
alice: is up
|
||||
bob: is up
|
||||
charlie: is up
|
||||
dave: is up
|
||||
eve: is up
|
||||
alice: parachain 2000 is registered within 225 seconds
|
||||
dave: reports block height is at least 7 within 250 seconds
|
||||
eve: reports block height is at least 7 within 250 seconds
|
||||
@@ -0,0 +1,42 @@
|
||||
[relaychain]
|
||||
default_image = "{{RELAY_IMAGE}}"
|
||||
default_command = "polkadot"
|
||||
default_args = [ "-lparachain=debug" ]
|
||||
|
||||
chain = "rococo-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
cumulus_based = true
|
||||
|
||||
# run charlie as parachain collator
|
||||
[[parachains.collators]]
|
||||
name = "charlie"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
|
||||
# run cumulus dave (a parachain full node) and wait for it to sync some blocks
|
||||
[[parachains.collators]]
|
||||
name = "dave"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["--reserved-only", "--reserved-nodes {{'charlie'|zombie('multiAddress')}}"]
|
||||
|
||||
# run cumulus eve (a parachain full node) and wait for it to sync some blocks
|
||||
[[parachains.collators]]
|
||||
name = "eve"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["--reserved-only", "--reserved-nodes {{'charlie'|zombie('multiAddress')}}", "--relay-chain-rpc-url {{'alice'|zombie('wsUri')}}"]
|
||||
@@ -0,0 +1,13 @@
|
||||
Description: Runtime Upgrade test
|
||||
Network: ./0004-runtime_upgrade.toml
|
||||
Creds: config
|
||||
|
||||
alice: is up
|
||||
bob: is up
|
||||
charlie: is up
|
||||
dave: is up
|
||||
alice: parachain 2000 is registered within 225 seconds
|
||||
charlie: reports block height is at least 5 within 250 seconds
|
||||
charlie: parachain 2000 perform upgrade with /tmp/wasm_binary_spec_version_incremented.rs.compact.compressed.wasm within 200 seconds
|
||||
dave: reports block height is at least 20 within 250 seconds
|
||||
dave: js-script ./runtime_upgrade.js within 200 seconds
|
||||
@@ -0,0 +1,33 @@
|
||||
[relaychain]
|
||||
default_image = "{{RELAY_IMAGE}}"
|
||||
default_command = "polkadot"
|
||||
default_args = [ "-lparachain=debug" ]
|
||||
|
||||
chain = "rococo-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
cumulus_based = true
|
||||
|
||||
# run charlie as parachain collator
|
||||
[[parachains.collators]]
|
||||
name = "charlie"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
|
||||
# Run dave as parachain full node
|
||||
[[parachains.collators]]
|
||||
name = "dave"
|
||||
validator = false
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
@@ -0,0 +1,13 @@
|
||||
Description: Migrate solo to para
|
||||
Network: ./0005-migrate_solo_to_para.toml
|
||||
Creds: config
|
||||
|
||||
alice: is up
|
||||
bob: is up
|
||||
dave: is up
|
||||
eve: is up
|
||||
alice: parachain 2000 is registered within 225 seconds
|
||||
alice: reports block height is at least 10 within 250 seconds
|
||||
alice: parachain 2000 block height is at least 10 within 250 seconds
|
||||
eve: reports block height is 0 within 20 seconds
|
||||
dave: js-script ./migrate_solo_to_para.js with "dave,2000-1,eve" within 200 seconds
|
||||
@@ -0,0 +1,45 @@
|
||||
[relaychain]
|
||||
default_image = "{{RELAY_IMAGE}}"
|
||||
default_command = "polkadot"
|
||||
default_args = [ "-lparachain=debug" ]
|
||||
|
||||
chain = "rococo-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
cumulus_based = true
|
||||
|
||||
# run the solo chain (in our case this is also already a parachain, but as it has a different genesis it will not produce any blocks.)
|
||||
[[parachains.collators]]
|
||||
name = "dave"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
cumulus_based = true
|
||||
add_to_genesis = false
|
||||
register_para = false
|
||||
# Set some random value in the genesis state to create a different genesis hash.
|
||||
[parachains.genesis.runtime.runtime_genesis_config.sudo]
|
||||
key = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
|
||||
|
||||
# run the parachain that will be used to return the header of the solo chain.
|
||||
[[parachains.collators]]
|
||||
name = "eve"
|
||||
validator = true
|
||||
add_to_bootnodes = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
@@ -0,0 +1,17 @@
|
||||
Description: RPC collator should build blocks
|
||||
Network: ./0006-rpc_collator_builds_blocks.toml
|
||||
Creds: config
|
||||
|
||||
alice: is up
|
||||
bob: is up
|
||||
charlie: is up
|
||||
one: is up
|
||||
two: is up
|
||||
dave: is up
|
||||
eve: is up
|
||||
|
||||
alice: parachain 2000 is registered within 225 seconds
|
||||
alice: parachain 2000 block height is at least 10 within 250 seconds
|
||||
|
||||
dave: reports block height is at least 12 within 250 seconds
|
||||
eve: reports block height is at least 12 within 250 seconds
|
||||
@@ -0,0 +1,46 @@
|
||||
[relaychain]
|
||||
default_image = "{{RELAY_IMAGE}}"
|
||||
default_command = "polkadot"
|
||||
default_args = [ "-lparachain=debug" ]
|
||||
|
||||
chain = "rococo-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "charlie"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "one"
|
||||
validator = false
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "two"
|
||||
validator = false
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
cumulus_based = true
|
||||
|
||||
# run dave as parachain full node
|
||||
[[parachains.collators]]
|
||||
name = "dave"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug,blockchain-rpc-client=debug", "--relay-chain-rpc-url {{'one'|zombie('wsUri')}}", "-- --bootnodes {{'one'|zombie('multiAddress')}}"]
|
||||
|
||||
# run eve as parachain full node
|
||||
[[parachains.collators]]
|
||||
name = "eve"
|
||||
validator = true
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "test-parachain"
|
||||
args = ["-lparachain=debug,blockchain-rpc-client=debug", "--relay-chain-rpc-url {{'two'|zombie('wsUri')}}", "-- --bootnodes {{'two'|zombie('multiAddress')}}"]
|
||||
@@ -0,0 +1,57 @@
|
||||
const assert = require("assert");
|
||||
const polkadotApi = require("@polkadot/api");
|
||||
const utilCrypto = require("@polkadot/util-crypto");
|
||||
const fs = require("fs").promises;
|
||||
|
||||
async function connect(apiUrl, types) {
|
||||
const provider = new polkadotApi.WsProvider(apiUrl);
|
||||
const api = new polkadotApi.ApiPromise({ provider, types });
|
||||
await api.isReady;
|
||||
return api;
|
||||
}
|
||||
|
||||
async function run(nodeName, networkInfo, args) {
|
||||
const [paraNode, partialPath, soloNode ] = args;
|
||||
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[paraNode];
|
||||
const {wsUri: wsUri_solo, userDefinedTypes: userDefinedTypes_solo } = networkInfo.nodesByName[soloNode];
|
||||
const para = await connect(wsUri, userDefinedTypes);
|
||||
const solo = await connect(wsUri_solo, userDefinedTypes_solo);
|
||||
|
||||
await utilCrypto.cryptoWaitReady();
|
||||
|
||||
// account to submit tx
|
||||
const keyring = new polkadotApi.Keyring({ type: "sr25519" });
|
||||
const alice = keyring.addFromUri("//Alice");
|
||||
|
||||
// get genesis to update
|
||||
const filePath = `${networkInfo.tmpDir}/${partialPath}/genesis-state`;
|
||||
const customHeader = await fs.readFile(filePath);
|
||||
|
||||
// get current header
|
||||
await para.tx.testPallet.setCustomValidationHeadData(customHeader.toString()).signAndSend(alice);
|
||||
|
||||
let parachain_best;
|
||||
let count = 0;
|
||||
|
||||
assertParachainBest = async (parachain_best) => {
|
||||
const current = await para.rpc.chain.getHeader();
|
||||
assert.equal(parachain_best.toHuman().number, current.toHuman().number, "parachain should not produce more blocks");
|
||||
}
|
||||
|
||||
|
||||
await new Promise( async (resolve, reject) => {
|
||||
const unsubscribe = await solo.rpc.chain.subscribeNewHeads(async (header) => {
|
||||
console.log(`Solo chain is at block: #${header.number}`);
|
||||
count++;
|
||||
if(count === 2) parachain_best = await para.rpc.chain.getHeader();
|
||||
|
||||
if(count > 4) {
|
||||
unsubscribe();
|
||||
await assertParachainBest(parachain_best);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { run }
|
||||
@@ -0,0 +1,9 @@
|
||||
async function run(nodeName, networkInfo, args) {
|
||||
const paraIdStr = args[0];
|
||||
const para = networkInfo.paras[paraIdStr];
|
||||
const relayNode = networkInfo.relay[0];
|
||||
|
||||
await zombie.registerParachain(parseInt(paraIdStr,10),para.wasmPath, para.statePath, relayNode.wsUri, "//Alice", true);
|
||||
}
|
||||
|
||||
module.exports = { run }
|
||||
@@ -0,0 +1,24 @@
|
||||
const assert = require("assert");
|
||||
|
||||
async function run(nodeName, networkInfo, args) {
|
||||
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName];
|
||||
const api = await zombie.connect(wsUri, userDefinedTypes);
|
||||
|
||||
// get blockhash/runtimeVersion at block 1
|
||||
const hashAtBlock1 = await api.rpc.chain.getBlockHash(1);
|
||||
const versionAtBlock1 = await api.rpc.state.getRuntimeVersion(hashAtBlock1.toHuman());
|
||||
|
||||
// get blockhash/runtimeVersion at current head
|
||||
const currentHeader = await api.rpc.chain.getHeader();
|
||||
const hashAtCurrent = await api.rpc.chain.getBlockHash(currentHeader.number.toHuman());
|
||||
const versionAtCurrent = await api.rpc.state.getRuntimeVersion(hashAtCurrent.toHuman());
|
||||
|
||||
const oldVersionIncremented = parseInt(versionAtBlock1.specVersion.toHuman(),10) + 1;
|
||||
console.log("current", versionAtCurrent.specVersion.toHuman());
|
||||
console.log("oldVersionIncremented", oldVersionIncremented);
|
||||
|
||||
// 2 == 2
|
||||
assert.equal( oldVersionIncremented, versionAtCurrent.specVersion.toHuman(), "Running version should be the incremented version");
|
||||
}
|
||||
|
||||
module.exports = { run }
|
||||
Reference in New Issue
Block a user