From 625dc9ff88880940e51e6334ea6ffd7a3db04b7c Mon Sep 17 00:00:00 2001 From: Emiliano <84690100+metricaez@users.noreply.github.com> Date: Tue, 16 Jan 2024 09:00:53 -0300 Subject: [PATCH] HRMP Workaround and Zombienet chores (#325) --- node/src/chain_spec/trappist.rs | 2 +- scripts/hrmp_helper.sh | 103 +++++++++++++++++++ zombienet/full_network.toml | 176 ++++++++++++++++---------------- zombienet/stout_rococo.toml | 24 +++-- zombienet/trappist_rococo.toml | 24 +++-- zombienet/trappist_stout.toml | 85 +++++++++++++++ 6 files changed, 307 insertions(+), 107 deletions(-) create mode 100755 scripts/hrmp_helper.sh create mode 100644 zombienet/trappist_stout.toml diff --git a/node/src/chain_spec/trappist.rs b/node/src/chain_spec/trappist.rs index b77d0530..f9aab398 100644 --- a/node/src/chain_spec/trappist.rs +++ b/node/src/chain_spec/trappist.rs @@ -137,7 +137,7 @@ pub fn trappist_local_testnet_config() -> ChainSpec { ) }, // Bootnodes - vec![], + Vec::new(), // Telemetry None, // Protocol ID diff --git a/scripts/hrmp_helper.sh b/scripts/hrmp_helper.sh new file mode 100755 index 00000000..d7831c3e --- /dev/null +++ b/scripts/hrmp_helper.sh @@ -0,0 +1,103 @@ +# Helper script to open HRMP channels between Trappist, Stout and Asset Hub. +# This script is meant to be run after the relay chain and parachains are spawned. + +# Change for your bin path +POLKADOT_BIN=~/projects/trappist/bin/polkadot +POLKADOT_PARACHAIN_BIN=~/projects/trappist/bin/polkadot-parachain + +function ensure_binaries() { + echo "*** Checking for required binaries" + if [[ ! -f "$POLKADOT_BIN" ]]; then + echo " Required polkadot binary '$POLKADOT_BIN' does not exist!" + echo " You need to build it and copy to this location!" + exit 1 + fi + if [[ ! -f "$POLKADOT_PARACHAIN_BIN" ]]; then + echo " Required polkadot-parachain binary '$POLKADOT_PARACHAIN_BIN' does not exist!" + echo " You need to build it and copy to this location!" + exit 1 + fi + echo "*** All required binaries are present" +} + +function ensure_polkadot_js_api() { + echo "*** Checking for required polkadot-js-api" + if ! which polkadot-js-api &>/dev/null; then + echo '' + echo 'Required command `polkadot-js-api` not in PATH, please, install, e.g.:' + echo "npm install -g @polkadot/api-cli" + echo " or" + echo "yarn global add @polkadot/api-cli" + echo '' + exit 1 + fi +} + +function open_hrmp_channels() { + local relay_url=$1 + local relay_chain_seed=$2 + local sender_para_id=$3 + local recipient_para_id=$4 + local max_capacity=$5 + local max_message_size=$6 + echo " calling open_hrmp_channels:" + echo " relay_url: ${relay_url}" + echo " relay_chain_seed: ${relay_chain_seed}" + echo " sender_para_id: ${sender_para_id}" + echo " recipient_para_id: ${recipient_para_id}" + echo " max_capacity: ${max_capacity}" + echo " max_message_size: ${max_message_size}" + echo " params:" + echo "--------------------------------------------------" + polkadot-js-api \ + --ws "${relay_url?}" \ + --seed "${relay_chain_seed?}" \ + --sudo \ + tx.hrmp.forceOpenHrmpChannel \ + ${sender_para_id} \ + ${recipient_para_id} \ + ${max_capacity} \ + ${max_message_size} +} + +# Check for binaries +ensure_binaries + +# Check for polkadot-js-api cli +ensure_polkadot_js_api + +# HRMP: Trappist - Stout +open_hrmp_channels \ + "ws://127.0.0.1:9900" \ + "//Alice" \ + 1836 3000 4 524288 + +# HRMP: Stout - Trappist +open_hrmp_channels \ + "ws://127.0.0.1:9900" \ + "//Alice" \ + 3000 1836 4 524288 + +# HRMP: Trappist - Asset Hub +open_hrmp_channels \ + "ws://127.0.0.1:9900" \ + "//Alice" \ + 1836 1000 4 524288 + +# HRMP: Asset Hub - Trappist +open_hrmp_channels \ + "ws://127.0.0.1:9900" \ + "//Alice" \ + 1000 1836 4 524288 + +# HRMP: Stout - Asset Hub +open_hrmp_channels \ + "ws://127.0.0.1:9900" \ + "//Alice" \ + 3000 1000 4 524288 + +# HRMP: Asset Hub - Stout +open_hrmp_channels \ + "ws://127.0.0.1:9900" \ + "//Alice" \ + 1000 3000 4 524288 diff --git a/zombienet/full_network.toml b/zombienet/full_network.toml index e0ba9e2a..dd0d8456 100644 --- a/zombienet/full_network.toml +++ b/zombienet/full_network.toml @@ -5,44 +5,44 @@ timeout = 1000 chain = "rococo-local" default_command = "./bin/polkadot" - [[relaychain.nodes]] - name = "alice" - validator = true - ws_port = 9900 - extra_args = [ "-lparachain=debug" ] - - [[relaychain.nodes]] - name = "bob" - validator = true - extra_args = [ "-lparachain=debug" ] - - [[relaychain.nodes]] - name = "charlie" - validator = true - extra_args = [ "-lparachain=debug" ] - - [[relaychain.nodes]] - name = "dave" - validator = true - extra_args = [ "-lparachain=debug" ] +[[relaychain.nodes]] +name = "alice" +validator = true +ws_port = 9900 +extra_args = ["-lparachain=debug"] + +[[relaychain.nodes]] +name = "bob" +validator = true +extra_args = ["-lparachain=debug"] + +[[relaychain.nodes]] +name = "charlie" +validator = true +extra_args = ["-lparachain=debug"] + +[[relaychain.nodes]] +name = "dave" +validator = true +extra_args = ["-lparachain=debug"] [[parachains]] id = 1000 add_to_genesis = true cumulus_based = true -chain = "statemine-local" +chain = "asset-hub-rococo-local" - [[parachains.collators]] - name = "statemine-collator01" - command = "./bin/polkadot-parachain" - ws_port = 9910 - args = ["--log=xcm=trace,pallet-assets=trace"] +[[parachains.collators]] +name = "asset-hub-collator01" +command = "./bin/polkadot-parachain" +ws_port = 9910 +args = ["--log=xcm=trace,pallet-assets=trace"] - [[parachains.collators]] - name = "statemine-collator02" - command = "./bin/polkadot-parachain" - ws_port = 9911 - args = ["--log=xcm=trace,pallet-assets=trace"] +[[parachains.collators]] +name = "asset-hub-collator02" +command = "./bin/polkadot-parachain" +ws_port = 9911 +args = ["--log=xcm=trace,pallet-assets=trace"] [[parachains]] id = 1836 @@ -50,17 +50,17 @@ add_to_genesis = true cumulus_based = true chain = "trappist-local" - [[parachains.collators]] - name = "trappist-collator01" - command = "./target/release/trappist-node" - ws_port = 9920 - args = ["--log=xcm=trace,pallet-assets=trace"] +[[parachains.collators]] +name = "trappist-collator01" +command = "./target/release/trappist-node" +ws_port = 9920 +args = ["--log=xcm=trace,pallet-assets=trace"] - [[parachains.collators]] - name = "trappist-collator02" - command = "./target/release/trappist-node" - ws_port = 9921 - args = ["--log=xcm=trace,pallet-assets=trace"] +[[parachains.collators]] +name = "trappist-collator02" +command = "./target/release/trappist-node" +ws_port = 9921 +args = ["--log=xcm=trace,pallet-assets=trace"] [[parachains]] id = 3000 @@ -68,55 +68,59 @@ add_to_genesis = true cumulus_based = true chain = "stout-local" - [[parachains.collators]] - name = "stout-collator01" - command = "./target/release/trappist-node" - ws_port = 9930 - args = ["--log=xcm=trace,pallet-assets=trace"] +[[parachains.collators]] +name = "stout-collator01" +command = "./target/release/trappist-node" +ws_port = 9930 +args = ["--log=xcm=trace,pallet-assets=trace"] - [[parachains.collators]] - name = "stout-collator02" - command = "./target/release/trappist-node" - ws_port = 9931 - args = ["--log=xcm=trace,pallet-assets=trace"] +[[parachains.collators]] +name = "stout-collator02" +command = "./target/release/trappist-node" +ws_port = 9931 +args = ["--log=xcm=trace,pallet-assets=trace"] [types.Header] number = "u64" parent_hash = "Hash" post_state = "Hash" -[[hrmp_channels]] -sender = 1000 -recipient = 1836 -max_capacity = 8 -max_message_size = 512 - -[[hrmp_channels]] -sender = 1836 -recipient = 1000 -max_capacity = 8 -max_message_size = 512 - -[[hrmp_channels]] -sender = 1000 -recipient = 3000 -max_capacity = 8 -max_message_size = 512 - -[[hrmp_channels]] -sender = 3000 -recipient = 1000 -max_capacity = 8 -max_message_size = 512 - -[[hrmp_channels]] -sender = 1836 -recipient = 3000 -max_capacity = 8 -max_message_size = 512 - -[[hrmp_channels]] -sender = 3000 -recipient = 1836 -max_capacity = 8 -max_message_size = 512 \ No newline at end of file +# Currently there is a known issue with opening hrmp channels +# on genesis that stops block production after epoch 1. +# Use hrmp_helper script after network spawn to open channels instead. + +# [[hrmp_channels]] +# sender = 1000 +# recipient = 1836 +# max_capacity = 8 +# max_message_size = 512 + +# [[hrmp_channels]] +# sender = 1836 +# recipient = 1000 +# max_capacity = 8 +# max_message_size = 512 + +# [[hrmp_channels]] +# sender = 1000 +# recipient = 3000 +# max_capacity = 8 +# max_message_size = 512 + +# [[hrmp_channels]] +# sender = 3000 +# recipient = 1000 +# max_capacity = 8 +# max_message_size = 512 + +# [[hrmp_channels]] +# sender = 1836 +# recipient = 3000 +# max_capacity = 8 +# max_message_size = 512 + +# [[hrmp_channels]] +# sender = 3000 +# recipient = 1836 +# max_capacity = 8 +# max_message_size = 512 diff --git a/zombienet/stout_rococo.toml b/zombienet/stout_rococo.toml index 140e56c6..52dbd765 100644 --- a/zombienet/stout_rococo.toml +++ b/zombienet/stout_rococo.toml @@ -67,14 +67,18 @@ number = "u64" parent_hash = "Hash" post_state = "Hash" -[[hrmp_channels]] -sender = 1000 -recipient = 3000 -max_capacity = 8 -max_message_size = 512 +# Currently there is a known issue with opening hrmp channels +# on genesis that stops block production after epoch 1. +# Use hrmp_helper script after network spawn to open channels instead. -[[hrmp_channels]] -sender = 3000 -recipient = 1000 -max_capacity = 8 -max_message_size = 512 \ No newline at end of file +# [[hrmp_channels]] +# sender = 1000 +# recipient = 3000 +# max_capacity = 8 +# max_message_size = 512 + +# [[hrmp_channels]] +# sender = 3000 +# recipient = 1000 +# max_capacity = 8 +# max_message_size = 512 \ No newline at end of file diff --git a/zombienet/trappist_rococo.toml b/zombienet/trappist_rococo.toml index c8259240..64c4b3b4 100644 --- a/zombienet/trappist_rococo.toml +++ b/zombienet/trappist_rococo.toml @@ -67,14 +67,18 @@ number = "u64" parent_hash = "Hash" post_state = "Hash" -[[hrmp_channels]] -sender = 1000 -recipient = 1836 -max_capacity = 8 -max_message_size = 512 +# Currently there is a known issue with opening hrmp channels +# on genesis that stops block production after epoch 1. +# Use hrmp_helper script after network spawn to open channels instead. -[[hrmp_channels]] -sender = 1836 -recipient = 1000 -max_capacity = 8 -max_message_size = 512 \ No newline at end of file +# [[hrmp_channels]] +# sender = 1000 +# recipient = 1836 +# max_capacity = 8 +# max_message_size = 512 + +# [[hrmp_channels]] +# sender = 1836 +# recipient = 1000 +# max_capacity = 8 +# max_message_size = 512 \ No newline at end of file diff --git a/zombienet/trappist_stout.toml b/zombienet/trappist_stout.toml new file mode 100644 index 00000000..cf8d8d34 --- /dev/null +++ b/zombienet/trappist_stout.toml @@ -0,0 +1,85 @@ +[settings] +timeout = 1000 + +[relaychain] +chain = "rococo-local" +default_command = "./bin/polkadot" +# chain_spec_path = "./bin/rococo-local-plain-custom.json" + + [[relaychain.nodes]] + name = "alice" + validator = true + ws_port = 9900 + extra_args = [ "-lparachain=debug" ] + + [[relaychain.nodes]] + name = "bob" + validator = true + extra_args = [ "-lparachain=debug" ] + + [[relaychain.nodes]] + name = "charlie" + validator = true + extra_args = [ "-lparachain=debug" ] + + [[relaychain.nodes]] + name = "dave" + validator = true + extra_args = [ "-lparachain=debug" ] + +[[parachains]] +id = 1836 +add_to_genesis = true +cumulus_based = true +chain = "trappist-local" + + [[parachains.collators]] + name = "trappist-collator01" + command = "./target/release/trappist-node" + ws_port = 9920 + args = ["--log=xcm=trace,pallet-assets=trace"] + + [[parachains.collators]] + name = "trappist-collator02" + command = "./target/release/trappist-node" + ws_port = 9921 + args = ["--log=xcm=trace,pallet-assets=trace"] + +[[parachains]] +id = 3000 +add_to_genesis = true +cumulus_based = true +chain = "stout-local" + + [[parachains.collators]] + name = "stout-collator01" + command = "./target/release/trappist-node" + ws_port = 9930 + args = ["--log=xcm=trace,pallet-assets=trace"] + + [[parachains.collators]] + name = "stout-collator02" + command = "./target/release/trappist-node" + ws_port = 9931 + args = ["--log=xcm=trace,pallet-assets=trace"] + +[types.Header] +number = "u64" +parent_hash = "Hash" +post_state = "Hash" + +# Currently there is a known issue with opening hrmp channels +# on genesis that stops block production after epoch 1. +# Use hrmp_helper script after network spawn to open channels instead. + +# [[hrmp_channels]] +# sender = 1836 +# recipient = 3000 +# max_capacity = 8 +# max_message_size = 512 + +# [[hrmp_channels]] +# sender = 3000 +# recipient = 1836 +# max_capacity = 8 +# max_message_size = 512