Skip to content

Commit

Permalink
replace all networkids in cumulus and polkadot
Browse files Browse the repository at this point in the history
  • Loading branch information
programskillforverification committed Aug 19, 2024
1 parent 78fb2ec commit 9d38797
Show file tree
Hide file tree
Showing 49 changed files with 213 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ use emulated_integration_tests_common::{
xcm_emulator::decl_test_parachains,
};

// Polkadot
use xcm::latest::{ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH};

// Penpal Parachain declaration
decl_test_parachains! {
pub struct PenpalA {
Expand All @@ -39,7 +42,7 @@ decl_test_parachains! {
penpal_runtime::AuraExt::on_initialize(1);
frame_support::assert_ok!(penpal_runtime::System::set_storage(
penpal_runtime::RuntimeOrigin::root(),
vec![(PenpalRelayNetworkId::key().to_vec(), NetworkId::Rococo.encode())],
vec![(PenpalRelayNetworkId::key().to_vec(), NetworkId::ByGenesis(ROCOCO_GENESIS_HASH).encode())],
));
},
runtime = penpal_runtime,
Expand All @@ -62,7 +65,7 @@ decl_test_parachains! {
penpal_runtime::AuraExt::on_initialize(1);
frame_support::assert_ok!(penpal_runtime::System::set_storage(
penpal_runtime::RuntimeOrigin::root(),
vec![(PenpalRelayNetworkId::key().to_vec(), NetworkId::Westend.encode())],
vec![(PenpalRelayNetworkId::key().to_vec(), NetworkId::ByGenesis(WESTEND_GENESIS_HASH).encode())],
));
},
runtime = penpal_runtime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ mod imports {

// Polkadot
pub use xcm::{
latest::{ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
v3,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ fn assets_can_be_claimed() {
let amount = AssetHubRococoExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_chain_can_claim_assets!(AssetHubRococo, RuntimeCall, NetworkId::Rococo, assets, amount);
test_chain_can_claim_assets!(
AssetHubRococo,
RuntimeCall,
NetworkId::ByGenesis(ROCOCO_GENESIS_HASH),
assets,
amount
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
// Foreign asset used: bridged WND
let foreign_amount_to_send = ASSET_HUB_ROCOCO_ED * 10_000_000;
let wnd_at_rococo_parachains =
Location::new(2, [Junction::GlobalConsensus(NetworkId::Westend)]);
Location::new(2, [Junction::GlobalConsensus(NetworkId::ByGenesis(WESTEND_GENESIS_HASH))]);

// Configure destination chain to trust AH as reserve of WND
PenpalA::execute_with(|| {
assert_ok!(<PenpalA as Chain>::System::set_storage(
<PenpalA as Chain>::RuntimeOrigin::root(),
vec![(
PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(),
Location::new(2, [GlobalConsensus(Westend)]).encode(),
Location::new(2, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))]).encode(),
)],
));
});
Expand Down Expand Up @@ -293,15 +293,15 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
// Foreign asset used: bridged WND
let foreign_amount_to_send = ASSET_HUB_ROCOCO_ED * 10_000_000;
let wnd_at_rococo_parachains =
Location::new(2, [Junction::GlobalConsensus(NetworkId::Westend)]);
Location::new(2, [Junction::GlobalConsensus(NetworkId::ByGenesis(WESTEND_GENESIS_HASH))]);

// Configure destination chain to trust AH as reserve of WND
PenpalA::execute_with(|| {
assert_ok!(<PenpalA as Chain>::System::set_storage(
<PenpalA as Chain>::RuntimeOrigin::root(),
vec![(
PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(),
Location::new(2, [GlobalConsensus(Westend)]).encode(),
Location::new(2, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))]).encode(),
)],
));
});
Expand Down Expand Up @@ -455,14 +455,14 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
<PenpalB as Chain>::RuntimeOrigin::root(),
vec![(
PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(),
Location::new(2, [GlobalConsensus(Westend)]).encode(),
Location::new(2, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))]).encode(),
)],
));
});

