diff --git a/Cargo.lock b/Cargo.lock index b6d01bb2ca9..ac2735b0da5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15929,6 +15929,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-tracing", "sp-trie", "xcm", "xcm-executor", diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index 4282e91c499..19689d41f66 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -17,7 +17,6 @@ pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, - instances::Instance1, pallet_prelude::Weight, sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress}, traits::{fungibles::Inspect, OriginTrait}, diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index 9d87458f876..62e744c87e7 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -17,7 +17,6 @@ pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, - instances::Instance1, pallet_prelude::Weight, sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress}, traits::{fungibles::Inspect, OriginTrait}, diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index b7f064e7d6e..a78dad75a3b 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -17,7 +17,6 @@ pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, - instances::{Instance1, Instance2}, pallet_prelude::Weight, sp_runtime::{AccountId32, DispatchError, DispatchResult, ModuleError, MultiAddress}, traits::{fungibles::Inspect, OriginTrait}, diff --git a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 2a4927d857c..bc44f070a09 100644 --- a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -18,7 +18,6 @@ pub use bp_messages::LaneId; pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, - instances::Instance1, pallet_prelude::Weight, sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress}, traits::{fungibles::Inspect, OriginTrait}, diff --git a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index b71ee65a222..c83578b234e 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -17,7 +17,6 @@ pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, - instances::Instance1, pallet_prelude::Weight, sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress}, traits::{fungibles::Inspect, OriginTrait}, diff --git a/parachains/integration-tests/emulated/common/src/impls.rs b/parachains/integration-tests/emulated/common/src/impls.rs index 92c68f4dd61..b7da17b5398 100644 --- a/parachains/integration-tests/emulated/common/src/impls.rs +++ b/parachains/integration-tests/emulated/common/src/impls.rs @@ -11,6 +11,9 @@ use pallet_bridge_messages::{Config, Instance1, Instance2, OutboundLanes, Pallet use sp_core::Get; use xcm_emulator::{BridgeMessage, BridgeMessageDispatchError, BridgeMessageHandler, Chain}; +pub use paste; +pub use parachains_common::{AccountId, Balance}; + pub struct BridgeHubMessageHandler { _marker: std::marker::PhantomData<(S, T, I)>, } @@ -129,10 +132,10 @@ where #[macro_export] macro_rules! impl_accounts_helpers_for_relay_chain { ( $chain:ident ) => { - $crate::paste::paste! { + $crate::impls::paste::paste! { impl $chain { /// Fund a set of accounts with a balance - pub fn fund_accounts(accounts: Vec<(AccountId, Balance)>) { + pub fn fund_accounts(accounts: Vec<($crate::impls::AccountId, $crate::impls::Balance)>) { Self::execute_with(|| { for account in accounts { assert_ok!(]>::Balances::force_set_balance( @@ -144,7 +147,7 @@ macro_rules! impl_accounts_helpers_for_relay_chain { }); } /// Fund a sovereign account based on its Parachain Id - pub fn fund_para_sovereign(amount: Balance, para_id: ParaId) -> sp_runtime::AccountId32 { + pub fn fund_para_sovereign(amount: $crate::impls::Balance, para_id: ParaId) -> sp_runtime::AccountId32 { let sovereign_account = Self::sovereign_account_id_of_child_para(para_id); Self::fund_accounts(vec![(sovereign_account.clone(), amount)]); sovereign_account @@ -157,7 +160,7 @@ macro_rules! impl_accounts_helpers_for_relay_chain { #[macro_export] macro_rules! impl_assert_events_helpers_for_relay_chain { ( $chain:ident ) => { - $crate::paste::paste! { + $crate::impls::paste::paste! { type [<$chain RuntimeEvent>] = <$chain as Chain>::RuntimeEvent; impl $chain { @@ -247,7 +250,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain { #[macro_export] macro_rules! impl_hrmp_channels_helpers_for_relay_chain { ( $chain:ident ) => { - $crate::paste::paste! { + $crate::impls::paste::paste! { impl $chain { /// Init open channel request with another Parachain pub fn init_open_channel_call( @@ -305,10 +308,10 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { #[macro_export] macro_rules! impl_accounts_helpers_for_parachain { ( $chain:ident ) => { - $crate::paste::paste! { + $crate::impls::paste::paste! { impl $chain { /// Fund a set of accounts with a balance - pub fn fund_accounts(accounts: Vec<(AccountId, Balance)>) { + pub fn fund_accounts(accounts: Vec<($crate::impls::AccountId, $crate::impls::Balance)>) { Self::execute_with(|| { for account in accounts { assert_ok!(]>::Balances::force_set_balance( @@ -327,7 +330,7 @@ macro_rules! impl_accounts_helpers_for_parachain { #[macro_export] macro_rules! impl_assert_events_helpers_for_parachain { ( $chain:ident ) => { - $crate::paste::paste! { + $crate::impls::paste::paste! { type [<$chain RuntimeEvent>] = <$chain as Chain>::RuntimeEvent; impl $chain { @@ -474,14 +477,14 @@ macro_rules! impl_assert_events_helpers_for_parachain { #[macro_export] macro_rules! impl_assets_helpers_for_parachain { ( $chain:ident, $relay_chain:ident ) => { - $crate::paste::paste! { + $crate::impls::paste::paste! { impl $chain { /// Returns the encoded call for `force_create` from the assets pallet pub fn force_create_asset_call( asset_id: u32, - owner: AccountId, + owner: $crate::impls::AccountId, is_sufficient: bool, - min_balance: Balance, + min_balance: $crate::impls::Balance, ) -> DoubleEncoded<()> { ::RuntimeCall::Assets(pallet_assets::Call::< ::Runtime, @@ -500,9 +503,9 @@ macro_rules! impl_assets_helpers_for_parachain { pub fn force_create_asset_xcm( origin_kind: OriginKind, asset_id: u32, - owner: AccountId, + owner: $crate::impls::AccountId, is_sufficient: bool, - min_balance: Balance, + min_balance: $crate::impls::Balance, ) -> VersionedXcm<()> { let call = Self::force_create_asset_call(asset_id, owner, is_sufficient, min_balance); xcm_transact_unpaid_execution(call, origin_kind) @@ -512,7 +515,7 @@ macro_rules! impl_assets_helpers_for_parachain { pub fn mint_asset( signed_origin: ::RuntimeOrigin, id: u32, - beneficiary: AccountId, + beneficiary: $crate::impls::AccountId, amount_to_mint: u128, ) { Self::execute_with(|| { @@ -543,7 +546,7 @@ macro_rules! impl_assets_helpers_for_parachain { id: u32, min_balance: u128, is_sufficient: bool, - asset_owner: AccountId, + asset_owner: $crate::impls::AccountId, amount_to_mint: u128, ) { // Init values for Relay Chain diff --git a/parachains/integration-tests/emulated/common/src/lib.rs b/parachains/integration-tests/emulated/common/src/lib.rs index 7ef57027c45..40f3ef91332 100644 --- a/parachains/integration-tests/emulated/common/src/lib.rs +++ b/parachains/integration-tests/emulated/common/src/lib.rs @@ -2,37 +2,16 @@ pub use lazy_static; pub mod constants; pub mod impls; -pub use codec::Encode; pub use constants::{ accounts::{ALICE, BOB}, asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama, bridge_hub_polkadot, bridge_hub_rococo, collectives, kusama, penpal, polkadot, rococo, westend, - PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, -}; -use frame_support::{ - assert_ok, instances::Instance1, parameter_types, sp_tracing, traits::fungibles::Inspect, }; +use frame_support::traits::fungibles::Inspect; pub use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler}; -pub use parachains_common::{AccountId, Balance}; -pub use paste; -use polkadot_parachain::primitives::HrmpChannelId; -pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; -pub use sp_core::{sr25519, storage::Storage, Get}; use xcm_emulator::{ assert_expected_events, bx, decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types, - helpers::weight_within_threshold, BridgeMessageHandler, Chain, DefaultMessageProcessor, ParaId, - Parachain, RelayChain, TestExt, -}; - -pub use xcm::{ - prelude::{ - AccountId32, All, BuyExecution, DepositAsset, MultiAsset, MultiAssets, MultiLocation, - OriginKind, Outcome, RefundSurplus, Transact, UnpaidExecution, VersionedXcm, Weight, - WeightLimit, WithdrawAsset, Xcm, X1, - }, - v3::Error, - DoubleEncoded, }; decl_test_relay_chains! { diff --git a/xcm/xcm-emulator/Cargo.toml b/xcm/xcm-emulator/Cargo.toml index 9a88eaf286a..1eb234eca4e 100644 --- a/xcm/xcm-emulator/Cargo.toml +++ b/xcm/xcm-emulator/Cargo.toml @@ -21,6 +21,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-message-queue = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/xcm/xcm-emulator/src/lib.rs b/xcm/xcm-emulator/src/lib.rs index a82b51948bc..065b93ae52d 100644 --- a/xcm/xcm-emulator/src/lib.rs +++ b/xcm/xcm-emulator/src/lib.rs @@ -43,8 +43,8 @@ pub use frame_support::{ pub use frame_system::{AccountInfo, Config as SystemConfig, Pallet as SystemPallet}; pub use pallet_balances::AccountData; pub use sp_arithmetic::traits::Bounded; -pub use sp_core::{sr25519, storage::Storage, Pair, H256}; -pub use sp_io::TestExternalities; +pub use sp_core::{parameter_types, sr25519, storage::Storage, Pair, H256}; +pub use sp_io::{self, TestExternalities}; pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, fmt::Debug}; pub use sp_trie::StorageProof; @@ -68,6 +68,7 @@ pub use polkadot_runtime_parachains::{ dmp, inclusion::{AggregateMessageOrigin, UmpQueueId}, }; +pub use sp_tracing; // Polkadot pub use xcm::{ @@ -358,6 +359,7 @@ macro_rules! decl_test_relay_chains { } ), + + $(,)? ) => { $( #[derive(Clone)] @@ -443,7 +445,7 @@ macro_rules! __impl_test_ext_for_relay_chain { ext.execute_with(|| { #[allow(clippy::no_effect)] $on_init; - sp_tracing::try_init_simple(); + $crate::sp_tracing::try_init_simple(); let mut block_number = ::System::block_number(); block_number = std::cmp::max(1, block_number); @@ -582,6 +584,7 @@ macro_rules! decl_test_parachains { } ), + + $(,)? ) => { $( #[derive(Clone)] @@ -684,7 +687,7 @@ macro_rules! __impl_test_ext_for_parachain { ext.execute_with(|| { #[allow(clippy::no_effect)] $on_init; - sp_tracing::try_init_simple(); + $crate::sp_tracing::try_init_simple(); let mut block_number = ::System::block_number(); block_number = std::cmp::max(1, block_number); @@ -789,8 +792,8 @@ macro_rules! __impl_test_ext_for_parachain { ); // get xcmp messages - ::ParachainSystem::on_finalize(block_number); - let collation_info = ::ParachainSystem::collect_collation_info(&mock_header); + ::ParachainSystem::on_finalize(block_number); + let collation_info = ::ParachainSystem::collect_collation_info(&mock_header); // send upward messages let relay_block_number = <$name as NetworkComponent>::Network::relay_block_number(); @@ -809,7 +812,7 @@ macro_rules! __impl_test_ext_for_parachain { // get bridge messages type NetworkBridge = <<$name as NetworkComponent>::Network as Network>::Bridge; - let bridge_messages = ::Handler::get_source_outbound_messages(); + let bridge_messages = <::Handler as $crate::BridgeMessageHandler>::get_source_outbound_messages(); // send bridged messages for msg in bridge_messages { @@ -857,6 +860,7 @@ macro_rules! decl_test_networks { } ), + + $(,)? ) => { $( pub struct $name; @@ -1014,8 +1018,8 @@ macro_rules! decl_test_networks { match dispatch_result { Err(e) => panic!("Error {:?} processing bridged message: {:?}", e, msg.clone()), Ok(()) => { - <::Source as TestExt>::ext_wrapper(|| { - <::Handler as BridgeMessageHandler>::notify_source_message_delivery(msg.id); + <::Source as $crate::TestExt>::ext_wrapper(|| { + <::Handler as $crate::BridgeMessageHandler>::notify_source_message_delivery(msg.id); }); $crate::log::debug!(target: concat!("bridge::", stringify!($name)) , "Bridged message processed {:?}", msg.clone()); } @@ -1096,6 +1100,7 @@ macro_rules! decl_test_bridges { } ), + + $(,)? ) => { $( #[derive(Debug)] @@ -1233,7 +1238,7 @@ macro_rules! bx { macro_rules! decl_test_sender_receiver_accounts_parameter_types { ( $( $chain:ident { sender: $sender:expr, receiver: $receiver:expr }),+ ) => { $crate::paste::paste! { - parameter_types! { + $crate::parameter_types! { $( pub [<$chain Sender>]: $crate::AccountId = <$chain>::account_id_of($sender); pub [<$chain Receiver>]: $crate::AccountId = <$chain>::account_id_of($receiver);