Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions integration-tests/bridges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ command.
- Copy the binary to `~/local_bridge_testing/bin/chain-spec-generator-polkadot`.
- check/change the `POLKADOT_BINARY` and `POLKADOT_PARACHAIN_BINARY` paths (and ensure that the nearby variables
have correct values) in the `./run-test.sh`.
- `./run-test.sh` needs polkadot-sdk testing framework, so:
- do nothing and it will checkout automatically `master` branch
- or specify `FRAMEWORK_REPO_TAG_OR_COMMIT` variable for specific tag/commit (useful for CI)
- or specify `FRAMEWORK_REPO_PATH` to the polkadot-sdk directory

After that, you can run `./run-tests.sh <test_name>` command.
E.g. `./run-test.sh 0001-polkadot-kusama-asset-transfer`.
After that, you can run `./run-tests.sh <test_name>` command, for example:
```
./run-test.sh 0001-polkadot-kusama-asset-transfer
or
E.g. `FRAMEWORK_REPO_PATH=/home/username/polkadot-sdk ./run-test.sh 0001-polkadot-kusama-asset-transfer`.
FRAMEWORK_REPO_PATH=/home/username/polkadot-sdk ./run-test.sh 0001-polkadot-kusama-asset-transfer
or
FRAMEWORK_REPO_TAG_OR_COMMIT=7d875655ea38b734d6f1a3a79aef227e846f227c ./run-test.sh 0001-polkadot-kusama-asset-transfer
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ source "$FRAMEWORK_PATH/utils/bridges.sh"
#
#
# println!(
# "GLOBAL_CONSENSUS_POLKADOT_SOVEREIGN_ACCOUNT=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# GlobalConsensusConvertsFor::<UniversalLocationAHK, [u8; 32]>::convert_location(
# &Location { parents: 2, interior: [GlobalConsensus(Polkadot)].into() }
# )
# .unwrap()
# )
# .to_ss58check_with_version(2_u16.into())
# );
#
# println!(
# "ASSET_HUB_KUSAMA_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_KUSAMA=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# SiblingParachainConvertsVia::<Sibling, [u8; 32]>::convert_location(&Location {
Expand All @@ -43,16 +32,6 @@ source "$FRAMEWORK_PATH/utils/bridges.sh"
#
#
# println!(
# "GLOBAL_CONSENSUS_KUSAMA_SOVEREIGN_ACCOUNT=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# GlobalConsensusConvertsFor::<UniversalLocationAHP, [u8; 32]>::convert_location(
# &Location { parents: 2, interior: [GlobalConsensus(Kusama)].into() }
# )
# .unwrap()
# )
# .to_ss58check_with_version(0_u16.into())
# );
# println!(
# "ASSET_HUB_POLKADOT_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_POLKADOT=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# SiblingParachainConvertsVia::<Sibling, [u8; 32]>::convert_location(&Location {
Expand All @@ -64,10 +43,10 @@ source "$FRAMEWORK_PATH/utils/bridges.sh"
# .to_ss58check_with_version(0_u16.into())
# );
#}
GLOBAL_CONSENSUS_POLKADOT_SOVEREIGN_ACCOUNT="FxqimVubBRPqJ8kTwb3wL7G4q645hEkBEnXPyttLsTrFc5Q"
ASSET_HUB_KUSAMA_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_KUSAMA="FBeL7EFTDeHnuViqaUHUXvhhUusN5FawDmHgfvzF97DXFr3"
GLOBAL_CONSENSUS_KUSAMA_SOVEREIGN_ACCOUNT="14zcUAhP5XypiFQWA3b1AnGKrhZqR4XWUo4deWkwuN5y983G"
ASSET_HUB_POLKADOT_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_POLKADOT="13cKp89SgdtqUngo2WiEijPrQWdHFhzYZLf2TJePKRvExk7o"
BOB_SOVEREIGN_ACCOUNT_AT_KUSAMA="FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP"
BOB_SOVEREIGN_ACCOUNT_AT_POLKADOT="14E5nqKAp3oAJcmzgZhUD2RcptBeUBScxKHgJKU4HPNcKVf3"

# Expected sovereign accounts for rewards on BridgeHubs.
#
Expand Down Expand Up @@ -133,12 +112,10 @@ ON_BRIDGE_HUB_KUSAMA_SOVEREIGN_ACCOUNT_FOR_LANE_00000001_bhpd_ThisChain="EoQBtnw
ON_BRIDGE_HUB_KUSAMA_SOVEREIGN_ACCOUNT_FOR_LANE_00000001_bhpd_BridgedChain="EoQBtnwp4jMtCEpV7CPsssT6bdDHuHZmf3aGXxHJiSA4Dz3"

LANE_ID="00000001"
XCM_VERSION=4
XCM_VERSION=5

AHK_DOT_ED=10000000
DOT=10000000000

AHP_KSM_ED=10000000
KSM=1000000000000

function init_polkadot_kusama() {
Expand Down Expand Up @@ -213,7 +190,7 @@ function run_parachains_relay() {
local relayer_path=$(ensure_relayer)

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-parachains polkadot-to-bridge-hub-kusama \
$relayer_path relay-parachains bridge-hub-polkadot-to-bridge-hub-kusama \
--only-free-headers \
--source-uri ws://localhost:9942 \
--source-version-mode Auto \
Expand All @@ -223,7 +200,7 @@ function run_parachains_relay() {
--target-transactions-mortality 4&

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-parachains kusama-to-bridge-hub-polkadot \
$relayer_path relay-parachains bridge-hub-kusama-to-bridge-hub-polkadot \
--only-free-headers \
--source-uri ws://localhost:9945 \
--source-version-mode Auto \
Expand Down Expand Up @@ -278,18 +255,8 @@ case "$1" in
run-messages-relay)
run_messages_relay
;;
init-asset-hub-polkadot-local)
init-polkadot-local)
ensure_polkadot_js_api
# create foreign assets for native Kusama token (governance call on Polkadot)
force_create_foreign_asset \
"ws://127.0.0.1:9942" \
"//Alice" \
1000 \
"ws://127.0.0.1:9910" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [ { "GlobalConsensus": "Kusama" } ] } }')" \
"$GLOBAL_CONSENSUS_KUSAMA_SOVEREIGN_ACCOUNT" \
$AHP_KSM_ED \
true
# HRMP
open_hrmp_channels \
"ws://127.0.0.1:9942" \
Expand All @@ -299,14 +266,40 @@ case "$1" in
"ws://127.0.0.1:9942" \
"//Alice" \
1002 1000 4 524288
# set XCM version of remote AssetHubKusama
# governance set XCM version of remote AssetHubKusama on AHP
force_xcm_version \
"ws://127.0.0.1:9942" \
"//Alice" \
1000 \
"ws://127.0.0.1:9910" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Kusama" }, { "Parachain": 1000 } ] } }')" \
$XCM_VERSION
# governance set XCM version of remote BridgeHubKusama on BHP
force_xcm_version \
"ws://127.0.0.1:9942" \
"//Alice" \
1002 \
"ws://127.0.0.1:8943" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Kusama" }, { "Parachain": 1002 } ] } }')" \
$XCM_VERSION
;;
init-asset-hub-polkadot-local)
ensure_polkadot_js_api
# create pool for DOT and wKSM
create_pool \
"ws://127.0.0.1:9910" \
"//Bob" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Kusama" }] } }')"
# Create liquidity in the pool
add_liquidity \
"ws://127.0.0.1:9910" \
"//Bob" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Kusama"}] } }')" \
100000000000 \
4000000000000 \
"$BOB_SOVEREIGN_ACCOUNT_AT_POLKADOT"
;;
init-bridge-hub-polkadot-local)
ensure_polkadot_js_api
Expand All @@ -328,27 +321,9 @@ case "$1" in
"//Alice" \
"$ON_BRIDGE_HUB_POLKADOT_SOVEREIGN_ACCOUNT_FOR_LANE_00000001_bhks_BridgedChain" \
$((25 * $DOT))
# set XCM version of remote BridgeHubKusama
force_xcm_version \
"ws://127.0.0.1:9942" \
"//Alice" \
1002 \
"ws://127.0.0.1:8943" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Kusama" }, { "Parachain": 1002 } ] } }')" \
$XCM_VERSION
;;
init-asset-hub-kusama-local)
init-kusama-local)
ensure_polkadot_js_api
# create foreign assets for native Polkadot token (governance call on Kusama)
force_create_foreign_asset \
"ws://127.0.0.1:9945" \
"//Alice" \
1000 \
"ws://127.0.0.1:9010" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [ { "GlobalConsensus": "Polkadot" } ] } }')" \
"$GLOBAL_CONSENSUS_POLKADOT_SOVEREIGN_ACCOUNT" \
$AHK_DOT_ED \
true
# HRMP
open_hrmp_channels \
"ws://127.0.0.1:9945" \
Expand All @@ -358,14 +333,40 @@ case "$1" in
"ws://127.0.0.1:9945" \
"//Alice" \
1002 1000 4 524288
# set XCM version of remote AssetHubPolkadot
# governance set XCM version of remote AssetHubPolkadot on AHK
force_xcm_version \
"ws://127.0.0.1:9945" \
"//Alice" \
1000 \
"ws://127.0.0.1:9010" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Polkadot" }, { "Parachain": 1000 } ] } }')" \
$XCM_VERSION
# governance set XCM version of remote BridgeHubPolkadot on BHK
force_xcm_version \
"ws://127.0.0.1:9945" \
"//Alice" \
1002 \
"ws://127.0.0.1:8945" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Polkadot" }, { "Parachain": 1002 } ] } }')" \
$XCM_VERSION
;;
init-asset-hub-kusama-local)
ensure_polkadot_js_api
# create pool for KSM and wDOT
create_pool \
"ws://127.0.0.1:9010" \
"//Bob" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Polkadot" }] } }')"
# Create liquidity in the pool
add_liquidity \
"ws://127.0.0.1:9010" \
"//Bob" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Polkadot"}] } }')" \
1000000000000 \
25000000000 \
"$BOB_SOVEREIGN_ACCOUNT_AT_KUSAMA"
;;
init-bridge-hub-kusama-local)
# SA of sibling asset hub pays for the execution
Expand All @@ -386,14 +387,6 @@ case "$1" in
"//Alice" \
"$ON_BRIDGE_HUB_KUSAMA_SOVEREIGN_ACCOUNT_FOR_LANE_00000001_bhpd_BridgedChain" \
$((25 * $KSM))
# set XCM version of remote BridgeHubPolkadot
force_xcm_version \
"ws://127.0.0.1:9945" \
"//Alice" \
1002 \
"ws://127.0.0.1:8945" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Polkadot" }, { "Parachain": 1002 } ] } }')" \
$XCM_VERSION
;;
reserve-transfer-assets-from-asset-hub-polkadot-local)
amount=$2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Network: ./bridge_hub_kusama_local_network.toml
Creds: config

# relay is already started - let's wait until with-Rococo GRANPDA pallet is initialized at Polkadot
# relay is already started - let's wait until with-Polkadot GRANPDA pallet is initialized at Kusama
bridge-hub-kusama-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/best-finalized-header-at-bridged-chain.js with "Polkadot,0" within 400 seconds
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Network: ./bridge_hub_polkadot_local_network.toml
Creds: config

# relay is already started - let's wait until with-Rococo GRANPDA pallet is initialized at Polkadot
# relay is already started - let's wait until with-Kusama GRANPDA pallet is initialized at Polkadot
bridge-hub-polkadot-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/best-finalized-header-at-bridged-chain.js with "Kusama,0" within 400 seconds
13 changes: 10 additions & 3 deletions integration-tests/bridges/environments/polkadot-kusama/spawn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ if [[ $init -eq 1 ]]; then
echo -e "Setting up the polkadot side of the bridge. Logs available at: $polkadot_init_log\n"
kusama_init_log=$logs_dir/kusama-init.log
echo -e "Setting up the kusama side of the bridge. Logs available at: $kusama_init_log\n"

$helper_script init-polkadot-local >> $polkadot_init_log 2>&1 &
polkadot_init_pid=$!
$helper_script init-kusama-local >> $kusama_init_log 2>&1 &
kusama_init_pid=$!
wait -n $polkadot_init_pid $kusama_init_pid

run_zndsl ${BASH_SOURCE%/*}/polkadot-init.zndsl $polkadot_dir
run_zndsl ${BASH_SOURCE%/*}/kusama-init.zndsl $kusama_dir

$helper_script init-asset-hub-polkadot-local >> $polkadot_init_log 2>&1 &
polkadot_init_pid=$!
$helper_script init-asset-hub-kusama-local >> $kusama_init_log 2>&1 &
Expand All @@ -50,9 +60,6 @@ if [[ $init -eq 1 ]]; then
$helper_script init-bridge-hub-kusama-local >> $kusama_init_log 2>&1 &
kusama_init_pid=$!
wait -n $polkadot_init_pid $kusama_init_pid

run_zndsl ${BASH_SOURCE%/*}/polkadot-init.zndsl $polkadot_dir
run_zndsl ${BASH_SOURCE%/*}/kusama-init.zndsl $kusama_dir
fi

if [[ $start_relayer -eq 1 ]]; then
Expand Down
9 changes: 7 additions & 2 deletions integration-tests/bridges/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ if [ -z "$FRAMEWORK_REPO_PATH" ]; then
https://github.com/paritytech/polkadot-sdk.git $framework_repo_path
pushd $framework_repo_path
git sparse-checkout set --no-cone bridges/testing/framework
git fetch --tags
git checkout polkadot-stable2409
# Checkout specified tag-or-commit, if not specified then master
if [ -n "$FRAMEWORK_REPO_TAG_OR_COMMIT" ]; then
git fetch --tags
git checkout $FRAMEWORK_REPO_TAG_OR_COMMIT
else
git checkout master
fi
popd
else
framework_repo_path=$FRAMEWORK_REPO_PATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ asset-hub-polkadot-collator-1: run {{ENV_PATH}}/helper.sh with "reserve-transfer
asset-hub-polkadot-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with '{ "accountAddress": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", "expectedAssetBalance": 4800000000000, "expectedAssetId": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Kusama" }] }}}' within 300 seconds

# check that the relayer //Ferdie is rewarded by Polkadot AH
bridge-hub-polkadot-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with '{ "relayerAccountAddress": "5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL", "reward": { "laneId": "0x00000001", "bridgedChainId": "0x62686b73", "owner": "ThisChain" }, "expectedRelayerReward": 1}' within 30 seconds
bridge-hub-polkadot-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with '{ "relayerAccountAddress": "5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL", "reward": { "PolkadotKusamaBridge": { "laneId": "0x00000001", "bridgedChainId": "0x62686b73", "owner": "ThisChain" }}, "expectedRelayerReward": 1}' within 30 seconds
Loading
Loading