From 6ad9a3327a47e8281be1f3a7af9532e8a5e2a5d0 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Tue, 29 Aug 2023 09:51:40 +0200 Subject: [PATCH 1/7] improve hygiene & clean up --- Cargo.lock | 2 +- .../assets/asset-hub-kusama/src/lib.rs | 6 +- .../assets/asset-hub-polkadot/src/lib.rs | 6 +- .../assets/asset-hub-westend/src/lib.rs | 7 +- .../bridges/bridge-hub-rococo/src/lib.rs | 6 +- .../collectives-polkadot/src/lib.rs | 6 +- .../emulated/common/Cargo.toml | 1 - .../emulated/common/src/impls.rs | 242 ++++++++++-------- .../emulated/common/src/lib.rs | 77 +----- .../emulated/common/src/xcm_helpers.rs | 50 ++++ cumulus/xcm/xcm-emulator/Cargo.toml | 1 + cumulus/xcm/xcm-emulator/src/lib.rs | 142 +++++----- 12 files changed, 279 insertions(+), 267 deletions(-) create mode 100644 cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs diff --git a/Cargo.lock b/Cargo.lock index c755be63042b..89842929d2d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6449,7 +6449,6 @@ dependencies = [ "frame-system", "kusama-runtime", "kusama-runtime-constants", - "lazy_static", "pallet-assets", "pallet-balances", "pallet-bridge-messages", @@ -20873,6 +20872,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-tracing", "sp-trie", "xcm", "xcm-executor", diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index 2609ba4ca8dc..9a6534423c12 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/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}, @@ -29,8 +28,7 @@ pub use integration_tests_common::{ kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AccountId, AssetHubKusama, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Collectives, @@ -40,7 +38,7 @@ pub use integration_tests_common::{ PenpalKusamaBSender, PenpalPolkadotA, PenpalPolkadotAReceiver, PenpalPolkadotASender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, }; -pub use parachains_common::Balance; +pub use parachains_common::{AccountId, Balance}; pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index 9d87458f876c..df75efda5bb5 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/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}, @@ -29,9 +28,8 @@ pub use integration_tests_common::{ polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubPolkadot, - AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, PenpalPolkadotA, PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotASender, PenpalPolkadotB, diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index b7f064e7d6ea..51d74089b803 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -17,7 +17,7 @@ pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, - instances::{Instance1, Instance2}, + instances::Instance2, pallet_prelude::Weight, sp_runtime::{AccountId32, DispatchError, DispatchResult, ModuleError, MultiAddress}, traits::{fungibles::Inspect, OriginTrait}, @@ -30,9 +30,8 @@ pub use integration_tests_common::{ westend::ED as WESTEND_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubWestend, - AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, Collectives, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, WestendMockNet, WestendPallet, WestendReceiver, WestendSender, diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 2a4927d857c3..712bad186b13 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/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}, @@ -30,9 +29,8 @@ pub use integration_tests_common::{ kusama::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubRococo, - AssetHubRococoPallet, AssetHubRococoReceiver, AssetHubRococoSender, AssetHubWococo, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + AssetHubRococo, AssetHubRococoPallet, AssetHubRococoReceiver, AssetHubRococoSender, AssetHubWococo, AssetHubWococoPallet, AssetHubWococoReceiver, AssetHubWococoSender, BridgeHubRococo, BridgeHubRococoPallet, BridgeHubRococoReceiver, BridgeHubRococoSender, BridgeHubWococo, BridgeHubWococoPallet, BridgeHubWococoReceiver, BridgeHubWococoSender, Collectives, diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index b71ee65a2221..1aa6009ea7ff 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/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}, @@ -29,9 +28,8 @@ pub use integration_tests_common::{ polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubPolkadot, - AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, PenpalPolkadotA, PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotASender, PenpalPolkadotB, diff --git a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml index 0122379b7d83..5403384095d2 100644 --- a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml @@ -7,7 +7,6 @@ description = "Common resources for integration testing with xcm-emulator" [dependencies] codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } -lazy_static = "1.4.0" paste = "1.0.14" # Substrate diff --git a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs index 92c68f4dd613..8e00ad3e9077 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs @@ -1,15 +1,38 @@ use super::{BridgeHubRococo, BridgeHubWococo}; -// pub use paste; +pub use crate::constants::{PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD}; +pub use crate::xcm_helpers::xcm_transact_unpaid_execution; use bp_messages::{ target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, LaneId, MessageKey, OutboundLaneData, }; use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; -use codec::Decode; -pub use cumulus_primitives_core::{DmpMessageHandler, XcmpMessageHandler}; +pub use codec::{Decode, Encode}; +pub use frame_support::{traits::fungibles::Inspect, assert_ok}; +pub use cumulus_primitives_core::{relay_chain::HrmpChannelId, DmpMessageHandler, ParaId, XcmpMessageHandler}; use pallet_bridge_messages::{Config, Instance1, Instance2, OutboundLanes, Pallet}; use sp_core::Get; -use xcm_emulator::{BridgeMessage, BridgeMessageDispatchError, BridgeMessageHandler, Chain}; +pub use xcm_emulator::{ + helpers::weight_within_threshold, BridgeMessageHandler, Chain, DefaultMessageProcessor, + BridgeMessage, BridgeMessageDispatchError, TestExt, Parachain, RelayChain, +}; +pub use paste; +pub use parachains_common::{AccountId, Balance}; +pub use polkadot_runtime_parachains::{ + dmp, + inclusion::{AggregateMessageOrigin, UmpQueueId}, +}; +pub use xcm_emulator::{ + assert_expected_events, bx, +}; +pub use xcm::{ + prelude::{ + OriginKind, Outcome, VersionedXcm, Weight, + }, + v3::Error, + DoubleEncoded, +}; + + pub struct BridgeHubMessageHandler { _marker: std::marker::PhantomData<(S, T, I)>, @@ -129,14 +152,14 @@ 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)>) { - Self::execute_with(|| { + pub fn fund_accounts(accounts: Vec<($crate::impls::AccountId, $crate::impls::Balance)>) { + ::execute_with(|| { for account in accounts { - assert_ok!(]>::Balances::force_set_balance( - ::RuntimeOrigin::root(), + $crate::impls::assert_ok!(]>::Balances::force_set_balance( + ::RuntimeOrigin::root(), account.0.into(), account.1, )); @@ -144,8 +167,8 @@ 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 { - let sovereign_account = Self::sovereign_account_id_of_child_para(para_id); + pub fn fund_para_sovereign(amount: $crate::impls::Balance, para_id: $crate::impls::ParaId) -> sp_runtime::AccountId32 { + let sovereign_account = ::sovereign_account_id_of_child_para(para_id); Self::fund_accounts(vec![(sovereign_account.clone(), amount)]); sovereign_account } @@ -157,20 +180,20 @@ macro_rules! impl_accounts_helpers_for_relay_chain { #[macro_export] macro_rules! impl_assert_events_helpers_for_relay_chain { ( $chain:ident ) => { - $crate::paste::paste! { - type [<$chain RuntimeEvent>] = <$chain as Chain>::RuntimeEvent; + $crate::impls::paste::paste! { + type [<$chain RuntimeEvent>] = <$chain as $crate::impls::Chain>::RuntimeEvent; impl $chain { /// Asserts a dispatchable is completely executed and XCM sent - pub fn assert_xcm_pallet_attempted_complete(expected_weight: Option) { - assert_expected_events!( + pub fn assert_xcm_pallet_attempted_complete(expected_weight: Option<$crate::impls::Weight>) { + $crate::impls::assert_expected_events!( Self, vec![ [<$chain RuntimeEvent>]::XcmPallet( - pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) } + pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } ) => { - weight: weight_within_threshold( - (REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), expected_weight.unwrap_or(*weight), *weight ), @@ -181,18 +204,18 @@ macro_rules! impl_assert_events_helpers_for_relay_chain { /// Asserts a dispatchable is incompletely executed and XCM sent pub fn assert_xcm_pallet_attempted_incomplete( - expected_weight: Option, - expected_error: Option, + expected_weight: Option<$crate::impls::Weight>, + expected_error: Option<$crate::impls::Error>, ) { - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ // Dispatchable is properly executed and XCM message sent [<$chain RuntimeEvent>]::XcmPallet( - pallet_xcm::Event::Attempted { outcome: Outcome::Incomplete(weight, error) } + pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } ) => { - weight: weight_within_threshold( - (REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), expected_weight.unwrap_or(*weight), *weight ), @@ -204,7 +227,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain { /// Asserts a XCM message is sent pub fn assert_xcm_pallet_sent() { - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ [<$chain RuntimeEvent>]::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, @@ -215,22 +238,22 @@ macro_rules! impl_assert_events_helpers_for_relay_chain { /// Asserts a XCM from System Parachain is succesfully received and proccessed pub fn assert_ump_queue_processed( expected_success: bool, - expected_id: Option, - expected_weight: Option, + expected_id: Option<$crate::impls::ParaId>, + expected_weight: Option<$crate::impls::Weight>, ) { - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ // XCM is succesfully received and proccessed [<$chain RuntimeEvent>]::MessageQueue(pallet_message_queue::Event::Processed { - origin: AggregateMessageOrigin::Ump(UmpQueueId::Para(id)), + origin: $crate::impls::AggregateMessageOrigin::Ump($crate::impls::UmpQueueId::Para(id)), weight_used, success, .. }) => { id: *id == expected_id.unwrap_or(*id), - weight_used: weight_within_threshold( - (REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), + weight_used: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), expected_weight.unwrap_or(*weight_used), *weight_used ), @@ -247,16 +270,18 @@ 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( - recipient_para_id: ParaId, + recipient_para_id: $crate::impls::ParaId, max_capacity: u32, max_message_size: u32, - ) -> DoubleEncoded<()> { - ::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< - ::Runtime, + ) -> $crate::impls::DoubleEncoded<()> { + use $crate::impls::Encode; + + ::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + ::Runtime, >::hrmp_init_open_channel { recipient: recipient_para_id, proposed_max_capacity: max_capacity, @@ -266,9 +291,11 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { .into() } /// Recipient Parachain accept the open request from another Parachain - pub fn accept_open_channel_call(sender_para_id: ParaId) -> DoubleEncoded<()> { - ::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< - ::Runtime, + pub fn accept_open_channel_call(sender_para_id: $crate::impls::ParaId) -> $crate::impls::DoubleEncoded<()> { + use $crate::impls::Encode; + + ::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + ::Runtime, >::hrmp_accept_open_channel { sender: sender_para_id, }) @@ -277,12 +304,14 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { } /// A root origin force to open a channel between two Parachains - pub fn force_process_hrmp_open(sender: ParaId, recipient: ParaId) { - Self::execute_with(|| { + pub fn force_process_hrmp_open(sender: $crate::impls::ParaId, recipient: $crate::impls::ParaId) { + use $crate::impls::{Chain, HrmpChannelId}; + + ::execute_with(|| { let relay_root_origin = ::RuntimeOrigin::root(); // Force process HRMP open channel requests without waiting for the next session - assert_ok!(]>::Hrmp::force_process_hrmp_open( + $crate::impls::assert_ok!(]>::Hrmp::force_process_hrmp_open( relay_root_origin, 0 )); @@ -305,14 +334,14 @@ 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)>) { - Self::execute_with(|| { + pub fn fund_accounts(accounts: Vec<($crate::impls::AccountId, $crate::impls::Balance)>) { + ::execute_with(|| { for account in accounts { - assert_ok!(]>::Balances::force_set_balance( - ::RuntimeOrigin::root(), + $crate::impls::assert_ok!(]>::Balances::force_set_balance( + ::RuntimeOrigin::root(), account.0.into(), account.1, )); @@ -327,20 +356,20 @@ macro_rules! impl_accounts_helpers_for_parachain { #[macro_export] macro_rules! impl_assert_events_helpers_for_parachain { ( $chain:ident ) => { - $crate::paste::paste! { - type [<$chain RuntimeEvent>] = <$chain as Chain>::RuntimeEvent; + $crate::impls::paste::paste! { + type [<$chain RuntimeEvent>] = <$chain as $crate::impls::Chain>::RuntimeEvent; impl $chain { /// Asserts a dispatchable is completely executed and XCM sent - pub fn assert_xcm_pallet_attempted_complete(expected_weight: Option) { - assert_expected_events!( + pub fn assert_xcm_pallet_attempted_complete(expected_weight: Option<$crate::impls::Weight>) { + $crate::impls::assert_expected_events!( Self, vec![ [<$chain RuntimeEvent>]::PolkadotXcm( - pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) } + pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } ) => { - weight: weight_within_threshold( - (REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), expected_weight.unwrap_or(*weight), *weight ), @@ -351,18 +380,18 @@ macro_rules! impl_assert_events_helpers_for_parachain { /// Asserts a dispatchable is incompletely executed and XCM sent pub fn assert_xcm_pallet_attempted_incomplete( - expected_weight: Option, - expected_error: Option, + expected_weight: Option<$crate::impls::Weight>, + expected_error: Option<$crate::impls::Error>, ) { - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ // Dispatchable is properly executed and XCM message sent [<$chain RuntimeEvent>]::PolkadotXcm( - pallet_xcm::Event::Attempted { outcome: Outcome::Incomplete(weight, error) } + pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } ) => { - weight: weight_within_threshold( - (REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), expected_weight.unwrap_or(*weight), *weight ), @@ -373,13 +402,13 @@ macro_rules! impl_assert_events_helpers_for_parachain { } /// Asserts a dispatchable throws and error when trying to be sent - pub fn assert_xcm_pallet_attempted_error(expected_error: Option) { - assert_expected_events!( + pub fn assert_xcm_pallet_attempted_error(expected_error: Option<$crate::impls::Error>) { + $crate::impls::assert_expected_events!( Self, vec![ // Execution fails in the origin with `Barrier` [<$chain RuntimeEvent>]::PolkadotXcm( - pallet_xcm::Event::Attempted { outcome: Outcome::Error(error) } + pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Error(error) } ) => { error: *error == expected_error.unwrap_or(*error), }, @@ -389,7 +418,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { /// Asserts a XCM message is sent pub fn assert_xcm_pallet_sent() { - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ [<$chain RuntimeEvent>]::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, @@ -399,7 +428,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { /// Asserts a XCM message is sent to Relay Chain pub fn assert_parachain_system_ump_sent() { - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ [<$chain RuntimeEvent>]::ParachainSystem( @@ -410,15 +439,15 @@ macro_rules! impl_assert_events_helpers_for_parachain { } /// Asserts a XCM from Relay Chain is completely executed - pub fn assert_dmp_queue_complete(expected_weight: Option) { - assert_expected_events!( + pub fn assert_dmp_queue_complete(expected_weight: Option<$crate::impls::Weight>) { + $crate::impls::assert_expected_events!( Self, vec![ [<$chain RuntimeEvent>]::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { - outcome: Outcome::Complete(weight), .. + outcome: $crate::impls::Outcome::Complete(weight), .. }) => { - weight: weight_within_threshold( - (REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), expected_weight.unwrap_or(*weight), *weight ), @@ -429,17 +458,17 @@ macro_rules! impl_assert_events_helpers_for_parachain { /// Asserts a XCM from Relay Chain is incompletely executed pub fn assert_dmp_queue_incomplete( - expected_weight: Option, - expected_error: Option, + expected_weight: Option<$crate::impls::Weight>, + expected_error: Option<$crate::impls::Error>, ) { - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ [<$chain RuntimeEvent>]::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { - outcome: Outcome::Incomplete(weight, error), .. + outcome: $crate::impls::Outcome::Incomplete(weight, error), .. }) => { - weight: weight_within_threshold( - (REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), expected_weight.unwrap_or(*weight), *weight ), @@ -450,15 +479,15 @@ macro_rules! impl_assert_events_helpers_for_parachain { } /// Asserts a XCM from another Parachain is completely executed - pub fn assert_xcmp_queue_success(expected_weight: Option) { - assert_expected_events!( + pub fn assert_xcmp_queue_success(expected_weight: Option<$crate::impls::Weight>) { + $crate::impls::assert_expected_events!( Self, vec![ [<$chain RuntimeEvent>]::XcmpQueue( cumulus_pallet_xcmp_queue::Event::Success { weight, .. } ) => { - weight: weight_within_threshold( - (REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), expected_weight.unwrap_or(*weight), *weight ), @@ -474,18 +503,20 @@ 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, - ) -> DoubleEncoded<()> { + min_balance: $crate::impls::Balance, + ) -> $crate::impls::DoubleEncoded<()> { + use $crate::impls::{Chain, Encode}; + ::RuntimeCall::Assets(pallet_assets::Call::< ::Runtime, - Instance1, + pallet_assets::Instance1, >::force_create { id: asset_id.into(), owner: owner.into(), @@ -498,34 +529,34 @@ macro_rules! impl_assets_helpers_for_parachain { /// Returns a `VersionedXcm` for `force_create` from the assets pallet pub fn force_create_asset_xcm( - origin_kind: OriginKind, + origin_kind: $crate::impls::OriginKind, asset_id: u32, - owner: AccountId, + owner: $crate::impls::AccountId, is_sufficient: bool, - min_balance: Balance, - ) -> VersionedXcm<()> { + min_balance: $crate::impls::Balance, + ) -> $crate::impls::VersionedXcm<()> { let call = Self::force_create_asset_call(asset_id, owner, is_sufficient, min_balance); - xcm_transact_unpaid_execution(call, origin_kind) + $crate::impls::xcm_transact_unpaid_execution(call, origin_kind) } /// Mint assets making use of the assets pallet pub fn mint_asset( - signed_origin: ::RuntimeOrigin, + signed_origin: ::RuntimeOrigin, id: u32, - beneficiary: AccountId, + beneficiary: $crate::impls::AccountId, amount_to_mint: u128, ) { - Self::execute_with(|| { - assert_ok!(]>::Assets::mint( + ::execute_with(|| { + $crate::impls::assert_ok!(]>::Assets::mint( signed_origin, id.into(), beneficiary.clone().into(), amount_to_mint )); - type RuntimeEvent = <$chain as Chain>::RuntimeEvent; + type RuntimeEvent = <$chain as $crate::impls::Chain>::RuntimeEvent; - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount }) => { @@ -543,22 +574,23 @@ 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, ) { + use $crate::impls::{bx, Chain, RelayChain, Parachain, Inspect}; // Init values for Relay Chain let root_origin = <$relay_chain as Chain>::RuntimeOrigin::root(); - let destination = <$relay_chain>::child_location_of(<$chain>::para_id()); + let destination = <$relay_chain as RelayChain>::child_location_of(<$chain as Parachain>::para_id()); let xcm = Self::force_create_asset_xcm( - OriginKind::Superuser, + $crate::impls::OriginKind::Superuser, id, asset_owner.clone(), is_sufficient, min_balance, ); - <$relay_chain>::execute_with(|| { - assert_ok!(<$relay_chain as [<$relay_chain Pallet>]>::XcmPallet::send( + <$relay_chain as $crate::impls::TestExt>::execute_with(|| { + $crate::impls::assert_ok!(<$relay_chain as [<$relay_chain Pallet>]>::XcmPallet::send( root_origin, bx!(destination.into()), bx!(xcm), @@ -567,12 +599,12 @@ macro_rules! impl_assets_helpers_for_parachain { <$relay_chain>::assert_xcm_pallet_sent(); }); - Self::execute_with(|| { - Self::assert_dmp_queue_complete(Some(Weight::from_parts(1_019_445_000, 200_000))); + ::execute_with(|| { + Self::assert_dmp_queue_complete(Some($crate::impls::Weight::from_parts(1_019_445_000, 200_000))); - type RuntimeEvent = <$chain as Chain>::RuntimeEvent; + type RuntimeEvent = <$chain as $crate::impls::Chain>::RuntimeEvent; - assert_expected_events!( + $crate::impls::assert_expected_events!( Self, vec![ // Asset has been created diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index f6d589700360..cf9fb42b8d52 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -1,42 +1,18 @@ -pub use lazy_static; pub mod constants; pub mod impls; +pub mod xcm_helpers; -pub use codec::Encode; -pub use constants::{ +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, - traits::{fungibles::Inspect, Hooks}, -}; -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 sp_tracing; +use frame_support::traits::OnInitialize; +use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler}; use xcm_emulator::{ - assert_expected_events, bx, decl_test_bridges, decl_test_networks, decl_test_parachains, + 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, + DefaultMessageProcessor, }; decl_test_relay_chains! { @@ -565,44 +541,3 @@ decl_test_sender_receiver_accounts_parameter_types! { PenpalWestendA { sender: ALICE, receiver: BOB }, PenpalRococoA { sender: ALICE, receiver: BOB } } - -/// Helper method to build a XCM with a `Transact` instruction and paying for its execution -pub fn xcm_transact_paid_execution( - call: DoubleEncoded<()>, - origin_kind: OriginKind, - native_asset: MultiAsset, - beneficiary: AccountId, -) -> VersionedXcm<()> { - let weight_limit = WeightLimit::Unlimited; - let require_weight_at_most = Weight::from_parts(1000000000, 200000); - let native_assets: MultiAssets = native_asset.clone().into(); - - VersionedXcm::from(Xcm(vec![ - WithdrawAsset(native_assets), - BuyExecution { fees: native_asset, weight_limit }, - Transact { require_weight_at_most, origin_kind, call }, - RefundSurplus, - DepositAsset { - assets: All.into(), - beneficiary: MultiLocation { - parents: 0, - interior: X1(AccountId32 { network: None, id: beneficiary.into() }), - }, - }, - ])) -} - -/// Helper method to build a XCM with a `Transact` instruction without paying for its execution -pub fn xcm_transact_unpaid_execution( - call: DoubleEncoded<()>, - origin_kind: OriginKind, -) -> VersionedXcm<()> { - let weight_limit = WeightLimit::Unlimited; - let require_weight_at_most = Weight::from_parts(1000000000, 200000); - let check_origin = None; - - VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit, check_origin }, - Transact { require_weight_at_most, origin_kind, call }, - ])) -} diff --git a/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs b/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs new file mode 100644 index 000000000000..be2dc25394d5 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs @@ -0,0 +1,50 @@ +use parachains_common::AccountId; +use xcm::{ + prelude::{ + AccountId32, All, BuyExecution, DepositAsset, MultiAsset, MultiAssets, MultiLocation, + OriginKind, RefundSurplus, Transact, UnpaidExecution, VersionedXcm, Weight, + WeightLimit, WithdrawAsset, Xcm, X1, + }, + DoubleEncoded, +}; + +/// Helper method to build a XCM with a `Transact` instruction and paying for its execution +pub fn xcm_transact_paid_execution( + call: DoubleEncoded<()>, + origin_kind: OriginKind, + native_asset: MultiAsset, + beneficiary: AccountId, +) -> VersionedXcm<()> { + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1000000000, 200000); + let native_assets: MultiAssets = native_asset.clone().into(); + + VersionedXcm::from(Xcm(vec![ + WithdrawAsset(native_assets), + BuyExecution { fees: native_asset, weight_limit }, + Transact { require_weight_at_most, origin_kind, call }, + RefundSurplus, + DepositAsset { + assets: All.into(), + beneficiary: MultiLocation { + parents: 0, + interior: X1(AccountId32 { network: None, id: beneficiary.into() }), + }, + }, + ])) +} + +/// Helper method to build a XCM with a `Transact` instruction without paying for its execution +pub fn xcm_transact_unpaid_execution( + call: DoubleEncoded<()>, + origin_kind: OriginKind, +) -> VersionedXcm<()> { + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1000000000, 200000); + let check_origin = None; + + VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit, check_origin }, + Transact { require_weight_at_most, origin_kind, call }, + ])) +} diff --git a/cumulus/xcm/xcm-emulator/Cargo.toml b/cumulus/xcm/xcm-emulator/Cargo.toml index 4d6bf1422b0a..e92753a7677c 100644 --- a/cumulus/xcm/xcm-emulator/Cargo.toml +++ b/cumulus/xcm/xcm-emulator/Cargo.toml @@ -21,6 +21,7 @@ sp-std = { path = "../../../substrate/primitives/std" } sp-runtime = { path = "../../../substrate/primitives/runtime" } sp-arithmetic = { path = "../../../substrate/primitives/arithmetic" } sp-trie = { path = "../../../substrate/primitives/trie" } +sp-tracing = { path = "../../../substrate/primitives/tracing" } pallet-balances = { path = "../../../substrate/frame/balances" } pallet-message-queue = { path = "../../../substrate/frame/message-queue" } diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index 72f88ee7fa97..dc91a3d74d17 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -25,14 +25,13 @@ pub use std::{ fmt, marker::PhantomData, ops::Deref, - sync::{Condvar, Mutex}, + sync::Mutex, thread::LocalKey, }; // Substrate pub use frame_support::{ assert_ok, - dispatch::EncodeLike, sp_runtime::{AccountId32, DispatchResult}, traits::{ tokens::currency::Currency, EnqueueMessage, Get, Hooks, OriginTrait, ProcessMessage, @@ -44,10 +43,11 @@ 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; +pub use sp_tracing; //Cumulus pub use cumulus_pallet_dmp_queue; @@ -55,8 +55,8 @@ pub use cumulus_pallet_parachain_system::{self, Pallet as ParachainSystemPallet} pub use cumulus_pallet_xcmp_queue::{Config as XcmpQueueConfig, Pallet as XcmpQueuePallet}; pub use cumulus_primitives_core::{ self, - relay_chain::{BlockNumber as RelayBlockNumber, HeadData}, - DmpMessageHandler, ParaId, PersistedValidationData, XcmpMessageHandler, + relay_chain::{BlockNumber as RelayBlockNumber, HeadData, HrmpChannelId}, + AbridgedHrmpChannel, DmpMessageHandler, ParaId, PersistedValidationData, XcmpMessageHandler, }; pub use cumulus_primitives_parachain_inherent::ParachainInherentData; pub use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; @@ -363,23 +363,24 @@ macro_rules! decl_test_relay_chains { } ), + + $(,)? ) => { $( #[derive(Clone)] pub struct $name; - impl Chain for $name { + impl $crate::Chain for $name { type Runtime = $runtime::Runtime; type RuntimeCall = $runtime::RuntimeCall; type RuntimeOrigin = $runtime::RuntimeOrigin; type RuntimeEvent = $runtime::RuntimeEvent; type System = $crate::SystemPallet::; - fn account_data_of(account: AccountId) -> $crate::AccountData { - Self::ext_wrapper(|| $crate::SystemPallet::::account(account).data.into()) + fn account_data_of(account: $crate::AccountId) -> $crate::AccountData<$crate::Balance> { + ::ext_wrapper(|| $crate::SystemPallet::::account(account).data.into()) } - fn events() -> Vec<::RuntimeEvent> { + fn events() -> Vec<::RuntimeEvent> { Self::System::events() .iter() .map(|record| record.event.clone()) @@ -387,7 +388,7 @@ macro_rules! decl_test_relay_chains { } } - impl RelayChain for $name { + impl $crate::RelayChain for $name { type SovereignAccountOf = $sovereign_acc_of; type MessageProcessor = $mp; } @@ -431,7 +432,7 @@ macro_rules! __impl_test_ext_for_relay_chain { (@impl $name:ident, $genesis:expr, $on_init:expr, $api_version:ident, $local_ext:ident, $global_ext:ident) => { thread_local! { pub static $local_ext: $crate::RefCell<$crate::TestExternalities> - = $crate::RefCell::new(<$name>::build_new_ext($genesis)); + = $crate::RefCell::new(<$name as $crate::TestExt>::build_new_ext($genesis)); } $crate::lazy_static! { @@ -439,11 +440,11 @@ macro_rules! __impl_test_ext_for_relay_chain { = $crate::Mutex::new($crate::RefCell::new($crate::HashMap::new())); } - impl TestExt for $name { + impl $crate::TestExt for $name { fn build_new_ext(storage: $crate::Storage) -> $crate::TestExternalities { - use $crate::{NetworkComponent, Network, Chain}; + use $crate::{sp_tracing, NetworkComponent, Network, Chain, TestExternalities}; - let mut ext = $crate::TestExternalities::new(storage); + let mut ext = TestExternalities::new(storage); ext.execute_with(|| { #[allow(clippy::no_effect)] @@ -513,7 +514,7 @@ macro_rules! __impl_test_ext_for_relay_chain { } fn execute_with(execute: impl FnOnce() -> R) -> R { - use $crate::{NetworkComponent, Network}; + use $crate::{Chain, NetworkComponent, Network}; // Make sure the Network is initialized <$name as NetworkComponent>::Network::init(); @@ -528,7 +529,7 @@ macro_rules! __impl_test_ext_for_relay_chain { //TODO: mark sent count & filter out sent msg for para_id in<$name as NetworkComponent>::Network::para_ids() { // downward messages - let downward_messages = ::Runtime::dmq_contents(para_id.into()) + let downward_messages = ::Runtime::dmq_contents(para_id.into()) .into_iter() .map(|inbound| (inbound.sent_at, inbound.msg)); if downward_messages.len() == 0 { @@ -541,7 +542,7 @@ macro_rules! __impl_test_ext_for_relay_chain { } // log events - Self::events().iter().for_each(|event| { + ::events().iter().for_each(|event| { $crate::log::debug!(target: concat!("events::", stringify!($name)), "{:?}", event); }); @@ -587,23 +588,24 @@ macro_rules! decl_test_parachains { } ), + + $(,)? ) => { $( #[derive(Clone)] pub struct $name; - impl Chain for $name { + impl $crate::Chain for $name { type Runtime = $runtime::Runtime; type RuntimeCall = $runtime::RuntimeCall; type RuntimeOrigin = $runtime::RuntimeOrigin; type RuntimeEvent = $runtime::RuntimeEvent; type System = $crate::SystemPallet::; - fn account_data_of(account: AccountId) -> $crate::AccountData { - Self::ext_wrapper(|| $crate::SystemPallet::::account(account).data.into()) + fn account_data_of(account: $crate::AccountId) -> $crate::AccountData<$crate::Balance> { + ::ext_wrapper(|| $crate::SystemPallet::::account(account).data.into()) } - fn events() -> Vec<::RuntimeEvent> { + fn events() -> Vec<::RuntimeEvent> { Self::System::events() .iter() .map(|record| record.event.clone()) @@ -611,25 +613,25 @@ macro_rules! decl_test_parachains { } } - impl Parachain for $name { + impl $crate::Parachain for $name { type XcmpMessageHandler = $xcmp_message_handler; type DmpMessageHandler = $dmp_message_handler; type LocationToAccountId = $location_to_account; - type ParachainSystem = $crate::ParachainSystemPallet<::Runtime>; + type ParachainSystem = $crate::ParachainSystemPallet<::Runtime>; type ParachainInfo = $parachain_info; fn init() { - use $crate::{Network, NetworkComponent, Hooks}; + use $crate::{Chain, HeadData, Network, NetworkComponent, Hooks, Encode, Parachain}; let para_id = Self::para_id(); - ::ext_wrapper(|| { + ::ext_wrapper(|| { let block_number = ::System::block_number(); let mut relay_block_number = ::Network::relay_block_number(); // Get parent head data let header = ::System::finalize(); - let parent_head_data = $crate::HeadData(header.encode()); + let parent_head_data = HeadData(header.encode()); $crate::LAST_HEAD.with(|b| b.borrow_mut() .get_mut(::Network::name()) @@ -639,7 +641,7 @@ macro_rules! decl_test_parachains { let next_block_number = block_number + 1; ::System::initialize(&next_block_number, &header.hash(), &Default::default()); - ::ParachainSystem::on_initialize(next_block_number); + <::ParachainSystem as Hooks<$crate::BlockNumber>>::on_initialize(next_block_number); }); } } @@ -676,7 +678,7 @@ macro_rules! __impl_test_ext_for_parachain { (@impl $name:ident, $genesis:expr, $on_init:expr, $local_ext:ident, $global_ext:ident) => { thread_local! { pub static $local_ext: $crate::RefCell<$crate::TestExternalities> - = $crate::RefCell::new(<$name>::build_new_ext($genesis)); + = $crate::RefCell::new(<$name as $crate::TestExt>::build_new_ext($genesis)); } $crate::lazy_static! { @@ -684,16 +686,16 @@ macro_rules! __impl_test_ext_for_parachain { = $crate::Mutex::new($crate::RefCell::new($crate::HashMap::new())); } - impl TestExt for $name { + impl $crate::TestExt for $name { fn build_new_ext(storage: $crate::Storage) -> $crate::TestExternalities { - use $crate::{NetworkComponent, Network, Chain}; + use $crate::{NetworkComponent, Network, TestExternalities, Chain}; - let mut ext = $crate::TestExternalities::new(storage); + let mut ext = TestExternalities::new(storage); 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); @@ -758,7 +760,7 @@ macro_rules! __impl_test_ext_for_parachain { } fn execute_with(execute: impl FnOnce() -> R) -> R { - use $crate::{Get, Hooks, NetworkComponent, Network, Bridge}; + use $crate::{Chain, Get, Hooks, HeadData, NetworkComponent, Network, Bridge, Parachain}; use sp_core::Encode; use sp_runtime::traits::BlakeTwo256; use polkadot_primitives::HashT; @@ -766,7 +768,7 @@ macro_rules! __impl_test_ext_for_parachain { // Make sure the Network is initialized <$name as NetworkComponent>::Network::init(); - let para_id = <$name>::para_id().into(); + let para_id = <$name as Parachain>::para_id().into(); // Initialize block $local_ext.with(|v| { @@ -820,7 +822,7 @@ macro_rules! __impl_test_ext_for_parachain { $crate::LAST_HEAD.with(|b| b.borrow_mut() .get_mut(::Network::name()) .expect("network not initialized?") - .insert(para_id.into(), $crate::HeadData(created_header.encode())) + .insert(para_id.into(), HeadData(created_header.encode())) ); let collation_info = ::ParachainSystem::collect_collation_info(&mock_header); @@ -842,7 +844,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 { @@ -850,17 +852,17 @@ macro_rules! __impl_test_ext_for_parachain { } // log events - Self::events().iter().for_each(|event| { + ::events().iter().for_each(|event| { $crate::log::debug!(target: concat!("events::", stringify!($name)), "{:?}", event); }); // clean events - ::System::reset_events(); + ::System::reset_events(); // reinitialize before next call. let next_block_number = block_number + 1; - ::System::initialize(&next_block_number, &created_header.hash(), &Default::default()); - ::ParachainSystem::on_initialize(next_block_number); + ::System::initialize(&next_block_number, &created_header.hash(), &Default::default()); + <::ParachainSystem as Hooks<$crate::BlockNumber>>::on_initialize(next_block_number); }) }); @@ -895,6 +897,7 @@ macro_rules! decl_test_networks { } ), + + $(,)? ) => { $( pub struct $name; @@ -934,25 +937,25 @@ macro_rules! decl_test_networks { $crate::PARA_IDS.with(|b| b.borrow_mut().insert(Self::name().to_string(), Self::para_ids())); $crate::LAST_HEAD.with(|b| b.borrow_mut().insert(Self::name().to_string(), $crate::HashMap::new())); - $( <$parachain>::init(); )* + $( <$parachain as $crate::Parachain>::init(); )* } } fn para_ids() -> Vec { vec![$( - <$parachain>::para_id().into(), + <$parachain as $crate::Parachain>::para_id().into(), )*] } fn relay_block_number() -> u32 { - Self::Relay::ext_wrapper(|| { - ::System::block_number() + ::ext_wrapper(|| { + ::System::block_number() }) } fn set_relay_block_number(number: u32) { - Self::Relay::ext_wrapper(|| { - ::System::set_block_number(number); + ::ext_wrapper(|| { + ::System::set_block_number(number); }) } @@ -973,13 +976,13 @@ macro_rules! decl_test_networks { } fn process_downward_messages() { - use $crate::{DmpMessageHandler, Bounded}; + use $crate::{DmpMessageHandler, Bounded, Parachain}; use polkadot_parachain::primitives::RelayChainBlockNumber; while let Some((to_para_id, messages)) = $crate::DOWNWARD_MESSAGES.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().pop_front()) { $( - let para_id: u32 = <$parachain>::para_id().into(); + let para_id: u32 = <$parachain as Parachain>::para_id().into(); if $crate::PARA_IDS.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().contains(&to_para_id)) && para_id == to_para_id { let mut msg_dedup: Vec<(RelayChainBlockNumber, Vec)> = Vec::new(); @@ -992,7 +995,7 @@ macro_rules! decl_test_networks { !$crate::DMP_DONE.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap_or(&mut $crate::VecDeque::new()).contains(&(to_para_id, m.0, m.1.clone()))) }).collect::)>>(); if msgs.len() != 0 { - <$parachain>::ext_wrapper(|| { + <$parachain as $crate::TestExt>::ext_wrapper(|| { <$parachain as Parachain>::DmpMessageHandler::handle_dmp_messages(msgs.clone().into_iter(), $crate::Weight::max_value()); }); $crate::log::debug!(target: concat!("dmp::", stringify!($name)) , "DMP messages processed {:?} to para_id {:?}", msgs.clone(), &to_para_id); @@ -1006,16 +1009,16 @@ macro_rules! decl_test_networks { } fn process_horizontal_messages() { - use $crate::{XcmpMessageHandler, Bounded}; + use $crate::{XcmpMessageHandler, Bounded, Parachain}; while let Some((to_para_id, messages)) = $crate::HORIZONTAL_MESSAGES.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().pop_front()) { let iter = messages.iter().map(|(p, b, m)| (*p, *b, &m[..])).collect::>().into_iter(); $( - let para_id: u32 = <$parachain>::para_id().into(); + let para_id: u32 = <$parachain as Parachain>::para_id().into(); if $crate::PARA_IDS.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().contains(&to_para_id)) && para_id == to_para_id { - <$parachain>::ext_wrapper(|| { + <$parachain as $crate::TestExt>::ext_wrapper(|| { <$parachain as Parachain>::XcmpMessageHandler::handle_xcmp_messages(iter.clone(), $crate::Weight::max_value()); }); $crate::log::debug!(target: concat!("hrmp::", stringify!($name)) , "HRMP messages processed {:?} to para_id {:?}", &messages, &to_para_id); @@ -1025,12 +1028,12 @@ macro_rules! decl_test_networks { } fn process_upward_messages() { - use $crate::{Bounded, ProcessMessage, WeightMeter}; + use $crate::{Bounded, ProcessMessage}; use sp_core::Encode; while let Some((from_para_id, msg)) = $crate::UPWARD_MESSAGES.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().pop_front()) { - let mut weight_meter = WeightMeter::max_limit(); - <$relay_chain>::ext_wrapper(|| { - let _ = <$relay_chain as RelayChain>::MessageProcessor::process_message( + let mut weight_meter = $crate::WeightMeter::max_limit(); + <$relay_chain as $crate::TestExt>::ext_wrapper(|| { + let _ = <$relay_chain as $crate::RelayChain>::MessageProcessor::process_message( &msg[..], from_para_id.into(), &mut weight_meter, @@ -1042,19 +1045,19 @@ macro_rules! decl_test_networks { } fn process_bridged_messages() { - use $crate::Bridge; + use $crate::{Bridge, BridgeMessageHandler, TestExt}; // Make sure both, including the target `Network` are initialized ::init(); while let Some(msg) = $crate::BRIDGED_MESSAGES.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().pop_front()) { - let dispatch_result = <::Target as TestExt>::ext_wrapper(|| { + let dispatch_result = <::Target as TestExt>::ext_wrapper(|| { <::Handler as BridgeMessageHandler>::dispatch_target_inbound_message(msg.clone()) }); match dispatch_result { Err(e) => panic!("Error {:?} processing bridged message: {:?}", e, msg.clone()), Ok(()) => { - <::Source as TestExt>::ext_wrapper(|| { + <::Source as TestExt>::ext_wrapper(|| { <::Handler as BridgeMessageHandler>::notify_source_message_delivery(msg.id); }); $crate::log::debug!(target: concat!("bridge::", stringify!($name)) , "Bridged message processed {:?}", msg.clone()); @@ -1068,7 +1071,7 @@ macro_rules! decl_test_networks { relay_parent_number: u32, parent_head_data: $crate::HeadData, ) -> $crate::ParachainInherentData { - use $crate::cumulus_primitives_core::{relay_chain::{HeadData, HrmpChannelId}, AbridgedHrmpChannel}; + use $crate::{HeadData, HrmpChannelId, AbridgedHrmpChannel}; let mut sproof = $crate::RelayStateSproofBuilder::default(); sproof.para_id = para_id.into(); @@ -1139,6 +1142,7 @@ macro_rules! decl_test_bridges { } ), + + $(,)? ) => { $( #[derive(Debug)] @@ -1166,8 +1170,8 @@ macro_rules! __impl_check_assertion { impl $crate::CheckAssertion for $chain where - Origin: Chain + Clone, - Destination: Chain + Clone, + Origin: $crate::Chain + Clone, + Destination: $crate::Chain + Clone, Origin::RuntimeOrigin: $crate::OriginTrait + Clone, Destination::RuntimeOrigin: $crate::OriginTrait + Clone, @@ -1177,7 +1181,7 @@ macro_rules! __impl_check_assertion { fn check_assertion(test: $crate::Test) { let chain_name = std::any::type_name::<$chain>(); - <$chain>::execute_with(|| { + <$chain as $crate::TestExt>::execute_with(|| { if let Some(dispatchable) = test.hops_dispatchable.get(chain_name) { $crate::assert_ok!(dispatchable(test.clone())); } @@ -1194,7 +1198,7 @@ macro_rules! __impl_check_assertion { macro_rules! assert_expected_events { ( $chain:ident, vec![$( $event_pat:pat => { $($attr:ident : $condition:expr, )* }, )*] ) => { let mut message: Vec = Vec::new(); - let mut events = <$chain>::events(); + let mut events = <$chain as $crate::Chain>::events(); $( let mut event_received = false; @@ -1257,7 +1261,7 @@ macro_rules! assert_expected_events { if !message.is_empty() { // Log events as they will not be logged after the panic - <$chain>::events().iter().for_each(|event| { + <$chain as $crate::Chain>::events().iter().for_each(|event| { $crate::log::debug!(target: concat!("events::", stringify!($chain)), "{:?}", event); }); panic!("{}", message.concat()) @@ -1276,10 +1280,10 @@ 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); + pub [<$chain Sender>]: $crate::AccountId = <$chain as $crate::Chain>::account_id_of($sender); + pub [<$chain Receiver>]: $crate::AccountId = <$chain as $crate::Chain>::account_id_of($receiver); )+ } } From 2524436b1907d0c445e05552c9f0bfcce33258dd Mon Sep 17 00:00:00 2001 From: NachoPal Date: Tue, 29 Aug 2023 12:55:45 +0200 Subject: [PATCH 2/7] improve hygiene & clean up - xcm-emulator --- Cargo.lock | 8 +- .../assets/asset-hub-kusama/Cargo.toml | 1 - .../assets/asset-hub-kusama/src/lib.rs | 6 +- .../assets/asset-hub-polkadot/Cargo.toml | 1 - .../assets/asset-hub-polkadot/src/lib.rs | 6 +- .../assets/asset-hub-westend/Cargo.toml | 1 - .../assets/asset-hub-westend/src/lib.rs | 6 +- .../bridges/bridge-hub-rococo/src/lib.rs | 6 +- .../collectives-polkadot/src/lib.rs | 6 +- cumulus/xcm/xcm-emulator/Cargo.toml | 5 +- cumulus/xcm/xcm-emulator/src/lib.rs | 95 ++++++++----------- 11 files changed, 55 insertions(+), 86 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89842929d2d6..810a470bb3cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -697,7 +697,6 @@ version = "1.0.0" dependencies = [ "assert_matches", "asset-hub-kusama-runtime", - "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", "frame-support", @@ -798,7 +797,6 @@ dependencies = [ name = "asset-hub-polkadot-integration-tests" version = "1.0.0" dependencies = [ - "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", "frame-support", @@ -896,7 +894,6 @@ version = "1.0.0" dependencies = [ "assert_matches", "asset-hub-westend-runtime", - "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", "frame-support", @@ -20848,9 +20845,7 @@ dependencies = [ name = "xcm-emulator" version = "0.1.0" dependencies = [ - "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", "cumulus-test-relay-sproof-builder", @@ -20861,10 +20856,10 @@ dependencies = [ "log", "pallet-balances", "pallet-message-queue", - "parachain-info", "parachains-common", "parity-scale-codec", "paste", + "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-parachains", "sp-arithmetic", @@ -20873,7 +20868,6 @@ dependencies = [ "sp-runtime", "sp-std", "sp-tracing", - "sp-trie", "xcm", "xcm-executor", ] diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml index 83209e7e46ce..1322139af16c 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml @@ -31,7 +31,6 @@ pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-featu # Cumulus parachains-common = { path = "../../../../common" } asset-hub-kusama-runtime = { path = "../../../../runtimes/assets/asset-hub-kusama" } -cumulus-pallet-dmp-queue = { path = "../../../../../pallets/dmp-queue" } cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index 9a6534423c12..cc0f2cc4e6ab 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -43,13 +43,13 @@ pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ - prelude::*, + prelude::{*, AccountId32 as AccountId32Junction}, v3::{Error, NetworkId::Kusama as KusamaId}, DoubleEncoded, }; pub use xcm_emulator::{ - assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold, - AccountId32Junction, Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, + assert_expected_events, bx, helpers::weight_within_threshold, + Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, TestContext, TestExt, TestExternalities, }; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml index 93cd66cf4db1..64a364b11b7f 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml @@ -28,7 +28,6 @@ pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-featu # Cumulus parachains-common = { path = "../../../../common" } -cumulus-pallet-dmp-queue = { path = "../../../../../pallets/dmp-queue" } cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index df75efda5bb5..48d0065bda3d 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -41,13 +41,13 @@ pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ - prelude::*, + prelude::{*, AccountId32 as AccountId32Junction}, v3::{Error, NetworkId::Polkadot as PolkadotId}, DoubleEncoded, }; pub use xcm_emulator::{ - assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold, - AccountId32Junction, Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, + assert_expected_events, bx, helpers::weight_within_threshold, + Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, TestContext, TestExt, TestExternalities, }; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml index 1225cf8763c8..785cdd936812 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml @@ -31,7 +31,6 @@ pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-featu # Cumulus parachains-common = { path = "../../../../common" } asset-hub-westend-runtime = { path = "../../../../runtimes/assets/asset-hub-westend" } -cumulus-pallet-dmp-queue = { path = "../../../../../pallets/dmp-queue" } cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index 51d74089b803..979fa06f825d 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -41,13 +41,13 @@ pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ - prelude::*, + prelude::{*, AccountId32 as AccountId32Junction}, v3::{Error, NetworkId::Westend as WestendId}, DoubleEncoded, }; pub use xcm_emulator::{ - assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold, - AccountId32Junction, Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, + assert_expected_events, bx, helpers::weight_within_threshold, + Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, TestContext, TestExt, TestExternalities, }; diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 712bad186b13..f5598e84fa62 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -44,7 +44,7 @@ pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ - prelude::*, + prelude::{*, AccountId32 as AccountId32Junction}, v3::{ Error, NetworkId::{Rococo as RococoId, Wococo as WococoId}, @@ -52,8 +52,8 @@ pub use xcm::{ DoubleEncoded, }; pub use xcm_emulator::{ - assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold, - AccountId32Junction, Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, + assert_expected_events, bx, helpers::weight_within_threshold, + Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, TestContext, TestExt, TestExternalities, }; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index 1aa6009ea7ff..ce7d8a5247ab 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -41,13 +41,13 @@ pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ - prelude::*, + prelude::{*, AccountId32 as AccountId32Junction}, v3::{Error, NetworkId::Polkadot as PolkadotId}, DoubleEncoded, }; pub use xcm_emulator::{ - assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold, - AccountId32Junction, Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, + assert_expected_events, bx, helpers::weight_within_threshold, + Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, TestContext, TestExt, TestExternalities, }; diff --git a/cumulus/xcm/xcm-emulator/Cargo.toml b/cumulus/xcm/xcm-emulator/Cargo.toml index e92753a7677c..199a3a74c6b4 100644 --- a/cumulus/xcm/xcm-emulator/Cargo.toml +++ b/cumulus/xcm/xcm-emulator/Cargo.toml @@ -20,17 +20,13 @@ sp-core = { path = "../../../substrate/primitives/core" } sp-std = { path = "../../../substrate/primitives/std" } sp-runtime = { path = "../../../substrate/primitives/runtime" } sp-arithmetic = { path = "../../../substrate/primitives/arithmetic" } -sp-trie = { path = "../../../substrate/primitives/trie" } sp-tracing = { path = "../../../substrate/primitives/tracing" } pallet-balances = { path = "../../../substrate/frame/balances" } pallet-message-queue = { path = "../../../substrate/frame/message-queue" } # Cumulus cumulus-primitives-core = { path = "../../primitives/core" } -cumulus-pallet-xcmp-queue = { path = "../../pallets/xcmp-queue" } -cumulus-pallet-dmp-queue = { path = "../../pallets/dmp-queue" } cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system" } -parachain-info = { path = "../../parachains/pallets/parachain-info" } cumulus-primitives-parachain-inherent = { path = "../../primitives/parachain-inherent" } cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder" } parachains-common = { path = "../../parachains/common" } @@ -39,4 +35,5 @@ parachains-common = { path = "../../parachains/common" } xcm = { path = "../../../polkadot/xcm" } xcm-executor = { path = "../../../polkadot/xcm/xcm-executor" } polkadot-primitives = { path = "../../../polkadot/primitives" } +polkadot-parachain = { path = "../../../polkadot/parachain" } polkadot-runtime-parachains = { path = "../../../polkadot/runtime/parachains" } diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index dc91a3d74d17..a8d597549065 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -pub use codec::{Decode, Encode}; pub use lazy_static::lazy_static; pub use log; pub use paste; @@ -26,55 +25,45 @@ pub use std::{ marker::PhantomData, ops::Deref, sync::Mutex, - thread::LocalKey, }; // Substrate pub use frame_support::{ assert_ok, - sp_runtime::{AccountId32, DispatchResult}, + sp_runtime::{traits::Header as HeaderT, AccountId32, DispatchResult}, traits::{ - tokens::currency::Currency, EnqueueMessage, Get, Hooks, OriginTrait, ProcessMessage, + EnqueueMessage, Get, Hooks, OriginTrait, ProcessMessage, ProcessMessageError, ServiceQueues, }, weights::{Weight, WeightMeter}, - StorageHasher, }; -pub use frame_system::{AccountInfo, Config as SystemConfig, Pallet as SystemPallet}; +pub use frame_system::{Config as SystemConfig, Pallet as SystemPallet}; pub use pallet_balances::AccountData; pub use sp_arithmetic::traits::Bounded; -pub use sp_core::{parameter_types, sr25519, storage::Storage, Pair, H256}; -pub use sp_io::{self, TestExternalities}; +pub use sp_core::{parameter_types, sr25519, storage::Storage, Pair, Encode}; +pub use sp_io::TestExternalities; pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, fmt::Debug}; -pub use sp_trie::StorageProof; pub use sp_tracing; -//Cumulus -pub use cumulus_pallet_dmp_queue; -pub use cumulus_pallet_parachain_system::{self, Pallet as ParachainSystemPallet}; -pub use cumulus_pallet_xcmp_queue::{Config as XcmpQueueConfig, Pallet as XcmpQueuePallet}; +// Cumulus +pub use cumulus_pallet_parachain_system::Pallet as ParachainSystemPallet; pub use cumulus_primitives_core::{ - self, relay_chain::{BlockNumber as RelayBlockNumber, HeadData, HrmpChannelId}, AbridgedHrmpChannel, DmpMessageHandler, ParaId, PersistedValidationData, XcmpMessageHandler, }; pub use cumulus_primitives_parachain_inherent::ParachainInherentData; pub use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; pub use pallet_message_queue::{ - Config as MessageQueueConfig, Event as MessageQueueEvent, Pallet as MessageQueuePallet, + Config as MessageQueueConfig, Pallet as MessageQueuePallet, }; -pub use parachain_info; pub use parachains_common::{AccountId, Balance, BlockNumber}; pub use polkadot_primitives; -pub use polkadot_runtime_parachains::{ - dmp, - inclusion::{AggregateMessageOrigin, UmpQueueId}, -}; +pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; // Polkadot -pub use xcm::{ - v3::prelude::{AccountId32 as AccountId32Junction, Parachain as ParachainJunction, *}, - VersionedMultiAssets, VersionedMultiLocation, +pub use polkadot_parachain::primitives::RelayChainBlockNumber; +pub use xcm::v3::prelude::{ + Ancestor, MultiAssets, MultiLocation, Parent, Parachain as ParachainJunction, WeightLimit, XcmHash, X1 }; pub use xcm_executor::traits::ConvertLocation; @@ -542,7 +531,7 @@ macro_rules! __impl_test_ext_for_relay_chain { } // log events - ::events().iter().for_each(|event| { + Self::events().iter().for_each(|event| { $crate::log::debug!(target: concat!("events::", stringify!($name)), "{:?}", event); }); @@ -621,11 +610,11 @@ macro_rules! decl_test_parachains { type ParachainInfo = $parachain_info; fn init() { - use $crate::{Chain, HeadData, Network, NetworkComponent, Hooks, Encode, Parachain}; + use $crate::{Chain, HeadData, Network, NetworkComponent, Hooks, Encode, Parachain, TestExt}; let para_id = Self::para_id(); - ::ext_wrapper(|| { + Self::ext_wrapper(|| { let block_number = ::System::block_number(); let mut relay_block_number = ::Network::relay_block_number(); @@ -688,18 +677,16 @@ macro_rules! __impl_test_ext_for_parachain { impl $crate::TestExt for $name { fn build_new_ext(storage: $crate::Storage) -> $crate::TestExternalities { - use $crate::{NetworkComponent, Network, TestExternalities, Chain}; - - let mut ext = TestExternalities::new(storage); + let mut ext = $crate::TestExternalities::new(storage); ext.execute_with(|| { #[allow(clippy::no_effect)] $on_init; $crate::sp_tracing::try_init_simple(); - let mut block_number = ::System::block_number(); + let mut block_number = ::System::block_number(); block_number = std::cmp::max(1, block_number); - ::System::set_block_number(block_number); + ::System::set_block_number(block_number); }); ext } @@ -760,15 +747,12 @@ macro_rules! __impl_test_ext_for_parachain { } fn execute_with(execute: impl FnOnce() -> R) -> R { - use $crate::{Chain, Get, Hooks, HeadData, NetworkComponent, Network, Bridge, Parachain}; - use sp_core::Encode; - use sp_runtime::traits::BlakeTwo256; - use polkadot_primitives::HashT; + use $crate::{Chain, Get, Hooks, NetworkComponent, Network, Parachain, Encode}; // Make sure the Network is initialized <$name as NetworkComponent>::Network::init(); - let para_id = <$name as Parachain>::para_id().into(); + let para_id = <$name>::para_id().into(); // Initialize block $local_ext.with(|v| { @@ -804,10 +788,8 @@ macro_rules! __impl_test_ext_for_parachain { // Finalize block and send messages if needed $local_ext.with(|v| { v.borrow_mut().execute_with(|| { - use sp_runtime::traits::Header as HeaderT; - let block_number = ::System::block_number(); - let mock_header = HeaderT::new( + let mock_header = $crate::HeaderT::new( 0, Default::default(), Default::default(), @@ -822,7 +804,7 @@ macro_rules! __impl_test_ext_for_parachain { $crate::LAST_HEAD.with(|b| b.borrow_mut() .get_mut(::Network::name()) .expect("network not initialized?") - .insert(para_id.into(), HeadData(created_header.encode())) + .insert(para_id.into(), $crate::HeadData(created_header.encode())) ); let collation_info = ::ParachainSystem::collect_collation_info(&mock_header); @@ -842,9 +824,9 @@ macro_rules! __impl_test_ext_for_parachain { } // get bridge messages - type NetworkBridge = <<$name as NetworkComponent>::Network as Network>::Bridge; + type NetworkBridge = <<$name as NetworkComponent>::Network as $crate::Network>::Bridge; - let bridge_messages = <::Handler as $crate::BridgeMessageHandler>::get_source_outbound_messages(); + let bridge_messages = <::Handler as $crate::BridgeMessageHandler>::get_source_outbound_messages(); // send bridged messages for msg in bridge_messages { @@ -911,7 +893,7 @@ macro_rules! decl_test_networks { } fn reset() { - use $crate::{TestExt, VecDeque}; + use $crate::{TestExt}; $crate::INITIALIZED.with(|b| b.borrow_mut().remove(Self::name())); $crate::DOWNWARD_MESSAGES.with(|b| b.borrow_mut().remove(Self::name())); @@ -976,13 +958,12 @@ macro_rules! decl_test_networks { } fn process_downward_messages() { - use $crate::{DmpMessageHandler, Bounded, Parachain}; - use polkadot_parachain::primitives::RelayChainBlockNumber; + use $crate::{DmpMessageHandler, Bounded, Parachain, RelayChainBlockNumber, TestExt}; while let Some((to_para_id, messages)) = $crate::DOWNWARD_MESSAGES.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().pop_front()) { $( - let para_id: u32 = <$parachain as Parachain>::para_id().into(); + let para_id: u32 = <$parachain>::para_id().into(); if $crate::PARA_IDS.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().contains(&to_para_id)) && para_id == to_para_id { let mut msg_dedup: Vec<(RelayChainBlockNumber, Vec)> = Vec::new(); @@ -995,7 +976,7 @@ macro_rules! decl_test_networks { !$crate::DMP_DONE.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap_or(&mut $crate::VecDeque::new()).contains(&(to_para_id, m.0, m.1.clone()))) }).collect::)>>(); if msgs.len() != 0 { - <$parachain as $crate::TestExt>::ext_wrapper(|| { + <$parachain>::ext_wrapper(|| { <$parachain as Parachain>::DmpMessageHandler::handle_dmp_messages(msgs.clone().into_iter(), $crate::Weight::max_value()); }); $crate::log::debug!(target: concat!("dmp::", stringify!($name)) , "DMP messages processed {:?} to para_id {:?}", msgs.clone(), &to_para_id); @@ -1009,16 +990,16 @@ macro_rules! decl_test_networks { } fn process_horizontal_messages() { - use $crate::{XcmpMessageHandler, Bounded, Parachain}; + use $crate::{XcmpMessageHandler, Bounded, Parachain, TestExt}; while let Some((to_para_id, messages)) = $crate::HORIZONTAL_MESSAGES.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().pop_front()) { let iter = messages.iter().map(|(p, b, m)| (*p, *b, &m[..])).collect::>().into_iter(); $( - let para_id: u32 = <$parachain as Parachain>::para_id().into(); + let para_id: u32 = <$parachain>::para_id().into(); if $crate::PARA_IDS.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().contains(&to_para_id)) && para_id == to_para_id { - <$parachain as $crate::TestExt>::ext_wrapper(|| { + <$parachain>::ext_wrapper(|| { <$parachain as Parachain>::XcmpMessageHandler::handle_xcmp_messages(iter.clone(), $crate::Weight::max_value()); }); $crate::log::debug!(target: concat!("hrmp::", stringify!($name)) , "HRMP messages processed {:?} to para_id {:?}", &messages, &to_para_id); @@ -1028,11 +1009,11 @@ macro_rules! decl_test_networks { } fn process_upward_messages() { - use $crate::{Bounded, ProcessMessage}; + use $crate::{ProcessMessage, TestExt}; use sp_core::Encode; while let Some((from_para_id, msg)) = $crate::UPWARD_MESSAGES.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().pop_front()) { let mut weight_meter = $crate::WeightMeter::max_limit(); - <$relay_chain as $crate::TestExt>::ext_wrapper(|| { + <$relay_chain>::ext_wrapper(|| { let _ = <$relay_chain as $crate::RelayChain>::MessageProcessor::process_message( &msg[..], from_para_id.into(), @@ -1071,8 +1052,6 @@ macro_rules! decl_test_networks { relay_parent_number: u32, parent_head_data: $crate::HeadData, ) -> $crate::ParachainInherentData { - use $crate::{HeadData, HrmpChannelId, AbridgedHrmpChannel}; - let mut sproof = $crate::RelayStateSproofBuilder::default(); sproof.para_id = para_id.into(); @@ -1088,11 +1067,11 @@ macro_rules! decl_test_networks { sproof .hrmp_channels - .entry(HrmpChannelId { + .entry($crate::HrmpChannelId { sender: sproof.para_id, recipient: recipient_para_id, }) - .or_insert_with(|| AbridgedHrmpChannel { + .or_insert_with(|| $crate::AbridgedHrmpChannel { max_capacity: 1024, max_total_size: 1024 * 1024, max_message_size: 1024 * 1024, @@ -1179,9 +1158,11 @@ macro_rules! __impl_check_assertion { Args: Clone, { fn check_assertion(test: $crate::Test) { + use $crate::TestExt; + let chain_name = std::any::type_name::<$chain>(); - <$chain as $crate::TestExt>::execute_with(|| { + <$chain>::execute_with(|| { if let Some(dispatchable) = test.hops_dispatchable.get(chain_name) { $crate::assert_ok!(dispatchable(test.clone())); } From b13e4e80cabb59a82798aa055fd69c14ae9d2d4c Mon Sep 17 00:00:00 2001 From: NachoPal Date: Tue, 29 Aug 2023 15:42:23 +0200 Subject: [PATCH 3/7] improve hygiene & clean up - common --- Cargo.lock | 8 --- .../emulated/common/Cargo.toml | 8 --- .../emulated/common/src/constants.rs | 35 ++++++++-- .../emulated/common/src/impls.rs | 66 ++++++++++++------- .../emulated/common/src/lib.rs | 22 ++++++- .../emulated/common/src/xcm_helpers.rs | 16 +++++ cumulus/xcm/xcm-emulator/src/lib.rs | 7 +- 7 files changed, 113 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 810a470bb3cd..2f6485d91ad5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6432,7 +6432,6 @@ dependencies = [ "asset-hub-polkadot-runtime", "asset-hub-westend-runtime", "bp-messages", - "bp-runtime", "bridge-hub-kusama-runtime", "bridge-hub-polkadot-runtime", "bridge-hub-rococo-runtime", @@ -6443,22 +6442,18 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "frame-support", - "frame-system", "kusama-runtime", "kusama-runtime-constants", "pallet-assets", - "pallet-balances", "pallet-bridge-messages", "pallet-im-online", "pallet-message-queue", "pallet-staking", "pallet-xcm", - "parachain-info", "parachains-common", "parity-scale-codec", "paste", "penpal-runtime", - "polkadot-core-primitives", "polkadot-parachain", "polkadot-primitives", "polkadot-runtime", @@ -6473,13 +6468,10 @@ dependencies = [ "sp-consensus-beefy", "sp-core", "sp-runtime", - "sp-tracing", - "sp-weights", "westend-runtime", "westend-runtime-constants", "xcm", "xcm-emulator", - "xcm-executor", ] [[package]] diff --git a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml index 5403384095d2..525675edf87e 100644 --- a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml @@ -14,12 +14,8 @@ grandpa = { package = "sc-consensus-grandpa", path = "../../../../../substrate/c sp-authority-discovery = { path = "../../../../../substrate/primitives/authority-discovery", default-features = false} sp-runtime = { path = "../../../../../substrate/primitives/runtime", default-features = false} frame-support = { path = "../../../../../substrate/frame/support", default-features = false} -frame-system = { path = "../../../../../substrate/frame/system", default-features = false} sp-core = { path = "../../../../../substrate/primitives/core", default-features = false} -sp-weights = { path = "../../../../../substrate/primitives/weights", default-features = false} sp-consensus-babe = { path = "../../../../../substrate/primitives/consensus/babe", default-features = false} -sp-tracing = { path = "../../../../../substrate/primitives/tracing" } -pallet-balances = { path = "../../../../../substrate/frame/balances", default-features = false} pallet-assets = { path = "../../../../../substrate/frame/assets", default-features = false} pallet-staking = { path = "../../../../../substrate/frame/staking", default-features = false} pallet-message-queue = { path = "../../../../../substrate/frame/message-queue", default-features = false} @@ -27,7 +23,6 @@ pallet-im-online = { path = "../../../../../substrate/frame/im-online", default- beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../substrate/primitives/consensus/beefy" } # Polkadot -polkadot-core-primitives = { path = "../../../../../polkadot/core-primitives", default-features = false} polkadot-parachain = { path = "../../../../../polkadot/parachain", default-features = false} polkadot-service = { path = "../../../../../polkadot/node/service", default-features = false, features = ["full-node"] } polkadot-primitives = { path = "../../../../../polkadot/primitives", default-features = false} @@ -41,12 +36,10 @@ rococo-runtime-constants = { path = "../../../../../polkadot/runtime/rococo/cons westend-runtime = { path = "../../../../../polkadot/runtime/westend" } westend-runtime-constants = { path = "../../../../../polkadot/runtime/westend/constants" } xcm = { path = "../../../../../polkadot/xcm", default-features = false} -xcm-executor = { path = "../../../../../polkadot/xcm/xcm-executor", default-features = false} pallet-xcm = { path = "../../../../../polkadot/xcm/pallet-xcm", default-features = false} # Cumulus parachains-common = { path = "../../../common" } -parachain-info = { path = "../../../pallets/parachain-info" } cumulus-primitives-core = { path = "../../../../primitives/core" } penpal-runtime = { path = "../../../runtimes/testing/penpal" } asset-hub-polkadot-runtime = { path = "../../../runtimes/assets/asset-hub-polkadot" } @@ -61,7 +54,6 @@ cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue" } cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false} cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system" } bp-messages = { path = "../../../../bridges/primitives/messages" } -bp-runtime = { path = "../../../../bridges/primitives/runtime" } pallet-bridge-messages = { path = "../../../../bridges/modules/messages" } bridge-runtime-common = { path = "../../../../bridges/bin/runtime-common" } diff --git a/cumulus/parachains/integration-tests/emulated/common/src/constants.rs b/cumulus/parachains/integration-tests/emulated/common/src/constants.rs index 3eb65fa26c16..38e6af0eaeca 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/constants.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/constants.rs @@ -1,7 +1,35 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +// Substrate +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_core::{sr25519, storage::Storage, Pair, Public}; +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + BuildStorage, MultiSignature, Perbill, +}; use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; use grandpa::AuthorityId as GrandpaId; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; + +// Cumulus use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; + +// Polkadot use polkadot_parachain::primitives::{HeadData, ValidationCode}; use polkadot_primitives::{AssignmentId, ValidatorId}; use polkadot_runtime_parachains::{ @@ -9,13 +37,6 @@ use polkadot_runtime_parachains::{ paras::{ParaGenesisArgs, ParaKind}, }; use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_consensus_babe::AuthorityId as BabeId; -use sp_core::{sr25519, storage::Storage, Pair, Public}; -use sp_runtime::{ - traits::{IdentifyAccount, Verify}, - BuildStorage, MultiSignature, Perbill, -}; use xcm; pub const XCM_V2: u32 = 3; diff --git a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs index 8e00ad3e9077..1177d06887e4 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs @@ -1,29 +1,53 @@ -use super::{BridgeHubRococo, BridgeHubWococo}; -pub use crate::constants::{PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD}; -pub use crate::xcm_helpers::xcm_transact_unpaid_execution; +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +pub use codec::{Decode, Encode}; +pub use paste; + +pub use crate::{ + constants::{PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD}, + xcm_helpers::xcm_transact_unpaid_execution, + BridgeHubRococo, BridgeHubWococo, +}; + +// Substrate +use sp_core::Get; +pub use frame_support::{traits::fungibles::Inspect, assert_ok}; + +// Cumulus use bp_messages::{ target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, LaneId, MessageKey, OutboundLaneData, }; use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; -pub use codec::{Decode, Encode}; -pub use frame_support::{traits::fungibles::Inspect, assert_ok}; -pub use cumulus_primitives_core::{relay_chain::HrmpChannelId, DmpMessageHandler, ParaId, XcmpMessageHandler}; use pallet_bridge_messages::{Config, Instance1, Instance2, OutboundLanes, Pallet}; -use sp_core::Get; +pub use cumulus_primitives_core::{relay_chain::HrmpChannelId, DmpMessageHandler, ParaId, XcmpMessageHandler}; +pub use parachains_common::{AccountId, Balance}; pub use xcm_emulator::{ - helpers::weight_within_threshold, BridgeMessageHandler, Chain, DefaultMessageProcessor, + assert_expected_events, bx, + helpers::weight_within_threshold, BridgeMessageHandler, Chain, BridgeMessage, BridgeMessageDispatchError, TestExt, Parachain, RelayChain, }; -pub use paste; -pub use parachains_common::{AccountId, Balance}; + +// Polkadot pub use polkadot_runtime_parachains::{ dmp, + hrmp::HrmpChannels, inclusion::{AggregateMessageOrigin, UmpQueueId}, }; -pub use xcm_emulator::{ - assert_expected_events, bx, -}; pub use xcm::{ prelude::{ OriginKind, Outcome, VersionedXcm, Weight, @@ -32,8 +56,6 @@ pub use xcm::{ DoubleEncoded, }; - - pub struct BridgeHubMessageHandler { _marker: std::marker::PhantomData<(S, T, I)>, } @@ -305,7 +327,7 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { /// A root origin force to open a channel between two Parachains pub fn force_process_hrmp_open(sender: $crate::impls::ParaId, recipient: $crate::impls::ParaId) { - use $crate::impls::{Chain, HrmpChannelId}; + use $crate::impls::Chain; ::execute_with(|| { let relay_root_origin = ::RuntimeOrigin::root(); @@ -316,9 +338,9 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { 0 )); - let channel_id = HrmpChannelId { sender, recipient }; + let channel_id = $crate::impls::HrmpChannelId { sender, recipient }; - let hrmp_channel_exist = polkadot_runtime_parachains::hrmp::HrmpChannels::< + let hrmp_channel_exist = $crate::impls::HrmpChannels::< ::Runtime, >::contains_key(&channel_id); @@ -577,10 +599,10 @@ macro_rules! impl_assets_helpers_for_parachain { asset_owner: $crate::impls::AccountId, amount_to_mint: u128, ) { - use $crate::impls::{bx, Chain, RelayChain, Parachain, Inspect}; + use $crate::impls::{bx, Chain, RelayChain, Parachain, Inspect, TestExt}; // Init values for Relay Chain let root_origin = <$relay_chain as Chain>::RuntimeOrigin::root(); - let destination = <$relay_chain as RelayChain>::child_location_of(<$chain as Parachain>::para_id()); + let destination = <$relay_chain>::child_location_of(<$chain>::para_id()); let xcm = Self::force_create_asset_xcm( $crate::impls::OriginKind::Superuser, id, @@ -589,7 +611,7 @@ macro_rules! impl_assets_helpers_for_parachain { min_balance, ); - <$relay_chain as $crate::impls::TestExt>::execute_with(|| { + <$relay_chain>::execute_with(|| { $crate::impls::assert_ok!(<$relay_chain as [<$relay_chain Pallet>]>::XcmPallet::send( root_origin, bx!(destination.into()), @@ -599,7 +621,7 @@ macro_rules! impl_assets_helpers_for_parachain { <$relay_chain>::assert_xcm_pallet_sent(); }); - ::execute_with(|| { + Self::execute_with(|| { Self::assert_dmp_queue_complete(Some($crate::impls::Weight::from_parts(1_019_445_000, 200_000))); type RuntimeEvent = <$chain as $crate::impls::Chain>::RuntimeEvent; diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index cf9fb42b8d52..52cefab0691b 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -1,3 +1,19 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + pub mod constants; pub mod impls; pub mod xcm_helpers; @@ -7,8 +23,12 @@ use constants::{ asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama, bridge_hub_polkadot, bridge_hub_rococo, collectives, kusama, penpal, polkadot, rococo, westend, }; -use frame_support::traits::OnInitialize; use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler}; + +// Substrate +use frame_support::traits::OnInitialize; + +// Cumulus use xcm_emulator::{ decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types, diff --git a/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs b/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs index be2dc25394d5..539698d460d0 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs @@ -1,3 +1,19 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + use parachains_common::AccountId; use xcm::{ prelude::{ diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index a8d597549065..e581a164c26b 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -26,6 +26,7 @@ pub use std::{ ops::Deref, sync::Mutex, }; +pub use codec::{Encode, Decode}; // Substrate pub use frame_support::{ @@ -40,7 +41,7 @@ pub use frame_support::{ pub use frame_system::{Config as SystemConfig, Pallet as SystemPallet}; pub use pallet_balances::AccountData; pub use sp_arithmetic::traits::Bounded; -pub use sp_core::{parameter_types, sr25519, storage::Storage, Pair, Encode}; +pub use sp_core::{parameter_types, sr25519, storage::Storage, Pair}; pub use sp_io::TestExternalities; pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, fmt::Debug}; pub use sp_tracing; @@ -1009,8 +1010,8 @@ macro_rules! decl_test_networks { } fn process_upward_messages() { - use $crate::{ProcessMessage, TestExt}; - use sp_core::Encode; + use $crate::{Encode, ProcessMessage, TestExt}; + while let Some((from_para_id, msg)) = $crate::UPWARD_MESSAGES.with(|b| b.borrow_mut().get_mut(Self::name()).unwrap().pop_front()) { let mut weight_meter = $crate::WeightMeter::max_limit(); <$relay_chain>::ext_wrapper(|| { From f29ba0f16033cf81983e68112dc66e85b24ff914 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Tue, 29 Aug 2023 20:59:44 +0200 Subject: [PATCH 4/7] improve hygiene & clean up - tests --- Cargo.lock | 1 + .../assets/asset-hub-kusama/src/lib.rs | 24 +++++------------ .../assets/asset-hub-polkadot/src/lib.rs | 22 +++++---------- .../assets/asset-hub-westend/src/lib.rs | 21 ++++++--------- .../bridges/bridge-hub-rococo/Cargo.toml | 1 + .../bridges/bridge-hub-rococo/src/lib.rs | 27 ++++--------------- .../collectives-polkadot/src/lib.rs | 19 +++---------- 7 files changed, 33 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f6485d91ad5..795ed6cb03c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1954,6 +1954,7 @@ name = "bridge-hub-rococo-integration-tests" version = "1.0.0" dependencies = [ "bp-messages", + "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", "frame-support", diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index cc0f2cc4e6ab..a61ea528bf5f 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -18,39 +18,29 @@ pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress}, - traits::{fungibles::Inspect, OriginTrait}, + sp_runtime::{AccountId32, DispatchError, DispatchResult}, + traits::fungibles::Inspect, }; pub use integration_tests_common::{ constants::{ - accounts::{ALICE, BOB}, asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubKusama, - AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, BridgeHubKusama, - BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot, - BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Collectives, - CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaMockNet, KusamaPallet, - KusamaReceiver, KusamaSender, PenpalKusamaA, PenpalKusamaAPallet, PenpalKusamaAReceiver, - PenpalKusamaASender, PenpalKusamaB, PenpalKusamaBPallet, PenpalKusamaBReceiver, - PenpalKusamaBSender, PenpalPolkadotA, PenpalPolkadotAReceiver, PenpalPolkadotASender, Polkadot, - PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, + Kusama, PenpalKusamaA, AssetHubKusamaReceiver, KusamaPallet, AssetHubKusamaPallet, + AssetHubKusamaSender, PenpalKusamaAReceiver, KusamaReceiver, KusamaSender, + PenpalKusamaAPallet, PenpalKusamaASender }; pub use parachains_common::{AccountId, Balance}; -pub use polkadot_core_primitives::InboundDownwardMessage; -pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; -pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ prelude::{*, AccountId32 as AccountId32Junction}, v3::{Error, NetworkId::Kusama as KusamaId}, - DoubleEncoded, }; pub use xcm_emulator::{ assert_expected_events, bx, helpers::weight_within_threshold, - Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt, TestExternalities, + Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, + TestContext, TestExt }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index 48d0065bda3d..b07416c8b048 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -18,37 +18,29 @@ pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress}, - traits::{fungibles::Inspect, OriginTrait}, + sp_runtime::{AccountId32, DispatchError, DispatchResult}, + traits::fungibles::Inspect, }; pub use integration_tests_common::{ constants::{ - accounts::{ALICE, BOB}, asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, - BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Collectives, - CollectivesPallet, CollectivesReceiver, CollectivesSender, PenpalPolkadotA, - PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotASender, PenpalPolkadotB, - PenpalPolkadotBPallet, PenpalPolkadotBReceiver, PenpalPolkadotBSender, Polkadot, - PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, + AssetHubPolkadot, Polkadot, PolkadotPallet, PenpalPolkadotA, AssetHubPolkadotPallet, + AssetHubPolkadotReceiver, PolkadotSender, PolkadotReceiver, AssetHubPolkadotSender, + PenpalPolkadotAReceiver }; pub use parachains_common::{AccountId, Balance}; -pub use polkadot_core_primitives::InboundDownwardMessage; -pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; -pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ prelude::{*, AccountId32 as AccountId32Junction}, v3::{Error, NetworkId::Polkadot as PolkadotId}, - DoubleEncoded, }; pub use xcm_emulator::{ assert_expected_events, bx, helpers::weight_within_threshold, - Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt, TestExternalities, + Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, + TestContext, TestExt }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index 979fa06f825d..f4cb7cafde27 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -19,36 +19,31 @@ pub use frame_support::{ assert_err, assert_ok, instances::Instance2, pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult, ModuleError, MultiAddress}, - traits::{fungibles::Inspect, OriginTrait}, + sp_runtime::{AccountId32, DispatchError, DispatchResult, ModuleError}, + traits::fungibles::Inspect, BoundedVec, }; pub use integration_tests_common::{ constants::{ - accounts::{ALICE, BOB}, asset_hub_westend::ED as ASSET_HUB_WESTEND_ED, westend::ED as WESTEND_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, Collectives, - CollectivesPallet, CollectivesReceiver, CollectivesSender, PenpalWestendA, - PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, WestendMockNet, - WestendPallet, WestendReceiver, WestendSender, + AssetHubWestend, Westend, PenpalWestendA, AssetHubWestendReceiver, + AssetHubWestendPallet, WestendPallet, WestendSender, WestendReceiver, + AssetHubWestendSender, PenpalWestendAReceiver, PenpalWestendASender, + PenpalWestendAPallet, }; pub use parachains_common::{AccountId, Balance}; -pub use polkadot_core_primitives::InboundDownwardMessage; -pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; -pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ prelude::{*, AccountId32 as AccountId32Junction}, v3::{Error, NetworkId::Westend as WestendId}, - DoubleEncoded, }; pub use xcm_emulator::{ assert_expected_events, bx, helpers::weight_within_threshold, - Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt, TestExternalities, + Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, + TestContext, TestExt }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml index fb3905c3c739..b076aba75d58 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml @@ -29,6 +29,7 @@ pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-featu # Cumulus parachains-common = { path = "../../../../common" } cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} +cumulus-pallet-dmp-queue = { path = "../../../../../pallets/dmp-queue", default-features = false} cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } pallet-bridge-messages = { path = "../../../../../bridges/modules/messages", default-features = false} bp-messages = { path = "../../../../../bridges/primitives/messages", default-features = false} diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index f5598e84fa62..0d985c1c4077 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -15,46 +15,29 @@ // along with Cumulus. If not, see . pub use bp_messages::LaneId; -pub use codec::Encode; -pub use frame_support::{ - assert_err, assert_ok, - pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress}, - traits::{fungibles::Inspect, OriginTrait}, -}; +pub use frame_support::assert_ok; pub use integration_tests_common::{ constants::{ - accounts::{ALICE, BOB}, asset_hub_kusama::ED as ASSET_HUB_ROCOCO_ED, kusama::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubRococo, AssetHubRococoPallet, AssetHubRococoReceiver, AssetHubRococoSender, AssetHubWococo, - AssetHubWococoPallet, AssetHubWococoReceiver, AssetHubWococoSender, BridgeHubRococo, - BridgeHubRococoPallet, BridgeHubRococoReceiver, BridgeHubRococoSender, BridgeHubWococo, - BridgeHubWococoPallet, BridgeHubWococoReceiver, BridgeHubWococoSender, Collectives, - CollectivesPallet, CollectivesReceiver, CollectivesSender, PenpalRococoA, PenpalRococoAPallet, - PenpalRococoAReceiver, PenpalRococoASender, Rococo, RococoMockNet, RococoPallet, - RococoReceiver, RococoSender, Wococo, WococoMockNet, WococoPallet, WococoReceiver, - WococoSender, + Rococo, BridgeHubRococo, AssetHubWococo, RococoPallet, BridgeHubWococo, + AssetHubRococo, PenpalRococoA, AssetHubRococoReceiver, }; pub use parachains_common::{AccountId, Balance}; -pub use polkadot_core_primitives::InboundDownwardMessage; -pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; -pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ prelude::{*, AccountId32 as AccountId32Junction}, v3::{ Error, NetworkId::{Rococo as RococoId, Wococo as WococoId}, }, - DoubleEncoded, }; pub use xcm_emulator::{ assert_expected_events, bx, helpers::weight_within_threshold, - Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt, TestExternalities, + Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, + TestContext, TestExt }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index ce7d8a5247ab..8f5bf6531dde 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -16,34 +16,23 @@ pub use codec::Encode; pub use frame_support::{ - assert_err, assert_ok, - pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress}, - traits::{fungibles::Inspect, OriginTrait}, + assert_ok, sp_runtime::AccountId32, }; pub use integration_tests_common::{ constants::{ - accounts::{ALICE, BOB}, + accounts::ALICE, asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, - BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Collectives, - CollectivesPallet, CollectivesReceiver, CollectivesSender, PenpalPolkadotA, - PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotASender, PenpalPolkadotB, - PenpalPolkadotBPallet, PenpalPolkadotBReceiver, PenpalPolkadotBSender, Polkadot, - PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, + AssetHubPolkadot, Polkadot, AssetHubPolkadotReceiver, PenpalPolkadotA, + AssetHubPolkadotPallet, Collectives, }; pub use parachains_common::{AccountId, Balance}; -pub use polkadot_core_primitives::InboundDownwardMessage; -pub use polkadot_parachain::primitives::{HrmpChannelId, Id}; -pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use xcm::{ prelude::{*, AccountId32 as AccountId32Junction}, v3::{Error, NetworkId::Polkadot as PolkadotId}, - DoubleEncoded, }; pub use xcm_emulator::{ assert_expected_events, bx, helpers::weight_within_threshold, From 435e84a48e98c3f80e66ff5b79c9176f4768ecac Mon Sep 17 00:00:00 2001 From: NachoPal Date: Tue, 29 Aug 2023 23:04:12 +0200 Subject: [PATCH 5/7] improve hygiene & clean up - tests 2 --- Cargo.lock | 44 +------------------ .../assets/asset-hub-kusama/Cargo.toml | 7 --- .../assets/asset-hub-polkadot/Cargo.toml | 9 +--- .../assets/asset-hub-westend/Cargo.toml | 7 --- .../bridges/bridge-hub-rococo/Cargo.toml | 12 ----- .../collectives-polkadot/Cargo.toml | 9 ---- 6 files changed, 4 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 795ed6cb03c9..2cd1d0a203c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -697,8 +697,6 @@ version = "1.0.0" dependencies = [ "assert_matches", "asset-hub-kusama-runtime", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", "frame-support", "frame-system", "integration-tests-common", @@ -708,16 +706,11 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", "polkadot-runtime", "polkadot-runtime-parachains", - "sp-core", "sp-runtime", - "sp-weights", "xcm", "xcm-emulator", - "xcm-executor", ] [[package]] @@ -797,26 +790,21 @@ dependencies = [ name = "asset-hub-polkadot-integration-tests" version = "1.0.0" dependencies = [ - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", + "asset-hub-kusama-runtime", "frame-support", "frame-system", "integration-tests-common", + "pallet-asset-conversion", "pallet-assets", "pallet-balances", "pallet-xcm", "parachains-common", "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", "polkadot-runtime", "polkadot-runtime-parachains", - "sp-core", "sp-runtime", - "sp-weights", "xcm", "xcm-emulator", - "xcm-executor", ] [[package]] @@ -894,8 +882,6 @@ version = "1.0.0" dependencies = [ "assert_matches", "asset-hub-westend-runtime", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", "frame-support", "frame-system", "integration-tests-common", @@ -905,16 +891,11 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", "polkadot-runtime", "polkadot-runtime-parachains", - "sp-core", "sp-runtime", - "sp-weights", "xcm", "xcm-emulator", - "xcm-executor", ] [[package]] @@ -1955,27 +1936,15 @@ version = "1.0.0" dependencies = [ "bp-messages", "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", "frame-support", - "frame-system", "integration-tests-common", - "pallet-assets", - "pallet-balances", "pallet-bridge-messages", "pallet-xcm", "parachains-common", "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-runtime", - "polkadot-runtime-parachains", - "sp-core", - "sp-runtime", - "sp-weights", "xcm", "xcm-emulator", - "xcm-executor", ] [[package]] @@ -2580,30 +2549,21 @@ dependencies = [ name = "collectives-polkadot-integration-tests" version = "0.1.0" dependencies = [ - "asset-hub-polkadot-runtime", "collectives-polkadot-runtime", "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", "frame-support", - "frame-system", "integration-tests-common", "pallet-assets", - "pallet-balances", "pallet-core-fellowship", "pallet-salary", "pallet-xcm", "parachains-common", "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-runtime", - "polkadot-runtime-parachains", "sp-core", "sp-runtime", - "sp-weights", "xcm", "xcm-emulator", - "xcm-executor", ] [[package]] diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml index 1322139af16c..6d7c0b6ea6af 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml @@ -13,26 +13,19 @@ assert_matches = "1.5.0" sp-runtime = { path = "../../../../../../substrate/primitives/runtime", default-features = false} frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} frame-system = { path = "../../../../../../substrate/frame/system", default-features = false} -sp-core = { path = "../../../../../../substrate/primitives/core", default-features = false} -sp-weights = { path = "../../../../../../substrate/primitives/weights", default-features = false} pallet-balances = { path = "../../../../../../substrate/frame/balances", default-features = false} pallet-assets = { path = "../../../../../../substrate/frame/assets", default-features = false} pallet-asset-conversion = { path = "../../../../../../substrate/frame/asset-conversion", default-features = false} # Polkadot -polkadot-core-primitives = { path = "../../../../../../polkadot/core-primitives", default-features = false} -polkadot-parachain = { path = "../../../../../../polkadot/parachain", default-features = false} polkadot-runtime-parachains = { path = "../../../../../../polkadot/runtime/parachains" } polkadot-runtime = { path = "../../../../../../polkadot/runtime/polkadot" } xcm = { path = "../../../../../../polkadot/xcm", default-features = false} -xcm-executor = { path = "../../../../../../polkadot/xcm/xcm-executor", default-features = false} pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-features = false} # Cumulus parachains-common = { path = "../../../../common" } asset-hub-kusama-runtime = { path = "../../../../runtimes/assets/asset-hub-kusama" } -cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} -cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } # Local xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml index 64a364b11b7f..a1962197850d 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml @@ -12,24 +12,19 @@ codec = { package = "parity-scale-codec", version = "3.4.0", default-features = sp-runtime = { path = "../../../../../../substrate/primitives/runtime", default-features = false} frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} frame-system = { path = "../../../../../../substrate/frame/system", default-features = false} -sp-core = { path = "../../../../../../substrate/primitives/core", default-features = false} -sp-weights = { path = "../../../../../../substrate/primitives/weights", default-features = false} pallet-balances = { path = "../../../../../../substrate/frame/balances", default-features = false} pallet-assets = { path = "../../../../../../substrate/frame/assets", default-features = false} +pallet-asset-conversion = { path = "../../../../../../substrate/frame/asset-conversion", default-features = false} # Polkadot -polkadot-core-primitives = { path = "../../../../../../polkadot/core-primitives", default-features = false} -polkadot-parachain = { path = "../../../../../../polkadot/parachain", default-features = false} polkadot-runtime-parachains = { path = "../../../../../../polkadot/runtime/parachains" } polkadot-runtime = { path = "../../../../../../polkadot/runtime/polkadot" } xcm = { path = "../../../../../../polkadot/xcm", default-features = false} -xcm-executor = { path = "../../../../../../polkadot/xcm/xcm-executor", default-features = false} pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-features = false} # Cumulus parachains-common = { path = "../../../../common" } -cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} -cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } +asset-hub-kusama-runtime = { path = "../../../../runtimes/assets/asset-hub-kusama" } # Local xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml index 785cdd936812..398fcf8701d8 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml @@ -13,26 +13,19 @@ assert_matches = "1.5.0" sp-runtime = { path = "../../../../../../substrate/primitives/runtime", default-features = false} frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} frame-system = { path = "../../../../../../substrate/frame/system", default-features = false} -sp-core = { path = "../../../../../../substrate/primitives/core", default-features = false} -sp-weights = { path = "../../../../../../substrate/primitives/weights", default-features = false} pallet-balances = { path = "../../../../../../substrate/frame/balances", default-features = false} pallet-assets = { path = "../../../../../../substrate/frame/assets", default-features = false} pallet-asset-conversion = { path = "../../../../../../substrate/frame/asset-conversion", default-features = false} # Polkadot -polkadot-core-primitives = { path = "../../../../../../polkadot/core-primitives", default-features = false} -polkadot-parachain = { path = "../../../../../../polkadot/parachain", default-features = false} polkadot-runtime-parachains = { path = "../../../../../../polkadot/runtime/parachains" } polkadot-runtime = { path = "../../../../../../polkadot/runtime/polkadot" } xcm = { path = "../../../../../../polkadot/xcm", default-features = false} -xcm-executor = { path = "../../../../../../polkadot/xcm/xcm-executor", default-features = false} pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-features = false} # Cumulus parachains-common = { path = "../../../../common" } asset-hub-westend-runtime = { path = "../../../../runtimes/assets/asset-hub-westend" } -cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} -cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } # Local xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml index b076aba75d58..43a6d8e54b5b 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/Cargo.toml @@ -9,28 +9,16 @@ description = "Bridge Hub Rococo runtime integration tests with xcm-emulator" codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } # Substrate -sp-runtime = { path = "../../../../../../substrate/primitives/runtime", default-features = false} frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} -frame-system = { path = "../../../../../../substrate/frame/system", default-features = false} -sp-core = { path = "../../../../../../substrate/primitives/core", default-features = false} -sp-weights = { path = "../../../../../../substrate/primitives/weights", default-features = false} -pallet-balances = { path = "../../../../../../substrate/frame/balances", default-features = false} -pallet-assets = { path = "../../../../../../substrate/frame/assets", default-features = false} # Polkadot -polkadot-core-primitives = { path = "../../../../../../polkadot/core-primitives", default-features = false} -polkadot-parachain = { path = "../../../../../../polkadot/parachain", default-features = false} -polkadot-runtime-parachains = { path = "../../../../../../polkadot/runtime/parachains" } -polkadot-runtime = { path = "../../../../../../polkadot/runtime/polkadot" } xcm = { path = "../../../../../../polkadot/xcm", default-features = false} -xcm-executor = { path = "../../../../../../polkadot/xcm/xcm-executor", default-features = false} pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-features = false} # Cumulus parachains-common = { path = "../../../../common" } cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} cumulus-pallet-dmp-queue = { path = "../../../../../pallets/dmp-queue", default-features = false} -cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } pallet-bridge-messages = { path = "../../../../../bridges/modules/messages", default-features = false} bp-messages = { path = "../../../../../bridges/primitives/messages", default-features = false} diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml index cee67639e27f..253971f1c073 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml @@ -11,21 +11,13 @@ codec = { package = "parity-scale-codec", version = "3.4.0", default-features = # Substrate sp-runtime = { path = "../../../../../../substrate/primitives/runtime", default-features = false} frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} -frame-system = { path = "../../../../../../substrate/frame/system", default-features = false} sp-core = { path = "../../../../../../substrate/primitives/core", default-features = false} -sp-weights = { path = "../../../../../../substrate/primitives/weights", default-features = false} -pallet-balances = { path = "../../../../../../substrate/frame/balances", default-features = false} pallet-assets = { path = "../../../../../../substrate/frame/assets", default-features = false} pallet-core-fellowship = { path = "../../../../../../substrate/frame/core-fellowship", default-features = false} pallet-salary = { path = "../../../../../../substrate/frame/salary", default-features = false} # Polkadot -polkadot-core-primitives = { path = "../../../../../../polkadot/core-primitives", default-features = false} -polkadot-parachain = { path = "../../../../../../polkadot/parachain", default-features = false} -polkadot-runtime-parachains = { path = "../../../../../../polkadot/runtime/parachains" } -polkadot-runtime = { path = "../../../../../../polkadot/runtime/polkadot" } xcm = { path = "../../../../../../polkadot/xcm", default-features = false} -xcm-executor = { path = "../../../../../../polkadot/xcm/xcm-executor", default-features = false} pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-features = false} # Cumulus @@ -33,7 +25,6 @@ parachains-common = { path = "../../../../common" } cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" } collectives-polkadot-runtime = { path = "../../../../runtimes/collectives/collectives-polkadot" } -asset-hub-polkadot-runtime = { path = "../../../../runtimes/assets/asset-hub-polkadot" } # Local xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} From c5a9c06056330147a747f52c697bf8e434221555 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Wed, 30 Aug 2023 12:08:07 +0200 Subject: [PATCH 6/7] last hygiene bits --- .../emulated/common/src/impls.rs | 46 +++++++++++-------- cumulus/xcm/xcm-emulator/src/lib.rs | 4 +- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs index 1177d06887e4..869b0b01a6f1 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs @@ -26,6 +26,8 @@ pub use crate::{ // Substrate use sp_core::Get; pub use frame_support::{traits::fungibles::Inspect, assert_ok}; +pub use pallet_assets; +pub use pallet_message_queue; // Cumulus use bp_messages::{ @@ -41,11 +43,14 @@ pub use xcm_emulator::{ helpers::weight_within_threshold, BridgeMessageHandler, Chain, BridgeMessage, BridgeMessageDispatchError, TestExt, Parachain, RelayChain, }; +pub use cumulus_pallet_parachain_system; +pub use cumulus_pallet_dmp_queue; +pub use cumulus_pallet_xcmp_queue; // Polkadot pub use polkadot_runtime_parachains::{ dmp, - hrmp::HrmpChannels, + hrmp, inclusion::{AggregateMessageOrigin, UmpQueueId}, }; pub use xcm::{ @@ -55,6 +60,7 @@ pub use xcm::{ v3::Error, DoubleEncoded, }; +pub use pallet_xcm; pub struct BridgeHubMessageHandler { _marker: std::marker::PhantomData<(S, T, I)>, @@ -212,7 +218,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain { Self, vec![ [<$chain RuntimeEvent>]::XcmPallet( - pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } ) => { weight: $crate::impls::weight_within_threshold( ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), @@ -234,7 +240,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain { vec![ // Dispatchable is properly executed and XCM message sent [<$chain RuntimeEvent>]::XcmPallet( - pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } ) => { weight: $crate::impls::weight_within_threshold( ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), @@ -252,7 +258,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain { $crate::impls::assert_expected_events!( Self, vec![ - [<$chain RuntimeEvent>]::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + [<$chain RuntimeEvent>]::XcmPallet($crate::impls::pallet_xcm::Event::Sent { .. }) => {}, ] ); } @@ -267,7 +273,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain { Self, vec![ // XCM is succesfully received and proccessed - [<$chain RuntimeEvent>]::MessageQueue(pallet_message_queue::Event::Processed { + [<$chain RuntimeEvent>]::MessageQueue($crate::impls::pallet_message_queue::Event::Processed { origin: $crate::impls::AggregateMessageOrigin::Ump($crate::impls::UmpQueueId::Para(id)), weight_used, success, @@ -302,7 +308,7 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { ) -> $crate::impls::DoubleEncoded<()> { use $crate::impls::Encode; - ::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + ::RuntimeCall::Hrmp($crate::impls::hrmp::Call::< ::Runtime, >::hrmp_init_open_channel { recipient: recipient_para_id, @@ -316,7 +322,7 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { pub fn accept_open_channel_call(sender_para_id: $crate::impls::ParaId) -> $crate::impls::DoubleEncoded<()> { use $crate::impls::Encode; - ::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + ::RuntimeCall::Hrmp($crate::impls::hrmp::Call::< ::Runtime, >::hrmp_accept_open_channel { sender: sender_para_id, @@ -340,7 +346,7 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { let channel_id = $crate::impls::HrmpChannelId { sender, recipient }; - let hrmp_channel_exist = $crate::impls::HrmpChannels::< + let hrmp_channel_exist = $crate::impls::hrmp::HrmpChannels::< ::Runtime, >::contains_key(&channel_id); @@ -388,7 +394,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { Self, vec![ [<$chain RuntimeEvent>]::PolkadotXcm( - pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } ) => { weight: $crate::impls::weight_within_threshold( ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), @@ -410,7 +416,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { vec![ // Dispatchable is properly executed and XCM message sent [<$chain RuntimeEvent>]::PolkadotXcm( - pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } ) => { weight: $crate::impls::weight_within_threshold( ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), @@ -430,7 +436,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { vec![ // Execution fails in the origin with `Barrier` [<$chain RuntimeEvent>]::PolkadotXcm( - pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Error(error) } + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Error(error) } ) => { error: *error == expected_error.unwrap_or(*error), }, @@ -443,7 +449,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { $crate::impls::assert_expected_events!( Self, vec![ - [<$chain RuntimeEvent>]::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + [<$chain RuntimeEvent>]::PolkadotXcm($crate::impls::pallet_xcm::Event::Sent { .. }) => {}, ] ); } @@ -454,7 +460,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { Self, vec![ [<$chain RuntimeEvent>]::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } + $crate::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } ) => {}, ] ); @@ -465,7 +471,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { $crate::impls::assert_expected_events!( Self, vec![ - [<$chain RuntimeEvent>]::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { + [<$chain RuntimeEvent>]::DmpQueue($crate::impls::cumulus_pallet_dmp_queue::Event::ExecutedDownward { outcome: $crate::impls::Outcome::Complete(weight), .. }) => { weight: $crate::impls::weight_within_threshold( @@ -486,7 +492,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { $crate::impls::assert_expected_events!( Self, vec![ - [<$chain RuntimeEvent>]::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { + [<$chain RuntimeEvent>]::DmpQueue($crate::impls::cumulus_pallet_dmp_queue::Event::ExecutedDownward { outcome: $crate::impls::Outcome::Incomplete(weight, error), .. }) => { weight: $crate::impls::weight_within_threshold( @@ -506,7 +512,7 @@ macro_rules! impl_assert_events_helpers_for_parachain { Self, vec![ [<$chain RuntimeEvent>]::XcmpQueue( - cumulus_pallet_xcmp_queue::Event::Success { weight, .. } + $crate::impls::cumulus_pallet_xcmp_queue::Event::Success { weight, .. } ) => { weight: $crate::impls::weight_within_threshold( ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), @@ -536,9 +542,9 @@ macro_rules! impl_assets_helpers_for_parachain { ) -> $crate::impls::DoubleEncoded<()> { use $crate::impls::{Chain, Encode}; - ::RuntimeCall::Assets(pallet_assets::Call::< + ::RuntimeCall::Assets($crate::impls::pallet_assets::Call::< ::Runtime, - pallet_assets::Instance1, + $crate::impls::pallet_assets::Instance1, >::force_create { id: asset_id.into(), owner: owner.into(), @@ -581,7 +587,7 @@ macro_rules! impl_assets_helpers_for_parachain { $crate::impls::assert_expected_events!( Self, vec![ - RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount }) => { + RuntimeEvent::Assets($crate::impls::pallet_assets::Event::Issued { asset_id, owner, amount }) => { asset_id: *asset_id == id, owner: *owner == beneficiary.clone().into(), amount: *amount == amount_to_mint, @@ -630,7 +636,7 @@ macro_rules! impl_assets_helpers_for_parachain { Self, vec![ // Asset has been created - RuntimeEvent::Assets(pallet_assets::Event::ForceCreated { asset_id, owner }) => { + RuntimeEvent::Assets($crate::impls::pallet_assets::Event::ForceCreated { asset_id, owner }) => { asset_id: *asset_id == id, owner: *owner == asset_owner.clone(), }, diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index e581a164c26b..650bc58c57cf 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -41,7 +41,7 @@ pub use frame_support::{ pub use frame_system::{Config as SystemConfig, Pallet as SystemPallet}; pub use pallet_balances::AccountData; pub use sp_arithmetic::traits::Bounded; -pub use sp_core::{parameter_types, sr25519, storage::Storage, Pair}; +pub use sp_core::{parameter_types, sr25519, blake2_256, storage::Storage, Pair}; pub use sp_io::TestExternalities; pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, fmt::Debug}; pub use sp_tracing; @@ -1019,7 +1019,7 @@ macro_rules! decl_test_networks { &msg[..], from_para_id.into(), &mut weight_meter, - &mut msg.using_encoded(sp_core::blake2_256), + &mut msg.using_encoded($crate::blake2_256), ); }); $crate::log::debug!(target: concat!("ump::", stringify!($name)) , "Upward message processed {:?} from para_id {:?}", &msg, &from_para_id); From fac6f8d4f70c594e57b3b5db86b5d780ddeb276a Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 30 Aug 2023 10:24:03 +0000 Subject: [PATCH 7/7] ".git/.scripts/commands/fmt/fmt.sh" --- .../assets/asset-hub-kusama/src/lib.rs | 20 ++++++------- .../assets/asset-hub-polkadot/src/lib.rs | 16 +++++------ .../assets/asset-hub-westend/src/lib.rs | 17 +++++------ .../bridges/bridge-hub-rococo/src/lib.rs | 16 +++++------ .../collectives-polkadot/src/lib.rs | 21 ++++++-------- .../emulated/common/src/constants.rs | 6 ++-- .../emulated/common/src/impls.rs | 28 +++++++++---------- .../emulated/common/src/lib.rs | 5 ++-- .../emulated/common/src/xcm_helpers.rs | 4 +-- cumulus/xcm/xcm-emulator/src/lib.rs | 21 +++++--------- 10 files changed, 65 insertions(+), 89 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index a61ea528bf5f..50acaa79b678 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -23,24 +23,22 @@ pub use frame_support::{ }; pub use integration_tests_common::{ constants::{ - asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, - kusama::ED as KUSAMA_ED, - PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, + REF_TIME_THRESHOLD, XCM_V3, }, - xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubKusama, - Kusama, PenpalKusamaA, AssetHubKusamaReceiver, KusamaPallet, AssetHubKusamaPallet, - AssetHubKusamaSender, PenpalKusamaAReceiver, KusamaReceiver, KusamaSender, - PenpalKusamaAPallet, PenpalKusamaASender + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, Kusama, + KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusamaA, PenpalKusamaAPallet, + PenpalKusamaAReceiver, PenpalKusamaASender, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ - prelude::{*, AccountId32 as AccountId32Junction}, + prelude::{AccountId32 as AccountId32Junction, *}, v3::{Error, NetworkId::Kusama as KusamaId}, }; pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, - Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt + assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index b07416c8b048..c6c07054710d 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -23,24 +23,22 @@ pub use frame_support::{ }; pub use integration_tests_common::{ constants::{ - asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, - polkadot::ED as POLKADOT_ED, + asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubPolkadot, Polkadot, PolkadotPallet, PenpalPolkadotA, AssetHubPolkadotPallet, - AssetHubPolkadotReceiver, PolkadotSender, PolkadotReceiver, AssetHubPolkadotSender, - PenpalPolkadotAReceiver + AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, + PenpalPolkadotA, PenpalPolkadotAReceiver, Polkadot, PolkadotPallet, PolkadotReceiver, + PolkadotSender, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ - prelude::{*, AccountId32 as AccountId32Junction}, + prelude::{AccountId32 as AccountId32Junction, *}, v3::{Error, NetworkId::Polkadot as PolkadotId}, }; pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, - Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt + assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index f4cb7cafde27..77e0326c7448 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -25,25 +25,22 @@ pub use frame_support::{ }; pub use integration_tests_common::{ constants::{ - asset_hub_westend::ED as ASSET_HUB_WESTEND_ED, - westend::ED as WESTEND_ED, + asset_hub_westend::ED as ASSET_HUB_WESTEND_ED, westend::ED as WESTEND_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubWestend, Westend, PenpalWestendA, AssetHubWestendReceiver, - AssetHubWestendPallet, WestendPallet, WestendSender, WestendReceiver, - AssetHubWestendSender, PenpalWestendAReceiver, PenpalWestendASender, - PenpalWestendAPallet, + AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, + PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, + WestendPallet, WestendReceiver, WestendSender, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ - prelude::{*, AccountId32 as AccountId32Junction}, + prelude::{AccountId32 as AccountId32Junction, *}, v3::{Error, NetworkId::Westend as WestendId}, }; pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, - Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt + assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 0d985c1c4077..639b6a30c3bd 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -18,26 +18,24 @@ pub use bp_messages::LaneId; pub use frame_support::assert_ok; pub use integration_tests_common::{ constants::{ - asset_hub_kusama::ED as ASSET_HUB_ROCOCO_ED, - kusama::ED as ROCOCO_ED, - PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + asset_hub_kusama::ED as ASSET_HUB_ROCOCO_ED, kusama::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, + REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - Rococo, BridgeHubRococo, AssetHubWococo, RococoPallet, BridgeHubWococo, - AssetHubRococo, PenpalRococoA, AssetHubRococoReceiver, + AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, BridgeHubRococo, BridgeHubWococo, + PenpalRococoA, Rococo, RococoPallet, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ - prelude::{*, AccountId32 as AccountId32Junction}, + prelude::{AccountId32 as AccountId32Junction, *}, v3::{ Error, NetworkId::{Rococo as RococoId, Wococo as WococoId}, }, }; pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, - Chain, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt + assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index 8f5bf6531dde..8578d25fe12e 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -15,29 +15,24 @@ // along with Cumulus. If not, see . pub use codec::Encode; -pub use frame_support::{ - assert_ok, sp_runtime::AccountId32, -}; +pub use frame_support::{assert_ok, sp_runtime::AccountId32}; pub use integration_tests_common::{ constants::{ - accounts::ALICE, - asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, - polkadot::ED as POLKADOT_ED, - PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + accounts::ALICE, asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, + polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubPolkadot, Polkadot, AssetHubPolkadotReceiver, PenpalPolkadotA, - AssetHubPolkadotPallet, Collectives, + AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, Collectives, + PenpalPolkadotA, Polkadot, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ - prelude::{*, AccountId32 as AccountId32Junction}, + prelude::{AccountId32 as AccountId32Junction, *}, v3::{Error, NetworkId::Polkadot as PolkadotId}, }; pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, - Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs, - TestContext, TestExt, TestExternalities, + assert_expected_events, bx, helpers::weight_within_threshold, Chain, ParaId, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, TestExternalities, }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/common/src/constants.rs b/cumulus/parachains/integration-tests/emulated/common/src/constants.rs index 38e6af0eaeca..d6a364c715dd 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/constants.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/constants.rs @@ -15,6 +15,9 @@ // along with Cumulus. If not, see . // Substrate +use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; +use grandpa::AuthorityId as GrandpaId; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; use sp_core::{sr25519, storage::Storage, Pair, Public}; @@ -22,9 +25,6 @@ use sp_runtime::{ traits::{IdentifyAccount, Verify}, BuildStorage, MultiSignature, Perbill, }; -use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; -use grandpa::AuthorityId as GrandpaId; -use pallet_im_online::sr25519::AuthorityId as ImOnlineId; // Cumulus use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; diff --git a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs index 869b0b01a6f1..6eaf4cdfa941 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs @@ -24,10 +24,10 @@ pub use crate::{ }; // Substrate -use sp_core::Get; -pub use frame_support::{traits::fungibles::Inspect, assert_ok}; +pub use frame_support::{assert_ok, traits::fungibles::Inspect}; pub use pallet_assets; pub use pallet_message_queue; +use sp_core::Get; // Cumulus use bp_messages::{ @@ -35,32 +35,30 @@ use bp_messages::{ LaneId, MessageKey, OutboundLaneData, }; use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; +pub use cumulus_pallet_dmp_queue; +pub use cumulus_pallet_parachain_system; +pub use cumulus_pallet_xcmp_queue; +pub use cumulus_primitives_core::{ + relay_chain::HrmpChannelId, DmpMessageHandler, ParaId, XcmpMessageHandler, +}; use pallet_bridge_messages::{Config, Instance1, Instance2, OutboundLanes, Pallet}; -pub use cumulus_primitives_core::{relay_chain::HrmpChannelId, DmpMessageHandler, ParaId, XcmpMessageHandler}; pub use parachains_common::{AccountId, Balance}; pub use xcm_emulator::{ - assert_expected_events, bx, - helpers::weight_within_threshold, BridgeMessageHandler, Chain, - BridgeMessage, BridgeMessageDispatchError, TestExt, Parachain, RelayChain, + assert_expected_events, bx, helpers::weight_within_threshold, BridgeMessage, + BridgeMessageDispatchError, BridgeMessageHandler, Chain, Parachain, RelayChain, TestExt, }; -pub use cumulus_pallet_parachain_system; -pub use cumulus_pallet_dmp_queue; -pub use cumulus_pallet_xcmp_queue; // Polkadot +pub use pallet_xcm; pub use polkadot_runtime_parachains::{ - dmp, - hrmp, + dmp, hrmp, inclusion::{AggregateMessageOrigin, UmpQueueId}, }; pub use xcm::{ - prelude::{ - OriginKind, Outcome, VersionedXcm, Weight, - }, + prelude::{OriginKind, Outcome, VersionedXcm, Weight}, v3::Error, DoubleEncoded, }; -pub use pallet_xcm; pub struct BridgeHubMessageHandler { _marker: std::marker::PhantomData<(S, T, I)>, diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index 52cefab0691b..29faa556d379 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -30,9 +30,8 @@ use frame_support::traits::OnInitialize; // Cumulus use xcm_emulator::{ - decl_test_bridges, decl_test_networks, decl_test_parachains, - decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types, - DefaultMessageProcessor, + decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains, + decl_test_sender_receiver_accounts_parameter_types, DefaultMessageProcessor, }; decl_test_relay_chains! { diff --git a/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs b/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs index 539698d460d0..4096cdbba0b9 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs @@ -18,8 +18,8 @@ use parachains_common::AccountId; use xcm::{ prelude::{ AccountId32, All, BuyExecution, DepositAsset, MultiAsset, MultiAssets, MultiLocation, - OriginKind, RefundSurplus, Transact, UnpaidExecution, VersionedXcm, Weight, - WeightLimit, WithdrawAsset, Xcm, X1, + OriginKind, RefundSurplus, Transact, UnpaidExecution, VersionedXcm, Weight, WeightLimit, + WithdrawAsset, Xcm, X1, }, DoubleEncoded, }; diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index 650bc58c57cf..35fdad99527c 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -14,34 +14,28 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +pub use codec::{Decode, Encode}; pub use lazy_static::lazy_static; pub use log; pub use paste; pub use std::{ - any::type_name, - collections::HashMap, - error::Error, - fmt, - marker::PhantomData, - ops::Deref, + any::type_name, collections::HashMap, error::Error, fmt, marker::PhantomData, ops::Deref, sync::Mutex, }; -pub use codec::{Encode, Decode}; // Substrate pub use frame_support::{ assert_ok, sp_runtime::{traits::Header as HeaderT, AccountId32, DispatchResult}, traits::{ - EnqueueMessage, Get, Hooks, OriginTrait, ProcessMessage, - ProcessMessageError, ServiceQueues, + EnqueueMessage, Get, Hooks, OriginTrait, ProcessMessage, ProcessMessageError, ServiceQueues, }, weights::{Weight, WeightMeter}, }; pub use frame_system::{Config as SystemConfig, Pallet as SystemPallet}; pub use pallet_balances::AccountData; pub use sp_arithmetic::traits::Bounded; -pub use sp_core::{parameter_types, sr25519, blake2_256, storage::Storage, Pair}; +pub use sp_core::{blake2_256, parameter_types, sr25519, storage::Storage, Pair}; pub use sp_io::TestExternalities; pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, fmt::Debug}; pub use sp_tracing; @@ -54,9 +48,7 @@ pub use cumulus_primitives_core::{ }; pub use cumulus_primitives_parachain_inherent::ParachainInherentData; pub use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; -pub use pallet_message_queue::{ - Config as MessageQueueConfig, Pallet as MessageQueuePallet, -}; +pub use pallet_message_queue::{Config as MessageQueueConfig, Pallet as MessageQueuePallet}; pub use parachains_common::{AccountId, Balance, BlockNumber}; pub use polkadot_primitives; pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; @@ -64,7 +56,8 @@ pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueu // Polkadot pub use polkadot_parachain::primitives::RelayChainBlockNumber; pub use xcm::v3::prelude::{ - Ancestor, MultiAssets, MultiLocation, Parent, Parachain as ParachainJunction, WeightLimit, XcmHash, X1 + Ancestor, MultiAssets, MultiLocation, Parachain as ParachainJunction, Parent, WeightLimit, + XcmHash, X1, }; pub use xcm_executor::traits::ConvertLocation;