diff --git a/Cargo.lock b/Cargo.lock index 193fcef7d639..cabddc6b881f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2354,6 +2354,7 @@ dependencies = [ "snowbridge-outbound-queue", "snowbridge-router-primitives", "sp-core", + "sp-weights", "staging-xcm", "staging-xcm-executor", "xcm-emulator", @@ -17462,6 +17463,7 @@ dependencies = [ "frame-support", "frame-system", "hex-literal", + "log", "parity-scale-codec", "scale-info", "serde", diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index 93c8db8ddc16..2bb42947e816 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -17,8 +17,8 @@ use super::{ AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, BaseDeliveryFee, FeeAssetId, ForeignAssets, ForeignAssetsInstance, ParachainInfo, ParachainSystem, PolkadotXcm, PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeFlavor, RuntimeOrigin, - ToRococoXcmRouter, ToWestendXcmRouter, ToWococoXcmRouter, TransactionByteFee, - TrustBackedAssetsInstance, WeightToFee, XcmpQueue, ToEthereumXcmRouter, + ToEthereumXcmRouter, ToRococoXcmRouter, ToWestendXcmRouter, ToWococoXcmRouter, + TransactionByteFee, TrustBackedAssetsInstance, WeightToFee, XcmpQueue, }; use assets_common::{ local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 65b3680d0664..4d66071d6cfc 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -41,8 +41,11 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; use cumulus_primitives_core::ParaId; -use bridge_hub_common::{AggregateMessageOrigin, message_queue::{NarrowOriginToSibling, ParaIdToSibling}}; use frame_support::{ construct_runtime, dispatch::DispatchClass, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index ddb6742b1989..079b6f18eb65 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -41,8 +41,11 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; use cumulus_primitives_core::ParaId; -use bridge_hub_common::{AggregateMessageOrigin, message_queue::{NarrowOriginToSibling, ParaIdToSibling}}; use frame_support::{ construct_runtime, dispatch::DispatchClass, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_rococo_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_rococo_config.rs index 21a42a522d99..25b192295bb0 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_rococo_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_rococo_config.rs @@ -18,7 +18,9 @@ use crate::{ bridge_common_config::{BridgeParachainRococoInstance, DeliveryRewardInBalance}, - weights, AccountId, BridgeRococoMessages, ParachainInfo, Runtime, RuntimeEvent, RuntimeOrigin, + weights, + xcm_config::{AgentIdOf, EthereumNetwork, UniversalLocation}, + AccountId, BridgeRococoMessages, ParachainInfo, Runtime, RuntimeEvent, RuntimeOrigin, XcmRouter, }; use bp_messages::LaneId; @@ -40,16 +42,13 @@ use bridge_runtime_common::{ }; use codec::Encode; use frame_support::{parameter_types, traits::PalletInfoAccess}; +use snowbridge_router_primitives::outbound::EthereumBlobExporter; use sp_runtime::RuntimeDebug; use xcm::{ latest::prelude::*, prelude::{InteriorMultiLocation, NetworkId}, }; use xcm_builder::{BridgeBlobDispatcher, HaulBlobExporter}; -use snowbridge_router_primitives::outbound::EthereumBlobExporter; -use crate::xcm_config::EthereumNetwork; -use crate::xcm_config::AgentIdOf; -use crate::xcm_config::UniversalLocation; parameter_types! { pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce = diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 654b3fcd9655..f54301fae62d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -80,10 +80,13 @@ use pallet_xcm::EnsureXcm; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm::VersionedMultiLocation; -use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin, XcmRouter}; +use xcm_config::{XcmOriginToTransactDispatchOrigin, XcmRouter}; use bp_runtime::HeaderId; -use bridge_hub_common::{AggregateMessageOrigin, BridgeHubMessageRouter, message_queue::{NarrowOriginToSibling, ParaIdToSibling}}; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, BridgeHubMessageRouter, +}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -99,7 +102,6 @@ use parachains_common::{ AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; -use xcm_executor::XcmExecutor; #[cfg(feature = "runtime-benchmarks")] use crate::xcm_config::benchmark_helper::DoNothingRouter; @@ -388,9 +390,8 @@ impl pallet_message_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_message_queue::WeightInfo; #[cfg(feature = "runtime-benchmarks")] - type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor< - AggregateMessageOrigin, - >; + type MessageProcessor = + pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(feature = "runtime-benchmarks"))] type MessageProcessor = BridgeHubMessageRouter< xcm_builder::ProcessXcmMessage< diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 0c01c5973690..b88838ff0bc7 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -40,7 +40,6 @@ use parachains_common::{ use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::xcm_sender::ExponentialPrice; use rococo_runtime_constants::system_parachain::SystemParachains; -use snowbridge_router_primitives::outbound::EthereumBlobExporter; use sp_core::{Get, H256}; use sp_runtime::traits::AccountIdConversion; use sp_std::marker::PhantomData; @@ -222,8 +221,8 @@ impl Contains for SafeCallFilter { ) | RuntimeCall::EthereumInboundQueue( snowbridge_inbound_queue::Call::set_operating_mode { .. }, ) /* | RuntimeCall::EthereumOutboundQueue( - snowbridge_outbound_queue::Call::set_operating_mode { .. }, - ) | RuntimeCall::EthereumControl(..) */ + snowbridge_outbound_queue::Call::set_operating_mode { .. }, + ) | RuntimeCall::EthereumControl(..) */ ) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index ff5dbe0ddea6..b5a386e8e6ea 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -32,9 +32,12 @@ pub mod bridge_to_rococo_config; mod weights; pub mod xcm_config; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use cumulus_primitives_core::ParaId; -use bridge_hub_common::{AggregateMessageOrigin, message_queue::{NarrowOriginToSibling, ParaIdToSibling}}; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs index ab9ba47a699b..0ed671ae4f1c 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs @@ -16,5 +16,4 @@ pub mod message_queue; -pub use message_queue::{AggregateMessageOrigin, SnowbridgeMessageOrigin, BridgeHubMessageRouter}; - +pub use message_queue::{AggregateMessageOrigin, BridgeHubMessageRouter, SnowbridgeMessageOrigin}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs index 976e16455d9a..fbbaa17b5a6f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs @@ -13,14 +13,16 @@ // See the License for the specific language governing permissions and // limitations under the License. //! Runtime configuration for MessageQueue pallet -use sp_std::{prelude::*, marker::PhantomData}; use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::{weights::WeightMeter, traits::{ProcessMessage, ProcessMessageError}}; -use scale_info::TypeInfo; use cumulus_primitives_core::ParaId; -use xcm::v3::{MultiLocation, Junction}; -use frame_support::traits::{QueueFootprint, QueuePausedQuery}; +use frame_support::{ + traits::{ProcessMessage, ProcessMessageError, QueueFootprint, QueuePausedQuery}, + weights::WeightMeter, +}; use pallet_message_queue::OnQueueChanged; +use scale_info::TypeInfo; +use sp_std::{marker::PhantomData, prelude::*}; +use xcm::v3::{Junction, MultiLocation}; /// The aggregate origin of an inbound message. /// This is specialized for BridgeHub, as the snowbridge-outbound-queue pallet is also using @@ -55,8 +57,7 @@ impl From for MultiLocation { match origin { Here => MultiLocation::here(), Parent => MultiLocation::parent(), - Sibling(id) => - MultiLocation::new(1, Junction::Parachain(id.into())), + Sibling(id) => MultiLocation::new(1, Junction::Parachain(id.into())), // NOTE: We don't need this conversion for Snowbridge. However we have to // implement it anyway as xcm_builder::ProcessXcmMessage requires it. Snowbridge(_) => MultiLocation::default(), @@ -76,21 +77,18 @@ impl From for AggregateMessageOrigin { } /// Routes messages to either the XCMP or Snowbridge processor. -pub struct BridgeHubMessageRouter(PhantomData<(XcmpProcessor, SnowbridgeProcessor)>) +pub struct BridgeHubMessageRouter( + PhantomData<(XcmpProcessor, SnowbridgeProcessor)>, +) where XcmpProcessor: ProcessMessage, SnowbridgeProcessor: ProcessMessage; -impl< - XcmpProcessor, - SnowbridgeProcessor -> ProcessMessage for BridgeHubMessageRouter< - XcmpProcessor, - SnowbridgeProcessor -> +impl ProcessMessage + for BridgeHubMessageRouter where XcmpProcessor: ProcessMessage, - SnowbridgeProcessor: ProcessMessage + SnowbridgeProcessor: ProcessMessage, { type Origin = AggregateMessageOrigin; @@ -102,15 +100,16 @@ where ) -> Result { use AggregateMessageOrigin::*; match origin { - Here | Parent | Sibling(_) => XcmpProcessor::process_message(message, origin, meter, id), - Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id) + Here | Parent | Sibling(_) => + XcmpProcessor::process_message(message, origin, meter, id), + Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id), } } } pub struct NarrowOriginToSibling(PhantomData); impl> QueuePausedQuery -for NarrowOriginToSibling + for NarrowOriginToSibling { fn is_paused(origin: &AggregateMessageOrigin) -> bool { match origin { @@ -121,7 +120,7 @@ for NarrowOriginToSibling } impl> OnQueueChanged -for NarrowOriginToSibling + for NarrowOriginToSibling { fn on_queue_changed(origin: AggregateMessageOrigin, fp: QueueFootprint) { if let AggregateMessageOrigin::Sibling(id) = origin {