Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XCMv5]Remove XCM testnet NetworkIds #5390

Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cd33e83
initial modifications
programskillforverification Aug 16, 2024
2ce6458
Replace unnecessary `&mut self` with `&self` in `BlockImport::import_…
nazar-pc Aug 18, 2024
e83e8b3
binary-merkle-tree: Do not spam test output (#5376)
bkchr Aug 18, 2024
856a3fe
replace all networkids in cumulus and polkadot
programskillforverification Aug 19, 2024
4f16f3c
remove networkis in xcm-v5
programskillforverification Aug 19, 2024
a43ca9c
fix From<NewNetworkId>
programskillforverification Aug 20, 2024
5d15302
make clippy happy
programskillforverification Aug 20, 2024
190dca7
Merge branch 'xcm-v5' into remove-networkids
programskillforverification Aug 22, 2024
d58209c
fix unrelated pr
programskillforverification Aug 22, 2024
736f2ec
Update cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/…
programskillforverification Aug 22, 2024
b22604a
bridge-hub-westend conditionally import
programskillforverification Aug 22, 2024
1d1d7c0
Merge branch 'xcm-v5' into remove-networkids
programskillforverification Sep 4, 2024
9f7dc75
fix a rococo network
programskillforverification Sep 5, 2024
c046a5c
Merge branch 'xcm-v5' into remove-networkids
programskillforverification Oct 18, 2024
7ec6498
fix confilct
programskillforverification Oct 18, 2024
910f4d2
Merge branch 'xcm-v5' into remove-networkids
franciscoaguirre Oct 31, 2024
c9c72ff
fix: add Cargo.lock
franciscoaguirre Oct 31, 2024
5d078b9
Merge branch 'xcm-v5' into remove-networkids
franciscoaguirre Oct 31, 2024
6decede
fix: Cargo.lock issue
franciscoaguirre Nov 1, 2024
3bbce95
fix: remove crates with publish = false from prdoc
franciscoaguirre Nov 1, 2024
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
1,251 changes: 447 additions & 804 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bridges/modules/xcm-bridge-hub/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use sp_runtime::{
AccountId32, BuildStorage, StateVersion,
};
use sp_std::cell::RefCell;
use xcm::prelude::*;
use xcm::{latest::ROCOCO_GENESIS_HASH, prelude::*};
use xcm_builder::{
AllowUnpaidExecutionFrom, DispatchBlob, DispatchBlobError, FixedWeightBounds,
InspectMessageQueues, NetworkExportTable, NetworkExportTableItem, ParentIsPreset,
Expand Down Expand Up @@ -160,7 +160,7 @@ parameter_types! {
pub BridgedRelayNetworkLocation: Location = (Parent, GlobalConsensus(BridgedRelayNetwork::get())).into();
pub BridgedRelativeDestination: InteriorLocation = [Parachain(BRIDGED_ASSET_HUB_ID)].into();
pub BridgedUniversalDestination: InteriorLocation = [GlobalConsensus(BridgedRelayNetwork::get()), Parachain(BRIDGED_ASSET_HUB_ID)].into();
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::Rococo;
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);

pub const BridgeDeposit: Balance = 100_000;

Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/messages/src/lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl TypeId for LegacyLaneId {
/// concatenation (separated by some binary data). I.e.:
///
/// ```nocompile
/// let endpoint1 = X2(GlobalConsensus(NetworkId::Rococo), Parachain(42));
/// let endpoint1 = X2(GlobalConsensus(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(42));
/// let endpoint2 = X2(GlobalConsensus(NetworkId::Wococo), Parachain(777));
///
/// let final_lane_key = if endpoint1 < endpoint2 {
Expand Down
3 changes: 2 additions & 1 deletion bridges/primitives/xcm-bridge-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,11 @@ impl BridgeLocations {
#[cfg(test)]
mod tests {
use super::*;
use xcm::latest::ROCOCO_GENESIS_HASH;

const LOCAL_NETWORK: NetworkId = Kusama;
const REMOTE_NETWORK: NetworkId = Polkadot;
const UNREACHABLE_NETWORK: NetworkId = Rococo;
const UNREACHABLE_NETWORK: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
const SIBLING_PARACHAIN: u32 = 1000;
const LOCAL_BRIDGE_HUB: u32 = 1001;
const REMOTE_PARACHAIN: u32 = 2000;
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sp_runtime::{
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, Keccak256},
AccountId32, BuildStorage, FixedU128,
};
use xcm::prelude::*;
use xcm::{latest::ROCOCO_GENESIS_HASH, prelude::*};

#[cfg(feature = "runtime-benchmarks")]
use crate::BenchmarkHelper;
Expand Down
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 @@ -63,7 +66,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 @@ -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 = 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 @@ -464,14 +464,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 @@ -27,7 +27,7 @@ mod imports {

// Polkadot
pub use xcm::{
latest::AssetTransferFilter,
latest::{AssetTransferFilter, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
};
pub use xcm_executor::traits::TransferType;
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 @@ -465,14 +465,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 @@ -22,9 +22,9 @@ mod imports {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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 @@ -125,7 +125,7 @@ fn send_roc_from_asset_hub_rococo_to_asset_hub_westend() {
set_up_pool_with_wnd_on_ah_westend(bridged_roc_at_asset_hub_westend.clone(), true);

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 @@ -199,7 +199,7 @@ fn send_back_wnds_usdt_and_weth_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 @@ -357,7 +357,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 @@ -463,7 +463,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 @@ -24,26 +24,38 @@ 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))])
}

// WND and wWND
pub(crate) fn wnd_at_ah_westend() -> Location {
Parent.into()
}
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 @@ -54,8 +66,8 @@ pub(crate) fn bridged_usdt_at_ah_rococo() -> Location {
Location::new(
2,
[
GlobalConsensus(Westend),
Parachain(AssetHubWestend::para_id().into()),
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 @@ -22,9 +22,9 @@ mod imports {

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

Expand Down
Loading