// Register WND as foreign asset and transfer it around the Rococo ecosystem
let wnd_at_rococo_parachains =
Location::new(2, [Junction::GlobalConsensus(NetworkId::Westend)]);
Location::new(2, [Junction::GlobalConsensus(NetworkId::ByGenesis(WESTEND_GENESIS_HASH))]);
AssetHubRococo::force_create_foreign_asset(
wnd_at_rococo_parachains.clone().try_into().unwrap(),
assets_owner.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ mod imports {
};

// Polkadot
pub use xcm::prelude::{AccountId32 as AccountId32Junction, *};
pub use xcm::{
latest::{ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
};
pub use xcm_executor::traits::TransferType;

// Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ fn assets_can_be_claimed() {
let amount = AssetHubWestendExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_chain_can_claim_assets!(AssetHubWestend, RuntimeCall, NetworkId::Westend, assets, amount);
test_chain_can_claim_assets!(
AssetHubWestend,
RuntimeCall,
NetworkId::ByGenesis(WESTEND_GENESIS_HASH),
assets,
amount
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
// Foreign asset used: bridged ROC
let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000;
let roc_at_westend_parachains =
Location::new(2, [Junction::GlobalConsensus(NetworkId::Rococo)]);
Location::new(2, [Junction::GlobalConsensus(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH))]);

// Configure destination chain to trust AH as reserve of ROC
PenpalA::execute_with(|| {
assert_ok!(<PenpalA as Chain>::System::set_storage(
<PenpalA as Chain>::RuntimeOrigin::root(),
vec![(
PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(),
Location::new(2, [GlobalConsensus(Rococo)]).encode(),
Location::new(2, [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH))]).encode(),
)],
));
});
Expand Down Expand Up @@ -293,15 +293,15 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
// Foreign asset used: bridged ROC
let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000;
let roc_at_westend_parachains =
Location::new(2, [Junction::GlobalConsensus(NetworkId::Rococo)]);
Location::new(2, [Junction::GlobalConsensus(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH))]);

// Configure destination chain to trust AH as reserve of ROC
PenpalA::execute_with(|| {
assert_ok!(<PenpalA as Chain>::System::set_storage(
<PenpalA as Chain>::RuntimeOrigin::root(),
vec![(
PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(),
Location::new(2, [GlobalConsensus(Rococo)]).encode(),
Location::new(2, [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH))]).encode(),
)],
));
});
Expand Down Expand Up @@ -456,14 +456,14 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
<PenpalB as Chain>::RuntimeOrigin::root(),
vec![(
PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(),
Location::new(2, [GlobalConsensus(Rococo)]).encode(),
Location::new(2, [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH))]).encode(),
)],
));
});

