contracts_rococo_runtime/
xcm_config.rs1use super::{
17 AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
18 Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, TransactionByteFee, WeightToFee, XcmpQueue,
19};
20use cumulus_primitives_core::AggregateMessageOrigin;
21use frame_support::{
22 parameter_types,
23 traits::{ConstU32, Contains, EitherOfDiverse, Equals, Everything, Nothing},
24 weights::Weight,
25};
26use frame_system::EnsureRoot;
27use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
28use parachains_common::{
29 xcm_config::{
30 AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
31 RelayOrOtherSystemParachains,
32 },
33 TREASURY_PALLET_ID,
34};
35use polkadot_parachain_primitives::primitives::Sibling;
36use polkadot_runtime_common::xcm_sender::ExponentialPrice;
37use sp_runtime::traits::AccountIdConversion;
38use testnet_parachains_constants::rococo::currency::CENTS;
39use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH};
40use xcm_builder::{
41 AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
42 AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
43 DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
44 EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter,
45 HashedDescription, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset,
46 RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
47 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
48 TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
49 XcmFeeManagerFromComponents,
50};
51use xcm_executor::XcmExecutor;
52
53parameter_types! {
54 pub const RelayLocation: Location = Location::parent();
55 pub const RelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
56 pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
57 pub UniversalLocation: InteriorLocation = [GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
58 pub const ExecutiveBody: BodyId = BodyId::Executive;
59 pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
60 pub RelayTreasuryLocation: Location = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
61}
62
63pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
65 EnsureRoot<AccountId>,
66 EnsureXcm<IsMajorityOfBody<RelayLocation, ExecutiveBody>>,
67>;
68
69pub type LocationToAccountId = (
73 ParentIsPreset<AccountId>,
75 SiblingParachainConvertsVia<Sibling, AccountId>,
77 AccountId32Aliases<RelayNetwork, AccountId>,
79 HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
81);
82
83pub type FungibleTransactor = FungibleAdapter<
85 Balances,
87 IsConcrete<RelayLocation>,
89 LocationToAccountId,
91 AccountId,
93 (),
95>;
96
97pub type XcmOriginToTransactDispatchOrigin = (
101 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
105 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
108 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
111 ParentAsSuperuser<RuntimeOrigin>,
114 SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
117 XcmPassthrough<RuntimeOrigin>,
119);
120
121parameter_types! {
122 pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
124 pub const MaxInstructions: u32 = 100;
125}
126
127pub struct ParentOrParentsPlurality;
128impl Contains<Location> for ParentOrParentsPlurality {
129 fn contains(location: &Location) -> bool {
130 matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
131 }
132}
133
134pub type Barrier = TrailingSetTopicAsId<
135 DenyThenTry<
136 DenyReserveTransferToRelayChain,
137 (
138 TakeWeightCredit,
139 AllowKnownQueryResponses<PolkadotXcm>,
141 WithComputedOrigin<
143 (
144 AllowTopLevelPaidExecutionFrom<Everything>,
147 AllowExplicitUnpaidExecutionFrom<(
150 ParentOrParentsPlurality,
151 Equals<RelayTreasuryLocation>,
152 )>,
153 AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
155 AllowHrmpNotificationsFromRelayChain,
157 ),
158 UniversalLocation,
159 ConstU32<8>,
160 >,
161 ),
162 >,
163>;
164
165pub type WaivedLocations = (
169 RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
170 Equals<RelayTreasuryLocation>,
171);
172
173pub type TrustedTeleporter = ConcreteAssetFromSystem<RelayLocation>;
174
175pub struct XcmConfig;
176impl xcm_executor::Config for XcmConfig {
177 type RuntimeCall = RuntimeCall;
178 type XcmSender = XcmRouter;
179 type AssetTransactor = FungibleTransactor;
180 type OriginConverter = XcmOriginToTransactDispatchOrigin;
181 type IsReserve = NativeAsset;
182 type IsTeleporter = TrustedTeleporter;
183 type UniversalLocation = UniversalLocation;
184 type Barrier = Barrier;
185 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
186 type Trader = UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ()>;
187 type ResponseHandler = PolkadotXcm;
188 type AssetTrap = PolkadotXcm;
189 type AssetClaims = PolkadotXcm;
190 type SubscriptionService = PolkadotXcm;
191 type PalletInstancesInfo = AllPalletsWithSystem;
192 type MaxAssetsIntoHolding = ConstU32<8>;
193 type AssetLocker = ();
194 type AssetExchanger = ();
195 type FeeManager = XcmFeeManagerFromComponents<
196 WaivedLocations,
197 SendXcmFeeToAccount<Self::AssetTransactor, TreasuryAccount>,
198 >;
199 type MessageExporter = ();
200 type UniversalAliases = Nothing;
201 type CallDispatcher = RuntimeCall;
202 type SafeCallFilter = Everything;
203 type Aliasers = Nothing;
204 type TransactionalProcessor = FrameTransactionalProcessor;
205 type HrmpNewChannelOpenRequestHandler = ();
206 type HrmpChannelAcceptedHandler = ();
207 type HrmpChannelClosingHandler = ();
208 type XcmRecorder = PolkadotXcm;
209}
210
211pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
214
215pub type PriceForParentDelivery =
216 ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
217
218pub type XcmRouter = WithUniqueTopic<(
221 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, PriceForParentDelivery>,
223 XcmpQueue,
225)>;
226
227impl pallet_xcm::Config for Runtime {
228 type RuntimeEvent = RuntimeEvent;
229 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
231 type XcmRouter = XcmRouter;
232 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
234 type XcmExecuteFilter = Everything;
236 type XcmExecutor = XcmExecutor<XcmConfig>;
237 type XcmTeleportFilter = Everything;
238 type XcmReserveTransferFilter = Everything;
239 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
240 type UniversalLocation = UniversalLocation;
241 type RuntimeOrigin = RuntimeOrigin;
242 type RuntimeCall = RuntimeCall;
243 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
244 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
245 type Currency = Balances;
246 type CurrencyMatcher = ();
247 type TrustedLockers = ();
248 type SovereignAccountOf = LocationToAccountId;
249 type MaxLockers = ConstU32<8>;
250 type WeightInfo = pallet_xcm::TestWeightInfo;
252 type AdminOrigin = EnsureRoot<AccountId>;
253 type MaxRemoteLockConsumers = ConstU32<0>;
254 type RemoteLockConsumerIdentifier = ();
255}
256
257impl cumulus_pallet_xcm::Config for Runtime {
258 type RuntimeEvent = RuntimeEvent;
259 type XcmExecutor = XcmExecutor<XcmConfig>;
260}
261
262parameter_types! {
263 pub FeeAssetId: AssetId = AssetId(RelayLocation::get());
265 pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
267}
268
269pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
270 FeeAssetId,
271 BaseDeliveryFee,
272 TransactionByteFee,
273 XcmpQueue,
274>;
275
276impl cumulus_pallet_xcmp_queue::Config for Runtime {
277 type RuntimeEvent = RuntimeEvent;
278 type ChannelInfo = ParachainSystem;
279 type VersionWrapper = PolkadotXcm;
280 #[cfg(feature = "runtime-benchmarks")]
282 type XcmpQueue = ();
283 #[cfg(not(feature = "runtime-benchmarks"))]
284 type XcmpQueue = frame_support::traits::TransformOrigin<
285 crate::MessageQueue,
286 AggregateMessageOrigin,
287 cumulus_primitives_core::ParaId,
288 parachains_common::message_queue::ParaIdToSibling,
289 >;
290 type MaxInboundSuspended = ConstU32<1_000>;
291 type MaxActiveOutboundChannels = ConstU32<128>;
292 type MaxPageSize = ConstU32<{ 103 * 1024 }>;
295 type ControllerOrigin = EitherOfDiverse<
296 EnsureRoot<AccountId>,
297 EnsureXcm<IsMajorityOfBody<RelayLocation, ExecutiveBody>>,
298 >;
299 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
300 type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Runtime>;
301 type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
302}
303
304impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
305 type ChannelList = ParachainSystem;
307}
308
309parameter_types! {
310 pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
311}