diff --git a/bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh b/bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh index f730efc1e66e3..2e9cde58a47be 100755 --- a/bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh +++ b/bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh @@ -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::::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::::convert_location( @@ -37,12 +31,6 @@ source "$FRAMEWORK_PATH/utils/bridges.sh" # ); # # // SS58=42 -# println!("GLOBAL_CONSENSUS_WESTEND_SOVEREIGN_ACCOUNT=\"{}\"", -# frame_support::sp_runtime::AccountId32::new( -# GlobalConsensusConvertsFor::::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::::convert_location( @@ -50,11 +38,10 @@ source "$FRAMEWORK_PATH/utils/bridges.sh" # ).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_ACCOUNT_AT_ROCOCO="5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" +BOB_ACCOUNT_AT_WESTEND="5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" # Expected sovereign accounts for rewards on BridgeHubs. # @@ -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" \ @@ -275,7 +236,7 @@ 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" \ @@ -283,6 +244,32 @@ case "$1" in "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_ACCOUNT_AT_ROCOCO" ;; init-bridge-hub-rococo-local) ensure_polkadot_js_api @@ -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" \ @@ -349,7 +302,7 @@ 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" \ @@ -357,6 +310,32 @@ case "$1" in "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_ACCOUNT_AT_WESTEND" ;; init-bridge-hub-westend-local) # SA of sibling asset hub pays for the execution @@ -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 @@ -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 diff --git a/bridges/testing/environments/rococo-westend/spawn.sh b/bridges/testing/environments/rococo-westend/spawn.sh index dccad6e4eb098..8d9ee6c428f70 100755 --- a/bridges/testing/environments/rococo-westend/spawn.sh +++ b/bridges/testing/environments/rococo-westend/spawn.sh @@ -43,20 +43,26 @@ 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 $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 & westend_init_pid=$! - wait -n $rococo_init_pid $westend_init_pid + wait $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 + wait $rococo_init_pid $westend_init_pid fi if [[ $start_relayer -eq 1 ]]; then diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs index d58d2f6d5f4d6..28eeeda3af154 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs @@ -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; @@ -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(); @@ -33,6 +39,8 @@ fn asset_hub_rococo_genesis( endowed_accounts: Vec, 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 { @@ -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() + }, }) } @@ -99,17 +118,39 @@ pub fn get_preset(id: &PresetId) -> Option> { 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::::convert_location( + &Location { parents: 2, interior: [GlobalConsensus(WestendNetwork::get())].into() }, + ) + .unwrap(), + 10_000_000, + ), ], - 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(), + 10_000_000 * 4096 * 4096, + ), + ], + ), sp_genesis_builder::DEV_RUNTIME_PRESET => asset_hub_rococo_genesis( // initial collators. vec![(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into())], @@ -121,6 +162,8 @@ pub fn get_preset(id: &PresetId) -> Option> { ], ROC * 1_000_000, 1000.into(), + vec![], + vec![], ), _ => return None, }; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs index 8b3805a548a1b..9bd617513bc09 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs @@ -15,7 +15,10 @@ //! # Asset Hub Westend Runtime genesis config presets -use crate::*; +use crate::{ + xcm_config::{bridging::to_rococo::RococoNetwork, UniversalLocation}, + *, +}; use alloc::{vec, vec::Vec}; use cumulus_primitives_core::ParaId; use frame_support::build_struct_json_patch; @@ -27,6 +30,9 @@ use sp_keyring::Sr25519Keyring; use testnet_parachains_constants::westend::{ currency::UNITS as WND, xcm_version::SAFE_XCM_VERSION, }; +use xcm::latest::prelude::*; +use xcm_builder::GlobalConsensusConvertsFor; +use xcm_executor::traits::ConvertLocation; const ASSET_HUB_WESTEND_ED: Balance = ExistentialDeposit::get(); @@ -36,6 +42,8 @@ fn asset_hub_westend_genesis( endowment: Balance, dev_stakers: Option<(u32, u32)>, 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 { @@ -74,6 +82,17 @@ fn asset_hub_westend_genesis( ], dev_stakers, ..Default::default() + }, + 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() } }) } @@ -116,18 +135,40 @@ pub fn get_preset(id: &PresetId) -> Option> { ASSET_HUB_WESTEND_ED * 4096, None, 1000.into(), + vec![], + vec![], ), - sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => asset_hub_westend_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_westend_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(|k| k.to_account_id()).collect(), + WND * 1_000_000, + dev_stakers, + 1000.into(), + vec![ + // bridged ROC + ( + Location::new(2, [GlobalConsensus(RococoNetwork::get())]), + GlobalConsensusConvertsFor::::convert_location( + &Location { parents: 2, interior: [GlobalConsensus(RococoNetwork::get())].into() }, + ) + .unwrap(), + 10_000_000, + ), ], - Sr25519Keyring::well_known().map(|k| k.to_account_id()).collect(), - WND * 1_000_000, - dev_stakers, - 1000.into(), - ), + vec![ + // bridged ROC to Bob + ( + Location::new(2, [GlobalConsensus(RococoNetwork::get())]), + Sr25519Keyring::Bob.to_account_id(), + 10_000_000 * 4096 * 4096, + ), + ], + ), sp_genesis_builder::DEV_RUNTIME_PRESET => asset_hub_westend_genesis( // initial collators. vec![(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into())], @@ -140,6 +181,8 @@ pub fn get_preset(id: &PresetId) -> Option> { WND * 1_000_000, dev_stakers, 1000.into(), + vec![], + vec![], ), _ => return None, };