From 7d58c547ec2a752ed78e51131950d9ec2cdc031b Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Tue, 30 Jan 2024 15:08:41 +0100 Subject: [PATCH 1/7] Remove unneeded paths --- bridges/zombienet/run-tests.sh | 7 ------- cumulus/parachains/runtimes/bridge-hubs/README.md | 2 -- .../bridge-hubs/bridge_hub_rococo_local_network.toml | 4 ++-- .../bridge-hubs/bridge_hub_westend_local_network.toml | 4 ++-- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/bridges/zombienet/run-tests.sh b/bridges/zombienet/run-tests.sh index cf3b529e6a9d..6c2b8b29d654 100755 --- a/bridges/zombienet/run-tests.sh +++ b/bridges/zombienet/run-tests.sh @@ -34,16 +34,12 @@ export BRIDGE_TESTS_FOLDER=$POLKADOT_SDK_FOLDER/bridges/zombienet/tests if [ "$ZOMBIENET_DOCKER_PATHS" -eq 1 ]; then export POLKADOT_BINARY_PATH=/usr/local/bin/polkadot export POLKADOT_PARACHAIN_BINARY_PATH=/usr/local/bin/polkadot-parachain - export POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_ROCOCO=/usr/local/bin/polkadot-parachain - export POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_WESTEND=/usr/local/bin/polkadot-parachain export SUBSTRATE_RELAY_PATH=/usr/local/bin/substrate-relay export ZOMBIENET_BINARY_PATH=/usr/local/bin/zombie else export POLKADOT_BINARY_PATH=$POLKADOT_SDK_FOLDER/target/release/polkadot export POLKADOT_PARACHAIN_BINARY_PATH=$POLKADOT_SDK_FOLDER/target/release/polkadot-parachain - export POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_ROCOCO=$POLKADOT_PARACHAIN_BINARY_PATH - export POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_WESTEND=$POLKADOT_PARACHAIN_BINARY_PATH export SUBSTRATE_RELAY_PATH=~/local_bridge_testing/bin/substrate-relay export ZOMBIENET_BINARY_PATH=~/local_bridge_testing/bin/zombienet-linux @@ -52,9 +48,6 @@ fi # check if `wait` supports -p flag if [ `printf "$BASH_VERSION\n5.1" | sort -V | head -n 1` = "5.1" ]; then IS_BASH_5_1=1; else IS_BASH_5_1=0; fi -# check if `wait` supports -p flag -if [ `printf "$BASH_VERSION\n5.1" | sort -V | head -n 1` = "5.1" ]; then IS_BASH_5_1=1; else IS_BASH_5_1=0; fi - # bridge configuration export LANE_ID="00000002" diff --git a/cumulus/parachains/runtimes/bridge-hubs/README.md b/cumulus/parachains/runtimes/bridge-hubs/README.md index cf617db730dd..6aa092e05ee8 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/README.md +++ b/cumulus/parachains/runtimes/bridge-hubs/README.md @@ -91,7 +91,6 @@ cd # Rococo + BridgeHubRococo + AssetHub for Rococo (mirroring Kusama) POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \ POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \ -POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_ROCOCO=~/local_bridge_testing/bin/polkadot-parachain-asset-hub \ ~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml ``` @@ -101,7 +100,6 @@ cd # Westend + BridgeHubWestend + AssetHub for Westend (mirroring Polkadot) POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \ POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \ -POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_WESTEND=~/local_bridge_testing/bin/polkadot-parachain-asset-hub \ ~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml ``` diff --git a/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml b/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml index 99a7d0035b51..9806903c8c0c 100644 --- a/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml +++ b/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml @@ -65,14 +65,14 @@ cumulus_based = true name = "asset-hub-rococo-collator1" rpc_port = 9911 ws_port = 9910 - command = "{{POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_ROCOCO}}" + command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" args = [ "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace" ] [[parachains.collators]] name = "asset-hub-rococo-collator2" - command = "{{POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_ROCOCO}}" + command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" args = [ "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace" ] diff --git a/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml b/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml index 1919d1c63f25..68ef0987b40f 100644 --- a/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +++ b/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml @@ -65,14 +65,14 @@ cumulus_based = true name = "asset-hub-westend-collator1" rpc_port = 9011 ws_port = 9010 - command = "{{POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_WESTEND}}" + command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" args = [ "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace" ] [[parachains.collators]] name = "asset-hub-westend-collator2" - command = "{{POLKADOT_PARACHAIN_BINARY_PATH_FOR_ASSET_HUB_WESTEND}}" + command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" args = [ "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace" ] From 3a32cc4d87b21c6f1dce5e3c32e8d2d6668de34b Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 7 Feb 2024 16:41:23 +0100 Subject: [PATCH 2/7] Rename some variables --- bridges/zombienet/README.md | 2 +- bridges/zombienet/run-tests.sh | 16 ++++++++-------- bridges/zombienet/scripts/invoke-script.sh | 2 +- bridges/zombienet/scripts/start-relayer.sh | 2 +- .../parachains/runtimes/bridge-hubs/README.md | 8 ++++---- cumulus/scripts/bridges_common.sh | 2 +- .../bridge_hub_rococo_local_network.toml | 10 +++++----- .../bridge_hub_westend_local_network.toml | 10 +++++----- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/bridges/zombienet/README.md b/bridges/zombienet/README.md index b601154b624c..bd467a410d01 100644 --- a/bridges/zombienet/README.md +++ b/bridges/zombienet/README.md @@ -23,7 +23,7 @@ To start those tests, you need to: - copy fresh `substrate-relay` binary, built in previous point, to the `~/local_bridge_testing/bin/substrate-relay`; -- change the `POLKADOT_SDK_FOLDER` and `ZOMBIENET_BINARY_PATH` (and ensure that the nearby variables +- change the `POLKADOT_SDK_PATH` and `ZOMBIENET_BINARY_PATH` (and ensure that the nearby variables have correct values) in the `./run-tests.sh`. After that, you could run tests with the `./run-tests.sh` command. Hopefully, it'll show the diff --git a/bridges/zombienet/run-tests.sh b/bridges/zombienet/run-tests.sh index 6c2b8b29d654..42818a5cdf36 100755 --- a/bridges/zombienet/run-tests.sh +++ b/bridges/zombienet/run-tests.sh @@ -27,21 +27,21 @@ done # assuming that we'll be using native provide && all processes will be executing locally # (we need absolute paths here, because they're used when scripts are called by zombienet from tmp folders) -export POLKADOT_SDK_FOLDER=`realpath $(dirname "$0")/../..` -export BRIDGE_TESTS_FOLDER=$POLKADOT_SDK_FOLDER/bridges/zombienet/tests +export POLKADOT_SDK_PATH=`realpath $(dirname "$0")/../..` +export BRIDGE_TESTS_FOLDER=$POLKADOT_SDK_PATH/bridges/zombienet/tests # set pathc to binaries if [ "$ZOMBIENET_DOCKER_PATHS" -eq 1 ]; then - export POLKADOT_BINARY_PATH=/usr/local/bin/polkadot - export POLKADOT_PARACHAIN_BINARY_PATH=/usr/local/bin/polkadot-parachain + export POLKADOT_BINARY=/usr/local/bin/polkadot + export POLKADOT_PARACHAIN_BINARY=/usr/local/bin/polkadot-parachain - export SUBSTRATE_RELAY_PATH=/usr/local/bin/substrate-relay + export SUBSTRATE_RELAY_BINARY=/usr/local/bin/substrate-relay export ZOMBIENET_BINARY_PATH=/usr/local/bin/zombie else - export POLKADOT_BINARY_PATH=$POLKADOT_SDK_FOLDER/target/release/polkadot - export POLKADOT_PARACHAIN_BINARY_PATH=$POLKADOT_SDK_FOLDER/target/release/polkadot-parachain + export POLKADOT_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot + export POLKADOT_PARACHAIN_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot-parachain - export SUBSTRATE_RELAY_PATH=~/local_bridge_testing/bin/substrate-relay + export SUBSTRATE_RELAY_BINARY=~/local_bridge_testing/bin/substrate-relay export ZOMBIENET_BINARY_PATH=~/local_bridge_testing/bin/zombienet-linux fi diff --git a/bridges/zombienet/scripts/invoke-script.sh b/bridges/zombienet/scripts/invoke-script.sh index 835b4fe500f0..1f814cd08562 100755 --- a/bridges/zombienet/scripts/invoke-script.sh +++ b/bridges/zombienet/scripts/invoke-script.sh @@ -2,6 +2,6 @@ INVOKE_LOG=`mktemp -p $TEST_FOLDER invoke.XXXXX` -pushd $POLKADOT_SDK_FOLDER/cumulus/scripts +pushd $POLKADOT_SDK_PATH/cumulus/scripts ./bridges_rococo_westend.sh $1 >$INVOKE_LOG 2>&1 popd diff --git a/bridges/zombienet/scripts/start-relayer.sh b/bridges/zombienet/scripts/start-relayer.sh index 2f72b5ee556b..630fd7316fe4 100755 --- a/bridges/zombienet/scripts/start-relayer.sh +++ b/bridges/zombienet/scripts/start-relayer.sh @@ -2,6 +2,6 @@ RELAY_LOG=`mktemp -p $TEST_FOLDER relay.XXXXX` -pushd $POLKADOT_SDK_FOLDER/cumulus/scripts +pushd $POLKADOT_SDK_PATH/cumulus/scripts ./bridges_rococo_westend.sh run-relay >$RELAY_LOG 2>&1& popd diff --git a/cumulus/parachains/runtimes/bridge-hubs/README.md b/cumulus/parachains/runtimes/bridge-hubs/README.md index 6aa092e05ee8..4e9403bf25ee 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/README.md +++ b/cumulus/parachains/runtimes/bridge-hubs/README.md @@ -89,8 +89,8 @@ cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-paracha cd # Rococo + BridgeHubRococo + AssetHub for Rococo (mirroring Kusama) -POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \ -POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \ +POLKADOT_BINARY=~/local_bridge_testing/bin/polkadot \ +POLKADOT_PARACHAIN_BINARY=~/local_bridge_testing/bin/polkadot-parachain \ ~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml ``` @@ -98,8 +98,8 @@ POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \ cd # Westend + BridgeHubWestend + AssetHub for Westend (mirroring Polkadot) -POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \ -POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \ +POLKADOT_BINARY=~/local_bridge_testing/bin/polkadot \ +POLKADOT_PARACHAIN_BINARY=~/local_bridge_testing/bin/polkadot-parachain \ ~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml ``` diff --git a/cumulus/scripts/bridges_common.sh b/cumulus/scripts/bridges_common.sh index 029d4cd4ff74..2064dbbb5b85 100755 --- a/cumulus/scripts/bridges_common.sh +++ b/cumulus/scripts/bridges_common.sh @@ -2,7 +2,7 @@ function relayer_path() { local default_path=~/local_bridge_testing/bin/substrate-relay - local path="${SUBSTRATE_RELAY_PATH:-$default_path}" + local path="${SUBSTRATE_RELAY_BINARY:-$default_path}" echo "$path" } diff --git a/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml b/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml index 9806903c8c0c..983ce21b3c0a 100644 --- a/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml +++ b/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml @@ -2,7 +2,7 @@ node_spawn_timeout = 240 [relaychain] -default_command = "{{POLKADOT_BINARY_PATH}}" +default_command = "{{POLKADOT_BINARY}}" default_args = [ "-lparachain=debug,xcm=trace" ] chain = "rococo-local" @@ -36,7 +36,7 @@ cumulus_based = true [[parachains.collators]] name = "bridge-hub-rococo-collator1" validator = true - command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + command = "{{POLKADOT_PARACHAIN_BINARY}}" rpc_port = 8933 ws_port = 8943 args = [ @@ -48,7 +48,7 @@ cumulus_based = true [[parachains.collators]] name = "bridge-hub-rococo-collator2" validator = true - command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + command = "{{POLKADOT_PARACHAIN_BINARY}}" rpc_port = 8934 ws_port = 8944 args = [ @@ -65,14 +65,14 @@ cumulus_based = true name = "asset-hub-rococo-collator1" rpc_port = 9911 ws_port = 9910 - command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + command = "{{POLKADOT_PARACHAIN_BINARY}}" args = [ "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace" ] [[parachains.collators]] name = "asset-hub-rococo-collator2" - command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + command = "{{POLKADOT_PARACHAIN_BINARY}}" args = [ "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace" ] diff --git a/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml b/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml index 68ef0987b40f..37dc03702303 100644 --- a/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +++ b/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml @@ -2,7 +2,7 @@ node_spawn_timeout = 240 [relaychain] -default_command = "{{POLKADOT_BINARY_PATH}}" +default_command = "{{POLKADOT_BINARY}}" default_args = [ "-lparachain=debug,xcm=trace" ] chain = "westend-local" @@ -36,7 +36,7 @@ cumulus_based = true [[parachains.collators]] name = "bridge-hub-westend-collator1" validator = true - command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + command = "{{POLKADOT_PARACHAIN_BINARY}}" rpc_port = 8935 ws_port = 8945 args = [ @@ -48,7 +48,7 @@ cumulus_based = true [[parachains.collators]] name = "bridge-hub-westend-collator2" validator = true - command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + command = "{{POLKADOT_PARACHAIN_BINARY}}" rpc_port = 8936 ws_port = 8946 args = [ @@ -65,14 +65,14 @@ cumulus_based = true name = "asset-hub-westend-collator1" rpc_port = 9011 ws_port = 9010 - command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + command = "{{POLKADOT_PARACHAIN_BINARY}}" args = [ "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace" ] [[parachains.collators]] name = "asset-hub-westend-collator2" - command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + command = "{{POLKADOT_PARACHAIN_BINARY}}" args = [ "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace" ] From f51360cbf7927a1b142e54c1d7a4339dd012ec00 Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 7 Feb 2024 19:43:54 +0100 Subject: [PATCH 3/7] Bridge zombienets and scripts adjustments --- .../helpers/best-finalized-header-at-bridged-chain.js | 2 +- .../zombienet/helpers/native-assets-balance-increased.js | 2 +- bridges/zombienet/helpers/relayer-rewards.js | 2 +- bridges/zombienet/helpers/wait-hrmp-channel-opened.js | 2 +- bridges/zombienet/helpers/wrapped-assets-balance.js | 2 +- .../bridge-hubs/bridge_hub_rococo_local_network.toml | 6 ++---- .../bridge-hubs/bridge_hub_westend_local_network.toml | 6 ++---- 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/bridges/zombienet/helpers/best-finalized-header-at-bridged-chain.js b/bridges/zombienet/helpers/best-finalized-header-at-bridged-chain.js index f7e1eefc84b3..af4f18aee9b2 100644 --- a/bridges/zombienet/helpers/best-finalized-header-at-bridged-chain.js +++ b/bridges/zombienet/helpers/best-finalized-header-at-bridged-chain.js @@ -18,7 +18,7 @@ async function run(nodeName, networkInfo, args) { } // else sleep and retry - await new Promise((resolve) => setTimeout(resolve, 12000)); + await new Promise((resolve) => setTimeout(resolve, 6000)); } } diff --git a/bridges/zombienet/helpers/native-assets-balance-increased.js b/bridges/zombienet/helpers/native-assets-balance-increased.js index 9ee1a769e9f2..a35c753d9732 100644 --- a/bridges/zombienet/helpers/native-assets-balance-increased.js +++ b/bridges/zombienet/helpers/native-assets-balance-increased.js @@ -13,7 +13,7 @@ async function run(nodeName, networkInfo, args) { } // else sleep and retry - await new Promise((resolve) => setTimeout(resolve, 12000)); + await new Promise((resolve) => setTimeout(resolve, 6000)); } } diff --git a/bridges/zombienet/helpers/relayer-rewards.js b/bridges/zombienet/helpers/relayer-rewards.js index a5f567db7977..5347c649604f 100644 --- a/bridges/zombienet/helpers/relayer-rewards.js +++ b/bridges/zombienet/helpers/relayer-rewards.js @@ -21,7 +21,7 @@ async function run(nodeName, networkInfo, args) { } // else sleep and retry - await new Promise((resolve) => setTimeout(resolve, 12000)); + await new Promise((resolve) => setTimeout(resolve, 6000)); } } diff --git a/bridges/zombienet/helpers/wait-hrmp-channel-opened.js b/bridges/zombienet/helpers/wait-hrmp-channel-opened.js index e700cab1d748..765d48cc4984 100644 --- a/bridges/zombienet/helpers/wait-hrmp-channel-opened.js +++ b/bridges/zombienet/helpers/wait-hrmp-channel-opened.js @@ -15,7 +15,7 @@ async function run(nodeName, networkInfo, args) { } // else sleep and retry - await new Promise((resolve) => setTimeout(resolve, 12000)); + await new Promise((resolve) => setTimeout(resolve, 6000)); } } diff --git a/bridges/zombienet/helpers/wrapped-assets-balance.js b/bridges/zombienet/helpers/wrapped-assets-balance.js index bb3cea8858a8..27287118547f 100644 --- a/bridges/zombienet/helpers/wrapped-assets-balance.js +++ b/bridges/zombienet/helpers/wrapped-assets-balance.js @@ -19,7 +19,7 @@ async function run(nodeName, networkInfo, args) { } // else sleep and retry - await new Promise((resolve) => setTimeout(resolve, 12000)); + await new Promise((resolve) => setTimeout(resolve, 6000)); } } diff --git a/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml b/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml index 983ce21b3c0a..52271f944213 100644 --- a/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml +++ b/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml @@ -40,8 +40,7 @@ cumulus_based = true rpc_port = 8933 ws_port = 8943 args = [ - "-lparachain=debug,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace", - "--force-authoring" + "-lparachain=debug,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace" ] # run bob as parachain collator @@ -52,8 +51,7 @@ cumulus_based = true rpc_port = 8934 ws_port = 8944 args = [ - "-lparachain=trace,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace", - "--force-authoring" + "-lparachain=trace,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace" ] [[parachains]] diff --git a/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml b/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml index 37dc03702303..f2550bcc9959 100644 --- a/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +++ b/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml @@ -40,8 +40,7 @@ cumulus_based = true rpc_port = 8935 ws_port = 8945 args = [ - "-lparachain=debug,runtime::mmr=info,substrate=info,runtime=info,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace", - "--force-authoring" + "-lparachain=debug,runtime::mmr=info,substrate=info,runtime=info,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace" ] # run bob as parachain collator @@ -52,8 +51,7 @@ cumulus_based = true rpc_port = 8936 ws_port = 8946 args = [ - "-lparachain=trace,runtime::mmr=info,substrate=info,runtime=info,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace", - "--force-authoring" + "-lparachain=trace,runtime::mmr=info,substrate=info,runtime=info,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace" ] [[parachains]] From 375c5fb27f4b0a390051079a22f668b12e515f5c Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 31 Jan 2024 13:27:25 +0100 Subject: [PATCH 4/7] Naive bridge testing framework --- .../environments/rococo-westend/helper.sh | 3 ++ .../environments/rococo-westend/rococo.zndsl | 10 ++++ .../environments/rococo-westend/spawn.sh | 46 +++++++++++++++++++ .../environments/rococo-westend/westend.zndsl | 9 ++++ bridges/zombienet/run-new-test.sh | 16 +++++++ .../roc-reaches-westend.zndsl | 12 +++++ .../tests/0001-asset-transfer/run.sh | 22 +++++++++ .../wnd-reaches-rococo.zndsl | 12 +++++ .../wroc-reaches-rococo.zndsl | 10 ++++ .../wwnd-reaches-westend.zndsl | 10 ++++ bridges/zombienet/utils/common.sh | 39 ++++++++++++++++ bridges/zombienet/utils/zombienet.sh | 39 ++++++++++++++++ cumulus/scripts/bridges_rococo_westend.sh | 2 +- 13 files changed, 229 insertions(+), 1 deletion(-) create mode 100755 bridges/zombienet/environments/rococo-westend/helper.sh create mode 100644 bridges/zombienet/environments/rococo-westend/rococo.zndsl create mode 100755 bridges/zombienet/environments/rococo-westend/spawn.sh create mode 100644 bridges/zombienet/environments/rococo-westend/westend.zndsl create mode 100755 bridges/zombienet/run-new-test.sh create mode 100644 bridges/zombienet/tests/0001-asset-transfer/roc-reaches-westend.zndsl create mode 100755 bridges/zombienet/tests/0001-asset-transfer/run.sh create mode 100644 bridges/zombienet/tests/0001-asset-transfer/wnd-reaches-rococo.zndsl create mode 100644 bridges/zombienet/tests/0001-asset-transfer/wroc-reaches-rococo.zndsl create mode 100644 bridges/zombienet/tests/0001-asset-transfer/wwnd-reaches-westend.zndsl create mode 100644 bridges/zombienet/utils/common.sh create mode 100644 bridges/zombienet/utils/zombienet.sh diff --git a/bridges/zombienet/environments/rococo-westend/helper.sh b/bridges/zombienet/environments/rococo-westend/helper.sh new file mode 100755 index 000000000000..049693e0e293 --- /dev/null +++ b/bridges/zombienet/environments/rococo-westend/helper.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +$POLKADOT_SDK_PATH/cumulus/scripts/bridges_rococo_westend.sh "$@" diff --git a/bridges/zombienet/environments/rococo-westend/rococo.zndsl b/bridges/zombienet/environments/rococo-westend/rococo.zndsl new file mode 100644 index 000000000000..34993eeacd9d --- /dev/null +++ b/bridges/zombienet/environments/rococo-westend/rococo.zndsl @@ -0,0 +1,10 @@ +Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back +Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml +Creds: config + +# step 0: ensure that initialization has completed +asset-hub-rococo-collator1: js-script ../../helpers/wait-hrmp-channel-opened.js with "1013" within 600 seconds + +# step 1: relay is already started - let's wait until with-Westend GRANPDA pallet is initialized at Rococo +bridge-hub-rococo-collator1: js-script ../../helpers/best-finalized-header-at-bridged-chain.js with "Westend,0" within 400 seconds + diff --git a/bridges/zombienet/environments/rococo-westend/spawn.sh b/bridges/zombienet/environments/rococo-westend/spawn.sh new file mode 100755 index 000000000000..54dd0be2c6ff --- /dev/null +++ b/bridges/zombienet/environments/rococo-westend/spawn.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -e + +trap "trap - SIGTERM && kill -9 -$$" SIGINT SIGTERM EXIT + +source "${BASH_SOURCE%/*}/../../utils/common.sh" +source "${BASH_SOURCE%/*}/../../utils/zombienet.sh" + +logs_dir=$TEST_DIR/logs +helper_script="${BASH_SOURCE%/*}/helper.sh" + +rococo_def=$POLKADOT_SDK_PATH/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml +start_zombienet $TEST_DIR $rococo_def rococo_dir rococo_pid +echo + +rococo_init_log=$logs_dir/rococo-init.log +echo -e "Setting up the rococo side of the bridge. Logs available at: $rococo_init_log\n" +$helper_script init-asset-hub-rococo-local >> $rococo_init_log 2>&1 +$helper_script init-bridge-hub-rococo-local >> $rococo_init_log 2>&1 +echo + +westend_def=$POLKADOT_SDK_PATH/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +start_zombienet $TEST_DIR $westend_def westend_dir westend_pid +echo + +westend_init_log=$logs_dir/westend-init.log +echo -e "Setting up the westend side of the bridge. Logs available at: $westend_init_log\n" +$helper_script init-asset-hub-westend-local >> $westend_init_log 2>&1 +$helper_script init-bridge-hub-westend-local >> $westend_init_log 2>&1 +echo + +relay_log=$logs_dir/relay.log +echo -e "Starting rococo-westend relay. Logs available at: $relay_log\n" +start_background_process "$helper_script run-relay" $relay_log relay_pid + +run_zndsl ${BASH_SOURCE%/*}/rococo.zndsl $rococo_dir +echo $rococo_dir > $TEST_DIR/rococo.env +echo + +run_zndsl ${BASH_SOURCE%/*}/westend.zndsl $westend_dir +echo $westend_dir > $TEST_DIR/westend.env +echo + +wait -n $rococo_pid $westend_pid $relay_pid +kill -9 -$$ diff --git a/bridges/zombienet/environments/rococo-westend/westend.zndsl b/bridges/zombienet/environments/rococo-westend/westend.zndsl new file mode 100644 index 000000000000..1d19b73adbb4 --- /dev/null +++ b/bridges/zombienet/environments/rococo-westend/westend.zndsl @@ -0,0 +1,9 @@ +Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back +Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +Creds: config + +# step 0: ensure that initialization has completed +asset-hub-westend-collator1: js-script ../../helpers/wait-hrmp-channel-opened.js with "1002" within 600 seconds + +# step 1: relay is already started - let's wait until with-Rococo GRANPDA pallet is initialized at Westend +bridge-hub-westend-collator1: js-script ../../helpers/best-finalized-header-at-bridged-chain.js with "Rococo,0" within 400 seconds diff --git a/bridges/zombienet/run-new-test.sh b/bridges/zombienet/run-new-test.sh new file mode 100755 index 000000000000..5ce84d5cace6 --- /dev/null +++ b/bridges/zombienet/run-new-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +trap "trap - SIGTERM && kill -9 -$$" SIGINT SIGTERM EXIT + +export POLKADOT_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot +export POLKADOT_PARACHAIN_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot-parachain +export ZOMBIENET_BINARY=~/local_bridge_testing/bin/zombienet-linux-x64 +export SUBSTRATE_RELAY_BINARY=~/local_bridge_testing/bin/substrate-relay + +export TEST_DIR=`mktemp -d /tmp/bridges-tests-run-XXXXX` +echo -e "Test folder: $TEST_DIR\n" + +test=$1 +${BASH_SOURCE%/*}/tests/$test/run.sh diff --git a/bridges/zombienet/tests/0001-asset-transfer/roc-reaches-westend.zndsl b/bridges/zombienet/tests/0001-asset-transfer/roc-reaches-westend.zndsl new file mode 100644 index 000000000000..c7fb73a88c0d --- /dev/null +++ b/bridges/zombienet/tests/0001-asset-transfer/roc-reaches-westend.zndsl @@ -0,0 +1,12 @@ +Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back +Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +Creds: config + +# send ROC to //Alice from Rococo AH to Westend AH +asset-hub-westend-collator1: run ../../environments/rococo-westend/helper.sh with "reserve-transfer-assets-from-asset-hub-rococo-local" within 120 seconds + +# check that //Alice received the ROC on Westend AH +asset-hub-westend-collator1: js-script ../../helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Rococo" within 300 seconds + +# check that the relayer //Charlie is rewarded by Westend AH +bridge-hub-westend-collator1: js-script ../../helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x6268726F,ThisChain,0" within 30 seconds diff --git a/bridges/zombienet/tests/0001-asset-transfer/run.sh b/bridges/zombienet/tests/0001-asset-transfer/run.sh new file mode 100755 index 000000000000..9056c0c6fe8c --- /dev/null +++ b/bridges/zombienet/tests/0001-asset-transfer/run.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +source "${BASH_SOURCE%/*}/../../utils/common.sh" +source "${BASH_SOURCE%/*}/../../utils/zombienet.sh" + +${BASH_SOURCE%/*}/../../environments/rococo-westend/spawn.sh & + +ensure_file $TEST_DIR/rococo.env 300 +rococo_dir=`cat $TEST_DIR/rococo.env` +echo + +ensure_file $TEST_DIR/westend.env 180 +westend_dir=`cat $TEST_DIR/westend.env` +echo + +run_zndsl ${BASH_SOURCE%/*}/roc-reaches-westend.zndsl $westend_dir +run_zndsl ${BASH_SOURCE%/*}/wnd-reaches-rococo.zndsl $rococo_dir + +run_zndsl ${BASH_SOURCE%/*}/wroc-reaches-rococo.zndsl $rococo_dir +run_zndsl ${BASH_SOURCE%/*}/wwnd-reaches-westend.zndsl $westend_dir diff --git a/bridges/zombienet/tests/0001-asset-transfer/wnd-reaches-rococo.zndsl b/bridges/zombienet/tests/0001-asset-transfer/wnd-reaches-rococo.zndsl new file mode 100644 index 000000000000..91ce8e5cbff9 --- /dev/null +++ b/bridges/zombienet/tests/0001-asset-transfer/wnd-reaches-rococo.zndsl @@ -0,0 +1,12 @@ +Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back +Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml +Creds: config + +# send WND to //Alice from Westend AH to Rococo AH +asset-hub-rococo-collator1: run ../../environments/rococo-westend/helper.sh with "reserve-transfer-assets-from-asset-hub-westend-local" within 120 seconds + +# check that //Alice received the WND on Rococo AH +asset-hub-rococo-collator1: js-script ../../helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Westend" within 300 seconds + +# check that the relayer //Charlie is rewarded by Rococo AH +bridge-hub-rococo-collator1: js-script ../../helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x62687764,ThisChain,0" within 30 seconds diff --git a/bridges/zombienet/tests/0001-asset-transfer/wroc-reaches-rococo.zndsl b/bridges/zombienet/tests/0001-asset-transfer/wroc-reaches-rococo.zndsl new file mode 100644 index 000000000000..7fbdecadeaef --- /dev/null +++ b/bridges/zombienet/tests/0001-asset-transfer/wroc-reaches-rococo.zndsl @@ -0,0 +1,10 @@ +Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back +Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +Creds: config + +# send wROC back to Alice from Westend AH to Rococo AH +asset-hub-rococo-collator1: run ../../environments/rococo-westend/helper.sh with "withdraw-reserve-assets-from-asset-hub-westend-local" within 120 seconds + +# check that //Alice received the wROC on Rococo AH +# (we wait until //Alice account increases here - there are no other transactions that may increase it) +asset-hub-rococo-collator1: js-script ../../helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds diff --git a/bridges/zombienet/tests/0001-asset-transfer/wwnd-reaches-westend.zndsl b/bridges/zombienet/tests/0001-asset-transfer/wwnd-reaches-westend.zndsl new file mode 100644 index 000000000000..662e88752688 --- /dev/null +++ b/bridges/zombienet/tests/0001-asset-transfer/wwnd-reaches-westend.zndsl @@ -0,0 +1,10 @@ +Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back +Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +Creds: config + +# send wWND back to Alice from Rococo AH to Westend AH +asset-hub-westend-collator1: run ../../environments/rococo-westend/helper.sh with "withdraw-reserve-assets-from-asset-hub-rococo-local" within 120 seconds + +# check that //Alice received the wWND on Westend AH +# (we wait until //Alice account increases here - there are no other transactions that may increase it) +asset-hub-westend-collator1: js-script ../../helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds diff --git a/bridges/zombienet/utils/common.sh b/bridges/zombienet/utils/common.sh new file mode 100644 index 000000000000..bc2a0344d4cd --- /dev/null +++ b/bridges/zombienet/utils/common.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +function start_background_process() { + local command=$1 + local log_file=$2 + local __pid=$3 + + $command > $log_file 2>&1 & + eval $__pid="'$!'" +} + +function wait_for_file() { + local file=$1 + local timeout=$2 + local __found=$3 + + local time=0 + until [ -e $file ]; do + if (( time++ >= timeout )) then + echo "Timeout waiting for file $file: $timeout seconds" + eval $__found=0 + return + fi + sleep 1 + done + + echo "File $file found after $time seconds" + eval $__found=1 +} + +function ensure_file() { + local file=$1 + local timeout=$2 + + wait_for_file $file $timeout file_found + if [ $file_found != 1 ]; then + exit 1 + fi +} diff --git a/bridges/zombienet/utils/zombienet.sh b/bridges/zombienet/utils/zombienet.sh new file mode 100644 index 000000000000..09d9f8fe992f --- /dev/null +++ b/bridges/zombienet/utils/zombienet.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +source "${BASH_SOURCE%/*}/common.sh" + +function start_zombienet() { + local test_dir=$1 + local definition_path=$2 + local __zombienet_dir=$3 + local __zombienet_pid=$4 + + local zombienet_name=`basename $definition_path .toml` + local zombienet_dir=$test_dir/$zombienet_name + eval $__zombienet_dir="'$zombienet_dir'" + mkdir -p $zombienet_dir + rm -rf $zombienet_dir + + local logs_dir=$test_dir/logs + mkdir -p $logs_dir + local zombienet_log=$logs_dir/$zombienet_name.log + + echo "Starting $zombienet_name zombienet. Logs available at: $zombienet_log" + start_background_process \ + "$ZOMBIENET_BINARY spawn --dir $zombienet_dir --provider native $definition_path" \ + "$zombienet_log" zombienet_pid + + ensure_file "$zombienet_dir/zombie.json" 180 + echo "$zombienet_name zombienet started successfully" + + eval $__zombienet_pid="'$zombienet_pid'" +} + +function run_zndsl() { + local zndsl_file=$1 + local zombienet_dir=$2 + + echo "Running $zndsl_file." + $ZOMBIENET_BINARY test --dir $zombienet_dir --provider native $zndsl_file $zombienet_dir/zombie.json + echo +} diff --git a/cumulus/scripts/bridges_rococo_westend.sh b/cumulus/scripts/bridges_rococo_westend.sh index 3b6f8e892858..7bde5ede77fd 100755 --- a/cumulus/scripts/bridges_rococo_westend.sh +++ b/cumulus/scripts/bridges_rococo_westend.sh @@ -185,8 +185,8 @@ function run_relay() { case "$1" in run-relay) - init_ro_wnd init_wnd_ro + init_ro_wnd run_relay ;; init-asset-hub-rococo-local) From 121b69e3f8489e46784fded774052f49c783b646 Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Fri, 9 Feb 2024 10:25:37 +0100 Subject: [PATCH 5/7] Address CR comments --- .../rococo-westend/rococo-init.zndsl | 8 ++++ .../environments/rococo-westend/rococo.zndsl | 5 +- .../environments/rococo-westend/spawn.sh | 47 ++++++++++++++----- .../rococo-westend/westend-init.zndsl | 7 +++ .../environments/rococo-westend/westend.zndsl | 5 +- bridges/zombienet/run-new-test.sh | 12 +++-- .../tests/0001-asset-transfer/run.sh | 7 +-- bridges/zombienet/utils/common.sh | 26 ++++++---- bridges/zombienet/utils/zombienet.sh | 2 +- 9 files changed, 83 insertions(+), 36 deletions(-) create mode 100644 bridges/zombienet/environments/rococo-westend/rococo-init.zndsl create mode 100644 bridges/zombienet/environments/rococo-westend/westend-init.zndsl diff --git a/bridges/zombienet/environments/rococo-westend/rococo-init.zndsl b/bridges/zombienet/environments/rococo-westend/rococo-init.zndsl new file mode 100644 index 000000000000..ae3e3e7cb67f --- /dev/null +++ b/bridges/zombienet/environments/rococo-westend/rococo-init.zndsl @@ -0,0 +1,8 @@ +Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Hub and back +Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml +Creds: config + +# ensure that initialization has completed +asset-hub-rococo-collator1: js-script ../../helpers/wait-hrmp-channel-opened.js with "1013" within 300 seconds + + diff --git a/bridges/zombienet/environments/rococo-westend/rococo.zndsl b/bridges/zombienet/environments/rococo-westend/rococo.zndsl index 34993eeacd9d..7ecb05ceefa3 100644 --- a/bridges/zombienet/environments/rococo-westend/rococo.zndsl +++ b/bridges/zombienet/environments/rococo-westend/rococo.zndsl @@ -2,9 +2,6 @@ Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml Creds: config -# step 0: ensure that initialization has completed -asset-hub-rococo-collator1: js-script ../../helpers/wait-hrmp-channel-opened.js with "1013" within 600 seconds - -# step 1: relay is already started - let's wait until with-Westend GRANPDA pallet is initialized at Rococo +# relay is already started - let's wait until with-Westend GRANPDA pallet is initialized at Rococo bridge-hub-rococo-collator1: js-script ../../helpers/best-finalized-header-at-bridged-chain.js with "Westend,0" within 400 seconds diff --git a/bridges/zombienet/environments/rococo-westend/spawn.sh b/bridges/zombienet/environments/rococo-westend/spawn.sh index 54dd0be2c6ff..dbdc58d5fa1b 100755 --- a/bridges/zombienet/environments/rococo-westend/spawn.sh +++ b/bridges/zombienet/environments/rococo-westend/spawn.sh @@ -7,6 +7,19 @@ trap "trap - SIGTERM && kill -9 -$$" SIGINT SIGTERM EXIT source "${BASH_SOURCE%/*}/../../utils/common.sh" source "${BASH_SOURCE%/*}/../../utils/zombienet.sh" +# whether to init the chains (open HRMP channels, set XCM version, create reserve assets, etc) +init=0 +while [ $# -ne 0 ] +do + arg="$1" + case "$arg" in + --init) + init=1 + ;; + esac + shift +done + logs_dir=$TEST_DIR/logs helper_script="${BASH_SOURCE%/*}/helper.sh" @@ -14,21 +27,33 @@ rococo_def=$POLKADOT_SDK_PATH/cumulus/zombienet/bridge-hubs/bridge_hub_rococo_lo start_zombienet $TEST_DIR $rococo_def rococo_dir rococo_pid echo -rococo_init_log=$logs_dir/rococo-init.log -echo -e "Setting up the rococo side of the bridge. Logs available at: $rococo_init_log\n" -$helper_script init-asset-hub-rococo-local >> $rococo_init_log 2>&1 -$helper_script init-bridge-hub-rococo-local >> $rococo_init_log 2>&1 -echo - westend_def=$POLKADOT_SDK_PATH/cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml start_zombienet $TEST_DIR $westend_def westend_dir westend_pid echo -westend_init_log=$logs_dir/westend-init.log -echo -e "Setting up the westend side of the bridge. Logs available at: $westend_init_log\n" -$helper_script init-asset-hub-westend-local >> $westend_init_log 2>&1 -$helper_script init-bridge-hub-westend-local >> $westend_init_log 2>&1 -echo +if [[ $init -eq 1 ]]; then + rococo_init_log=$logs_dir/rococo-init.log + echo -e "Setting up the rococo side of the bridge. Logs available at: $rococo_init_log\n" + + westend_init_log=$logs_dir/westend-init.log + echo -e "Setting up the westend side of the bridge. Logs available at: $westend_init_log\n" + + $helper_script init-asset-hub-rococo-local >> $rococo_init_log 2>&1 & + rococo_init_pid=$! + $helper_script init-asset-hub-westend-local >> $westend_init_log 2>&1 & + westend_init_pid=$! + wait -n $rococo_init_pid $westend_init_pid + + + $helper_script init-bridge-hub-rococo-local >> $rococo_init_log 2>&1 & + rococo_init_pid=$! + $helper_script init-bridge-hub-westend-local >> $westend_init_log 2>&1 & + westend_init_pid=$! + wait -n $rococo_init_pid $westend_init_pid + + run_zndsl ${BASH_SOURCE%/*}/rococo-init.zndsl $rococo_dir + run_zndsl ${BASH_SOURCE%/*}/westend-init.zndsl $westend_dir +fi relay_log=$logs_dir/relay.log echo -e "Starting rococo-westend relay. Logs available at: $relay_log\n" diff --git a/bridges/zombienet/environments/rococo-westend/westend-init.zndsl b/bridges/zombienet/environments/rococo-westend/westend-init.zndsl new file mode 100644 index 000000000000..3b3e4bd91e22 --- /dev/null +++ b/bridges/zombienet/environments/rococo-westend/westend-init.zndsl @@ -0,0 +1,7 @@ +Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Hub and back +Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml +Creds: config + +# ensure that initialization has completed +asset-hub-westend-collator1: js-script ../../helpers/wait-hrmp-channel-opened.js with "1002" within 600 seconds + diff --git a/bridges/zombienet/environments/rococo-westend/westend.zndsl b/bridges/zombienet/environments/rococo-westend/westend.zndsl index 1d19b73adbb4..b3864d12a0e3 100644 --- a/bridges/zombienet/environments/rococo-westend/westend.zndsl +++ b/bridges/zombienet/environments/rococo-westend/westend.zndsl @@ -2,8 +2,5 @@ Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset Network: ../../../../cumulus/zombienet/bridge-hubs/bridge_hub_westend_local_network.toml Creds: config -# step 0: ensure that initialization has completed -asset-hub-westend-collator1: js-script ../../helpers/wait-hrmp-channel-opened.js with "1002" within 600 seconds - -# step 1: relay is already started - let's wait until with-Rococo GRANPDA pallet is initialized at Westend +# relay is already started - let's wait until with-Rococo GRANPDA pallet is initialized at Westend bridge-hub-westend-collator1: js-script ../../helpers/best-finalized-header-at-bridged-chain.js with "Rococo,0" within 400 seconds diff --git a/bridges/zombienet/run-new-test.sh b/bridges/zombienet/run-new-test.sh index 5ce84d5cace6..5ac70378238d 100755 --- a/bridges/zombienet/run-new-test.sh +++ b/bridges/zombienet/run-new-test.sh @@ -4,13 +4,19 @@ set -e trap "trap - SIGTERM && kill -9 -$$" SIGINT SIGTERM EXIT +test=$1 + +export POLKADOT_SDK_PATH=`realpath ${BASH_SOURCE%/*}/../..` + export POLKADOT_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot export POLKADOT_PARACHAIN_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot-parachain -export ZOMBIENET_BINARY=~/local_bridge_testing/bin/zombienet-linux-x64 -export SUBSTRATE_RELAY_BINARY=~/local_bridge_testing/bin/substrate-relay + +export ZOMBIENET_BINARY=/home/serban/scripts/zombienet-linux-x64 +export SUBSTRATE_RELAY_BINARY=/home/serban/workplace/sources/parity-bridges-common/target/release/substrate-relay export TEST_DIR=`mktemp -d /tmp/bridges-tests-run-XXXXX` echo -e "Test folder: $TEST_DIR\n" -test=$1 ${BASH_SOURCE%/*}/tests/$test/run.sh + +kill -9 -$$ \ No newline at end of file diff --git a/bridges/zombienet/tests/0001-asset-transfer/run.sh b/bridges/zombienet/tests/0001-asset-transfer/run.sh index 9056c0c6fe8c..9233435dc1da 100755 --- a/bridges/zombienet/tests/0001-asset-transfer/run.sh +++ b/bridges/zombienet/tests/0001-asset-transfer/run.sh @@ -5,13 +5,14 @@ set -e source "${BASH_SOURCE%/*}/../../utils/common.sh" source "${BASH_SOURCE%/*}/../../utils/zombienet.sh" -${BASH_SOURCE%/*}/../../environments/rococo-westend/spawn.sh & +${BASH_SOURCE%/*}/../../environments/rococo-westend/spawn.sh --init & +env_pid=$! -ensure_file $TEST_DIR/rococo.env 300 +ensure_process_file $env_pid $TEST_DIR/rococo.env 300 rococo_dir=`cat $TEST_DIR/rococo.env` echo -ensure_file $TEST_DIR/westend.env 180 +ensure_process_file $env_pid $TEST_DIR/westend.env 180 westend_dir=`cat $TEST_DIR/westend.env` echo diff --git a/bridges/zombienet/utils/common.sh b/bridges/zombienet/utils/common.sh index bc2a0344d4cd..06f41320be13 100644 --- a/bridges/zombienet/utils/common.sh +++ b/bridges/zombienet/utils/common.sh @@ -9,14 +9,19 @@ function start_background_process() { eval $__pid="'$!'" } -function wait_for_file() { - local file=$1 - local timeout=$2 - local __found=$3 +function wait_for_process_file() { + local pid=$1 + local file=$2 + local timeout=$3 + local __found=$4 local time=0 until [ -e $file ]; do - if (( time++ >= timeout )) then + if ! kill -0 $pid; then + echo "Process finished unsuccessfully" + return + fi + if (( time++ >= timeout )); then echo "Timeout waiting for file $file: $timeout seconds" eval $__found=0 return @@ -28,12 +33,13 @@ function wait_for_file() { eval $__found=1 } -function ensure_file() { - local file=$1 - local timeout=$2 +function ensure_process_file() { + local pid=$1 + local file=$2 + local timeout=$3 - wait_for_file $file $timeout file_found - if [ $file_found != 1 ]; then + wait_for_process_file $pid $file $timeout file_found + if [ "$file_found" != "1" ]; then exit 1 fi } diff --git a/bridges/zombienet/utils/zombienet.sh b/bridges/zombienet/utils/zombienet.sh index 09d9f8fe992f..bbcd1a306202 100644 --- a/bridges/zombienet/utils/zombienet.sh +++ b/bridges/zombienet/utils/zombienet.sh @@ -23,7 +23,7 @@ function start_zombienet() { "$ZOMBIENET_BINARY spawn --dir $zombienet_dir --provider native $definition_path" \ "$zombienet_log" zombienet_pid - ensure_file "$zombienet_dir/zombie.json" 180 + ensure_process_file $zombienet_pid "$zombienet_dir/zombie.json" 180 echo "$zombienet_name zombienet started successfully" eval $__zombienet_pid="'$zombienet_pid'" From 363b22e32ee2acc04bee3164a2db3764895521d9 Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Fri, 9 Feb 2024 12:15:55 +0100 Subject: [PATCH 6/7] Fix paths --- bridges/zombienet/run-new-test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/zombienet/run-new-test.sh b/bridges/zombienet/run-new-test.sh index 5ac70378238d..4f4c9ecd3661 100755 --- a/bridges/zombienet/run-new-test.sh +++ b/bridges/zombienet/run-new-test.sh @@ -11,8 +11,8 @@ export POLKADOT_SDK_PATH=`realpath ${BASH_SOURCE%/*}/../..` export POLKADOT_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot export POLKADOT_PARACHAIN_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot-parachain -export ZOMBIENET_BINARY=/home/serban/scripts/zombienet-linux-x64 -export SUBSTRATE_RELAY_BINARY=/home/serban/workplace/sources/parity-bridges-common/target/release/substrate-relay +export ZOMBIENET_BINARY=~/local_bridge_testing/bin/zombienet-linux-x64 +export SUBSTRATE_RELAY_BINARY=~/local_bridge_testing/bin/substrate-relay export TEST_DIR=`mktemp -d /tmp/bridges-tests-run-XXXXX` echo -e "Test folder: $TEST_DIR\n" From 851d18c48366ff9921120308f4391f613e2603bf Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Fri, 9 Feb 2024 14:54:52 +0100 Subject: [PATCH 7/7] prepare CI run --- bridges/zombienet/run-new-test.sh | 39 +++++++++++++++---- .../tests/0001-asset-transfer/run.sh | 2 +- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/bridges/zombienet/run-new-test.sh b/bridges/zombienet/run-new-test.sh index 4f4c9ecd3661..3bfcb6d83e9a 100755 --- a/bridges/zombienet/run-new-test.sh +++ b/bridges/zombienet/run-new-test.sh @@ -2,21 +2,46 @@ set -e -trap "trap - SIGTERM && kill -9 -$$" SIGINT SIGTERM EXIT - test=$1 +shift + +# whether to use paths for zombienet+bridges tests container or for local testing +ZOMBIENET_DOCKER_PATHS=0 +while [ $# -ne 0 ] +do + arg="$1" + case "$arg" in + --docker) + ZOMBIENET_DOCKER_PATHS=1 + ;; + esac + shift +done export POLKADOT_SDK_PATH=`realpath ${BASH_SOURCE%/*}/../..` -export POLKADOT_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot -export POLKADOT_PARACHAIN_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot-parachain +# set path to binaries +if [ "$ZOMBIENET_DOCKER_PATHS" -eq 1 ]; then + # otherwise zombienet uses some hardcoded paths + unset RUN_IN_CONTAINER + unset ZOMBIENET_IMAGE + + export POLKADOT_BINARY=/usr/local/bin/polkadot + export POLKADOT_PARACHAIN_BINARY=/usr/local/bin/polkadot-parachain + + export ZOMBIENET_BINARY=/usr/local/bin/zombie + export SUBSTRATE_RELAY_BINARY=/usr/local/bin/substrate-relay +else + export POLKADOT_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot + export POLKADOT_PARACHAIN_BINARY=$POLKADOT_SDK_PATH/target/release/polkadot-parachain -export ZOMBIENET_BINARY=~/local_bridge_testing/bin/zombienet-linux-x64 -export SUBSTRATE_RELAY_BINARY=~/local_bridge_testing/bin/substrate-relay + export ZOMBIENET_BINARY=~/local_bridge_testing/bin/zombienet-linux-x64 + export SUBSTRATE_RELAY_BINARY=~/local_bridge_testing/bin/substrate-relay +fi export TEST_DIR=`mktemp -d /tmp/bridges-tests-run-XXXXX` echo -e "Test folder: $TEST_DIR\n" ${BASH_SOURCE%/*}/tests/$test/run.sh -kill -9 -$$ \ No newline at end of file +kill -9 -$$ || echo "Environment already teared down" \ No newline at end of file diff --git a/bridges/zombienet/tests/0001-asset-transfer/run.sh b/bridges/zombienet/tests/0001-asset-transfer/run.sh index 9233435dc1da..07951a0e321a 100755 --- a/bridges/zombienet/tests/0001-asset-transfer/run.sh +++ b/bridges/zombienet/tests/0001-asset-transfer/run.sh @@ -8,7 +8,7 @@ source "${BASH_SOURCE%/*}/../../utils/zombienet.sh" ${BASH_SOURCE%/*}/../../environments/rococo-westend/spawn.sh --init & env_pid=$! -ensure_process_file $env_pid $TEST_DIR/rococo.env 300 +ensure_process_file $env_pid $TEST_DIR/rococo.env 400 rococo_dir=`cat $TEST_DIR/rococo.env` echo