Skip to content
147 changes: 60 additions & 87 deletions bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ source "$FRAMEWORK_PATH/utils/bridges.sh"
# }
#
# // 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(
Expand All @@ -37,24 +31,17 @@ source "$FRAMEWORK_PATH/utils/bridges.sh"
# );
#
# // 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="5CtHyjQE8fbPaQeBrwaGph6qsSEtnMFBAZcAkxwnEfQkkYAq"
ASSET_HUB_ROCOCO_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_ROCOCO="5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV"
ALICE_SOVEREIGN_ACCOUNT="5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
BOB_SOVEREIGN_ACCOUNT_AT_ROCOCO="5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
BOB_SOVEREIGN_ACCOUNT_AT_WESTEND="5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"

# Expected sovereign accounts for rewards on BridgeHubs.
#
Expand Down Expand Up @@ -239,33 +226,7 @@ case "$1" in
run-messages-relay)
run_messages_relay
;;
init-asset-hub-rococo-local)
ensure_polkadot_js_api
# create foreign assets for native Westend token (governance call on Rococo)
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": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }')" \
"$GLOBAL_CONSENSUS_WESTEND_SOVEREIGN_ACCOUNT" \
10000000000 \
true
# create foreign asset pool
create_pool \
"ws://127.0.0.1:9910" \
"//Alice" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }')"
# Create liquidity in the pool
add_liquidity \
"ws://127.0.0.1:9910" \
"//Alice" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }')" \
10000000000 \
10000000000 \
"$ALICE_SOVEREIGN_ACCOUNT"
init-rococo-local)
# HRMP
open_hrmp_channels \
"ws://127.0.0.1:9942" \
Expand All @@ -275,14 +236,40 @@ case "$1" in
"ws://127.0.0.1:9942" \
"//Alice" \
1013 1000 4 524288
# set XCM version of remote AssetHubWestend
# governance set XCM version of remote AssetHubWestend on AHR
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": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1000 } ] } }')" \
$XCM_VERSION
# governance set XCM version of remote BridgeHubWestend on BHR
force_xcm_version \
"ws://127.0.0.1:9942" \
"//Alice" \
1013 \
"ws://127.0.0.1:8943" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1002 } ] } }')" \
$XCM_VERSION
;;
init-asset-hub-rococo-local)
ensure_polkadot_js_api
# create foreign asset pool
create_pool \
"ws://127.0.0.1:9910" \
"//Bob" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }')"
# 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": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }')" \
1000000000000 \
2500000000000 \
"$BOB_SOVEREIGN_ACCOUNT_AT_ROCOCO"
;;
init-bridge-hub-rococo-local)
ensure_polkadot_js_api
Expand All @@ -304,42 +291,8 @@ case "$1" in
"//Alice" \
"$ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_BridgedChain" \
100000000000000
# set XCM version of remote BridgeHubWestend
force_xcm_version \
"ws://127.0.0.1:9942" \
"//Alice" \
1013 \
"ws://127.0.0.1:8943" \
"$(jq --null-input '{ "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1002 } ] } }')" \
$XCM_VERSION
;;
init-asset-hub-westend-local)
ensure_polkadot_js_api
# create foreign assets for native Rococo token (governance call on Westend)
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": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }')" \
"$GLOBAL_CONSENSUS_ROCOCO_SOVEREIGN_ACCOUNT" \
10000000000 \
true
# create foreign asset pool
create_pool \
"ws://127.0.0.1:9010" \
"//Alice" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }')"
# Create liquidity in the pool
add_liquidity \
"ws://127.0.0.1:9010" \
"//Alice" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }')" \
10000000000 \
10000000000 \
"$ALICE_SOVEREIGN_ACCOUNT"
init-westend-local)
# HRMP
open_hrmp_channels \
"ws://127.0.0.1:9945" \
Expand All @@ -349,14 +302,40 @@ case "$1" in
"ws://127.0.0.1:9945" \
"//Alice" \
1002 1000 4 524288
# set XCM version of remote AssetHubRococo
# governance set XCM version of remote AssetHubRococo on AHW
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": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1000 } ] } }')" \
$XCM_VERSION
# governance set XCM version of remote BridgeHubRococo on BHW
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": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1013 } ] } }')" \
$XCM_VERSION
;;
init-asset-hub-westend-local)
ensure_polkadot_js_api
# create foreign asset pool
create_pool \
"ws://127.0.0.1:9010" \
"//Bob" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }')"
# 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": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }')" \
1000000000000 \
4000000000000 \
"$BOB_SOVEREIGN_ACCOUNT_AT_WESTEND"
;;
init-bridge-hub-westend-local)
# SA of sibling asset hub pays for the execution
Expand All @@ -377,14 +356,6 @@ case "$1" in
"//Alice" \
"$ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_BridgedChain" \
100000000000000
# set XCM version of remote BridgeHubRococo
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": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1013 } ] } }')" \
$XCM_VERSION
;;
reserve-transfer-assets-from-asset-hub-rococo-local)
amount=$2
Expand Down Expand Up @@ -482,8 +453,10 @@ case "$1" in
- run-finality-relay
- run-parachains-relay
- run-messages-relay
- init-rococo-local
- init-asset-hub-rococo-local
- init-bridge-hub-rococo-local
- init-westend-local
- init-asset-hub-westend-local
- init-bridge-hub-westend-local
- reserve-transfer-assets-from-asset-hub-rococo-local
Expand Down
12 changes: 9 additions & 3 deletions bridges/testing/environments/rococo-westend/spawn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ if [[ $init -eq 1 ]]; then
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-rococo-local >> $rococo_init_log 2>&1 &
rococo_init_pid=$!
$helper_script init-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

