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, XcmConfig,
103 XcmOriginToTransactDispatchOrigin,
104};
105
106#[cfg(any(feature = "std", test))]
107pub use sp_runtime::BuildStorage;
108
109use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
111use polkadot_runtime_common::{
112 impls::VersionedLocatableAsset, BlockHashCount, SlowAdjustingFeeUpdate,
113};
114use xcm::{prelude::*, Version as XcmVersion};
115use xcm_runtime_apis::{
116 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
117 fees::Error as XcmPaymentApiError,
118};
119
120use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
121
122impl_opaque_keys! {
123 pub struct SessionKeys {
124 pub aura: Aura,
125 }
126}
127
128#[sp_version::runtime_version]
129pub const VERSION: RuntimeVersion = RuntimeVersion {
130 spec_name: alloc::borrow::Cow::Borrowed("collectives-westend"),
131 impl_name: alloc::borrow::Cow::Borrowed("collectives-westend"),
132 authoring_version: 1,
133 spec_version: 1_021_000,
134 impl_version: 0,
135 apis: RUNTIME_API_VERSIONS,
136 transaction_version: 6,
137 system_version: 1,
138};
139
140#[cfg(feature = "std")]
142pub fn native_version() -> NativeVersion {
143 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
144}
145
146pub type RootOrAllianceTwoThirdsMajority = EitherOfDiverse<
148 EnsureRoot<AccountId>,
149 pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
150>;
151
152parameter_types! {
153 pub const Version: RuntimeVersion = VERSION;
154 pub RuntimeBlockLength: BlockLength =
155 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
156 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
157 .base_block(BlockExecutionWeight::get())
158 .for_class(DispatchClass::all(), |weights| {
159 weights.base_extrinsic = ExtrinsicBaseWeight::get();
160 })
161 .for_class(DispatchClass::Normal, |weights| {
162 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
163 })
164 .for_class(DispatchClass::Operational, |weights| {
165 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
166 weights.reserved = Some(
169 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
170 );
171 })
172 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
173 .build_or_panic();
174 pub const SS58Prefix: u8 = 42;
175}
176
177#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
179impl frame_system::Config for Runtime {
180 type BlockWeights = RuntimeBlockWeights;
181 type BlockLength = RuntimeBlockLength;
182 type AccountId = AccountId;
183 type RuntimeCall = RuntimeCall;
184 type Nonce = Nonce;
185 type Hash = Hash;
186 type Block = Block;
187 type BlockHashCount = BlockHashCount;
188 type DbWeight = RocksDbWeight;
189 type Version = Version;
190 type AccountData = pallet_balances::AccountData<Balance>;
191 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
192 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
193 type SS58Prefix = SS58Prefix;
194 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
195 type MaxConsumers = frame_support::traits::ConstU32<16>;
196 type SingleBlockMigrations = Migrations;
197}
198
199impl cumulus_pallet_weight_reclaim::Config for Runtime {
200 type WeightInfo = weights::cumulus_pallet_weight_reclaim::WeightInfo<Runtime>;
201}
202
203impl pallet_timestamp::Config for Runtime {
204 type Moment = u64;
206 type OnTimestampSet = Aura;
207 type MinimumPeriod = ConstU64<0>;
208 type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
209}
210
211impl pallet_authorship::Config for Runtime {
212 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
213 type EventHandler = (CollatorSelection,);
214}
215
216parameter_types! {
217 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
218}
219
220impl pallet_balances::Config for Runtime {
221 type MaxLocks = ConstU32<50>;
222 type Balance = Balance;
224 type RuntimeEvent = RuntimeEvent;
226 type DustRemoval = ();
227 type ExistentialDeposit = ExistentialDeposit;
228 type AccountStore = System;
229 type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
230 type MaxReserves = ConstU32<50>;
231 type ReserveIdentifier = [u8; 8];
232 type RuntimeHoldReason = RuntimeHoldReason;
233 type RuntimeFreezeReason = RuntimeFreezeReason;
234 type FreezeIdentifier = ();
235 type MaxFreezes = ConstU32<0>;
236 type DoneSlashHandler = ();
237}
238
239parameter_types! {
240 pub const TransactionByteFee: Balance = MILLICENTS;
242}
243
244impl pallet_transaction_payment::Config for Runtime {
245 type RuntimeEvent = RuntimeEvent;
246 type OnChargeTransaction =
247 pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
248 type WeightToFee = WeightToFee;
249 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
250 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
251 type OperationalFeeMultiplier = ConstU8<5>;
252 type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
253}
254
255parameter_types! {
256 pub const DepositBase: Balance = deposit(1, 88);
258 pub const DepositFactor: Balance = deposit(0, 32);
260}
261
262impl pallet_multisig::Config for Runtime {
263 type RuntimeEvent = RuntimeEvent;
264 type RuntimeCall = RuntimeCall;
265 type Currency = Balances;
266 type DepositBase = DepositBase;
267 type DepositFactor = DepositFactor;
268 type MaxSignatories = ConstU32<100>;
269 type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
270 type BlockNumberProvider = frame_system::Pallet<Runtime>;
271}
272
273impl pallet_utility::Config for Runtime {
274 type RuntimeEvent = RuntimeEvent;
275 type RuntimeCall = RuntimeCall;
276 type PalletsOrigin = OriginCaller;
277 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
278}
279
280parameter_types! {
281 pub const ProxyDepositBase: Balance = deposit(1, 40);
283 pub const ProxyDepositFactor: Balance = deposit(0, 33);
285 pub const AnnouncementDepositBase: Balance = deposit(1, 48);
287 pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
288}
289
290#[derive(
292 Copy,
293 Clone,
294 Eq,
295 PartialEq,
296 Ord,
297 PartialOrd,
298 Encode,
299 Decode,
300 DecodeWithMemTracking,
301 RuntimeDebug,
302 MaxEncodedLen,
303 scale_info::TypeInfo,
304)]
305pub enum ProxyType {
306 Any,
308 NonTransfer,
310 CancelProxy,
312 Collator,
314 Alliance,
316 Fellowship,
318 Ambassador,
320 Secretary,
322}
323impl Default for ProxyType {
324 fn default() -> Self {
325 Self::Any
326 }
327}
328impl InstanceFilter<RuntimeCall> for ProxyType {
329 fn filter(&self, c: &RuntimeCall) -> bool {
330 match self {
331 ProxyType::Any => true,
332 ProxyType::NonTransfer => !matches!(c, RuntimeCall::Balances { .. }),
333 ProxyType::CancelProxy => matches!(
334 c,
335 RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
336 RuntimeCall::Utility { .. } |
337 RuntimeCall::Multisig { .. }
338 ),
339 ProxyType::Collator => matches!(
340 c,
341 RuntimeCall::CollatorSelection { .. } |
342 RuntimeCall::Utility { .. } |
343 RuntimeCall::Multisig { .. }
344 ),
345 ProxyType::Alliance => matches!(
346 c,
347 RuntimeCall::AllianceMotion { .. } |
348 RuntimeCall::Alliance { .. } |
349 RuntimeCall::Utility { .. } |
350 RuntimeCall::Multisig { .. }
351 ),
352 ProxyType::Fellowship => matches!(
353 c,
354 RuntimeCall::FellowshipCollective { .. } |
355 RuntimeCall::FellowshipReferenda { .. } |
356 RuntimeCall::FellowshipCore { .. } |
357 RuntimeCall::FellowshipSalary { .. } |
358 RuntimeCall::FellowshipTreasury { .. } |
359 RuntimeCall::Utility { .. } |
360 RuntimeCall::Multisig { .. }
361 ),
362 ProxyType::Ambassador => matches!(
363 c,
364 RuntimeCall::AmbassadorCollective { .. } |
365 RuntimeCall::AmbassadorReferenda { .. } |
366 RuntimeCall::AmbassadorContent { .. } |
367 RuntimeCall::AmbassadorCore { .. } |
368 RuntimeCall::AmbassadorSalary { .. } |
369 RuntimeCall::Utility { .. } |
370 RuntimeCall::Multisig { .. }
371 ),
372 ProxyType::Secretary => matches!(
373 c,
374 RuntimeCall::SecretaryCollective { .. } |
375 RuntimeCall::SecretarySalary { .. } |
376 RuntimeCall::Utility { .. } |
377 RuntimeCall::Multisig { .. }
378 ),
379 }
380 }
381 fn is_superset(&self, o: &Self) -> bool {
382 match (self, o) {
383 (x, y) if x == y => true,
384 (ProxyType::Any, _) => true,
385 (_, ProxyType::Any) => false,
386 (ProxyType::NonTransfer, _) => true,
387 _ => false,
388 }
389 }
390}
391
392impl pallet_proxy::Config for Runtime {
393 type RuntimeEvent = RuntimeEvent;
394 type RuntimeCall = RuntimeCall;
395 type Currency = Balances;
396 type ProxyType = ProxyType;
397 type ProxyDepositBase = ProxyDepositBase;
398 type ProxyDepositFactor = ProxyDepositFactor;
399 type MaxProxies = ConstU32<32>;
400 type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
401 type MaxPending = ConstU32<32>;
402 type CallHasher = BlakeTwo256;
403 type AnnouncementDepositBase = AnnouncementDepositBase;
404 type AnnouncementDepositFactor = AnnouncementDepositFactor;
405 type BlockNumberProvider = frame_system::Pallet<Runtime>;
406}
407
408parameter_types! {
409 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
410 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
411}
412
413impl cumulus_pallet_parachain_system::Config for Runtime {
414 type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
415 type RuntimeEvent = RuntimeEvent;
416 type OnSystemEvent = ();
417 type SelfParaId = parachain_info::Pallet<Runtime>;
418 type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
419 type ReservedDmpWeight = ReservedDmpWeight;
420 type OutboundXcmpMessageSource = XcmpQueue;
421 type XcmpMessageHandler = XcmpQueue;
422 type ReservedXcmpWeight = ReservedXcmpWeight;
423 type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
424 type ConsensusHook = ConsensusHook;
425 type RelayParentOffset = ConstU32<0>;
426}
427
428type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
429 Runtime,
430 RELAY_CHAIN_SLOT_DURATION_MILLIS,
431 BLOCK_PROCESSING_VELOCITY,
432 UNINCLUDED_SEGMENT_CAPACITY,
433>;
434
435impl parachain_info::Config for Runtime {}
436
437parameter_types! {
438 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
439}
440
441impl pallet_message_queue::Config for Runtime {
442 type RuntimeEvent = RuntimeEvent;
443 type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
444 #[cfg(feature = "runtime-benchmarks")]
445 type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
446 cumulus_primitives_core::AggregateMessageOrigin,
447 >;
448 #[cfg(not(feature = "runtime-benchmarks"))]
449 type MessageProcessor = xcm_builder::ProcessXcmMessage<
450 AggregateMessageOrigin,
451 xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
452 RuntimeCall,
453 >;
454 type Size = u32;
455 type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
457 type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
458 type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
459 type MaxStale = sp_core::ConstU32<8>;
460 type ServiceWeight = MessageQueueServiceWeight;
461 type IdleMaxServiceWeight = MessageQueueServiceWeight;
462}
463
464impl cumulus_pallet_aura_ext::Config for Runtime {}
465
466parameter_types! {
467 pub FeeAssetId: AssetId = AssetId(xcm_config::WndLocation::get());
469 pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
471}
472
473pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
474 FeeAssetId,
475 BaseDeliveryFee,
476 TransactionByteFee,
477 XcmpQueue,
478>;
479
480impl cumulus_pallet_xcmp_queue::Config for Runtime {
481 type RuntimeEvent = RuntimeEvent;
482 type ChannelInfo = ParachainSystem;
483 type VersionWrapper = PolkadotXcm;
484 type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
486 type MaxInboundSuspended = ConstU32<1_000>;
487 type MaxActiveOutboundChannels = ConstU32<128>;
488 type MaxPageSize = ConstU32<{ 103 * 1024 }>;
491 type ControllerOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Fellows>;
492 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
493 type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
494 type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
495}
496
497impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
498 type ChannelList = ParachainSystem;
500}
501
502parameter_types! {
503 pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
504}
505
506pub const PERIOD: u32 = 6 * HOURS;
507pub const OFFSET: u32 = 0;
508
509impl pallet_session::Config for Runtime {
510 type RuntimeEvent = RuntimeEvent;
511 type ValidatorId = <Self as frame_system::Config>::AccountId;
512 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
514 type ShouldEndSession = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
515 type NextSessionRotation = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
516 type SessionManager = CollatorSelection;
517 type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
519 type Keys = SessionKeys;
520 type DisablingStrategy = ();
521 type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
522 type Currency = Balances;
523 type KeyDeposit = ();
524}
525
526impl pallet_aura::Config for Runtime {
527 type AuthorityId = AuraId;
528 type DisabledValidators = ();
529 type MaxAuthorities = ConstU32<100_000>;
530 type AllowMultipleBlocksPerSlot = ConstBool<true>;
531 type SlotDuration = ConstU64<SLOT_DURATION>;
532}
533
534parameter_types! {
535 pub const PotId: PalletId = PalletId(*b"PotStake");
536 pub const SessionLength: BlockNumber = 6 * HOURS;
537 pub const StakingAdminBodyId: BodyId = BodyId::Defense;
539}
540
541pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
543 EnsureRoot<AccountId>,
544 EnsureXcm<IsVoiceOfBody<GovernanceLocation, StakingAdminBodyId>>,
545>;
546
547impl pallet_collator_selection::Config for Runtime {
548 type RuntimeEvent = RuntimeEvent;
549 type Currency = Balances;
550 type UpdateOrigin = CollatorSelectionUpdateOrigin;
551 type PotId = PotId;
552 type MaxCandidates = ConstU32<100>;
553 type MinEligibleCollators = ConstU32<4>;
554 type MaxInvulnerables = ConstU32<20>;
555 type KickThreshold = ConstU32<PERIOD>;
557 type ValidatorId = <Self as frame_system::Config>::AccountId;
558 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
559 type ValidatorRegistration = Session;
560 type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
561}
562
563pub const ALLIANCE_MOTION_DURATION: BlockNumber = 5 * DAYS;
564
565parameter_types! {
566 pub const AllianceMotionDuration: BlockNumber = ALLIANCE_MOTION_DURATION;
567 pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
568}
569pub const ALLIANCE_MAX_PROPOSALS: u32 = 100;
570pub const ALLIANCE_MAX_MEMBERS: u32 = 100;
571
572type AllianceCollective = pallet_collective::Instance1;
573impl pallet_collective::Config<AllianceCollective> for Runtime {
574 type RuntimeOrigin = RuntimeOrigin;
575 type Proposal = RuntimeCall;
576 type RuntimeEvent = RuntimeEvent;
577 type MotionDuration = AllianceMotionDuration;
578 type MaxProposals = ConstU32<ALLIANCE_MAX_PROPOSALS>;
579 type MaxMembers = ConstU32<ALLIANCE_MAX_MEMBERS>;
580 type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
581 type SetMembersOrigin = EnsureRoot<AccountId>;
582 type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
583 type MaxProposalWeight = MaxProposalWeight;
584 type DisapproveOrigin = EnsureRoot<Self::AccountId>;
585 type KillOrigin = EnsureRoot<Self::AccountId>;
586 type Consideration = ();
587}
588
589pub const MAX_FELLOWS: u32 = ALLIANCE_MAX_MEMBERS;
590pub const MAX_ALLIES: u32 = 100;
591
592parameter_types! {
593 pub const AllyDeposit: Balance = 1_000 * UNITS; pub WestendTreasuryAccount: AccountId = WESTEND_TREASURY_PALLET_ID.into_account_truncating();
595 pub const AllianceRetirementPeriod: BlockNumber = (90 * DAYS) + ALLIANCE_MOTION_DURATION;
598}
599
600impl pallet_alliance::Config for Runtime {
601 type RuntimeEvent = RuntimeEvent;
602 type Proposal = RuntimeCall;
603 type AdminOrigin = RootOrAllianceTwoThirdsMajority;
604 type MembershipManager = RootOrAllianceTwoThirdsMajority;
605 type AnnouncementOrigin = RootOrAllianceTwoThirdsMajority;
606 type Currency = Balances;
607 type Slashed = ToParentTreasury<WestendTreasuryAccount, LocationToAccountId, Runtime>;
608 type InitializeMembers = AllianceMotion;
609 type MembershipChanged = AllianceMotion;
610 type RetirementPeriod = AllianceRetirementPeriod;
611 type IdentityVerifier = (); type ProposalProvider = AllianceProposalProvider<Runtime, AllianceCollective>;
613 type MaxProposals = ConstU32<ALLIANCE_MAX_MEMBERS>;
614 type MaxFellows = ConstU32<MAX_FELLOWS>;
615 type MaxAllies = ConstU32<MAX_ALLIES>;
616 type MaxUnscrupulousItems = ConstU32<100>;
617 type MaxWebsiteUrlLength = ConstU32<255>;
618 type MaxAnnouncementsCount = ConstU32<100>;
619 type MaxMembersCount = ConstU32<ALLIANCE_MAX_MEMBERS>;
620 type AllyDeposit = AllyDeposit;
621 type WeightInfo = weights::pallet_alliance::WeightInfo<Runtime>;
622}
623
624parameter_types! {
625 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
626}
627
628#[cfg(not(feature = "runtime-benchmarks"))]
629parameter_types! {
630 pub const MaxScheduledPerBlock: u32 = 50;
631}
632
633#[cfg(feature = "runtime-benchmarks")]
634parameter_types! {
635 pub const MaxScheduledPerBlock: u32 = 200;
636}
637
638impl pallet_scheduler::Config for Runtime {
639 type RuntimeOrigin = RuntimeOrigin;
640 type RuntimeEvent = RuntimeEvent;
641 type PalletsOrigin = OriginCaller;
642 type RuntimeCall = RuntimeCall;
643 type MaximumWeight = MaximumSchedulerWeight;
644 type ScheduleOrigin = EnsureRoot<AccountId>;
645 type MaxScheduledPerBlock = MaxScheduledPerBlock;
646 type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
647 type OriginPrivilegeCmp = EqualOrGreatestRootCmp;
648 type Preimages = Preimage;
649 type BlockNumberProvider = frame_system::Pallet<Runtime>;
650}
651
652parameter_types! {
653 pub const PreimageBaseDeposit: Balance = deposit(2, 64);
654 pub const PreimageByteDeposit: Balance = deposit(0, 1);
655 pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
656}
657
658impl pallet_preimage::Config for Runtime {
659 type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
660 type RuntimeEvent = RuntimeEvent;
661 type Currency = Balances;
662 type ManagerOrigin = EnsureRoot<AccountId>;
663 type Consideration = HoldConsideration<
664 AccountId,
665 Balances,
666 PreimageHoldReason,
667 LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
668 >;
669}
670
671impl pallet_asset_rate::Config for Runtime {
672 type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
673 type RuntimeEvent = RuntimeEvent;
674 type CreateOrigin = EitherOfDiverse<
675 EnsureRoot<AccountId>,
676 EitherOfDiverse<EnsureXcm<IsVoiceOfBody<GovernanceLocation, TreasurerBodyId>>, Fellows>,
677 >;
678 type RemoveOrigin = Self::CreateOrigin;
679 type UpdateOrigin = Self::CreateOrigin;
680 type Currency = Balances;
681 type AssetKind = VersionedLocatableAsset;
682 #[cfg(feature = "runtime-benchmarks")]
683 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
684}
685
686construct_runtime!(
688 pub enum Runtime
689 {
690 System: frame_system = 0,
692 ParachainSystem: cumulus_pallet_parachain_system = 1,
693 Timestamp: pallet_timestamp = 2,
694 ParachainInfo: parachain_info = 3,
695 WeightReclaim: cumulus_pallet_weight_reclaim = 4,
696
697 Balances: pallet_balances = 10,
699 TransactionPayment: pallet_transaction_payment = 11,
700
701 Authorship: pallet_authorship = 20,
703 CollatorSelection: pallet_collator_selection = 21,
704 Session: pallet_session = 22,
705 Aura: pallet_aura = 23,
706 AuraExt: cumulus_pallet_aura_ext = 24,
707
708 XcmpQueue: cumulus_pallet_xcmp_queue = 30,
710 PolkadotXcm: pallet_xcm = 31,
711 CumulusXcm: cumulus_pallet_xcm = 32,
712 MessageQueue: pallet_message_queue = 34,
713
714 Utility: pallet_utility = 40,
716 Multisig: pallet_multisig = 41,
717 Proxy: pallet_proxy = 42,
718 Preimage: pallet_preimage = 43,
719 Scheduler: pallet_scheduler = 44,
720 AssetRate: pallet_asset_rate = 45,
721
722 Alliance: pallet_alliance = 50,
726 AllianceMotion: pallet_collective::<Instance1> = 51,
727
728 FellowshipCollective: pallet_ranked_collective::<Instance1> = 60,
731 FellowshipReferenda: pallet_referenda::<Instance1> = 61,
733 FellowshipOrigins: pallet_fellowship_origins = 62,
734 FellowshipCore: pallet_core_fellowship::<Instance1> = 63,
736 FellowshipSalary: pallet_salary::<Instance1> = 64,
738 FellowshipTreasury: pallet_treasury::<Instance1> = 65,
740
741 AmbassadorCollective: pallet_ranked_collective::<Instance2> = 70,
743 AmbassadorReferenda: pallet_referenda::<Instance2> = 71,
744 AmbassadorOrigins: pallet_ambassador_origins = 72,
745 AmbassadorCore: pallet_core_fellowship::<Instance2> = 73,
746 AmbassadorSalary: pallet_salary::<Instance2> = 74,
747 AmbassadorContent: pallet_collective_content::<Instance1> = 75,
748
749 StateTrieMigration: pallet_state_trie_migration = 80,
750
751 SecretaryCollective: pallet_ranked_collective::<Instance3> = 90,
754 SecretarySalary: pallet_salary::<Instance3> = 91,
756 }
757);
758
759pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
761pub type Block = generic::Block<Header, UncheckedExtrinsic>;
763pub type SignedBlock = generic::SignedBlock<Block>;
765pub type BlockId = generic::BlockId<Block>;
767pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
769 Runtime,
770 (
771 frame_system::AuthorizeCall<Runtime>,
772 frame_system::CheckNonZeroSender<Runtime>,
773 frame_system::CheckSpecVersion<Runtime>,
774 frame_system::CheckTxVersion<Runtime>,
775 frame_system::CheckGenesis<Runtime>,
776 frame_system::CheckEra<Runtime>,
777 frame_system::CheckNonce<Runtime>,
778 frame_system::CheckWeight<Runtime>,
779 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
780 ),
781>;
782
783pub type UncheckedExtrinsic =
785 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
786type Migrations = (
789 pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
791 cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
793 cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
794 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
796 pallet_core_fellowship::migration::MigrateV0ToV1<Runtime, FellowshipCoreInstance>,
798 pallet_core_fellowship::migration::MigrateV0ToV1<Runtime, AmbassadorCoreInstance>,
800 cumulus_pallet_aura_ext::migration::MigrateV0ToV1<Runtime>,
801 pallet_session::migrations::v1::MigrateV0ToV1<
802 Runtime,
803 pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
804 >,
805);
806
807pub type Executive = frame_executive::Executive<
809 Runtime,
810 Block,
811 frame_system::ChainContext<Runtime>,
812 Runtime,
813 AllPalletsWithSystem,
814>;
815
816#[cfg(feature = "runtime-benchmarks")]
817mod benches {
818 frame_benchmarking::define_benchmarks!(
819 [frame_system, SystemBench::<Runtime>]
820 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
821 [pallet_balances, Balances]
822 [pallet_message_queue, MessageQueue]
823 [pallet_multisig, Multisig]
824 [pallet_proxy, Proxy]
825 [pallet_session, SessionBench::<Runtime>]
826 [pallet_utility, Utility]
827 [pallet_timestamp, Timestamp]
828 [pallet_transaction_payment, TransactionPayment]
829 [pallet_collator_selection, CollatorSelection]
830 [cumulus_pallet_parachain_system, ParachainSystem]
831 [cumulus_pallet_xcmp_queue, XcmpQueue]
832 [pallet_alliance, Alliance]
833 [pallet_collective, AllianceMotion]
834 [pallet_preimage, Preimage]
835 [pallet_scheduler, Scheduler]
836 [pallet_referenda, FellowshipReferenda]
837 [pallet_ranked_collective, FellowshipCollective]
838 [pallet_core_fellowship, FellowshipCore]
839 [pallet_salary, FellowshipSalary]
840 [pallet_treasury, FellowshipTreasury]
841 [pallet_referenda, AmbassadorReferenda]
842 [pallet_ranked_collective, AmbassadorCollective]
843 [pallet_collective_content, AmbassadorContent]
844 [pallet_core_fellowship, AmbassadorCore]
845 [pallet_salary, AmbassadorSalary]
846 [pallet_ranked_collective, SecretaryCollective]
847 [pallet_salary, SecretarySalary]
848 [pallet_asset_rate, AssetRate]
849 [cumulus_pallet_weight_reclaim, WeightReclaim]
850 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
852 [pallet_xcm_benchmarks::fungible, XcmBalances]
854 [pallet_xcm_benchmarks::generic, XcmGeneric]
855 );
856}
857
858impl_runtime_apis! {
859 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
860 fn slot_duration() -> sp_consensus_aura::SlotDuration {
861 sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
862 }
863
864 fn authorities() -> Vec<AuraId> {
865 pallet_aura::Authorities::<Runtime>::get().into_inner()
866 }
867 }
868
869 impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
870 fn relay_parent_offset() -> u32 {
871 0
872 }
873 }
874
875 impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
876 fn can_build_upon(
877 included_hash: <Block as BlockT>::Hash,
878 slot: cumulus_primitives_aura::Slot,
879 ) -> bool {
880 ConsensusHook::can_build_upon(included_hash, slot)
881 }
882 }
883
884 impl sp_api::Core<Block> for Runtime {
885 fn version() -> RuntimeVersion {
886 VERSION
887 }
888
889 fn execute_block(block: <Block as BlockT>::LazyBlock) {
890 Executive::execute_block(block)
891 }
892
893 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
894 Executive::initialize_block(header)
895 }
896 }
897
898 impl sp_api::Metadata<Block> for Runtime {
899 fn metadata() -> OpaqueMetadata {
900 OpaqueMetadata::new(Runtime::metadata().into())
901 }
902
903 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
904 Runtime::metadata_at_version(version)
905 }
906
907 fn metadata_versions() -> alloc::vec::Vec<u32> {
908 Runtime::metadata_versions()
909 }
910 }
911
912 impl sp_block_builder::BlockBuilder<Block> for Runtime {
913 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
914 Executive::apply_extrinsic(extrinsic)
915 }
916
917 fn finalize_block() -> <Block as BlockT>::Header {
918 Executive::finalize_block()
919 }
920
921 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
922 data.create_extrinsics()
923 }
924
925 fn check_inherents(
926 block: <Block as BlockT>::LazyBlock,
927 data: sp_inherents::InherentData,
928 ) -> sp_inherents::CheckInherentsResult {
929 data.check_extrinsics(&block)
930 }
931 }
932
933 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
934 fn validate_transaction(
935 source: TransactionSource,
936 tx: <Block as BlockT>::Extrinsic,
937 block_hash: <Block as BlockT>::Hash,
938 ) -> TransactionValidity {
939 Executive::validate_transaction(source, tx, block_hash)
940 }
941 }
942
943 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
944 fn offchain_worker(header: &<Block as BlockT>::Header) {
945 Executive::offchain_worker(header)
946 }
947 }
948
949 impl sp_session::SessionKeys<Block> for Runtime {
950 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
951 SessionKeys::generate(seed)
952 }
953
954 fn decode_session_keys(
955 encoded: Vec<u8>,
956 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
957 SessionKeys::decode_into_raw_public_keys(&encoded)
958 }
959 }
960
961 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
962 fn account_nonce(account: AccountId) -> Nonce {
963 System::account_nonce(account)
964 }
965 }
966
967 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
968 fn query_info(
969 uxt: <Block as BlockT>::Extrinsic,
970 len: u32,
971 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
972 TransactionPayment::query_info(uxt, len)
973 }
974 fn query_fee_details(
975 uxt: <Block as BlockT>::Extrinsic,
976 len: u32,
977 ) -> pallet_transaction_payment::FeeDetails<Balance> {
978 TransactionPayment::query_fee_details(uxt, len)
979 }
980 fn query_weight_to_fee(weight: Weight) -> Balance {
981 TransactionPayment::weight_to_fee(weight)
982 }
983 fn query_length_to_fee(length: u32) -> Balance {
984 TransactionPayment::length_to_fee(length)
985 }
986 }
987
988 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
989 for Runtime
990 {
991 fn query_call_info(
992 call: RuntimeCall,
993 len: u32,
994 ) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
995 TransactionPayment::query_call_info(call, len)
996 }
997 fn query_call_fee_details(
998 call: RuntimeCall,
999 len: u32,
1000 ) -> pallet_transaction_payment::FeeDetails<Balance> {
1001 TransactionPayment::query_call_fee_details(call, len)
1002 }
1003 fn query_weight_to_fee(weight: Weight) -> Balance {
1004 TransactionPayment::weight_to_fee(weight)
1005 }
1006 fn query_length_to_fee(length: u32) -> Balance {
1007 TransactionPayment::length_to_fee(length)
1008 }
1009 }
1010
1011 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
1012 fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
1013 let acceptable_assets = vec![AssetId(xcm_config::WndLocation::get())];
1014 PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
1015 }
1016
1017 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
1018 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
1019 PolkadotXcm::query_weight_to_asset_fee::<Trader>(weight, asset)
1020 }
1021
1022 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
1023 PolkadotXcm::query_xcm_weight(message)
1024 }
1025
1026 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>, asset_id: VersionedAssetId) -> Result<VersionedAssets, XcmPaymentApiError> {
1027 type AssetExchanger = <XcmConfig as xcm_executor::Config>::AssetExchanger;
1028 PolkadotXcm::query_delivery_fees::<AssetExchanger>(destination, message, asset_id)
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::<xcm_config::XcmRouter>(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 as BlockT>::LazyBlock,
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 impl cumulus_primitives_core::TargetBlockRate<Block> for Runtime {
1351 fn target_block_rate() -> u32 {
1352 1
1353 }
1354 }
1355}
1356
1357cumulus_pallet_parachain_system::register_validate_block! {
1358 Runtime = Runtime,
1359 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
1360}
1361
1362parameter_types! {
1363 pub const MigrationSignedDepositPerItem: Balance = CENTS;
1365 pub const MigrationSignedDepositBase: Balance = 2_000 * CENTS;
1366 pub const MigrationMaxKeyLen: u32 = 512;
1367}
1368
1369impl pallet_state_trie_migration::Config for Runtime {
1370 type RuntimeEvent = RuntimeEvent;
1371 type Currency = Balances;
1372 type RuntimeHoldReason = RuntimeHoldReason;
1373 type SignedDepositPerItem = MigrationSignedDepositPerItem;
1374 type SignedDepositBase = MigrationSignedDepositBase;
1375 type ControlOrigin = frame_system::EnsureSignedBy<RootMigController, AccountId>;
1377 type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
1379
1380 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
1382
1383 type MaxKeyLen = MigrationMaxKeyLen;
1384}
1385
1386frame_support::ord_parameter_types! {
1387 pub const MigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
1388 pub const RootMigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
1389}
1390
1391#[test]
1392fn ensure_key_ss58() {
1393 use frame_support::traits::SortedMembers;
1394 use sp_core::crypto::Ss58Codec;
1395 let acc =
1396 AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap();
1397 assert_eq!(acc, MigController::sorted_members()[0]);
1398 let acc =
1399 AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap();
1400 assert_eq!(acc, RootMigController::sorted_members()[0]);
1401}