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 all 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
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 @@ -23,6 +23,7 @@ use emulated_integration_tests_common::{
};
use parachains_common::Balance;
use xcm::latest::prelude::*;
use xcm::latest::ROCOCO_GENESIS_HASH;

pub const PARA_ID: u32 = 1002;
pub const ASSETHUB_PARA_ID: u32 = 1000;
Expand Down Expand Up @@ -73,7 +74,7 @@ pub fn genesis() -> Storage {
// open AHW -> AHR bridge
(
Location::new(1, [Parachain(1000)]),
Junctions::from([Rococo.into(), Parachain(1000)]),
Junctions::from([NetworkId::ByGenesis(ROCOCO_GENESIS_HASH).into(), Parachain(1000)]),
Some(bp_messages::LegacyLaneId([0, 0, 0, 2])),
),
],
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 @@ -456,7 +456,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
<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 All @@ -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 @@ -83,7 +83,7 @@ fn account_and_location(account: &str) -> (AccountId32, Location) {
let account_id = AssetHubWestend::account_id_of(account);
let account_clone = account_id.clone();
let location: Location =
[Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into();
[Junction::AccountId32 { network: Some(ByGenesis(WESTEND_GENESIS_HASH)), id: account_id.into() }].into();
(account_clone, location)
}

Expand All @@ -99,7 +99,7 @@ fn test_set_asset_claimer_between_the_chains() {
1,
[
Parachain(AssetHubWestend::para_id().into()),
Junction::AccountId32 { network: Some(Westend), id: alice.clone().into() },
Junction::AccountId32 { network: Some(ByGenesis(WESTEND_GENESIS_HASH)), id: alice.clone().into() },
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ fn transfer_and_transact_in_same_xcm(
let fees_for_ah: Asset = (usdt.id.clone(), ah_fees_amount).into();
let usdt_to_ah_then_onward: Asset = (usdt.id.clone(), usdt_to_ah_then_onward_amount).into();

let require_weight_at_most = Weight::from_parts(1000000000, 200000);
// xcm to be executed at dest
let xcm_on_dest = Xcm(vec![
Transact { require_weight_at_most, origin_kind: OriginKind::Xcm, call },
Transact { origin_kind: OriginKind::Xcm, call },
ExpectTransactStatus(MaybeErrorCode::Success),
// since this is the last hop, we don't need to further use any assets previously
// reserved for fees (there are no further hops to cover transport fees for); we
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
);
}
Loading
Loading