1#![cfg_attr(not(feature = "std"), no_std)]
33#![recursion_limit = "256"]
34
35#[cfg(feature = "std")]
37include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
38
39pub mod ambassador;
40mod genesis_config_presets;
41pub mod impls;
42mod weights;
43pub mod xcm_config;
44pub mod fellowship;
46
47pub mod secretary;
49
50extern crate alloc;
51
52pub use ambassador::pallet_ambassador_origins;
53
54use alloc::{vec, vec::Vec};
55use ambassador::AmbassadorCoreInstance;
56use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
57use fellowship::{pallet_fellowship_origins, Fellows, FellowshipCoreInstance};
58use impls::{AllianceProposalProvider, EqualOrGreatestRootCmp};
59use sp_api::impl_runtime_apis;
60use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
61use sp_runtime::{
62 generic, impl_opaque_keys,
63 traits::{AccountIdConversion, BlakeTwo256, Block as BlockT},
64 transaction_validity::{TransactionSource, TransactionValidity},
65 ApplyExtrinsicResult, Perbill,
66};
67
68#[cfg(feature = "std")]
69use sp_version::NativeVersion;
70use sp_version::RuntimeVersion;
71
72use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
73use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
74use frame_support::{
75 construct_runtime, derive_impl,
76 dispatch::DispatchClass,
77 genesis_builder_helper::{build_state, get_preset},
78 parameter_types,
79 traits::{
80 fungible::HoldConsideration, ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse,
81 InstanceFilter, LinearStoragePrice, TransformOrigin,
82 },
83 weights::{ConstantMultiplier, Weight},
84 PalletId,
85};
86use frame_system::{
87 limits::{BlockLength, BlockWeights},
88 EnsureRoot,
89};
90pub use parachains_common as common;
91use parachains_common::{
92 impls::{DealWithFees, ToParentTreasury},
93 message_queue::*,
94 AccountId, AuraId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
95 AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO,
96};
97use sp_runtime::RuntimeDebug;
98use testnet_parachains_constants::westend::{
99 account::*, consensus::*, currency::*, fee::WeightToFee, time::*,
100};
101use xcm_config::{
102 GovernanceLocation, LocationToAccountId, TreasurerBodyId, XcmOriginToTransactDispatchOrigin,
103};
104
105#[cfg(any(feature = "std", test))]
106pub use sp_runtime::BuildStorage;
107
108use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
110use polkadot_runtime_common::{
111 impls::VersionedLocatableAsset, BlockHashCount, SlowAdjustingFeeUpdate,
112};
113use xcm::{prelude::*, Version as XcmVersion};
114use xcm_runtime_apis::{
115 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
116 fees::Error as XcmPaymentApiError,
117};
118
119use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
120
121impl_opaque_keys! {
122 pub struct SessionKeys {
123 pub aura: Aura,
124 }
125}
126
127#[sp_version::runtime_version]
128pub const VERSION: RuntimeVersion = RuntimeVersion {
129 spec_name: alloc::borrow::Cow::Borrowed("collectives-westend"),
130 impl_name: alloc::borrow::Cow::Borrowed("collectives-westend"),
131 authoring_version: 1,
132 spec_version: 1_019_003,
133 impl_version: 0,
134 apis: RUNTIME_API_VERSIONS,
135 transaction_version: 6,
136 system_version: 1,
137};
138
139#[cfg(feature = "std")]
141pub fn native_version() -> NativeVersion {
142 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
143}
144
145pub type RootOrAllianceTwoThirdsMajority = EitherOfDiverse<
147 EnsureRoot<AccountId>,
148 pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
149>;
150
151parameter_types! {
152 pub const Version: RuntimeVersion = VERSION;
153 pub RuntimeBlockLength: BlockLength =
154 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
155 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
156 .base_block(BlockExecutionWeight::get())
157 .for_class(DispatchClass::all(), |weights| {
158 weights.base_extrinsic = ExtrinsicBaseWeight::get();
159 })
160 .for_class(DispatchClass::Normal, |weights| {
161 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
162 })
163 .for_class(DispatchClass::Operational, |weights| {
164 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
165 weights.reserved = Some(
168 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
169 );
170 })
171 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
172 .build_or_panic();
173 pub const SS58Prefix: u8 = 42;
174}
175
176#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
178impl frame_system::Config for Runtime {
179 type BlockWeights = RuntimeBlockWeights;
180 type BlockLength = RuntimeBlockLength;
181 type AccountId = AccountId;
182 type RuntimeCall = RuntimeCall;
183 type Nonce = Nonce;
184 type Hash = Hash;
185 type Block = Block;
186 type BlockHashCount = BlockHashCount;
187 type DbWeight = RocksDbWeight;
188 type Version = Version;
189 type AccountData = pallet_balances::AccountData<Balance>;
190 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
191 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
192 type SS58Prefix = SS58Prefix;
193 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
194 type MaxConsumers = frame_support::traits::ConstU32<16>;
195}
196
197impl cumulus_pallet_weight_reclaim::Config for Runtime {
198 type WeightInfo = weights::cumulus_pallet_weight_reclaim::WeightInfo<Runtime>;
199}
200
201impl pallet_timestamp::Config for Runtime {
202 type Moment = u64;
204 type OnTimestampSet = Aura;
205 type MinimumPeriod = ConstU64<0>;
206 type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
207}
208
209impl pallet_authorship::Config for Runtime {
210 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
211 type EventHandler = (CollatorSelection,);
212}
213
214parameter_types! {
215 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
216}
217
218impl pallet_balances::Config for Runtime {
219 type MaxLocks = ConstU32<50>;
220 type Balance = Balance;
222 type RuntimeEvent = RuntimeEvent;
224 type DustRemoval = ();
225 type ExistentialDeposit = ExistentialDeposit;
226 type AccountStore = System;
227 type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
228 type MaxReserves = ConstU32<50>;
229 type ReserveIdentifier = [u8; 8];
230 type RuntimeHoldReason = RuntimeHoldReason;
231 type RuntimeFreezeReason = RuntimeFreezeReason;
232 type FreezeIdentifier = ();
233 type MaxFreezes = ConstU32<0>;
234 type DoneSlashHandler = ();
235}
236
237parameter_types! {
238 pub const TransactionByteFee: Balance = MILLICENTS;
240}
241
242impl pallet_transaction_payment::Config for Runtime {
243 type RuntimeEvent = RuntimeEvent;
244 type OnChargeTransaction =
245 pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
246 type WeightToFee = WeightToFee;
247 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
248 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
249 type OperationalFeeMultiplier = ConstU8<5>;
250 type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
251}
252
253parameter_types! {
254 pub const DepositBase: Balance = deposit(1, 88);
256 pub const DepositFactor: Balance = deposit(0, 32);
258}
259
260impl pallet_multisig::Config for Runtime {
261 type RuntimeEvent = RuntimeEvent;
262 type RuntimeCall = RuntimeCall;
263 type Currency = Balances;
264 type DepositBase = DepositBase;
265 type DepositFactor = DepositFactor;
266 type MaxSignatories = ConstU32<100>;
267 type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
268 type BlockNumberProvider = frame_system::Pallet<Runtime>;
269}
270
271impl pallet_utility::Config for Runtime {
272 type RuntimeEvent = RuntimeEvent;
273 type RuntimeCall = RuntimeCall;
274 type PalletsOrigin = OriginCaller;
275 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
276}
277
278parameter_types! {
279 pub const ProxyDepositBase: Balance = deposit(1, 40);
281 pub const ProxyDepositFactor: Balance = deposit(0, 33);
283 pub const AnnouncementDepositBase: Balance = deposit(1, 48);
285 pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
286}
287
288#[derive(
290 Copy,
291 Clone,
292 Eq,
293 PartialEq,
294 Ord,
295 PartialOrd,
296 Encode,
297 Decode,
298 DecodeWithMemTracking,
299 RuntimeDebug,
300 MaxEncodedLen,
301 scale_info::TypeInfo,
302)]
303pub enum ProxyType {
304 Any,
306 NonTransfer,
308 CancelProxy,
310 Collator,
312 Alliance,
314 Fellowship,
316 Ambassador,
318 Secretary,
320}
321impl Default for ProxyType {
322 fn default() -> Self {
323 Self::Any
324 }
325}
326impl InstanceFilter<RuntimeCall> for ProxyType {
327 fn filter(&self, c: &RuntimeCall) -> bool {
328 match self {
329 ProxyType::Any => true,
330 ProxyType::NonTransfer => !matches!(c, RuntimeCall::Balances { .. }),
331 ProxyType::CancelProxy => matches!(
332 c,
333 RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
334 RuntimeCall::Utility { .. } |
335 RuntimeCall::Multisig { .. }
336 ),
337 ProxyType::Collator => matches!(
338 c,
339 RuntimeCall::CollatorSelection { .. } |
340 RuntimeCall::Utility { .. } |
341 RuntimeCall::Multisig { .. }
342 ),
343 ProxyType::Alliance => matches!(
344 c,
345 RuntimeCall::AllianceMotion { .. } |
346 RuntimeCall::Alliance { .. } |
347 RuntimeCall::Utility { .. } |
348 RuntimeCall::Multisig { .. }
349 ),
350 ProxyType::Fellowship => matches!(
351 c,
352 RuntimeCall::FellowshipCollective { .. } |
353 RuntimeCall::FellowshipReferenda { .. } |
354 RuntimeCall::FellowshipCore { .. } |
355 RuntimeCall::FellowshipSalary { .. } |
356 RuntimeCall::FellowshipTreasury { .. } |
357 RuntimeCall::Utility { .. } |
358 RuntimeCall::Multisig { .. }
359 ),
360 ProxyType::Ambassador => matches!(
361 c,
362 RuntimeCall::AmbassadorCollective { .. } |
363 RuntimeCall::AmbassadorReferenda { .. } |
364 RuntimeCall::AmbassadorContent { .. } |
365 RuntimeCall::AmbassadorCore { .. } |
366 RuntimeCall::AmbassadorSalary { .. } |
367 RuntimeCall::Utility { .. } |
368 RuntimeCall::Multisig { .. }
369 ),
370 ProxyType::Secretary => matches!(
371 c,
372 RuntimeCall::SecretaryCollective { .. } |
373 RuntimeCall::SecretarySalary { .. } |
374 RuntimeCall::Utility { .. } |
375 RuntimeCall::Multisig { .. }
376 ),
377 }
378 }
379 fn is_superset(&self, o: &Self) -> bool {
380 match (self, o) {
381 (x, y) if x == y => true,
382 (ProxyType::Any, _) => true,
383 (_, ProxyType::Any) => false,
384 (ProxyType::NonTransfer, _) => true,
385 _ => false,
386 }
387 }
388}
389
390impl pallet_proxy::Config for Runtime {
391 type RuntimeEvent = RuntimeEvent;
392 type RuntimeCall = RuntimeCall;
393 type Currency = Balances;
394 type ProxyType = ProxyType;
395 type ProxyDepositBase = ProxyDepositBase;
396 type ProxyDepositFactor = ProxyDepositFactor;
397 type MaxProxies = ConstU32<32>;
398 type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
399 type MaxPending = ConstU32<32>;
400 type CallHasher = BlakeTwo256;
401 type AnnouncementDepositBase = AnnouncementDepositBase;
402 type AnnouncementDepositFactor = AnnouncementDepositFactor;
403 type BlockNumberProvider = frame_system::Pallet<Runtime>;
404}
405
406parameter_types! {
407 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
408 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
409}
410
411impl cumulus_pallet_parachain_system::Config for Runtime {
412 type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
413 type RuntimeEvent = RuntimeEvent;
414 type OnSystemEvent = ();
415 type SelfParaId = parachain_info::Pallet<Runtime>;
416 type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
417 type ReservedDmpWeight = ReservedDmpWeight;
418 type OutboundXcmpMessageSource = XcmpQueue;
419 type XcmpMessageHandler = XcmpQueue;
420 type ReservedXcmpWeight = ReservedXcmpWeight;
421 type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
422 type ConsensusHook = ConsensusHook;
423 type RelayParentOffset = ConstU32<0>;
424}
425
426type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
427 Runtime,
428 RELAY_CHAIN_SLOT_DURATION_MILLIS,
429 BLOCK_PROCESSING_VELOCITY,
430 UNINCLUDED_SEGMENT_CAPACITY,
431>;
432
433impl parachain_info::Config for Runtime {}
434
435parameter_types! {
436 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
437}
438
439impl pallet_message_queue::Config for Runtime {
440 type RuntimeEvent = RuntimeEvent;
441 type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
442 #[cfg(feature = "runtime-benchmarks")]
443 type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
444 cumulus_primitives_core::AggregateMessageOrigin,
445 >;
446 #[cfg(not(feature = "runtime-benchmarks"))]
447 type MessageProcessor = xcm_builder::ProcessXcmMessage<
448 AggregateMessageOrigin,
449 xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
450 RuntimeCall,
451 >;
452 type Size = u32;
453 type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
455 type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
456 type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
457 type MaxStale = sp_core::ConstU32<8>;
458 type ServiceWeight = MessageQueueServiceWeight;
459 type IdleMaxServiceWeight = MessageQueueServiceWeight;
460}
461
462impl cumulus_pallet_aura_ext::Config for Runtime {}
463
464parameter_types! {
465 pub FeeAssetId: AssetId = AssetId(xcm_config::WndLocation::get());
467 pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
469}
470
471pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
472 FeeAssetId,
473 BaseDeliveryFee,
474 TransactionByteFee,
475 XcmpQueue,
476>;
477
478impl cumulus_pallet_xcmp_queue::Config for Runtime {
479 type RuntimeEvent = RuntimeEvent;
480 type ChannelInfo = ParachainSystem;
481 type VersionWrapper = PolkadotXcm;
482 type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
484 type MaxInboundSuspended = ConstU32<1_000>;
485 type MaxActiveOutboundChannels = ConstU32<128>;
486 type MaxPageSize = ConstU32<{ 103 * 1024 }>;
489 type ControllerOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Fellows>;
490 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
491 type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
492 type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
493}
494
495impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
496 type ChannelList = ParachainSystem;
498}
499
500parameter_types! {
501 pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
502}
503
504pub const PERIOD: u32 = 6 * HOURS;
505pub const OFFSET: u32 = 0;
506
507impl pallet_session::Config for Runtime {
508 type RuntimeEvent = RuntimeEvent;
509 type ValidatorId = <Self as frame_system::Config>::AccountId;
510 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
512 type ShouldEndSession = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
513 type NextSessionRotation = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
514 type SessionManager = CollatorSelection;
515 type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
517 type Keys = SessionKeys;
518 type DisablingStrategy = ();
519 type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
520 type Currency = Balances;
521 type KeyDeposit = ();
522}
523
524impl pallet_aura::Config for Runtime {
525 type AuthorityId = AuraId;
526 type DisabledValidators = ();
527 type MaxAuthorities = ConstU32<100_000>;
528 type AllowMultipleBlocksPerSlot = ConstBool<true>;
529 type SlotDuration = ConstU64<SLOT_DURATION>;
530}
531
532parameter_types! {
533 pub const PotId: PalletId = PalletId(*b"PotStake");
534 pub const SessionLength: BlockNumber = 6 * HOURS;
535 pub const StakingAdminBodyId: BodyId = BodyId::Defense;
537}
538
539pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
541 EnsureRoot<AccountId>,
542 EnsureXcm<IsVoiceOfBody<GovernanceLocation, StakingAdminBodyId>>,
543>;
544
545impl pallet_collator_selection::Config for Runtime {
546 type RuntimeEvent = RuntimeEvent;
547 type Currency = Balances;
548 type UpdateOrigin = CollatorSelectionUpdateOrigin;
549 type PotId = PotId;
550 type MaxCandidates = ConstU32<100>;
551 type MinEligibleCollators = ConstU32<4>;
552 type MaxInvulnerables = ConstU32<20>;
553 type KickThreshold = ConstU32<PERIOD>;
555 type ValidatorId = <Self as frame_system::Config>::AccountId;
556 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
557 type ValidatorRegistration = Session;
558 type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
559}
560
561pub const ALLIANCE_MOTION_DURATION: BlockNumber = 5 * DAYS;
562
563parameter_types! {
564 pub const AllianceMotionDuration: BlockNumber = ALLIANCE_MOTION_DURATION;
565 pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
566}
567pub const ALLIANCE_MAX_PROPOSALS: u32 = 100;
568pub const ALLIANCE_MAX_MEMBERS: u32 = 100;
569
570type AllianceCollective = pallet_collective::Instance1;
571impl pallet_collective::Config<AllianceCollective> for Runtime {
572 type RuntimeOrigin = RuntimeOrigin;
573 type Proposal = RuntimeCall;
574 type RuntimeEvent = RuntimeEvent;
575 type MotionDuration = AllianceMotionDuration;
576 type MaxProposals = ConstU32<ALLIANCE_MAX_PROPOSALS>;
577 type MaxMembers = ConstU32<ALLIANCE_MAX_MEMBERS>;
578 type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
579 type SetMembersOrigin = EnsureRoot<AccountId>;
580 type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
581 type MaxProposalWeight = MaxProposalWeight;
582 type DisapproveOrigin = EnsureRoot<Self::AccountId>;
583 type KillOrigin = EnsureRoot<Self::AccountId>;
584 type Consideration = ();
585}
586
587pub const MAX_FELLOWS: u32 = ALLIANCE_MAX_MEMBERS;
588pub const MAX_ALLIES: u32 = 100;
589
590parameter_types! {
591 pub const AllyDeposit: Balance = 1_000 * UNITS; pub WestendTreasuryAccount: AccountId = WESTEND_TREASURY_PALLET_ID.into_account_truncating();
593 pub const AllianceRetirementPeriod: BlockNumber = (90 * DAYS) + ALLIANCE_MOTION_DURATION;
596}
597
598impl pallet_alliance::Config for Runtime {
599 type RuntimeEvent = RuntimeEvent;
600 type Proposal = RuntimeCall;
601 type AdminOrigin = RootOrAllianceTwoThirdsMajority;
602 type MembershipManager = RootOrAllianceTwoThirdsMajority;
603 type AnnouncementOrigin = RootOrAllianceTwoThirdsMajority;
604 type Currency = Balances;
605 type Slashed = ToParentTreasury<WestendTreasuryAccount, LocationToAccountId, Runtime>;
606 type InitializeMembers = AllianceMotion;
607 type MembershipChanged = AllianceMotion;
608 type RetirementPeriod = AllianceRetirementPeriod;
609 type IdentityVerifier = (); type ProposalProvider = AllianceProposalProvider<Runtime, AllianceCollective>;
611 type MaxProposals = ConstU32<ALLIANCE_MAX_MEMBERS>;
612 type MaxFellows = ConstU32<MAX_FELLOWS>;
613 type MaxAllies = ConstU32<MAX_ALLIES>;
614 type MaxUnscrupulousItems = ConstU32<100>;
615 type MaxWebsiteUrlLength = ConstU32<255>;
616 type MaxAnnouncementsCount = ConstU32<100>;
617 type MaxMembersCount = ConstU32<ALLIANCE_MAX_MEMBERS>;
618 type AllyDeposit = AllyDeposit;
619 type WeightInfo = weights::pallet_alliance::WeightInfo<Runtime>;
620}
621
622parameter_types! {
623 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
624}
625
626#[cfg(not(feature = "runtime-benchmarks"))]
627parameter_types! {
628 pub const MaxScheduledPerBlock: u32 = 50;
629}
630
631#[cfg(feature = "runtime-benchmarks")]
632parameter_types! {
633 pub const MaxScheduledPerBlock: u32 = 200;
634}
635
636impl pallet_scheduler::Config for Runtime {
637 type RuntimeOrigin = RuntimeOrigin;
638 type RuntimeEvent = RuntimeEvent;
639 type PalletsOrigin = OriginCaller;
640 type RuntimeCall = RuntimeCall;
641 type MaximumWeight = MaximumSchedulerWeight;
642 type ScheduleOrigin = EnsureRoot<AccountId>;
643 type MaxScheduledPerBlock = MaxScheduledPerBlock;
644 type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
645 type OriginPrivilegeCmp = EqualOrGreatestRootCmp;
646 type Preimages = Preimage;
647 type BlockNumberProvider = frame_system::Pallet<Runtime>;
648}
649
650parameter_types! {
651 pub const PreimageBaseDeposit: Balance = deposit(2, 64);
652 pub const PreimageByteDeposit: Balance = deposit(0, 1);
653 pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
654}
655
656impl pallet_preimage::Config for Runtime {
657 type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
658 type RuntimeEvent = RuntimeEvent;
659 type Currency = Balances;
660 type ManagerOrigin = EnsureRoot<AccountId>;
661 type Consideration = HoldConsideration<
662 AccountId,
663 Balances,
664 PreimageHoldReason,
665 LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
666 >;
667}
668
669impl pallet_asset_rate::Config for Runtime {
670 type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
671 type RuntimeEvent = RuntimeEvent;
672 type CreateOrigin = EitherOfDiverse<
673 EnsureRoot<AccountId>,
674 EitherOfDiverse<EnsureXcm<IsVoiceOfBody<GovernanceLocation, TreasurerBodyId>>, Fellows>,
675 >;
676 type RemoveOrigin = Self::CreateOrigin;
677 type UpdateOrigin = Self::CreateOrigin;
678 type Currency = Balances;
679 type AssetKind = VersionedLocatableAsset;
680 #[cfg(feature = "runtime-benchmarks")]
681 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
682}
683
684construct_runtime!(
686 pub enum Runtime
687 {
688 System: frame_system = 0,
690 ParachainSystem: cumulus_pallet_parachain_system = 1,
691 Timestamp: pallet_timestamp = 2,
692 ParachainInfo: parachain_info = 3,
693 WeightReclaim: cumulus_pallet_weight_reclaim = 4,
694
695 Balances: pallet_balances = 10,
697 TransactionPayment: pallet_transaction_payment = 11,
698
699 Authorship: pallet_authorship = 20,
701 CollatorSelection: pallet_collator_selection = 21,
702 Session: pallet_session = 22,
703 Aura: pallet_aura = 23,
704 AuraExt: cumulus_pallet_aura_ext = 24,
705
706 XcmpQueue: cumulus_pallet_xcmp_queue = 30,
708 PolkadotXcm: pallet_xcm = 31,
709 CumulusXcm: cumulus_pallet_xcm = 32,
710 MessageQueue: pallet_message_queue = 34,
711
712 Utility: pallet_utility = 40,
714 Multisig: pallet_multisig = 41,
715 Proxy: pallet_proxy = 42,
716 Preimage: pallet_preimage = 43,
717 Scheduler: pallet_scheduler = 44,
718 AssetRate: pallet_asset_rate = 45,
719
720 Alliance: pallet_alliance = 50,
724 AllianceMotion: pallet_collective::<Instance1> = 51,
725
726 FellowshipCollective: pallet_ranked_collective::<Instance1> = 60,
729 FellowshipReferenda: pallet_referenda::<Instance1> = 61,
731 FellowshipOrigins: pallet_fellowship_origins = 62,
732 FellowshipCore: pallet_core_fellowship::<Instance1> = 63,
734 FellowshipSalary: pallet_salary::<Instance1> = 64,
736 FellowshipTreasury: pallet_treasury::<Instance1> = 65,
738
739 AmbassadorCollective: pallet_ranked_collective::<Instance2> = 70,
741 AmbassadorReferenda: pallet_referenda::<Instance2> = 71,
742 AmbassadorOrigins: pallet_ambassador_origins = 72,
743 AmbassadorCore: pallet_core_fellowship::<Instance2> = 73,
744 AmbassadorSalary: pallet_salary::<Instance2> = 74,
745 AmbassadorContent: pallet_collective_content::<Instance1> = 75,
746
747 StateTrieMigration: pallet_state_trie_migration = 80,
748
749 SecretaryCollective: pallet_ranked_collective::<Instance3> = 90,
752 SecretarySalary: pallet_salary::<Instance3> = 91,
754 }
755);
756
757pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
759pub type Block = generic::Block<Header, UncheckedExtrinsic>;
761pub type SignedBlock = generic::SignedBlock<Block>;
763pub type BlockId = generic::BlockId<Block>;
765pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
767 Runtime,
768 (
769 frame_system::AuthorizeCall<Runtime>,
770 frame_system::CheckNonZeroSender<Runtime>,
771 frame_system::CheckSpecVersion<Runtime>,
772 frame_system::CheckTxVersion<Runtime>,
773 frame_system::CheckGenesis<Runtime>,
774 frame_system::CheckEra<Runtime>,
775 frame_system::CheckNonce<Runtime>,
776 frame_system::CheckWeight<Runtime>,
777 ),
778>;
779
780pub type UncheckedExtrinsic =
782 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
783type Migrations = (
786 pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
788 cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
790 cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
791 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
793 pallet_core_fellowship::migration::MigrateV0ToV1<Runtime, FellowshipCoreInstance>,
795 pallet_core_fellowship::migration::MigrateV0ToV1<Runtime, AmbassadorCoreInstance>,
797 cumulus_pallet_aura_ext::migration::MigrateV0ToV1<Runtime>,
798 pallet_session::migrations::v1::MigrateV0ToV1<
799 Runtime,
800 pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
801 >,
802);
803
804pub type Executive = frame_executive::Executive<
806 Runtime,
807 Block,
808 frame_system::ChainContext<Runtime>,
809 Runtime,
810 AllPalletsWithSystem,
811 Migrations,
812>;
813
814#[cfg(feature = "runtime-benchmarks")]
815mod benches {
816 frame_benchmarking::define_benchmarks!(
817 [frame_system, SystemBench::<Runtime>]
818 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
819 [pallet_balances, Balances]
820 [pallet_message_queue, MessageQueue]
821 [pallet_multisig, Multisig]
822 [pallet_proxy, Proxy]
823 [pallet_session, SessionBench::<Runtime>]
824 [pallet_utility, Utility]
825 [pallet_timestamp, Timestamp]
826 [pallet_transaction_payment, TransactionPayment]
827 [pallet_collator_selection, CollatorSelection]
828 [cumulus_pallet_parachain_system, ParachainSystem]
829 [cumulus_pallet_xcmp_queue, XcmpQueue]
830 [pallet_alliance, Alliance]
831 [pallet_collective, AllianceMotion]
832 [pallet_preimage, Preimage]
833 [pallet_scheduler, Scheduler]
834 [pallet_referenda, FellowshipReferenda]
835 [pallet_ranked_collective, FellowshipCollective]
836 [pallet_core_fellowship, FellowshipCore]
837 [pallet_salary, FellowshipSalary]
838 [pallet_treasury, FellowshipTreasury]
839 [pallet_referenda, AmbassadorReferenda]
840 [pallet_ranked_collective, AmbassadorCollective]
841 [pallet_collective_content, AmbassadorContent]
842 [pallet_core_fellowship, AmbassadorCore]
843 [pallet_salary, AmbassadorSalary]
844 [pallet_ranked_collective, SecretaryCollective]
845 [pallet_salary, SecretarySalary]
846 [pallet_asset_rate, AssetRate]
847 [cumulus_pallet_weight_reclaim, WeightReclaim]
848 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
850 [pallet_xcm_benchmarks::fungible, XcmBalances]
852 [pallet_xcm_benchmarks::generic, XcmGeneric]
853 );
854}
855
856impl_runtime_apis! {
857 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
858 fn slot_duration() -> sp_consensus_aura::SlotDuration {
859 sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
860 }
861
862 fn authorities() -> Vec<AuraId> {
863 pallet_aura::Authorities::<Runtime>::get().into_inner()
864 }
865 }
866
867 impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
868 fn relay_parent_offset() -> u32 {
869 0
870 }
871 }
872
873 impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
874 fn can_build_upon(
875 included_hash: <Block as BlockT>::Hash,
876 slot: cumulus_primitives_aura::Slot,
877 ) -> bool {
878 ConsensusHook::can_build_upon(included_hash, slot)
879 }
880 }
881
882 impl sp_api::Core<Block> for Runtime {
883 fn version() -> RuntimeVersion {
884 VERSION
885 }
886
887 fn execute_block(block: Block) {
888 Executive::execute_block(block)
889 }
890
891 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
892 Executive::initialize_block(header)
893 }
894 }
895
896 impl sp_api::Metadata<Block> for Runtime {
897 fn metadata() -> OpaqueMetadata {
898 OpaqueMetadata::new(Runtime::metadata().into())
899 }
900
901 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
902 Runtime::metadata_at_version(version)
903 }
904
905 fn metadata_versions() -> alloc::vec::Vec<u32> {
906 Runtime::metadata_versions()
907 }
908 }
909
910 impl sp_block_builder::BlockBuilder<Block> for Runtime {
911 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
912 Executive::apply_extrinsic(extrinsic)
913 }
914
915 fn finalize_block() -> <Block as BlockT>::Header {
916 Executive::finalize_block()
917 }
918
919 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
920 data.create_extrinsics()
921 }
922
923 fn check_inherents(
924 block: Block,
925 data: sp_inherents::InherentData,
926 ) -> sp_inherents::CheckInherentsResult {
927 data.check_extrinsics(&block)
928 }
929 }
930
931 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
932 fn validate_transaction(
933 source: TransactionSource,
934 tx: <Block as BlockT>::Extrinsic,
935 block_hash: <Block as BlockT>::Hash,
936 ) -> TransactionValidity {
937 Executive::validate_transaction(source, tx, block_hash)
938 }
939 }
940
941 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
942 fn offchain_worker(header: &<Block as BlockT>::Header) {
943 Executive::offchain_worker(header)
944 }
945 }
946
947 impl sp_session::SessionKeys<Block> for Runtime {
948 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
949 SessionKeys::generate(seed)
950 }
951
952 fn decode_session_keys(
953 encoded: Vec<u8>,
954 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
955 SessionKeys::decode_into_raw_public_keys(&encoded)
956 }
957 }
958
959 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
960 fn account_nonce(account: AccountId) -> Nonce {
961 System::account_nonce(account)
962 }
963 }
964
965 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
966 fn query_info(
967 uxt: <Block as BlockT>::Extrinsic,
968 len: u32,
969 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
970 TransactionPayment::query_info(uxt, len)
971 }
972 fn query_fee_details(
973 uxt: <Block as BlockT>::Extrinsic,
974 len: u32,
975 ) -> pallet_transaction_payment::FeeDetails<Balance> {
976 TransactionPayment::query_fee_details(uxt, len)
977 }
978 fn query_weight_to_fee(weight: Weight) -> Balance {
979 TransactionPayment::weight_to_fee(weight)
980 }
981 fn query_length_to_fee(length: u32) -> Balance {
982 TransactionPayment::length_to_fee(length)
983 }
984 }
985
986 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
987 for Runtime
988 {
989 fn query_call_info(
990 call: RuntimeCall,
991 len: u32,
992 ) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
993 TransactionPayment::query_call_info(call, len)
994 }
995 fn query_call_fee_details(
996 call: RuntimeCall,
997 len: u32,
998 ) -> pallet_transaction_payment::FeeDetails<Balance> {
999 TransactionPayment::query_call_fee_details(call, len)
1000 }
1001 fn query_weight_to_fee(weight: Weight) -> Balance {
1002 TransactionPayment::weight_to_fee(weight)
1003 }
1004 fn query_length_to_fee(length: u32) -> Balance {
1005 TransactionPayment::length_to_fee(length)
1006 }
1007 }
1008
1009 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
1010 fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
1011 let acceptable_assets = vec![AssetId(xcm_config::WndLocation::get())];
1012 PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
1013 }
1014
1015 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
1016 use crate::xcm_config::XcmConfig;
1017
1018 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
1019
1020 PolkadotXcm::query_weight_to_asset_fee::<Trader>(weight, asset)
1021 }
1022
1023 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
1024 PolkadotXcm::query_xcm_weight(message)
1025 }
1026
1027 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
1028 PolkadotXcm::query_delivery_fees(destination, message)
1029 }
1030 }
1031
1032 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
1033 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1034 PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
1035 }
1036
1037 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1038 PolkadotXcm::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
1039 }
1040 }
1041
1042 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
1043 fn convert_location(location: VersionedLocation) -> Result<
1044 AccountId,
1045 xcm_runtime_apis::conversions::Error
1046 > {
1047 xcm_runtime_apis::conversions::LocationToAccountHelper::<
1048 AccountId,
1049 LocationToAccountId,
1050 >::convert_location(location)
1051 }
1052 }
1053
1054 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
1055 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
1056 PolkadotXcm::is_trusted_reserve(asset, location)
1057 }
1058 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
1059 PolkadotXcm::is_trusted_teleporter(asset, location)
1060 }
1061 }
1062
1063 impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi<Block> for Runtime {
1064 fn authorized_aliasers(target: VersionedLocation) -> Result<
1065 Vec<xcm_runtime_apis::authorized_aliases::OriginAliaser>,
1066 xcm_runtime_apis::authorized_aliases::Error
1067 > {
1068 PolkadotXcm::authorized_aliasers(target)
1069 }
1070 fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result<
1071 bool,
1072 xcm_runtime_apis::authorized_aliases::Error
1073 > {
1074 PolkadotXcm::is_authorized_alias(origin, target)
1075 }
1076 }
1077
1078 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
1079 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
1080 ParachainSystem::collect_collation_info(header)
1081 }
1082 }
1083
1084 #[cfg(feature = "try-runtime")]
1085 impl frame_try_runtime::TryRuntime<Block> for Runtime {
1086 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
1087 let weight = Executive::try_runtime_upgrade(checks).unwrap();
1088 (weight, RuntimeBlockWeights::get().max_block)
1089 }
1090
1091 fn execute_block(
1092 block: Block,
1093 state_root_check: bool,
1094 signature_check: bool,
1095 select: frame_try_runtime::TryStateSelect,
1096 ) -> Weight {
1097 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
1100 }
1101 }
1102
1103 #[cfg(feature = "runtime-benchmarks")]
1104 impl frame_benchmarking::Benchmark<Block> for Runtime {
1105 fn benchmark_metadata(extra: bool) -> (
1106 Vec<frame_benchmarking::BenchmarkList>,
1107 Vec<frame_support::traits::StorageInfo>,
1108 ) {
1109 use frame_benchmarking::BenchmarkList;
1110 use frame_support::traits::StorageInfoTrait;
1111 use frame_system_benchmarking::Pallet as SystemBench;
1112 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
1113 use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
1114 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
1115
1116 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
1120 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
1121
1122 let mut list = Vec::<BenchmarkList>::new();
1123 list_benchmarks!(list, extra);
1124
1125 let storage_info = AllPalletsWithSystem::storage_info();
1126 (list, storage_info)
1127 }
1128
1129 #[allow(non_local_definitions)]
1130 fn dispatch_benchmark(
1131 config: frame_benchmarking::BenchmarkConfig
1132 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
1133 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
1134 use sp_storage::TrackedStorageKey;
1135
1136 use frame_system_benchmarking::Pallet as SystemBench;
1137 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
1138 impl frame_system_benchmarking::Config for Runtime {
1139 fn setup_set_code_requirements(code: &alloc::vec::Vec<u8>) -> Result<(), BenchmarkError> {
1140 ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
1141 Ok(())
1142 }
1143
1144 fn verify_set_code() {
1145 System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
1146 }
1147 }
1148
1149 use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
1150 impl cumulus_pallet_session_benchmarking::Config for Runtime {}
1151 use xcm_config::WndLocation;
1152 use testnet_parachains_constants::westend::locations::{AssetHubParaId, AssetHubLocation};
1153
1154 parameter_types! {
1155 pub ExistentialDepositAsset: Option<Asset> = Some((
1156 WndLocation::get(),
1157 ExistentialDeposit::get()
1158 ).into());
1159 }
1160
1161 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
1162 impl pallet_xcm::benchmarking::Config for Runtime {
1163 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
1164 xcm_config::XcmConfig,
1165 ExistentialDepositAsset,
1166 PriceForSiblingParachainDelivery,
1167 AssetHubParaId,
1168 ParachainSystem,
1169 >;
1170
1171 fn reachable_dest() -> Option<Location> {
1172 Some(AssetHubLocation::get())
1173 }
1174
1175 fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
1176 Some((
1178 Asset {
1179 fun: Fungible(ExistentialDeposit::get()),
1180 id: AssetId(WndLocation::get())
1181 }.into(),
1182 AssetHubLocation::get(),
1183 ))
1184 }
1185
1186 fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
1187 None
1189 }
1190
1191 fn set_up_complex_asset_transfer(
1192 ) -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
1193 let native_location = WndLocation::get();
1196 let dest = AssetHubLocation::get();
1197 pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
1198 native_location,
1199 dest
1200 )
1201 }
1202
1203 fn get_asset() -> Asset {
1204 Asset {
1205 id: AssetId(WndLocation::get()),
1206 fun: Fungible(ExistentialDeposit::get()),
1207 }
1208 }
1209 }
1210
1211 impl pallet_xcm_benchmarks::Config for Runtime {
1212 type XcmConfig = xcm_config::XcmConfig;
1213 type AccountIdConverter = xcm_config::LocationToAccountId;
1214 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
1215 xcm_config::XcmConfig,
1216 ExistentialDepositAsset,
1217 PriceForSiblingParachainDelivery,
1218 AssetHubParaId,
1219 ParachainSystem
1220 >;
1221 fn valid_destination() -> Result<Location, BenchmarkError> {
1222 Ok(AssetHubLocation::get())
1223 }
1224 fn worst_case_holding(_depositable_count: u32) -> Assets {
1225 let assets: Vec<Asset> = vec![
1227 Asset {
1228 id: AssetId(WndLocation::get()),
1229 fun: Fungible(1_000_000 * UNITS),
1230 }
1231 ];
1232 assets.into()
1233 }
1234 }
1235
1236 parameter_types! {
1237 pub TrustedTeleporter: Option<(Location, Asset)> = Some((
1238 AssetHubLocation::get(),
1239 Asset { fun: Fungible(UNITS), id: AssetId(WndLocation::get()) },
1240 ));
1241 pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
1242 pub const TrustedReserve: Option<(Location, Asset)> = None;
1243 }
1244
1245 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
1246 type TransactAsset = Balances;
1247
1248 type CheckedAccount = CheckedAccount;
1249 type TrustedTeleporter = TrustedTeleporter;
1250 type TrustedReserve = TrustedReserve;
1251
1252 fn get_asset() -> Asset {
1253 Asset {
1254 id: AssetId(WndLocation::get()),
1255 fun: Fungible(UNITS),
1256 }
1257 }
1258 }
1259
1260 impl pallet_xcm_benchmarks::generic::Config for Runtime {
1261 type TransactAsset = Balances;
1262 type RuntimeCall = RuntimeCall;
1263
1264 fn worst_case_response() -> (u64, Response) {
1265 (0u64, Response::Version(Default::default()))
1266 }
1267
1268 fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
1269 Err(BenchmarkError::Skip)
1270 }
1271
1272 fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
1273 Err(BenchmarkError::Skip)
1274 }
1275
1276 fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
1277 Ok((AssetHubLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
1278 }
1279
1280 fn subscribe_origin() -> Result<Location, BenchmarkError> {
1281 Ok(AssetHubLocation::get())
1282 }
1283
1284 fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
1285 let origin = AssetHubLocation::get();
1286 let assets: Assets = (AssetId(WndLocation::get()), 1_000 * UNITS).into();
1287 let ticket = Location { parents: 0, interior: Here };
1288 Ok((origin, ticket, assets))
1289 }
1290
1291 fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
1292 Ok((Asset {
1293 id: AssetId(WndLocation::get()),
1294 fun: Fungible(1_000_000 * UNITS),
1295 }, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
1296 }
1297
1298 fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
1299 Err(BenchmarkError::Skip)
1300 }
1301
1302 fn export_message_origin_and_destination(
1303 ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
1304 Err(BenchmarkError::Skip)
1305 }
1306
1307 fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
1308 let origin = Location::new(1, [Parachain(1000)]);
1311 let target = Location::new(1, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]);
1312 Ok((origin, target))
1313 }
1314 }
1315
1316 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
1317 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
1318
1319 use frame_support::traits::WhitelistedStorageKeys;
1320 let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
1321
1322 let mut batches = Vec::<BenchmarkBatch>::new();
1323 let params = (&config, &whitelist);
1324 add_benchmarks!(params, batches);
1325
1326 Ok(batches)
1327 }
1328 }
1329
1330 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1331 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1332 build_state::<RuntimeGenesisConfig>(config)
1333 }
1334
1335 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1336 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
1337 }
1338
1339 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1340 genesis_config_presets::preset_names()
1341 }
1342 }
1343
1344 impl cumulus_primitives_core::GetParachainInfo<Block> for Runtime {
1345 fn parachain_id() -> ParaId {
1346 ParachainInfo::parachain_id()
1347 }
1348 }
1349}
1350
1351cumulus_pallet_parachain_system::register_validate_block! {
1352 Runtime = Runtime,
1353 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
1354}
1355
1356parameter_types! {
1357 pub const MigrationSignedDepositPerItem: Balance = CENTS;
1359 pub const MigrationSignedDepositBase: Balance = 2_000 * CENTS;
1360 pub const MigrationMaxKeyLen: u32 = 512;
1361}
1362
1363impl pallet_state_trie_migration::Config for Runtime {
1364 type RuntimeEvent = RuntimeEvent;
1365 type Currency = Balances;
1366 type RuntimeHoldReason = RuntimeHoldReason;
1367 type SignedDepositPerItem = MigrationSignedDepositPerItem;
1368 type SignedDepositBase = MigrationSignedDepositBase;
1369 type ControlOrigin = frame_system::EnsureSignedBy<RootMigController, AccountId>;
1371 type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
1373
1374 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
1376
1377 type MaxKeyLen = MigrationMaxKeyLen;
1378}
1379
1380frame_support::ord_parameter_types! {
1381 pub const MigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
1382 pub const RootMigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
1383}
1384
1385#[test]
1386fn ensure_key_ss58() {
1387 use frame_support::traits::SortedMembers;
1388 use sp_core::crypto::Ss58Codec;
1389 let acc =
1390 AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap();
1391 assert_eq!(acc, MigController::sorted_members()[0]);
1392 let acc =
1393 AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap();
1394 assert_eq!(acc, RootMigController::sorted_members()[0]);
1395}