Skip to content

Commit

Permalink
Fixed bridges zombienet tests because of removed NetworkId::Rococo/We…
Browse files Browse the repository at this point in the history
…stend from xcm::v5 (#6465)

Closes: #6449
  • Loading branch information
bkontur authored Nov 13, 2024
1 parent 6b84431 commit bff395f
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 68 deletions.
121 changes: 65 additions & 56 deletions bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,52 @@ source "$FRAMEWORK_PATH/utils/bridges.sh"
#
# Generated by:
#
# #[test]
# fn generate_sovereign_accounts() {
# use sp_core::crypto::Ss58Codec;
# use polkadot_parachain_primitives::primitives::Sibling;
##[test]
#fn generate_sovereign_accounts() {
# use polkadot_parachain_primitives::primitives::Sibling;
# use sp_core::crypto::Ss58Codec;
# use staging_xcm_builder::{GlobalConsensusConvertsFor, SiblingParachainConvertsVia};
# use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH};
# use xcm_executor::traits::ConvertLocation;
#
# parameter_types! {
# pub UniversalLocationAHR: InteriorMultiLocation = X2(GlobalConsensus(Rococo), Parachain(1000));
# pub UniversalLocationAHW: InteriorMultiLocation = X2(GlobalConsensus(Westend), Parachain(1000));
# }
# const Rococo: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
# const Westend: NetworkId = NetworkId::ByGenesis(WESTEND_GENESIS_HASH);
# frame_support::parameter_types! {
# pub UniversalLocationAHR: InteriorLocation = [GlobalConsensus(Rococo), Parachain(1000)].into();
# pub UniversalLocationAHW: InteriorLocation = [GlobalConsensus(Westend), Parachain(1000)].into();
# }
#
# // SS58=42
# println!("GLOBAL_CONSENSUS_ROCOCO_SOVEREIGN_ACCOUNT=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# GlobalConsensusConvertsFor::<UniversalLocationAHW, [u8; 32]>::convert_location(
# &MultiLocation { parents: 2, interior: X1(GlobalConsensus(Rococo)) }).unwrap()
# ).to_ss58check_with_version(42_u16.into())
# );
# println!("ASSET_HUB_WESTEND_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_WESTEND=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# SiblingParachainConvertsVia::<Sibling, [u8; 32]>::convert_location(
# &MultiLocation { parents: 1, interior: X1(Parachain(1000)) }).unwrap()
# ).to_ss58check_with_version(42_u16.into())
# );
# // SS58=42
# println!("GLOBAL_CONSENSUS_ROCOCO_SOVEREIGN_ACCOUNT=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# GlobalConsensusConvertsFor::<UniversalLocationAHW, [u8; 32]>::convert_location(
# &Location { parents: 2, interior: GlobalConsensus(Rococo).into() }).unwrap()
# ).to_ss58check_with_version(42_u16.into())
# );
# println!("ASSET_HUB_WESTEND_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_WESTEND=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# SiblingParachainConvertsVia::<Sibling, [u8; 32]>::convert_location(
# &Location { parents: 1, interior: Parachain(1000).into() }).unwrap()
# ).to_ss58check_with_version(42_u16.into())
# );
#
# // SS58=42
# println!("GLOBAL_CONSENSUS_WESTEND_SOVEREIGN_ACCOUNT=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# GlobalConsensusConvertsFor::<UniversalLocationAHR, [u8; 32]>::convert_location(
# &MultiLocation { parents: 2, interior: X1(GlobalConsensus(Westend)) }).unwrap()
# ).to_ss58check_with_version(42_u16.into())
# );
# println!("ASSET_HUB_ROCOCO_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_ROCOCO=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# SiblingParachainConvertsVia::<Sibling, [u8; 32]>::convert_location(
# &MultiLocation { parents: 1, interior: X1(Parachain(1000)) }).unwrap()
# ).to_ss58check_with_version(42_u16.into())
# );
# }
GLOBAL_CONSENSUS_ROCOCO_SOVEREIGN_ACCOUNT="5GxRGwT8bU1JeBPTUXc7LEjZMxNrK8MyL2NJnkWFQJTQ4sii"
# // SS58=42
# println!("GLOBAL_CONSENSUS_WESTEND_SOVEREIGN_ACCOUNT=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# GlobalConsensusConvertsFor::<UniversalLocationAHR, [u8; 32]>::convert_location(
# &Location { parents: 2, interior: GlobalConsensus(Westend).into() }).unwrap()
# ).to_ss58check_with_version(42_u16.into())
# );
# println!("ASSET_HUB_ROCOCO_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_ROCOCO=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# SiblingParachainConvertsVia::<Sibling, [u8; 32]>::convert_location(
# &Location { parents: 1, interior: Parachain(1000).into() }).unwrap()
# ).to_ss58check_with_version(42_u16.into())
# );
#}
GLOBAL_CONSENSUS_ROCOCO_SOVEREIGN_ACCOUNT="5HmYPhRNAenHN6xnDLQDLZq71d4BgzPrdJ2sNZo8o1KXi9wr"
ASSET_HUB_WESTEND_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_WESTEND="5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV"
GLOBAL_CONSENSUS_WESTEND_SOVEREIGN_ACCOUNT="5He2Qdztyxxa4GoagY6q1jaiLMmKy1gXS7PdZkhfj8ZG9hk5"
GLOBAL_CONSENSUS_WESTEND_SOVEREIGN_ACCOUNT="5CtHyjQE8fbPaQeBrwaGph6qsSEtnMFBAZcAkxwnEfQkkYAq"
ASSET_HUB_ROCOCO_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_ROCOCO="5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV"

# Expected sovereign accounts for rewards on BridgeHubs.
Expand Down Expand Up @@ -115,7 +120,11 @@ ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_ThisChain="5EHnXa
ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_BridgedChain="5EHnXaT5Tnt3VGpEvc6jSgYwVToDGxLRMuYoZ8coo6GHyWbR"

LANE_ID="00000002"
XCM_VERSION=3
XCM_VERSION=5
# 6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e
ROCOCO_GENESIS_HASH=[100,8,222,119,55,197,156,35,136,144,83,58,242,88,150,162,194,6,8,216,179,128,187,1,2,154,203,57,39,129,6,62]
# e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e
WESTEND_GENESIS_HASH=[225,67,242,56,3,172,80,232,246,248,230,38,149,209,206,158,78,29,104,170,54,193,205,44,253,21,52,2,19,243,66,62]

function init_ro_wnd() {
local relayer_path=$(ensure_relayer)
Expand Down Expand Up @@ -270,7 +279,7 @@ case "$1" in
"//Alice" \
1000 \
"ws://127.0.0.1:9910" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Westend" }] } }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }')" \
"$GLOBAL_CONSENSUS_WESTEND_SOVEREIGN_ACCOUNT" \
10000000000 \
true
Expand All @@ -289,7 +298,7 @@ case "$1" in
"//Alice" \
1000 \
"ws://127.0.0.1:9910" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Westend" }, { "Parachain": 1000 } ] } }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1000 } ] } }')" \
$XCM_VERSION
;;
init-bridge-hub-rococo-local)
Expand Down Expand Up @@ -318,7 +327,7 @@ case "$1" in
"//Alice" \
1013 \
"ws://127.0.0.1:8943" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Westend" }, { "Parachain": 1002 } ] } }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1002 } ] } }')" \
$XCM_VERSION
;;
init-asset-hub-westend-local)
Expand All @@ -329,7 +338,7 @@ case "$1" in
"//Alice" \
1000 \
"ws://127.0.0.1:9010" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Rococo" }] } }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }')" \
"$GLOBAL_CONSENSUS_ROCOCO_SOVEREIGN_ACCOUNT" \
10000000000 \
true
Expand All @@ -348,7 +357,7 @@ case "$1" in
"//Alice" \
1000 \
"ws://127.0.0.1:9010" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Rococo" }, { "Parachain": 1000 } ] } }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1000 } ] } }')" \
$XCM_VERSION
;;
init-bridge-hub-westend-local)
Expand Down Expand Up @@ -376,7 +385,7 @@ case "$1" in
"//Alice" \
1002 \
"ws://127.0.0.1:8945" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Rococo" }, { "Parachain": 1013 } ] } }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1013 } ] } }')" \
$XCM_VERSION
;;
reserve-transfer-assets-from-asset-hub-rococo-local)
Expand All @@ -386,9 +395,9 @@ case "$1" in
limited_reserve_transfer_assets \
"ws://127.0.0.1:9910" \
"//Alice" \
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Westend" }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": '$amount' } } ] }')" \
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
"$(jq --null-input '{ "V5": [ { "id": { "parents": 1, "interior": "Here" }, "fun": { "Fungible": '$amount' } } ] }')" \
0 \
"Unlimited"
;;
Expand All @@ -399,9 +408,9 @@ case "$1" in
limited_reserve_transfer_assets \
"ws://127.0.0.1:9910" \
"//Alice" \
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Westend" }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 2, "interior": { "X1": { "GlobalConsensus": "Westend" } } } }, "fun": { "Fungible": '$amount' } } ] }')" \
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
"$(jq --null-input '{ "V5": [ { "id": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }, "fun": { "Fungible": '$amount' } } ] }')" \
0 \
"Unlimited"
;;
Expand All @@ -412,9 +421,9 @@ case "$1" in
limited_reserve_transfer_assets \
"ws://127.0.0.1:9010" \
"//Alice" \
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Rococo" }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": '$amount' } } ] }')" \
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
"$(jq --null-input '{ "V5": [ { "id": { "parents": 1, "interior": "Here" }, "fun": { "Fungible": '$amount' } } ] }')" \
0 \
"Unlimited"
;;
Expand All @@ -425,9 +434,9 @@ case "$1" in
limited_reserve_transfer_assets \
"ws://127.0.0.1:9010" \
"//Alice" \
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Rococo" }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 2, "interior": { "X1": { "GlobalConsensus": "Rococo" } } } }, "fun": { "Fungible": '$amount' } } ] }')" \
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
"$(jq --null-input '{ "V5": [ { "id": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }, "fun": { "Fungible": '$amount' } } ] }')" \
0 \
"Unlimited"
;;
Expand Down
14 changes: 6 additions & 8 deletions bridges/testing/framework/js-helpers/wrapped-assets-balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ async function run(nodeName, networkInfo, args) {
const api = await zombie.connect(wsUri, userDefinedTypes);

// TODO: could be replaced with https://github.com/polkadot-js/api/issues/4930 (depends on metadata v15) later
const accountAddress = args[0];
const expectedForeignAssetBalance = BigInt(args[1]);
const bridgedNetworkName = args[2];
const accountAddress = args.accountAddress;
const expectedAssetId = args.expectedAssetId;
const expectedAssetBalance = BigInt(args.expectedAssetBalance);

while (true) {
const foreignAssetAccount = await api.query.foreignAssets.account(
{ parents: 2, interior: { X1: [{ GlobalConsensus: bridgedNetworkName }] } },
accountAddress
);
const foreignAssetAccount = await api.query.foreignAssets.account(expectedAssetId, accountAddress);
if (foreignAssetAccount.isSome) {
const foreignAssetAccountBalance = foreignAssetAccount.unwrap().balance.toBigInt();
if (foreignAssetAccountBalance > expectedForeignAssetBalance) {
if (foreignAssetAccountBalance > expectedAssetBalance) {
return foreignAssetAccountBalance;
}
}
Expand Down
4 changes: 2 additions & 2 deletions bridges/testing/framework/utils/bridges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ function send_governance_transact() {

local dest=$(jq --null-input \
--arg para_id "$para_id" \
'{ "V3": { "parents": 0, "interior": { "X1": { "Parachain": $para_id } } } }')
'{ "V4": { "parents": 0, "interior": { "X1": [{ "Parachain": $para_id }] } } }')

local message=$(jq --null-input \
--argjson hex_encoded_data $hex_encoded_data \
--arg require_weight_at_most_ref_time "$require_weight_at_most_ref_time" \
--arg require_weight_at_most_proof_size "$require_weight_at_most_proof_size" \
'
{
"V3": [
"V4": [
{
"UnpaidExecution": {
"weight_limit": "Unlimited"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Creds: config
asset-hub-westend-collator1: run {{ENV_PATH}}/helper.sh with "auto-log reserve-transfer-assets-from-asset-hub-rococo-local 5000000000000" within 120 seconds

# check that //Alice received at least 4.8 ROC on Westend AH
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,4800000000000,Rococo" within 600 seconds
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with '{ "accountAddress": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", "expectedAssetBalance": 4800000000000, "expectedAssetId": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { "ByGenesis": [100,8,222,119,55,197,156,35,136,144,83,58,242,88,150,162,194,6,8,216,179,128,187,1,2,154,203,57,39,129,6,62] } }] }}}' within 600 seconds

# relayer //Ferdie is rewarded for delivering messages from Rococo BH
bridge-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw,0x00000002,0x6268726F,ThisChain,0" within 300 seconds
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Creds: config
asset-hub-rococo-collator1: run {{ENV_PATH}}/helper.sh with "auto-log reserve-transfer-assets-from-asset-hub-westend-local 5000000000000" within 120 seconds

# check that //Alice received at least 4.8 WND on Rococo AH
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,4800000000000,Westend" within 600 seconds
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with '{ "accountAddress": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", "expectedAssetBalance": 4800000000000, "expectedAssetId": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { "ByGenesis": [225,67,242,56,3,172,80,232,246,248,230,38,149,209,206,158,78,29,104,170,54,193,205,44,253,21,52,2,19,243,66,62] } }] }}}' within 600 seconds

# relayer //Eve is rewarded for delivering messages from Westend BH
bridge-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with "5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL,0x00000002,0x62687764,ThisChain,0" within 300 seconds

0 comments on commit bff395f

Please sign in to comment.