// Register ROC as foreign asset and transfer it around the Westend ecosystem
let roc_at_westend_parachains =
Location::new(2, [Junction::GlobalConsensus(NetworkId::Rococo)]);
Location::new(2, [Junction::GlobalConsensus(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH))]);
AssetHubWestend::force_create_foreign_asset(
roc_at_westend_parachains.clone().try_into().unwrap(),
assets_owner.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ mod imports {

// Polkadot
pub use xcm::{
latest::ParentThen,
latest::{ParentThen, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
v4,
v4::NetworkId::Westend as WestendId,
};
pub use xcm_executor::traits::TransferType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn send_assets_from_penpal_rococo_through_rococo_ah_to_westend_ah(
);
let sov_ahw_on_ahr =
AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus(
Westend,
ByGenesis(WESTEND_GENESIS_HASH),
AssetHubWestend::para_id(),
);
// send message over bridge
Expand Down Expand Up @@ -131,7 +131,7 @@ fn send_roc_usdt_and_weth_from_asset_hub_rococo_to_asset_hub_westend() {
// Let's first send over just some ROCs as a simple example
////////////////////////////////////////////////////////////
let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus(
Westend,
ByGenesis(WESTEND_GENESIS_HASH),
AssetHubWestend::para_id(),
);
let rocs_in_reserve_on_ahr_before =
Expand Down Expand Up @@ -268,7 +268,7 @@ fn send_back_wnds_from_asset_hub_rococo_to_asset_hub_westend() {

// fund the AHR's SA on AHW with the WND tokens held in reserve
let sov_ahr_on_ahw = AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus(
Rococo,
ByGenesis(ROCOCO_GENESIS_HASH),
AssetHubRococo::para_id(),
);
AssetHubWestend::fund_accounts(vec![(sov_ahr_on_ahw.clone(), prefund_amount)]);
Expand Down Expand Up @@ -336,7 +336,7 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend()
set_up_rocs_for_penpal_rococo_through_ahr_to_ahw(&sender, amount);

let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus(
Westend,
ByGenesis(WESTEND_GENESIS_HASH),
AssetHubWestend::para_id(),
);
let rocs_in_reserve_on_ahr_before =
Expand Down Expand Up @@ -432,7 +432,7 @@ fn send_back_wnds_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_weste

// fund the AHR's SA on AHW with the WND tokens held in reserve
let sov_ahr_on_ahw = AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus(
NetworkId::Rococo,
NetworkId::ByGenesis(ROCOCO_GENESIS_HASH),
AssetHubRococo::para_id(),
);
AssetHubWestend::fund_accounts(vec![(sov_ahr_on_ahw.clone(), amount * 2)]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ fn assets_can_be_claimed() {
let amount = BridgeHubRococoExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_chain_can_claim_assets!(AssetHubRococo, RuntimeCall, NetworkId::Rococo, assets, amount);
test_chain_can_claim_assets!(
AssetHubRococo,
RuntimeCall,
NetworkId::ByGenesis(ROCOCO_GENESIS_HASH),
assets,
amount
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,35 @@ mod snowbridge;
mod teleport;

pub(crate) fn asset_hub_westend_location() -> Location {
Location::new(2, [GlobalConsensus(Westend), Parachain(AssetHubWestend::para_id().into())])
Location::new(
2,
[
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(AssetHubWestend::para_id().into()),
],
)
}
pub(crate) fn bridge_hub_westend_location() -> Location {
Location::new(2, [GlobalConsensus(Westend), Parachain(BridgeHubWestend::para_id().into())])
Location::new(
2,
[
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(BridgeHubWestend::para_id().into()),
],
)
}

// ROC and wROC
pub(crate) fn roc_at_ah_rococo() -> Location {
Parent.into()
}
pub(crate) fn bridged_roc_at_ah_westend() -> Location {
Location::new(2, [GlobalConsensus(Rococo)])
Location::new(2, [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH))])
}

// wWND
pub(crate) fn bridged_wnd_at_ah_rococo() -> Location {
Location::new(2, [GlobalConsensus(Westend)])
Location::new(2, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))])
}

// USDT and wUSDT
Expand All @@ -49,7 +61,7 @@ pub(crate) fn bridged_usdt_at_ah_westend() -> Location {
Location::new(
2,
[
GlobalConsensus(Rococo),
GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)),
Parachain(AssetHubRococo::para_id().into()),
PalletInstance(ASSETS_PALLET_ID),
GeneralIndex(USDT_ID.into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable
let xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit, check_origin },
ExportMessage {
network: WestendId,
network: ByGenesis(WESTEND_GENESIS_HASH),
destination: [Parachain(AssetHubWestend::para_id().into())].into(),
xcm: remote_xcm,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ mod imports {

// Polkadot
pub use xcm::{
latest::ParentThen,
latest::{ParentThen, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
v4::{self, NetworkId::Rococo as RococoId},
v4,
};
pub use xcm_executor::traits::TransferType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn send_assets_from_penpal_westend_through_westend_ah_to_rococo_ah(
);
let sov_ahr_on_ahw =
AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus(
Rococo,
ByGenesis(ROCOCO_GENESIS_HASH),
AssetHubRococo::para_id(),
);

Expand Down Expand Up @@ -122,7 +122,7 @@ fn send_wnds_from_asset_hub_westend_to_asset_hub_rococo() {
set_up_pool_with_roc_on_ah_rococo(bridged_wnd_at_asset_hub_rococo.clone(), true);

let sov_ahr_on_ahw = AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus(
Rococo,
ByGenesis(ROCOCO_GENESIS_HASH),
AssetHubRococo::para_id(),
);
let wnds_in_reserve_on_ahw_before =
Expand Down Expand Up @@ -196,7 +196,7 @@ fn send_back_rocs_usdt_and_weth_from_asset_hub_westend_to_asset_hub_rococo() {

// fund the AHW's SA on AHR with the ROC tokens held in reserve
let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus(
Westend,
ByGenesis(WESTEND_GENESIS_HASH),
AssetHubWestend::para_id(),
);
AssetHubRococo::fund_accounts(vec![(sov_ahw_on_ahr.clone(), prefund_amount)]);
Expand Down Expand Up @@ -270,7 +270,7 @@ fn send_back_rocs_usdt_and_weth_from_asset_hub_westend_to_asset_hub_rococo() {
create_foreign_on_ah_rococo(bridged_weth_at_ah.clone(), true);
// prefund AHW's sovereign account on AHR to be able to withdraw USDT and wETH from reserves
let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus(
Westend,
ByGenesis(WESTEND_GENESIS_HASH),
AssetHubWestend::para_id(),
);
AssetHubRococo::mint_asset(
Expand Down Expand Up @@ -356,7 +356,7 @@ fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo()
set_up_wnds_for_penpal_westend_through_ahw_to_ahr(&sender, amount);

let sov_ahr_on_ahw = AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus(
Rococo,
ByGenesis(ROCOCO_GENESIS_HASH),
AssetHubRococo::para_id(),
);
let wnds_in_reserve_on_ahw_before =
Expand Down Expand Up @@ -452,7 +452,7 @@ fn send_back_rocs_from_penpal_westend_through_asset_hub_westend_to_asset_hub_roc

// fund the AHW's SA on AHR with the ROC tokens held in reserve
let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus(
Westend,
ByGenesis(WESTEND_GENESIS_HASH),
AssetHubWestend::para_id(),
);
AssetHubRococo::fund_accounts(vec![(sov_ahw_on_ahr.clone(), amount * 2)]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ fn assets_can_be_claimed() {
let amount = BridgeHubWestendExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_chain_can_claim_assets!(AssetHubWestend, RuntimeCall, NetworkId::Westend, assets, amount);
test_chain_can_claim_assets!(
AssetHubWestend,
RuntimeCall,
NetworkId::ByGenesis(WESTEND_GENESIS_HASH),
assets,
amount
);
}
Loading

0 comments on commit 9d38797

Please sign in to comment.