$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 &
Expand All @@ -54,9 +63,6 @@ if [[ $init -eq 1 ]]; then
$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

if [[ $start_relayer -eq 1 ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

//! # Asset Hub Rococo Runtime genesis config presets

use crate::*;
use crate::{
xcm_config::{bridging::to_westend::WestendNetwork, UniversalLocation},
*,
};
use alloc::{vec, vec::Vec};
use cumulus_primitives_core::ParaId;
use frame_support::build_struct_json_patch;
Expand All @@ -25,6 +28,9 @@ use sp_core::crypto::UncheckedInto;
use sp_genesis_builder::PresetId;
use sp_keyring::Sr25519Keyring;
use testnet_parachains_constants::rococo::{currency::UNITS as ROC, xcm_version::SAFE_XCM_VERSION};
use xcm::latest::prelude::*;
use xcm_builder::GlobalConsensusConvertsFor;
use xcm_executor::traits::ConvertLocation;

const ASSET_HUB_ROCOCO_ED: Balance = ExistentialDeposit::get();

Expand All @@ -33,6 +39,8 @@ fn asset_hub_rococo_genesis(
endowed_accounts: Vec<AccountId>,
endowment: Balance,
id: ParaId,
foreign_assets: Vec<(Location, AccountId, Balance)>,
foreign_assets_endowed_accounts: Vec<(Location, AccountId, Balance)>,
) -> serde_json::Value {
build_struct_json_patch!(RuntimeGenesisConfig {
balances: BalancesConfig {
Expand All @@ -56,6 +64,17 @@ fn asset_hub_rococo_genesis(
.collect(),
},
polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) },
foreign_assets: ForeignAssetsConfig {
assets: foreign_assets
.into_iter()
.map(|asset| (asset.0.try_into().unwrap(), asset.1, false, asset.2))
.collect(),
accounts: foreign_assets_endowed_accounts
.into_iter()
.map(|asset| (asset.0.try_into().unwrap(), asset.1, asset.2))
.collect(),
..Default::default()
},
})
}

Expand Down Expand Up @@ -99,17 +118,39 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
Vec::new(),
ASSET_HUB_ROCOCO_ED * 524_288,
1000.into(),
vec![],
vec![],
),
sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => asset_hub_rococo_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
(Sr25519Keyring::Bob.to_account_id(), Sr25519Keyring::Bob.public().into()),
sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET =>
asset_hub_rococo_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
(Sr25519Keyring::Bob.to_account_id(), Sr25519Keyring::Bob.public().into()),
],
Sr25519Keyring::well_known().map(|x| x.to_account_id()).collect(),
testnet_parachains_constants::rococo::currency::UNITS * 1_000_000,
1000.into(),
vec![
// bridged WND
(
Location::new(2, [GlobalConsensus(WestendNetwork::get())]),
GlobalConsensusConvertsFor::<UniversalLocation, AccountId>::convert_location(
&Location { parents: 2, interior: [GlobalConsensus(WestendNetwork::get())].into() },
)
.unwrap(),
10000000,
),
],
Sr25519Keyring::well_known().map(|x| x.to_account_id()).collect(),
testnet_parachains_constants::rococo::currency::UNITS * 1_000_000,
1000.into(),
),
vec![
// bridged WND to Bob
(
Location::new(2, [GlobalConsensus(WestendNetwork::get())]),
Sr25519Keyring::Bob.to_account_id(),
10000000 * 4096 * 4096,
),
],
),
sp_genesis_builder::DEV_RUNTIME_PRESET => asset_hub_rococo_genesis(
// initial collators.
vec![(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into())],
Expand All @@ -121,6 +162,8 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
],
ROC * 1_000_000,
1000.into(),
vec![],
vec![],
),
_ => return None,
};
Expand Down
Loading
Loading