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 7 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 @@ -37,7 +37,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, FixedWeightBounds, InspectMessageQueues, NetworkExportTable,
NetworkExportTableItem,
Expand Down Expand Up @@ -158,7 +158,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;
pub const Penalty: Balance = 1_000;
Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -177,7 +177,7 @@ pub const DOT: u128 = 10_000_000_000;
parameter_types! {
pub TreasuryAccount: AccountId = PalletId(*b"py/trsry").into_account_truncating();
pub Fee: u64 = 1000;
pub const RococoNetwork: NetworkId = NetworkId::Rococo;
pub const RococoNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
pub const InitialFunding: u128 = 1_000_000_000_000;
pub AssetHubParaId: ParaId = ParaId::new(1000);
pub TestParaId: u32 = 2000;
Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/consensus/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ where
}

async fn import_block(
&mut self,
programskillforverification marked this conversation as resolved.
Show resolved Hide resolved
&self,
mut params: sc_consensus::BlockImportParams<Block>,
) -> Result<sc_consensus::ImportResult, Self::Error> {
// Blocks are stored within the backend by using POST hash.
Expand Down
7 changes: 2 additions & 5 deletions cumulus/client/consensus/common/src/parachain_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,8 @@ async fn handle_new_best_parachain_head<Block, P>(
}
}

async fn import_block_as_new_best<Block, P>(
hash: Block::Hash,
header: Block::Header,
mut parachain: &P,
) where
async fn import_block_as_new_best<Block, P>(hash: Block::Hash, header: Block::Header, parachain: &P)
where
Block: BlockT,
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
for<'a> &'a P: BlockImport<Block>,
Expand Down
4 changes: 2 additions & 2 deletions cumulus/client/consensus/common/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ fn build_block<B: InitBlockBuilder>(
}

async fn import_block<I: BlockImport<Block>>(
importer: &mut I,
importer: &I,
block: Block,
origin: BlockOrigin,
import_as_best: bool,
Expand Down Expand Up @@ -568,7 +568,7 @@ fn follow_finalized_does_not_stop_on_unknown_block() {
fn follow_new_best_sets_best_after_it_is_imported() {
sp_tracing::try_init_simple();

let mut client = Arc::new(TestClientBuilder::default().build());
let client = Arc::new(TestClientBuilder::default().build());

let block = build_and_import_block(client.clone(), false);

Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ fn relay_parent_not_imported_when_block_announce_is_processed() {
block_on(async move {
let (mut validator, api) = make_validator_and_api();

let mut client = api.relay_client.clone();
let client = api.relay_client.clone();
let block = client.init_polkadot_block_builder().build().expect("Build new block").block;

let (signal, header) = make_gossip_message_and_header(api, block.hash(), 0).await;
Expand Down
6 changes: 3 additions & 3 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ mod tests {

#[test]
fn returns_directly_for_available_block() {
let (mut client, block, relay_chain_interface) = build_client_backend_and_block();
let (client, block, relay_chain_interface) = build_client_backend_and_block();
let hash = block.hash();

block_on(client.import(BlockOrigin::Own, block)).expect("Imports the block");
Expand All @@ -439,7 +439,7 @@ mod tests {

#[test]
fn resolve_after_block_import_notification_was_received() {
let (mut client, block, relay_chain_interface) = build_client_backend_and_block();
let (client, block, relay_chain_interface) = build_client_backend_and_block();
let hash = block.hash();

block_on(async move {
Expand Down Expand Up @@ -468,7 +468,7 @@ mod tests {

#[test]
fn do_not_resolve_after_different_block_import_notification_was_received() {
let (mut client, block, relay_chain_interface) = build_client_backend_and_block();
let (client, block, relay_chain_interface) = build_client_backend_and_block();
let hash = block.hash();

let ext = construct_transfer_extrinsic(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn validation_params_and_memory_optimized_validation_params_encode_and_decode()
fn validate_block_works_with_child_tries() {
sp_tracing::try_init_simple();

let (mut client, parent_head) = create_test_client();
let (client, parent_head) = create_test_client();
let TestBlockData { block, .. } = build_block_with_witness(
&client,
vec![generate_extrinsic(&client, Charlie, TestPalletCall::read_and_write_child_tries {})],
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 @@ -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, *},
v5,
v5::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
);
}
Loading
Loading