frequency_runtime/xcm/
queue.rs

1use crate::{
2	weights, AccountId, MessageQueue, ParachainSystem, PolkadotXcm, Runtime, RuntimeBlockWeights,
3	RuntimeEvent, XcmpQueue,
4};
5
6#[cfg(not(feature = "runtime-benchmarks"))]
7use crate::RuntimeCall;
8
9use frame_support::{
10	parameter_types,
11	traits::{ConstU32, TransformOrigin},
12	weights::Weight,
13};
14
15use crate::xcm::{
16	location_converter::XcmOriginToTransactDispatchOrigin,
17	parameters::{BaseDeliveryFee, FeeAssetId, TransactionByteFee},
18};
19
20use frame_system::EnsureRoot;
21use staging_xcm_builder::WithUniqueTopic;
22
23use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
24
25use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
26
27pub use sp_runtime::{Perbill, Saturating};
28
29#[cfg(not(feature = "runtime-benchmarks"))]
30use crate::xcm::XcmConfig;
31
32#[cfg(not(feature = "runtime-benchmarks"))]
33use xcm_executor;
34
35/// Pricing logic for sibling parachain message delivery
36pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
37	FeeAssetId,
38	BaseDeliveryFee,
39	TransactionByteFee,
40	XcmpQueue,
41>;
42
43/// Pricing logic for relay message delivery
44pub type PriceForParentDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
45	FeeAssetId,
46	BaseDeliveryFee,
47	TransactionByteFee,
48	ParachainSystem,
49>;
50
51parameter_types! {
52	/// How much weight to allocate to the background message queue service
53	pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
54}
55
56/// The means for routing XCM messages which are not for local execution into the right message
57/// queues.
58pub type XcmRouter = WithUniqueTopic<(
59	// Two routers - use UMP to communicate with the relay chain:
60	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, PriceForParentDelivery>,
61	// ..and XCMP to communicate with the sibling chains.
62	XcmpQueue,
63)>;
64
65/// Configures the queue that handles incoming XCMP messages
66impl cumulus_pallet_xcmp_queue::Config for Runtime {
67	type RuntimeEvent = RuntimeEvent;
68	type ChannelInfo = ParachainSystem;
69	type VersionWrapper = PolkadotXcm;
70	// Enqueue XCMP messages from siblings for later processing.
71	type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
72	type MaxInboundSuspended = sp_core::ConstU32<1_000>;
73	type MaxActiveOutboundChannels = ConstU32<128>;
74	type MaxPageSize = ConstU32<{ 1 << 16 }>;
75	type ControllerOrigin = EnsureRoot<AccountId>;
76	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
77	type WeightInfo = weights::cumulus_pallet_xcmp_queue::SubstrateWeight<Runtime>;
78	type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
79}
80
81/// Configures the local message queue service
82impl pallet_message_queue::Config for Runtime {
83	type RuntimeEvent = RuntimeEvent;
84	type WeightInfo = weights::pallet_message_queue::SubstrateWeight<Runtime>;
85	#[cfg(feature = "runtime-benchmarks")]
86	type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
87		cumulus_primitives_core::AggregateMessageOrigin,
88	>;
89	#[cfg(not(feature = "runtime-benchmarks"))]
90	type MessageProcessor = staging_xcm_builder::ProcessXcmMessage<
91		AggregateMessageOrigin,
92		xcm_executor::XcmExecutor<XcmConfig>,
93		RuntimeCall,
94	>;
95	type Size = u32;
96	// The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin:
97	type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
98	type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
99	type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
100	type MaxStale = sp_core::ConstU32<8>;
101	type ServiceWeight = MessageQueueServiceWeight;
102	type IdleMaxServiceWeight = ();
103}