1#![cfg_attr(not(feature = "std"), no_std)]
20#![recursion_limit = "512"]
22
23extern crate alloc;
24
25use alloc::{
26 collections::{btree_map::BTreeMap, vec_deque::VecDeque},
27 vec,
28 vec::Vec,
29};
30use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
31use frame_election_provider_support::{bounds::ElectionBoundsBuilder, onchain, SequentialPhragmen};
32use frame_support::{
33 derive_impl,
34 dynamic_params::{dynamic_pallet_params, dynamic_params},
35 genesis_builder_helper::{build_state, get_preset},
36 parameter_types,
37 traits::{
38 fungible::HoldConsideration, tokens::UnityOrOuterConversion, AsEnsureOriginWithArg,
39 ConstU32, Contains, EitherOf, EitherOfDiverse, EnsureOriginWithArg, FromContains,
40 InstanceFilter, KeyOwnerProofSystem, LinearStoragePrice, Nothing, ProcessMessage,
41 ProcessMessageError, VariantCountOf, WithdrawReasons,
42 },
43 weights::{ConstantMultiplier, WeightMeter},
44 PalletId,
45};
46use frame_system::{EnsureRoot, EnsureSigned};
47use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
48use pallet_identity::legacy::IdentityInfo;
49use pallet_nomination_pools::PoolId;
50use pallet_session::historical as session_historical;
51use pallet_staking::UseValidatorsMap;
52use pallet_staking_async_ah_client as ah_client;
53use pallet_staking_async_rc_client as rc_client;
54use pallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
55use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
56use polkadot_primitives::{
57 slashing,
58 vstaging::{
59 async_backing::Constraints, CandidateEvent,
60 CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreState, ScrapedOnChainVotes,
61 },
62 AccountId, AccountIndex, ApprovalVotingParams, Balance, BlockNumber, CandidateHash, CoreIndex,
63 DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage,
64 InboundHrmpMessage, Moment, NodeFeatures, Nonce, OccupiedCoreAssumption,
65 PersistedValidationData, PvfCheckStatement, SessionInfo, Signature, ValidationCode,
66 ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, PARACHAIN_KEY_TYPE_ID,
67};
68use polkadot_runtime_common::{
69 assigned_slots, auctions, crowdloan,
70 elections::OnChainAccuracy,
71 identity_migrator, impl_runtime_weights,
72 impls::{
73 ContainsParts, LocatableAssetConverter, ToAuthor, VersionedLocatableAsset,
74 VersionedLocationConverter,
75 },
76 paras_registrar, paras_sudo_wrapper, prod_or_fast, slots,
77 traits::OnSwap,
78 BalanceToU256, BlockHashCount, BlockLength, SlowAdjustingFeeUpdate, U256ToBalance,
79};
80use polkadot_runtime_parachains::{
81 assigner_coretime as parachains_assigner_coretime, configuration as parachains_configuration,
82 configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
83 coretime, disputes as parachains_disputes,
84 disputes::slashing as parachains_slashing,
85 dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
86 inclusion::{AggregateMessageOrigin, UmpQueueId},
87 initializer as parachains_initializer, on_demand as parachains_on_demand,
88 origin as parachains_origin, paras as parachains_paras,
89 paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points,
90 runtime_api_impl::{
91 v11 as parachains_runtime_api_impl, vstaging as parachains_staging_runtime_api_impl,
92 },
93 scheduler as parachains_scheduler, session_info as parachains_session_info,
94 shared as parachains_shared,
95};
96use scale_info::TypeInfo;
97use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
98use sp_consensus_beefy::{
99 ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
100 mmr::{BeefyDataProvider, MmrLeafVersion},
101};
102use sp_core::{ConstBool, ConstU8, ConstUint, OpaqueMetadata, RuntimeDebug, H256};
103#[cfg(any(feature = "std", test))]
104pub use sp_runtime::BuildStorage;
105use sp_runtime::{
106 generic, impl_opaque_keys,
107 traits::{
108 AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, Get, IdentityLookup,
109 Keccak256, OpaqueKeys, SaturatedConversion, Verify,
110 },
111 transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
112 ApplyExtrinsicResult, FixedU128, KeyTypeId, MultiSignature, MultiSigner, Percent, Permill,
113};
114use sp_staking::{EraIndex, SessionIndex};
115#[cfg(any(feature = "std", test))]
116use sp_version::NativeVersion;
117use sp_version::RuntimeVersion;
118use xcm::{
119 latest::prelude::*, Version as XcmVersion, VersionedAsset, VersionedAssetId, VersionedAssets,
120 VersionedLocation, VersionedXcm,
121};
122use xcm_builder::PayOverXcm;
123use xcm_runtime_apis::{
124 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
125 fees::Error as XcmPaymentApiError,
126};
127
128pub use frame_system::Call as SystemCall;
129pub use pallet_balances::Call as BalancesCall;
130pub use pallet_election_provider_multi_phase::{Call as EPMCall, GeometricDepositBase};
131pub use pallet_timestamp::Call as TimestampCall;
132
133use westend_runtime_constants::{
135 currency::*,
136 fee::*,
137 system_parachain::{coretime::TIMESLICE_PERIOD, ASSET_HUB_ID, BROKER_ID},
138 time::*,
139};
140
141mod bag_thresholds;
142mod genesis_config_presets;
143mod weights;
144pub mod xcm_config;
145
146mod impls;
148use impls::ToParachainIdentityReaper;
149
150pub mod governance;
152use governance::{
153 pallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin, LeaseAdmin, StakingAdmin,
154 Treasurer, TreasurySpender,
155};
156
157#[cfg(test)]
158mod tests;
159
160impl_runtime_weights!(westend_runtime_constants);
161
162#[cfg(feature = "std")]
164include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
165
166#[cfg(feature = "std")]
167pub mod fast_runtime_binary {
168 include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
169}
170
171#[sp_version::runtime_version]
173pub const VERSION: RuntimeVersion = RuntimeVersion {
174 spec_name: alloc::borrow::Cow::Borrowed("westend"),
175 impl_name: alloc::borrow::Cow::Borrowed("parity-westend"),
176 authoring_version: 2,
177 spec_version: 1_018_012,
178 impl_version: 0,
179 apis: RUNTIME_API_VERSIONS,
180 transaction_version: 27,
181 system_version: 1,
182};
183
184pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
186 sp_consensus_babe::BabeEpochConfiguration {
187 c: PRIMARY_PROBABILITY,
188 allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots,
189 };
190
191#[cfg(any(feature = "std", test))]
193pub fn native_version() -> NativeVersion {
194 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
195}
196
197pub struct IsIdentityCall;
202impl Contains<RuntimeCall> for IsIdentityCall {
203 fn contains(c: &RuntimeCall) -> bool {
204 matches!(c, RuntimeCall::Identity(_))
205 }
206}
207
208parameter_types! {
209 pub const Version: RuntimeVersion = VERSION;
210 pub const SS58Prefix: u8 = 42;
211}
212
213#[derive_impl(frame_system::config_preludes::RelayChainDefaultConfig)]
214impl frame_system::Config for Runtime {
215 type BlockWeights = BlockWeights;
216 type BlockLength = BlockLength;
217 type Nonce = Nonce;
218 type Hash = Hash;
219 type AccountId = AccountId;
220 type Block = Block;
221 type BlockHashCount = BlockHashCount;
222 type DbWeight = RocksDbWeight;
223 type Version = Version;
224 type AccountData = pallet_balances::AccountData<Balance>;
225 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
226 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
227 type SS58Prefix = SS58Prefix;
228 type MaxConsumers = frame_support::traits::ConstU32<16>;
229 type MultiBlockMigrator = MultiBlockMigrations;
230}
231
232parameter_types! {
233 pub MaximumSchedulerWeight: frame_support::weights::Weight = Perbill::from_percent(80) *
234 BlockWeights::get().max_block;
235 pub const MaxScheduledPerBlock: u32 = 50;
236 pub const NoPreimagePostponement: Option<u32> = Some(10);
237}
238
239impl pallet_scheduler::Config for Runtime {
240 type RuntimeOrigin = RuntimeOrigin;
241 type RuntimeEvent = RuntimeEvent;
242 type PalletsOrigin = OriginCaller;
243 type RuntimeCall = RuntimeCall;
244 type MaximumWeight = MaximumSchedulerWeight;
245 type ScheduleOrigin = EitherOf<EnsureRoot<AccountId>, AuctionAdmin>;
248 type MaxScheduledPerBlock = MaxScheduledPerBlock;
249 type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
250 type OriginPrivilegeCmp = frame_support::traits::EqualPrivilegeOnly;
251 type Preimages = Preimage;
252 type BlockNumberProvider = System;
253}
254
255parameter_types! {
256 pub const PreimageBaseDeposit: Balance = deposit(2, 64);
257 pub const PreimageByteDeposit: Balance = deposit(0, 1);
258 pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
259}
260
261#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
263pub mod dynamic_params {
264 use super::*;
265
266 #[dynamic_pallet_params]
269 #[codec(index = 0)]
270 pub mod inflation {
271 #[codec(index = 0)]
273 pub static MinInflation: Perquintill = Perquintill::from_rational(25u64, 1000u64);
274
275 #[codec(index = 1)]
277 pub static MaxInflation: Perquintill = Perquintill::from_rational(10u64, 100u64);
278
279 #[codec(index = 2)]
281 pub static IdealStake: Perquintill = Perquintill::from_rational(50u64, 100u64);
282
283 #[codec(index = 3)]
285 pub static Falloff: Perquintill = Perquintill::from_rational(50u64, 1000u64);
286
287 #[codec(index = 4)]
290 pub static UseAuctionSlots: bool = false;
291 }
292}
293
294#[cfg(feature = "runtime-benchmarks")]
295impl Default for RuntimeParameters {
296 fn default() -> Self {
297 RuntimeParameters::Inflation(dynamic_params::inflation::Parameters::MinInflation(
298 dynamic_params::inflation::MinInflation,
299 Some(Perquintill::from_rational(25u64, 1000u64)),
300 ))
301 }
302}
303
304impl pallet_parameters::Config for Runtime {
305 type RuntimeEvent = RuntimeEvent;
306 type RuntimeParameters = RuntimeParameters;
307 type AdminOrigin = DynamicParameterOrigin;
308 type WeightInfo = weights::pallet_parameters::WeightInfo<Runtime>;
309}
310
311pub struct DynamicParameterOrigin;
313impl EnsureOriginWithArg<RuntimeOrigin, RuntimeParametersKey> for DynamicParameterOrigin {
314 type Success = ();
315
316 fn try_origin(
317 origin: RuntimeOrigin,
318 key: &RuntimeParametersKey,
319 ) -> Result<Self::Success, RuntimeOrigin> {
320 use crate::RuntimeParametersKey::*;
321
322 match key {
323 Inflation(_) => frame_system::ensure_root(origin.clone()),
324 }
325 .map_err(|_| origin)
326 }
327
328 #[cfg(feature = "runtime-benchmarks")]
329 fn try_successful_origin(_key: &RuntimeParametersKey) -> Result<RuntimeOrigin, ()> {
330 Ok(RuntimeOrigin::root())
332 }
333}
334
335impl pallet_preimage::Config for Runtime {
336 type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
337 type RuntimeEvent = RuntimeEvent;
338 type Currency = Balances;
339 type ManagerOrigin = EnsureRoot<AccountId>;
340 type Consideration = HoldConsideration<
341 AccountId,
342 Balances,
343 PreimageHoldReason,
344 LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
345 >;
346}
347
348parameter_types! {
349 pub const EpochDuration: u64 = prod_or_fast!(
350 EPOCH_DURATION_IN_SLOTS as u64,
351 2 * MINUTES as u64
352 );
353 pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
354 pub const ReportLongevity: u64 =
355 BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get();
356}
357
358impl pallet_babe::Config for Runtime {
359 type EpochDuration = EpochDuration;
360 type ExpectedBlockTime = ExpectedBlockTime;
361
362 type EpochChangeTrigger = pallet_babe::ExternalTrigger;
364
365 type DisabledValidators = Session;
366
367 type WeightInfo = ();
368
369 type MaxAuthorities = MaxAuthorities;
370 type MaxNominators = MaxNominators;
371
372 type KeyOwnerProof = sp_session::MembershipProof;
373
374 type EquivocationReportSystem =
375 pallet_babe::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
376}
377
378parameter_types! {
379 pub const IndexDeposit: Balance = 100 * CENTS;
380}
381
382impl pallet_indices::Config for Runtime {
383 type AccountIndex = AccountIndex;
384 type Currency = Balances;
385 type Deposit = IndexDeposit;
386 type RuntimeEvent = RuntimeEvent;
387 type WeightInfo = weights::pallet_indices::WeightInfo<Runtime>;
388}
389
390parameter_types! {
391 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
392 pub const MaxLocks: u32 = 50;
393 pub const MaxReserves: u32 = 50;
394}
395
396impl pallet_balances::Config for Runtime {
397 type Balance = Balance;
398 type DustRemoval = ();
399 type RuntimeEvent = RuntimeEvent;
400 type ExistentialDeposit = ExistentialDeposit;
401 type AccountStore = System;
402 type MaxLocks = MaxLocks;
403 type MaxReserves = MaxReserves;
404 type ReserveIdentifier = [u8; 8];
405 type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
406 type RuntimeHoldReason = RuntimeHoldReason;
407 type RuntimeFreezeReason = RuntimeFreezeReason;
408 type FreezeIdentifier = RuntimeFreezeReason;
409 type MaxFreezes = VariantCountOf<RuntimeFreezeReason>;
410 type DoneSlashHandler = ();
411}
412
413parameter_types! {
414 pub const BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
415}
416
417impl pallet_beefy::Config for Runtime {
418 type BeefyId = BeefyId;
419 type MaxAuthorities = MaxAuthorities;
420 type MaxNominators = MaxNominators;
421 type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
422 type OnNewValidatorSet = BeefyMmrLeaf;
423 type AncestryHelper = BeefyMmrLeaf;
424 type WeightInfo = ();
425 type KeyOwnerProof = sp_session::MembershipProof;
426 type EquivocationReportSystem =
427 pallet_beefy::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
428}
429
430impl pallet_mmr::Config for Runtime {
431 const INDEXING_PREFIX: &'static [u8] = mmr::INDEXING_PREFIX;
432 type Hashing = Keccak256;
433 type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
434 type LeafData = pallet_beefy_mmr::Pallet<Runtime>;
435 type BlockHashProvider = pallet_mmr::DefaultBlockHashProvider<Runtime>;
436 type WeightInfo = weights::pallet_mmr::WeightInfo<Runtime>;
437 #[cfg(feature = "runtime-benchmarks")]
438 type BenchmarkHelper = parachains_paras::benchmarking::mmr_setup::MmrSetup<Runtime>;
439}
440
441mod mmr {
443 use super::Runtime;
444 pub use pallet_mmr::primitives::*;
445
446 pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
447 pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
448 pub type Hash = <Hashing as sp_runtime::traits::Hash>::Output;
449}
450
451parameter_types! {
452 pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0);
453}
454
455pub struct ParaHeadsRootProvider;
458impl BeefyDataProvider<H256> for ParaHeadsRootProvider {
459 fn extra_data() -> H256 {
460 let para_heads: Vec<(u32, Vec<u8>)> =
461 parachains_paras::Pallet::<Runtime>::sorted_para_heads();
462 binary_merkle_tree::merkle_root::<mmr::Hashing, _>(
463 para_heads.into_iter().map(|pair| pair.encode()),
464 )
465 .into()
466 }
467}
468
469impl pallet_beefy_mmr::Config for Runtime {
470 type LeafVersion = LeafVersion;
471 type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum;
472 type LeafExtra = H256;
473 type BeefyDataProvider = ParaHeadsRootProvider;
474 type WeightInfo = weights::pallet_beefy_mmr::WeightInfo<Runtime>;
475}
476
477parameter_types! {
478 pub const TransactionByteFee: Balance = 10 * MILLICENTS;
479 pub const OperationalFeeMultiplier: u8 = 5;
482}
483
484impl pallet_transaction_payment::Config for Runtime {
485 type RuntimeEvent = RuntimeEvent;
486 type OnChargeTransaction = FungibleAdapter<Balances, ToAuthor<Runtime>>;
487 type OperationalFeeMultiplier = OperationalFeeMultiplier;
488 type WeightToFee = WeightToFee;
489 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
490 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
491 type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
492}
493
494parameter_types! {
495 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
496}
497impl pallet_timestamp::Config for Runtime {
498 type Moment = u64;
499 type OnTimestampSet = Babe;
500 type MinimumPeriod = MinimumPeriod;
501 type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
502}
503
504impl pallet_authorship::Config for Runtime {
505 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
506 type EventHandler = StakingAhClient;
507}
508
509parameter_types! {
510 pub const Period: BlockNumber = 10 * MINUTES;
511 pub const Offset: BlockNumber = 0;
512}
513
514impl_opaque_keys! {
515 pub struct SessionKeys {
516 pub grandpa: Grandpa,
517 pub babe: Babe,
518 pub para_validator: Initializer,
519 pub para_assignment: ParaSessionInfo,
520 pub authority_discovery: AuthorityDiscovery,
521 pub beefy: Beefy,
522 }
523}
524
525impl pallet_session::Config for Runtime {
526 type RuntimeEvent = RuntimeEvent;
527 type ValidatorId = AccountId;
528 type ValidatorIdOf = ConvertInto;
529 type ShouldEndSession = Babe;
530 type NextSessionRotation = Babe;
531 type SessionManager = session_historical::NoteHistoricalRoot<Self, StakingAhClient>;
532 type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
533 type Keys = SessionKeys;
534 type DisablingStrategy = pallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy;
535 type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
536 type Currency = Balances;
537 type KeyDeposit = ();
538}
539
540impl pallet_session::historical::Config for Runtime {
541 type RuntimeEvent = RuntimeEvent;
542 type FullIdentification = sp_staking::Exposure<AccountId, Balance>;
543 type FullIdentificationOf = pallet_staking::DefaultExposureOf<Self>;
544}
545
546pub struct MaybeSignedPhase;
547
548impl Get<u32> for MaybeSignedPhase {
549 fn get() -> u32 {
550 if pallet_staking::CurrentEra::<Runtime>::get().unwrap_or(1) % 28 == 0 {
553 0
554 } else {
555 SignedPhase::get()
556 }
557 }
558}
559
560parameter_types! {
561 pub SignedPhase: u32 = prod_or_fast!(
563 EPOCH_DURATION_IN_SLOTS / 4,
564 (1 * MINUTES).min(EpochDuration::get().saturated_into::<u32>() / 2)
565 );
566 pub UnsignedPhase: u32 = prod_or_fast!(
567 EPOCH_DURATION_IN_SLOTS / 4,
568 (1 * MINUTES).min(EpochDuration::get().saturated_into::<u32>() / 2)
569 );
570
571 pub const SignedMaxSubmissions: u32 = 128;
573 pub const SignedMaxRefunds: u32 = 128 / 4;
574 pub const SignedFixedDeposit: Balance = deposit(2, 0);
575 pub const SignedDepositIncreaseFactor: Percent = Percent::from_percent(10);
576 pub const SignedDepositByte: Balance = deposit(0, 10) / 1024;
577 pub SignedRewardBase: Balance = 1 * UNITS;
579
580 pub OffchainRepeat: BlockNumber = UnsignedPhase::get() / 4;
582
583 pub const MaxElectingVoters: u32 = 22_500;
584 pub ElectionBounds: frame_election_provider_support::bounds::ElectionBounds =
588 ElectionBoundsBuilder::default().voters_count(MaxElectingVoters::get().into()).build();
589 pub const MaxActiveValidators: u32 = 1000;
591 pub const MaxWinnersPerPage: u32 = MaxActiveValidators::get();
593 pub const MaxBackersPerWinner: u32 = MaxElectingVoters::get();
595}
596
597frame_election_provider_support::generate_solution_type!(
598 #[compact]
599 pub struct NposCompactSolution16::<
600 VoterIndex = u32,
601 TargetIndex = u16,
602 Accuracy = sp_runtime::PerU16,
603 MaxVoters = MaxElectingVoters,
604 >(16)
605);
606
607pub struct OnChainSeqPhragmen;
608impl onchain::Config for OnChainSeqPhragmen {
609 type Sort = ConstBool<true>;
610 type System = Runtime;
611 type Solver = SequentialPhragmen<AccountId, OnChainAccuracy>;
612 type DataProvider = Staking;
613 type WeightInfo = weights::frame_election_provider_support::WeightInfo<Runtime>;
614 type Bounds = ElectionBounds;
615 type MaxBackersPerWinner = MaxBackersPerWinner;
616 type MaxWinnersPerPage = MaxWinnersPerPage;
617}
618
619impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
620 type AccountId = AccountId;
621 type MaxLength = OffchainSolutionLengthLimit;
622 type MaxWeight = OffchainSolutionWeightLimit;
623 type Solution = NposCompactSolution16;
624 type MaxVotesPerVoter = <
625 <Self as pallet_election_provider_multi_phase::Config>::DataProvider
626 as
627 frame_election_provider_support::ElectionDataProvider
628 >::MaxVotesPerVoter;
629 type MaxBackersPerWinner = MaxBackersPerWinner;
630 type MaxWinners = MaxWinnersPerPage;
631
632 fn solution_weight(v: u32, t: u32, a: u32, d: u32) -> Weight {
635 <
636 <Self as pallet_election_provider_multi_phase::Config>::WeightInfo
637 as
638 pallet_election_provider_multi_phase::WeightInfo
639 >::submit_unsigned(v, t, a, d)
640 }
641}
642
643impl pallet_election_provider_multi_phase::Config for Runtime {
644 type RuntimeEvent = RuntimeEvent;
645 type Currency = Balances;
646 type EstimateCallFee = TransactionPayment;
647 type SignedPhase = MaybeSignedPhase;
648 type UnsignedPhase = UnsignedPhase;
649 type SignedMaxSubmissions = SignedMaxSubmissions;
650 type SignedMaxRefunds = SignedMaxRefunds;
651 type SignedRewardBase = SignedRewardBase;
652 type SignedDepositBase =
653 GeometricDepositBase<Balance, SignedFixedDeposit, SignedDepositIncreaseFactor>;
654 type SignedDepositByte = SignedDepositByte;
655 type SignedDepositWeight = ();
656 type SignedMaxWeight =
657 <Self::MinerConfig as pallet_election_provider_multi_phase::MinerConfig>::MaxWeight;
658 type MinerConfig = Self;
659 type SlashHandler = (); type RewardHandler = (); type BetterSignedThreshold = ();
662 type OffchainRepeat = OffchainRepeat;
663 type MinerTxPriority = NposSolutionPriority;
664 type MaxWinners = MaxWinnersPerPage;
665 type MaxBackersPerWinner = MaxBackersPerWinner;
666 type DataProvider = Staking;
667 #[cfg(any(feature = "fast-runtime", feature = "runtime-benchmarks"))]
668 type Fallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
669 #[cfg(not(any(feature = "fast-runtime", feature = "runtime-benchmarks")))]
670 type Fallback = frame_election_provider_support::NoElection<(
671 AccountId,
672 BlockNumber,
673 Staking,
674 MaxWinnersPerPage,
675 MaxBackersPerWinner,
676 )>;
677 type GovernanceFallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
678 type Solver = SequentialPhragmen<
679 AccountId,
680 pallet_election_provider_multi_phase::SolutionAccuracyOf<Self>,
681 (),
682 >;
683 type BenchmarkingConfig = polkadot_runtime_common::elections::BenchmarkConfig;
684 type ForceOrigin = EnsureRoot<AccountId>;
685 type WeightInfo = weights::pallet_election_provider_multi_phase::WeightInfo<Self>;
686 type ElectionBounds = ElectionBounds;
687}
688
689parameter_types! {
690 pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS;
691 pub const AutoRebagNumber: u32 = 10;
692}
693
694type VoterBagsListInstance = pallet_bags_list::Instance1;
695impl pallet_bags_list::Config<VoterBagsListInstance> for Runtime {
696 type RuntimeEvent = RuntimeEvent;
697 type WeightInfo = weights::pallet_bags_list::WeightInfo<Runtime>;
698 type ScoreProvider = Staking;
699 type BagThresholds = BagThresholds;
700 type MaxAutoRebagPerBlock = AutoRebagNumber;
701 type Score = sp_npos_elections::VoteWeight;
702}
703
704pub struct EraPayout;
705impl pallet_staking::EraPayout<Balance> for EraPayout {
706 fn era_payout(
707 _total_staked: Balance,
708 _total_issuance: Balance,
709 era_duration_millis: u64,
710 ) -> (Balance, Balance) {
711 const MILLISECONDS_PER_YEAR: u64 = (1000 * 3600 * 24 * 36525) / 100;
712 let relative_era_len =
714 FixedU128::from_rational(era_duration_millis.into(), MILLISECONDS_PER_YEAR.into());
715
716 let fixed_total_issuance: i128 = 5_216_342_402_773_185_773;
718 let fixed_inflation_rate = FixedU128::from_rational(8, 100);
719 let yearly_emission = fixed_inflation_rate.saturating_mul_int(fixed_total_issuance);
720
721 let era_emission = relative_era_len.saturating_mul_int(yearly_emission);
722 let to_treasury = FixedU128::from_rational(15, 100).saturating_mul_int(era_emission);
724 let to_stakers = era_emission.saturating_sub(to_treasury);
725
726 (to_stakers.saturated_into(), to_treasury.saturated_into())
727 }
728}
729
730parameter_types! {
731 pub const SessionsPerEra: SessionIndex = prod_or_fast!(6, 2);
733 pub const BondingDuration: EraIndex = 2;
735 pub const SlashDeferDuration: EraIndex = 1;
737 pub const MaxExposurePageSize: u32 = 64;
738 pub const MaxNominators: u32 = 64;
742 pub const MaxNominations: u32 = <NposCompactSolution16 as frame_election_provider_support::NposSolution>::LIMIT as u32;
743 pub const MaxControllersInDeprecationBatch: u32 = 751;
744}
745
746impl pallet_staking::Config for Runtime {
747 type OldCurrency = Balances;
748 type Currency = Balances;
749 type CurrencyBalance = Balance;
750 type RuntimeHoldReason = RuntimeHoldReason;
751 type UnixTime = Timestamp;
752 type CurrencyToVote = sp_staking::currency_to_vote::SaturatingCurrencyToVote;
754 type RewardRemainder = ();
755 type RuntimeEvent = RuntimeEvent;
756 type Slash = ();
757 type Reward = ();
758 type SessionsPerEra = SessionsPerEra;
759 type BondingDuration = BondingDuration;
760 type SlashDeferDuration = SlashDeferDuration;
761 type AdminOrigin = EitherOf<EnsureRoot<AccountId>, StakingAdmin>;
762 type SessionInterface = Self;
763 type EraPayout = EraPayout;
764 type MaxExposurePageSize = MaxExposurePageSize;
765 type NextNewSession = Session;
766 type ElectionProvider = ElectionProviderMultiPhase;
767 type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
768 type VoterList = VoterList;
769 type TargetList = UseValidatorsMap<Self>;
770 type MaxValidatorSet = MaxActiveValidators;
771 type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>;
772 type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
773 type HistoryDepth = frame_support::traits::ConstU32<84>;
774 type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
775 type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig;
776 type EventListeners = (NominationPools, DelegatedStaking);
777 type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
778 #[cfg(not(feature = "on-chain-release-build"))]
780 type Filter = Nothing;
781 #[cfg(feature = "on-chain-release-build")]
782 type Filter = frame_support::traits::Everything;
783}
784
785#[derive(Encode, Decode)]
786enum AssetHubRuntimePallets<AccountId> {
787 #[codec(index = 89)]
789 RcClient(RcClientCalls<AccountId>),
790}
791
792#[derive(Encode, Decode)]
793enum RcClientCalls<AccountId> {
794 #[codec(index = 0)]
795 RelaySessionReport(rc_client::SessionReport<AccountId>),
796 #[codec(index = 1)]
797 RelayNewOffencePaged(Vec<(SessionIndex, rc_client::Offence<AccountId>)>),
798}
799
800pub struct AssetHubLocation;
801impl Get<Location> for AssetHubLocation {
802 fn get() -> Location {
803 Location::new(0, [Junction::Parachain(ASSET_HUB_ID)])
804 }
805}
806
807pub struct EnsureAssetHub;
808impl frame_support::traits::EnsureOrigin<RuntimeOrigin> for EnsureAssetHub {
809 type Success = ();
810 fn try_origin(o: RuntimeOrigin) -> Result<Self::Success, RuntimeOrigin> {
811 match <RuntimeOrigin as Into<Result<parachains_origin::Origin, RuntimeOrigin>>>::into(
812 o.clone(),
813 ) {
814 Ok(parachains_origin::Origin::Parachain(id)) if id == ASSET_HUB_ID.into() => Ok(()),
815 _ => Err(o),
816 }
817 }
818
819 #[cfg(feature = "runtime-benchmarks")]
820 fn try_successful_origin() -> Result<RuntimeOrigin, ()> {
821 Ok(RuntimeOrigin::root())
822 }
823}
824
825pub struct SessionReportToXcm;
826impl sp_runtime::traits::Convert<rc_client::SessionReport<AccountId>, Xcm<()>>
827 for SessionReportToXcm
828{
829 fn convert(a: rc_client::SessionReport<AccountId>) -> Xcm<()> {
830 Xcm(vec![
831 Instruction::UnpaidExecution {
832 weight_limit: WeightLimit::Unlimited,
833 check_origin: None,
834 },
835 Instruction::Transact {
836 origin_kind: OriginKind::Superuser,
837 fallback_max_weight: None,
838 call: AssetHubRuntimePallets::RcClient(RcClientCalls::RelaySessionReport(a))
839 .encode()
840 .into(),
841 },
842 ])
843 }
844}
845
846pub struct QueuedOffenceToXcm;
847impl sp_runtime::traits::Convert<Vec<ah_client::QueuedOffenceOf<Runtime>>, Xcm<()>>
848 for QueuedOffenceToXcm
849{
850 fn convert(offences: Vec<ah_client::QueuedOffenceOf<Runtime>>) -> Xcm<()> {
851 Xcm(vec![
852 Instruction::UnpaidExecution {
853 weight_limit: WeightLimit::Unlimited,
854 check_origin: None,
855 },
856 Instruction::Transact {
857 origin_kind: OriginKind::Superuser,
858 fallback_max_weight: None,
859 call: AssetHubRuntimePallets::RcClient(RcClientCalls::RelayNewOffencePaged(
860 offences,
861 ))
862 .encode()
863 .into(),
864 },
865 ])
866 }
867}
868
869pub struct StakingXcmToAssetHub;
870impl ah_client::SendToAssetHub for StakingXcmToAssetHub {
871 type AccountId = AccountId;
872
873 fn relay_session_report(
874 session_report: rc_client::SessionReport<Self::AccountId>,
875 ) -> Result<(), ()> {
876 rc_client::XCMSender::<
877 xcm_config::XcmRouter,
878 AssetHubLocation,
879 rc_client::SessionReport<AccountId>,
880 SessionReportToXcm,
881 >::send(session_report)
882 }
883
884 fn relay_new_offence_paged(
885 offences: Vec<ah_client::QueuedOffenceOf<Runtime>>,
886 ) -> Result<(), ()> {
887 rc_client::XCMSender::<
888 xcm_config::XcmRouter,
889 AssetHubLocation,
890 Vec<ah_client::QueuedOffenceOf<Runtime>>,
891 QueuedOffenceToXcm,
892 >::send(offences)
893 }
894}
895
896impl ah_client::Config for Runtime {
897 type CurrencyBalance = Balance;
898 type AssetHubOrigin =
899 frame_support::traits::EitherOfDiverse<EnsureRoot<AccountId>, EnsureAssetHub>;
900 type AdminOrigin = EnsureRoot<AccountId>;
901 type SessionInterface = Self;
902 type SendToAssetHub = StakingXcmToAssetHub;
903 type MinimumValidatorSetSize = ConstU32<1>;
904 type UnixTime = Timestamp;
905 type PointsPerBlock = ConstU32<20>;
906 type MaxOffenceBatchSize = ConstU32<50>;
907 type Fallback = Staking;
908 type MaximumValidatorsWithPoints = ConstU32<{ MaxActiveValidators::get() * 4 }>;
909 type MaxSessionReportRetries = ConstU32<5>;
910}
911
912impl pallet_fast_unstake::Config for Runtime {
913 type RuntimeEvent = RuntimeEvent;
914 type Currency = Balances;
915 type BatchSize = frame_support::traits::ConstU32<64>;
916 type Deposit = frame_support::traits::ConstU128<{ UNITS }>;
917 type ControlOrigin = EnsureRoot<AccountId>;
918 type Staking = Staking;
919 type MaxErasToCheckPerBlock = ConstU32<1>;
920 type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
921}
922
923parameter_types! {
924 pub const SpendPeriod: BlockNumber = 6 * DAYS;
925 pub const Burn: Permill = Permill::from_perthousand(2);
926 pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
927 pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
928 pub TreasuryInteriorLocation: InteriorLocation = PalletInstance(37).into();
931
932 pub const TipCountdown: BlockNumber = 1 * DAYS;
933 pub const TipFindersFee: Percent = Percent::from_percent(20);
934 pub const TipReportDepositBase: Balance = 100 * CENTS;
935 pub const DataDepositPerByte: Balance = 1 * CENTS;
936 pub const MaxApprovals: u32 = 100;
937 pub const MaxAuthorities: u32 = 100_000;
938 pub const MaxKeys: u32 = 10_000;
939 pub const MaxPeerInHeartbeats: u32 = 10_000;
940 pub const MaxBalance: Balance = Balance::max_value();
941}
942
943impl pallet_treasury::Config for Runtime {
944 type PalletId = TreasuryPalletId;
945 type Currency = Balances;
946 type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
947 type RuntimeEvent = RuntimeEvent;
948 type SpendPeriod = SpendPeriod;
949 type Burn = Burn;
950 type BurnDestination = ();
951 type MaxApprovals = MaxApprovals;
952 type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
953 type SpendFunds = ();
954 type SpendOrigin = TreasurySpender;
955 type AssetKind = VersionedLocatableAsset;
956 type Beneficiary = VersionedLocation;
957 type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
958 type Paymaster = PayOverXcm<
959 TreasuryInteriorLocation,
960 crate::xcm_config::XcmRouter,
961 crate::XcmPallet,
962 ConstU32<{ 6 * HOURS }>,
963 Self::Beneficiary,
964 Self::AssetKind,
965 LocatableAssetConverter,
966 VersionedLocationConverter,
967 >;
968 type BalanceConverter = UnityOrOuterConversion<
969 ContainsParts<
970 FromContains<
971 xcm_builder::IsChildSystemParachain<ParaId>,
972 xcm_builder::IsParentsOnly<ConstU8<1>>,
973 >,
974 >,
975 AssetRate,
976 >;
977 type PayoutPeriod = PayoutSpendPeriod;
978 type BlockNumberProvider = System;
979 #[cfg(feature = "runtime-benchmarks")]
980 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments;
981}
982
983impl pallet_offences::Config for Runtime {
984 type RuntimeEvent = RuntimeEvent;
985 type IdentificationTuple = session_historical::IdentificationTuple<Self>;
986 type OnOffenceHandler = StakingAhClient;
987}
988
989impl pallet_authority_discovery::Config for Runtime {
990 type MaxAuthorities = MaxAuthorities;
991}
992
993parameter_types! {
994 pub const NposSolutionPriority: TransactionPriority = TransactionPriority::max_value() / 2;
995}
996
997parameter_types! {
998 pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
999}
1000
1001impl pallet_grandpa::Config for Runtime {
1002 type RuntimeEvent = RuntimeEvent;
1003
1004 type WeightInfo = ();
1005 type MaxAuthorities = MaxAuthorities;
1006 type MaxNominators = MaxNominators;
1007 type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
1008
1009 type KeyOwnerProof = sp_session::MembershipProof;
1010
1011 type EquivocationReportSystem =
1012 pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
1013}
1014
1015impl frame_system::offchain::SigningTypes for Runtime {
1016 type Public = <Signature as Verify>::Signer;
1017 type Signature = Signature;
1018}
1019
1020impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
1021where
1022 RuntimeCall: From<C>,
1023{
1024 type RuntimeCall = RuntimeCall;
1025 type Extrinsic = UncheckedExtrinsic;
1026}
1027
1028impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
1029where
1030 RuntimeCall: From<LocalCall>,
1031{
1032 type Extension = TxExtension;
1033
1034 fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
1035 UncheckedExtrinsic::new_transaction(call, extension)
1036 }
1037}
1038
1039impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
1042where
1043 RuntimeCall: From<LocalCall>,
1044{
1045 fn create_signed_transaction<
1046 C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
1047 >(
1048 call: RuntimeCall,
1049 public: <Signature as Verify>::Signer,
1050 account: AccountId,
1051 nonce: <Runtime as frame_system::Config>::Nonce,
1052 ) -> Option<UncheckedExtrinsic> {
1053 use sp_runtime::traits::StaticLookup;
1054 let period =
1056 BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
1057
1058 let current_block = System::block_number()
1059 .saturated_into::<u64>()
1060 .saturating_sub(1);
1063 let tip = 0;
1064 let tx_ext: TxExtension = (
1065 frame_system::AuthorizeCall::<Runtime>::new(),
1066 frame_system::CheckNonZeroSender::<Runtime>::new(),
1067 frame_system::CheckSpecVersion::<Runtime>::new(),
1068 frame_system::CheckTxVersion::<Runtime>::new(),
1069 frame_system::CheckGenesis::<Runtime>::new(),
1070 frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(
1071 period,
1072 current_block,
1073 )),
1074 frame_system::CheckNonce::<Runtime>::from(nonce),
1075 frame_system::CheckWeight::<Runtime>::new(),
1076 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
1077 frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(true),
1078 frame_system::WeightReclaim::<Runtime>::new(),
1079 )
1080 .into();
1081 let raw_payload = SignedPayload::new(call, tx_ext)
1082 .map_err(|e| {
1083 log::warn!("Unable to create signed payload: {:?}", e);
1084 })
1085 .ok()?;
1086 let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
1087 let (call, tx_ext, _) = raw_payload.deconstruct();
1088 let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
1089 let transaction = UncheckedExtrinsic::new_signed(call, address, signature, tx_ext);
1090 Some(transaction)
1091 }
1092}
1093
1094impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
1095where
1096 RuntimeCall: From<LocalCall>,
1097{
1098 fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
1099 UncheckedExtrinsic::new_bare(call)
1100 }
1101}
1102
1103impl<LocalCall> frame_system::offchain::CreateAuthorizedTransaction<LocalCall> for Runtime
1104where
1105 RuntimeCall: From<LocalCall>,
1106{
1107 fn create_extension() -> Self::Extension {
1108 (
1109 frame_system::AuthorizeCall::<Runtime>::new(),
1110 frame_system::CheckNonZeroSender::<Runtime>::new(),
1111 frame_system::CheckSpecVersion::<Runtime>::new(),
1112 frame_system::CheckTxVersion::<Runtime>::new(),
1113 frame_system::CheckGenesis::<Runtime>::new(),
1114 frame_system::CheckMortality::<Runtime>::from(generic::Era::Immortal),
1115 frame_system::CheckNonce::<Runtime>::from(0),
1116 frame_system::CheckWeight::<Runtime>::new(),
1117 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
1118 frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
1119 frame_system::WeightReclaim::<Runtime>::new(),
1120 )
1121 }
1122}
1123
1124parameter_types! {
1125 pub const BasicDeposit: Balance = 1000 * CENTS; pub const ByteDeposit: Balance = deposit(0, 1);
1128 pub const UsernameDeposit: Balance = deposit(0, 32);
1129 pub const SubAccountDeposit: Balance = 200 * CENTS; pub const MaxSubAccounts: u32 = 100;
1131 pub const MaxAdditionalFields: u32 = 100;
1132 pub const MaxRegistrars: u32 = 20;
1133}
1134
1135impl pallet_identity::Config for Runtime {
1136 type RuntimeEvent = RuntimeEvent;
1137 type Currency = Balances;
1138 type Slashed = ();
1139 type BasicDeposit = BasicDeposit;
1140 type ByteDeposit = ByteDeposit;
1141 type UsernameDeposit = UsernameDeposit;
1142 type SubAccountDeposit = SubAccountDeposit;
1143 type MaxSubAccounts = MaxSubAccounts;
1144 type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
1145 type MaxRegistrars = MaxRegistrars;
1146 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
1147 type RegistrarOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
1148 type OffchainSignature = Signature;
1149 type SigningPublicKey = <Signature as Verify>::Signer;
1150 type UsernameAuthorityOrigin = EnsureRoot<Self::AccountId>;
1151 type PendingUsernameExpiration = ConstU32<{ 7 * DAYS }>;
1152 type UsernameGracePeriod = ConstU32<{ 30 * DAYS }>;
1153 type MaxSuffixLength = ConstU32<7>;
1154 type MaxUsernameLength = ConstU32<32>;
1155 #[cfg(feature = "runtime-benchmarks")]
1156 type BenchmarkHelper = ();
1157 type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
1158}
1159
1160impl pallet_utility::Config for Runtime {
1161 type RuntimeEvent = RuntimeEvent;
1162 type RuntimeCall = RuntimeCall;
1163 type PalletsOrigin = OriginCaller;
1164 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
1165}
1166
1167parameter_types! {
1168 pub const DepositBase: Balance = deposit(1, 88);
1170 pub const DepositFactor: Balance = deposit(0, 32);
1172 pub const MaxSignatories: u32 = 100;
1173}
1174
1175impl pallet_multisig::Config for Runtime {
1176 type RuntimeEvent = RuntimeEvent;
1177 type RuntimeCall = RuntimeCall;
1178 type Currency = Balances;
1179 type DepositBase = DepositBase;
1180 type DepositFactor = DepositFactor;
1181 type MaxSignatories = MaxSignatories;
1182 type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
1183 type BlockNumberProvider = frame_system::Pallet<Runtime>;
1184}
1185
1186parameter_types! {
1187 pub const ConfigDepositBase: Balance = 500 * CENTS;
1188 pub const FriendDepositFactor: Balance = 50 * CENTS;
1189 pub const MaxFriends: u16 = 9;
1190 pub const RecoveryDeposit: Balance = 500 * CENTS;
1191}
1192
1193impl pallet_recovery::Config for Runtime {
1194 type RuntimeEvent = RuntimeEvent;
1195 type WeightInfo = ();
1196 type RuntimeCall = RuntimeCall;
1197 type BlockNumberProvider = System;
1198 type Currency = Balances;
1199 type ConfigDepositBase = ConfigDepositBase;
1200 type FriendDepositFactor = FriendDepositFactor;
1201 type MaxFriends = MaxFriends;
1202 type RecoveryDeposit = RecoveryDeposit;
1203}
1204
1205parameter_types! {
1206 pub const MinVestedTransfer: Balance = 100 * CENTS;
1207 pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
1208 WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
1209}
1210
1211impl pallet_vesting::Config for Runtime {
1212 type RuntimeEvent = RuntimeEvent;
1213 type Currency = Balances;
1214 type BlockNumberToBalance = ConvertInto;
1215 type MinVestedTransfer = MinVestedTransfer;
1216 type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
1217 type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
1218 type BlockNumberProvider = System;
1219 const MAX_VESTING_SCHEDULES: u32 = 28;
1220}
1221
1222impl pallet_sudo::Config for Runtime {
1223 type RuntimeEvent = RuntimeEvent;
1224 type RuntimeCall = RuntimeCall;
1225 type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
1226}
1227
1228parameter_types! {
1229 pub const ProxyDepositBase: Balance = deposit(1, 8);
1231 pub const ProxyDepositFactor: Balance = deposit(0, 33);
1233 pub const MaxProxies: u16 = 32;
1234 pub const AnnouncementDepositBase: Balance = deposit(1, 8);
1235 pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
1236 pub const MaxPending: u16 = 32;
1237}
1238
1239#[derive(
1241 Copy,
1242 Clone,
1243 Eq,
1244 PartialEq,
1245 Ord,
1246 PartialOrd,
1247 Encode,
1248 Decode,
1249 DecodeWithMemTracking,
1250 RuntimeDebug,
1251 MaxEncodedLen,
1252 TypeInfo,
1253)]
1254pub enum ProxyType {
1255 Any,
1256 NonTransfer,
1257 Governance,
1258 Staking,
1259 SudoBalances,
1260 IdentityJudgement,
1261 CancelProxy,
1262 Auction,
1263 NominationPools,
1264 ParaRegistration,
1265}
1266impl Default for ProxyType {
1267 fn default() -> Self {
1268 Self::Any
1269 }
1270}
1271impl InstanceFilter<RuntimeCall> for ProxyType {
1272 fn filter(&self, c: &RuntimeCall) -> bool {
1273 match self {
1274 ProxyType::Any => true,
1275 ProxyType::NonTransfer => matches!(
1276 c,
1277 RuntimeCall::System(..) |
1278 RuntimeCall::Babe(..) |
1279 RuntimeCall::Timestamp(..) |
1280 RuntimeCall::Indices(pallet_indices::Call::claim{..}) |
1281 RuntimeCall::Indices(pallet_indices::Call::free{..}) |
1282 RuntimeCall::Indices(pallet_indices::Call::freeze{..}) |
1283 RuntimeCall::Staking(..) |
1286 RuntimeCall::Session(..) |
1287 RuntimeCall::Grandpa(..) |
1288 RuntimeCall::Utility(..) |
1289 RuntimeCall::Identity(..) |
1290 RuntimeCall::ConvictionVoting(..) |
1291 RuntimeCall::Referenda(..) |
1292 RuntimeCall::Whitelist(..) |
1293 RuntimeCall::Recovery(pallet_recovery::Call::as_recovered{..}) |
1294 RuntimeCall::Recovery(pallet_recovery::Call::vouch_recovery{..}) |
1295 RuntimeCall::Recovery(pallet_recovery::Call::claim_recovery{..}) |
1296 RuntimeCall::Recovery(pallet_recovery::Call::close_recovery{..}) |
1297 RuntimeCall::Recovery(pallet_recovery::Call::remove_recovery{..}) |
1298 RuntimeCall::Recovery(pallet_recovery::Call::cancel_recovered{..}) |
1299 RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) |
1301 RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) |
1302 RuntimeCall::Scheduler(..) |
1304 RuntimeCall::Proxy(..) |
1306 RuntimeCall::Multisig(..) |
1307 RuntimeCall::Registrar(paras_registrar::Call::register{..}) |
1308 RuntimeCall::Registrar(paras_registrar::Call::deregister{..}) |
1309 RuntimeCall::Registrar(paras_registrar::Call::reserve{..}) |
1311 RuntimeCall::Crowdloan(..) |
1312 RuntimeCall::Slots(..) |
1313 RuntimeCall::Auctions(..) | RuntimeCall::VoterList(..) |
1315 RuntimeCall::NominationPools(..) |
1316 RuntimeCall::FastUnstake(..)
1317 ),
1318 ProxyType::Staking => {
1319 matches!(
1320 c,
1321 RuntimeCall::Staking(..) |
1322 RuntimeCall::Session(..) |
1323 RuntimeCall::Utility(..) |
1324 RuntimeCall::FastUnstake(..) |
1325 RuntimeCall::VoterList(..) |
1326 RuntimeCall::NominationPools(..)
1327 )
1328 },
1329 ProxyType::NominationPools => {
1330 matches!(c, RuntimeCall::NominationPools(..) | RuntimeCall::Utility(..))
1331 },
1332 ProxyType::SudoBalances => match c {
1333 RuntimeCall::Sudo(pallet_sudo::Call::sudo { call: ref x }) => {
1334 matches!(x.as_ref(), &RuntimeCall::Balances(..))
1335 },
1336 RuntimeCall::Utility(..) => true,
1337 _ => false,
1338 },
1339 ProxyType::Governance => matches!(
1340 c,
1341 RuntimeCall::ConvictionVoting(..) |
1343 RuntimeCall::Referenda(..) |
1344 RuntimeCall::Whitelist(..)
1345 ),
1346 ProxyType::IdentityJudgement => matches!(
1347 c,
1348 RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
1349 RuntimeCall::Utility(..)
1350 ),
1351 ProxyType::CancelProxy => {
1352 matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }))
1353 },
1354 ProxyType::Auction => matches!(
1355 c,
1356 RuntimeCall::Auctions(..) |
1357 RuntimeCall::Crowdloan(..) |
1358 RuntimeCall::Registrar(..) |
1359 RuntimeCall::Slots(..)
1360 ),
1361 ProxyType::ParaRegistration => matches!(
1362 c,
1363 RuntimeCall::Registrar(paras_registrar::Call::reserve { .. }) |
1364 RuntimeCall::Registrar(paras_registrar::Call::register { .. }) |
1365 RuntimeCall::Utility(pallet_utility::Call::batch { .. }) |
1366 RuntimeCall::Utility(pallet_utility::Call::batch_all { .. }) |
1367 RuntimeCall::Utility(pallet_utility::Call::force_batch { .. }) |
1368 RuntimeCall::Proxy(pallet_proxy::Call::remove_proxy { .. })
1369 ),
1370 }
1371 }
1372 fn is_superset(&self, o: &Self) -> bool {
1373 match (self, o) {
1374 (x, y) if x == y => true,
1375 (ProxyType::Any, _) => true,
1376 (_, ProxyType::Any) => false,
1377 (ProxyType::NonTransfer, _) => true,
1378 _ => false,
1379 }
1380 }
1381}
1382
1383impl pallet_proxy::Config for Runtime {
1384 type RuntimeEvent = RuntimeEvent;
1385 type RuntimeCall = RuntimeCall;
1386 type Currency = Balances;
1387 type ProxyType = ProxyType;
1388 type ProxyDepositBase = ProxyDepositBase;
1389 type ProxyDepositFactor = ProxyDepositFactor;
1390 type MaxProxies = MaxProxies;
1391 type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
1392 type MaxPending = MaxPending;
1393 type CallHasher = BlakeTwo256;
1394 type AnnouncementDepositBase = AnnouncementDepositBase;
1395 type AnnouncementDepositFactor = AnnouncementDepositFactor;
1396 type BlockNumberProvider = frame_system::Pallet<Runtime>;
1397}
1398
1399impl parachains_origin::Config for Runtime {}
1400
1401impl parachains_configuration::Config for Runtime {
1402 type WeightInfo = weights::polkadot_runtime_parachains_configuration::WeightInfo<Runtime>;
1403}
1404
1405impl parachains_shared::Config for Runtime {
1406 type DisabledValidators = Session;
1407}
1408
1409impl parachains_session_info::Config for Runtime {
1410 type ValidatorSet = Historical;
1411}
1412
1413impl parachains_inclusion::Config for Runtime {
1414 type RuntimeEvent = RuntimeEvent;
1415 type DisputesHandler = ParasDisputes;
1416 type RewardValidators =
1417 parachains_reward_points::RewardValidatorsWithEraPoints<Runtime, StakingAhClient>;
1418 type MessageQueue = MessageQueue;
1419 type WeightInfo = weights::polkadot_runtime_parachains_inclusion::WeightInfo<Runtime>;
1420}
1421
1422parameter_types! {
1423 pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
1424}
1425
1426impl parachains_paras::Config for Runtime {
1427 type RuntimeEvent = RuntimeEvent;
1428 type WeightInfo = weights::polkadot_runtime_parachains_paras::WeightInfo<Runtime>;
1429 type UnsignedPriority = ParasUnsignedPriority;
1430 type QueueFootprinter = ParaInclusion;
1431 type NextSessionRotation = Babe;
1432 type OnNewHead = ();
1433 type AssignCoretime = CoretimeAssignmentProvider;
1434 type Fungible = Balances;
1435 type CooldownRemovalMultiplier = ConstUint<{ 1000 * UNITS / DAYS as u128 }>;
1437 type AuthorizeCurrentCodeOrigin = EitherOfDiverse<
1438 EnsureRoot<AccountId>,
1439 AsEnsureOriginWithArg<
1441 EnsureXcm<IsVoiceOfBody<xcm_config::Collectives, xcm_config::DDayBodyId>>,
1442 >,
1443 >;
1444}
1445
1446parameter_types! {
1447 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(20) * BlockWeights::get().max_block;
1453 pub const MessageQueueHeapSize: u32 = 128 * 1024;
1454 pub const MessageQueueMaxStale: u32 = 48;
1455}
1456
1457pub struct MessageProcessor;
1459impl ProcessMessage for MessageProcessor {
1460 type Origin = AggregateMessageOrigin;
1461
1462 fn process_message(
1463 message: &[u8],
1464 origin: Self::Origin,
1465 meter: &mut WeightMeter,
1466 id: &mut [u8; 32],
1467 ) -> Result<bool, ProcessMessageError> {
1468 let para = match origin {
1469 AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para,
1470 };
1471 xcm_builder::ProcessXcmMessage::<
1472 Junction,
1473 xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
1474 RuntimeCall,
1475 >::process_message(message, Junction::Parachain(para.into()), meter, id)
1476 }
1477}
1478
1479impl pallet_message_queue::Config for Runtime {
1480 type RuntimeEvent = RuntimeEvent;
1481 type Size = u32;
1482 type HeapSize = MessageQueueHeapSize;
1483 type MaxStale = MessageQueueMaxStale;
1484 type ServiceWeight = MessageQueueServiceWeight;
1485 type IdleMaxServiceWeight = MessageQueueServiceWeight;
1486 #[cfg(not(feature = "runtime-benchmarks"))]
1487 type MessageProcessor = MessageProcessor;
1488 #[cfg(feature = "runtime-benchmarks")]
1489 type MessageProcessor =
1490 pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
1491 type QueueChangeHandler = ParaInclusion;
1492 type QueuePausedQuery = ();
1493 type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
1494}
1495
1496impl parachains_dmp::Config for Runtime {}
1497
1498parameter_types! {
1499 pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
1500}
1501
1502impl parachains_hrmp::Config for Runtime {
1503 type RuntimeOrigin = RuntimeOrigin;
1504 type RuntimeEvent = RuntimeEvent;
1505 type ChannelManager = EnsureRoot<AccountId>;
1506 type Currency = Balances;
1507 type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
1508 Runtime,
1509 HrmpChannelSizeAndCapacityWithSystemRatio,
1510 >;
1511 type VersionWrapper = crate::XcmPallet;
1512 type WeightInfo = weights::polkadot_runtime_parachains_hrmp::WeightInfo<Self>;
1513}
1514
1515impl parachains_paras_inherent::Config for Runtime {
1516 type WeightInfo = weights::polkadot_runtime_parachains_paras_inherent::WeightInfo<Runtime>;
1517}
1518
1519impl parachains_scheduler::Config for Runtime {
1520 type AssignmentProvider = CoretimeAssignmentProvider;
1523}
1524
1525parameter_types! {
1526 pub const BrokerId: u32 = BROKER_ID;
1527 pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
1528 pub MaxXcmTransactWeight: Weight = Weight::from_parts(200_000_000, 20_000);
1529}
1530
1531pub struct BrokerPot;
1532impl Get<InteriorLocation> for BrokerPot {
1533 fn get() -> InteriorLocation {
1534 Junction::AccountId32 { network: None, id: BrokerPalletId::get().into_account_truncating() }
1535 .into()
1536 }
1537}
1538
1539impl coretime::Config for Runtime {
1540 type RuntimeOrigin = RuntimeOrigin;
1541 type RuntimeEvent = RuntimeEvent;
1542 type BrokerId = BrokerId;
1543 type BrokerPotLocation = BrokerPot;
1544 type WeightInfo = weights::polkadot_runtime_parachains_coretime::WeightInfo<Runtime>;
1545 type SendXcm = crate::xcm_config::XcmRouter;
1546 type AssetTransactor = crate::xcm_config::LocalAssetTransactor;
1547 type AccountToLocation = xcm_builder::AliasesIntoAccountId32<
1548 xcm_config::ThisNetwork,
1549 <Runtime as frame_system::Config>::AccountId,
1550 >;
1551 type MaxXcmTransactWeight = MaxXcmTransactWeight;
1552}
1553
1554parameter_types! {
1555 pub const OnDemandTrafficDefaultValue: FixedU128 = FixedU128::from_u32(1);
1556 pub const MaxHistoricalRevenue: BlockNumber = 2 * TIMESLICE_PERIOD;
1558 pub const OnDemandPalletId: PalletId = PalletId(*b"py/ondmd");
1559}
1560
1561impl parachains_on_demand::Config for Runtime {
1562 type RuntimeEvent = RuntimeEvent;
1563 type Currency = Balances;
1564 type TrafficDefaultValue = OnDemandTrafficDefaultValue;
1565 type WeightInfo = weights::polkadot_runtime_parachains_on_demand::WeightInfo<Runtime>;
1566 type MaxHistoricalRevenue = MaxHistoricalRevenue;
1567 type PalletId = OnDemandPalletId;
1568}
1569
1570impl parachains_assigner_coretime::Config for Runtime {}
1571
1572impl parachains_initializer::Config for Runtime {
1573 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1574 type ForceOrigin = EnsureRoot<AccountId>;
1575 type WeightInfo = weights::polkadot_runtime_parachains_initializer::WeightInfo<Runtime>;
1576 type CoretimeOnNewSession = Coretime;
1577}
1578
1579impl paras_sudo_wrapper::Config for Runtime {}
1580
1581parameter_types! {
1582 pub const PermanentSlotLeasePeriodLength: u32 = 26;
1583 pub const TemporarySlotLeasePeriodLength: u32 = 1;
1584 pub const MaxTemporarySlotPerLeasePeriod: u32 = 5;
1585}
1586
1587impl assigned_slots::Config for Runtime {
1588 type RuntimeEvent = RuntimeEvent;
1589 type AssignSlotOrigin = EnsureRoot<AccountId>;
1590 type Leaser = Slots;
1591 type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
1592 type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength;
1593 type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod;
1594 type WeightInfo = weights::polkadot_runtime_common_assigned_slots::WeightInfo<Runtime>;
1595}
1596
1597impl parachains_disputes::Config for Runtime {
1598 type RuntimeEvent = RuntimeEvent;
1599 type RewardValidators =
1600 parachains_reward_points::RewardValidatorsWithEraPoints<Runtime, StakingAhClient>;
1601 type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes<ParasSlashing>;
1602 type WeightInfo = weights::polkadot_runtime_parachains_disputes::WeightInfo<Runtime>;
1603}
1604
1605impl parachains_slashing::Config for Runtime {
1606 type KeyOwnerProofSystem = Historical;
1607 type KeyOwnerProof =
1608 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
1609 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
1610 KeyTypeId,
1611 ValidatorId,
1612 )>>::IdentificationTuple;
1613 type HandleReports = parachains_slashing::SlashingReportHandler<
1614 Self::KeyOwnerIdentification,
1615 Offences,
1616 ReportLongevity,
1617 >;
1618 type WeightInfo = weights::polkadot_runtime_parachains_disputes_slashing::WeightInfo<Runtime>;
1619 type BenchmarkingConfig = parachains_slashing::BenchConfig<300>;
1620}
1621
1622parameter_types! {
1623 pub const ParaDeposit: Balance = 2000 * CENTS;
1624 pub const RegistrarDataDepositPerByte: Balance = deposit(0, 1);
1625}
1626
1627impl paras_registrar::Config for Runtime {
1628 type RuntimeOrigin = RuntimeOrigin;
1629 type RuntimeEvent = RuntimeEvent;
1630 type Currency = Balances;
1631 type OnSwap = (Crowdloan, Slots, SwapLeases);
1632 type ParaDeposit = ParaDeposit;
1633 type DataDepositPerByte = RegistrarDataDepositPerByte;
1634 type WeightInfo = weights::polkadot_runtime_common_paras_registrar::WeightInfo<Runtime>;
1635}
1636
1637parameter_types! {
1638 pub const LeasePeriod: BlockNumber = 28 * DAYS;
1639}
1640
1641impl slots::Config for Runtime {
1642 type RuntimeEvent = RuntimeEvent;
1643 type Currency = Balances;
1644 type Registrar = Registrar;
1645 type LeasePeriod = LeasePeriod;
1646 type LeaseOffset = ();
1647 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, LeaseAdmin>;
1648 type WeightInfo = weights::polkadot_runtime_common_slots::WeightInfo<Runtime>;
1649}
1650
1651parameter_types! {
1652 pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
1653 pub const SubmissionDeposit: Balance = 100 * 100 * CENTS;
1654 pub const MinContribution: Balance = 100 * CENTS;
1655 pub const RemoveKeysLimit: u32 = 500;
1656 pub const MaxMemoLength: u8 = 32;
1658}
1659
1660impl crowdloan::Config for Runtime {
1661 type RuntimeEvent = RuntimeEvent;
1662 type PalletId = CrowdloanId;
1663 type SubmissionDeposit = SubmissionDeposit;
1664 type MinContribution = MinContribution;
1665 type RemoveKeysLimit = RemoveKeysLimit;
1666 type Registrar = Registrar;
1667 type Auctioneer = Auctions;
1668 type MaxMemoLength = MaxMemoLength;
1669 type WeightInfo = weights::polkadot_runtime_common_crowdloan::WeightInfo<Runtime>;
1670}
1671
1672parameter_types! {
1673 pub const EndingPeriod: BlockNumber = 5 * DAYS;
1676 pub const SampleLength: BlockNumber = 2 * MINUTES;
1678}
1679
1680impl auctions::Config for Runtime {
1681 type RuntimeEvent = RuntimeEvent;
1682 type Leaser = Slots;
1683 type Registrar = Registrar;
1684 type EndingPeriod = EndingPeriod;
1685 type SampleLength = SampleLength;
1686 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1687 type InitiateOrigin = EitherOf<EnsureRoot<Self::AccountId>, AuctionAdmin>;
1688 type WeightInfo = weights::polkadot_runtime_common_auctions::WeightInfo<Runtime>;
1689}
1690
1691impl identity_migrator::Config for Runtime {
1692 type RuntimeEvent = RuntimeEvent;
1693 type Reaper = EnsureSigned<AccountId>;
1694 type ReapIdentityHandler = ToParachainIdentityReaper<Runtime, Self::AccountId>;
1695 type WeightInfo = weights::polkadot_runtime_common_identity_migrator::WeightInfo<Runtime>;
1696}
1697
1698parameter_types! {
1699 pub const PoolsPalletId: PalletId = PalletId(*b"py/nopls");
1700 pub const MaxPointsToBalance: u8 = 10;
1701}
1702
1703impl pallet_nomination_pools::Config for Runtime {
1704 type RuntimeEvent = RuntimeEvent;
1705 type WeightInfo = weights::pallet_nomination_pools::WeightInfo<Self>;
1706 type Currency = Balances;
1707 type RuntimeFreezeReason = RuntimeFreezeReason;
1708 type RewardCounter = FixedU128;
1709 type BalanceToU256 = BalanceToU256;
1710 type U256ToBalance = U256ToBalance;
1711 type StakeAdapter =
1712 pallet_nomination_pools::adapter::DelegateStake<Self, Staking, DelegatedStaking>;
1713 type PostUnbondingPoolsWindow = ConstU32<4>;
1714 type MaxMetadataLen = ConstU32<256>;
1715 type MaxUnbonding = <Self as pallet_staking::Config>::MaxUnlockingChunks;
1717 type PalletId = PoolsPalletId;
1718 type MaxPointsToBalance = MaxPointsToBalance;
1719 type AdminOrigin = EitherOf<EnsureRoot<AccountId>, StakingAdmin>;
1720 type BlockNumberProvider = System;
1721 type Filter = Nothing;
1722}
1723
1724parameter_types! {
1725 pub const DelegatedStakingPalletId: PalletId = PalletId(*b"py/dlstk");
1726 pub const SlashRewardFraction: Perbill = Perbill::from_percent(1);
1727}
1728
1729impl pallet_delegated_staking::Config for Runtime {
1730 type RuntimeEvent = RuntimeEvent;
1731 type PalletId = DelegatedStakingPalletId;
1732 type Currency = Balances;
1733 type OnSlash = ();
1734 type SlashRewardFraction = SlashRewardFraction;
1735 type RuntimeHoldReason = RuntimeHoldReason;
1736 type CoreStaking = Staking;
1737}
1738
1739impl pallet_root_testing::Config for Runtime {
1740 type RuntimeEvent = RuntimeEvent;
1741}
1742
1743parameter_types! {
1744 pub MbmServiceWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
1745}
1746
1747impl pallet_migrations::Config for Runtime {
1748 type RuntimeEvent = RuntimeEvent;
1749 #[cfg(not(feature = "runtime-benchmarks"))]
1750 type Migrations = pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>;
1751 #[cfg(feature = "runtime-benchmarks")]
1753 type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
1754 type CursorMaxLen = ConstU32<65_536>;
1755 type IdentifierMaxLen = ConstU32<256>;
1756 type MigrationStatusHandler = ();
1757 type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
1758 type MaxServiceWeight = MbmServiceWeight;
1759 type WeightInfo = weights::pallet_migrations::WeightInfo<Runtime>;
1760}
1761
1762parameter_types! {
1763 pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
1765 pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100;
1766 pub const MigrationMaxKeyLen: u32 = 512;
1767}
1768
1769impl pallet_asset_rate::Config for Runtime {
1770 type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
1771 type RuntimeEvent = RuntimeEvent;
1772 type CreateOrigin = EnsureRoot<AccountId>;
1773 type RemoveOrigin = EnsureRoot<AccountId>;
1774 type UpdateOrigin = EnsureRoot<AccountId>;
1775 type Currency = Balances;
1776 type AssetKind = <Runtime as pallet_treasury::Config>::AssetKind;
1777 #[cfg(feature = "runtime-benchmarks")]
1778 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
1779}
1780
1781pub struct SwapLeases;
1783impl OnSwap for SwapLeases {
1784 fn on_swap(one: ParaId, other: ParaId) {
1785 coretime::Pallet::<Runtime>::on_legacy_lease_swap(one, other);
1786 }
1787}
1788
1789pub type MetaTxExtension = (
1790 pallet_verify_signature::VerifySignature<Runtime>,
1791 pallet_meta_tx::MetaTxMarker<Runtime>,
1792 frame_system::CheckNonZeroSender<Runtime>,
1793 frame_system::CheckSpecVersion<Runtime>,
1794 frame_system::CheckTxVersion<Runtime>,
1795 frame_system::CheckGenesis<Runtime>,
1796 frame_system::CheckMortality<Runtime>,
1797 frame_system::CheckNonce<Runtime>,
1798 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
1799);
1800
1801impl pallet_meta_tx::Config for Runtime {
1802 type WeightInfo = weights::pallet_meta_tx::WeightInfo<Runtime>;
1803 type RuntimeEvent = RuntimeEvent;
1804 #[cfg(not(feature = "runtime-benchmarks"))]
1805 type Extension = MetaTxExtension;
1806 #[cfg(feature = "runtime-benchmarks")]
1807 type Extension = pallet_meta_tx::WeightlessExtension<Runtime>;
1808}
1809
1810impl pallet_verify_signature::Config for Runtime {
1811 type Signature = MultiSignature;
1812 type AccountIdentifier = MultiSigner;
1813 type WeightInfo = weights::pallet_verify_signature::WeightInfo<Runtime>;
1814 #[cfg(feature = "runtime-benchmarks")]
1815 type BenchmarkHelper = ();
1816}
1817
1818#[frame_support::runtime(legacy_ordering)]
1819mod runtime {
1820 #[runtime::runtime]
1821 #[runtime::derive(
1822 RuntimeCall,
1823 RuntimeEvent,
1824 RuntimeError,
1825 RuntimeOrigin,
1826 RuntimeFreezeReason,
1827 RuntimeHoldReason,
1828 RuntimeSlashReason,
1829 RuntimeLockId,
1830 RuntimeTask,
1831 RuntimeViewFunction
1832 )]
1833 pub struct Runtime;
1834
1835 #[runtime::pallet_index(0)]
1837 pub type System = frame_system;
1838
1839 #[runtime::pallet_index(1)]
1841 pub type Babe = pallet_babe;
1842
1843 #[runtime::pallet_index(2)]
1844 pub type Timestamp = pallet_timestamp;
1845 #[runtime::pallet_index(3)]
1846 pub type Indices = pallet_indices;
1847 #[runtime::pallet_index(4)]
1848 pub type Balances = pallet_balances;
1849 #[runtime::pallet_index(26)]
1850 pub type TransactionPayment = pallet_transaction_payment;
1851
1852 #[runtime::pallet_index(5)]
1855 pub type Authorship = pallet_authorship;
1856 #[runtime::pallet_index(6)]
1857 pub type Staking = pallet_staking;
1858 #[runtime::pallet_index(7)]
1859 pub type Offences = pallet_offences;
1860 #[runtime::pallet_index(27)]
1861 pub type Historical = session_historical;
1862 #[runtime::pallet_index(70)]
1863 pub type Parameters = pallet_parameters;
1864
1865 #[runtime::pallet_index(8)]
1866 pub type Session = pallet_session;
1867 #[runtime::pallet_index(10)]
1868 pub type Grandpa = pallet_grandpa;
1869 #[runtime::pallet_index(12)]
1870 pub type AuthorityDiscovery = pallet_authority_discovery;
1871
1872 #[runtime::pallet_index(16)]
1874 pub type Utility = pallet_utility;
1875
1876 #[runtime::pallet_index(17)]
1878 pub type Identity = pallet_identity;
1879
1880 #[runtime::pallet_index(18)]
1882 pub type Recovery = pallet_recovery;
1883
1884 #[runtime::pallet_index(19)]
1886 pub type Vesting = pallet_vesting;
1887
1888 #[runtime::pallet_index(20)]
1890 pub type Scheduler = pallet_scheduler;
1891
1892 #[runtime::pallet_index(28)]
1894 pub type Preimage = pallet_preimage;
1895
1896 #[runtime::pallet_index(21)]
1898 pub type Sudo = pallet_sudo;
1899
1900 #[runtime::pallet_index(22)]
1902 pub type Proxy = pallet_proxy;
1903
1904 #[runtime::pallet_index(23)]
1906 pub type Multisig = pallet_multisig;
1907
1908 #[runtime::pallet_index(24)]
1910 pub type ElectionProviderMultiPhase = pallet_election_provider_multi_phase;
1911
1912 #[runtime::pallet_index(25)]
1914 pub type VoterList = pallet_bags_list<Instance1>;
1915
1916 #[runtime::pallet_index(29)]
1918 pub type NominationPools = pallet_nomination_pools;
1919
1920 #[runtime::pallet_index(30)]
1922 pub type FastUnstake = pallet_fast_unstake;
1923
1924 #[runtime::pallet_index(31)]
1926 pub type ConvictionVoting = pallet_conviction_voting;
1927 #[runtime::pallet_index(32)]
1928 pub type Referenda = pallet_referenda;
1929 #[runtime::pallet_index(35)]
1930 pub type Origins = pallet_custom_origins;
1931 #[runtime::pallet_index(36)]
1932 pub type Whitelist = pallet_whitelist;
1933
1934 #[runtime::pallet_index(37)]
1936 pub type Treasury = pallet_treasury;
1937
1938 #[runtime::pallet_index(38)]
1940 pub type DelegatedStaking = pallet_delegated_staking;
1941
1942 #[runtime::pallet_index(41)]
1944 pub type ParachainsOrigin = parachains_origin;
1945 #[runtime::pallet_index(42)]
1946 pub type Configuration = parachains_configuration;
1947 #[runtime::pallet_index(43)]
1948 pub type ParasShared = parachains_shared;
1949 #[runtime::pallet_index(44)]
1950 pub type ParaInclusion = parachains_inclusion;
1951 #[runtime::pallet_index(45)]
1952 pub type ParaInherent = parachains_paras_inherent;
1953 #[runtime::pallet_index(46)]
1954 pub type ParaScheduler = parachains_scheduler;
1955 #[runtime::pallet_index(47)]
1956 pub type Paras = parachains_paras;
1957 #[runtime::pallet_index(48)]
1958 pub type Initializer = parachains_initializer;
1959 #[runtime::pallet_index(49)]
1960 pub type Dmp = parachains_dmp;
1961 #[runtime::pallet_index(51)]
1963 pub type Hrmp = parachains_hrmp;
1964 #[runtime::pallet_index(52)]
1965 pub type ParaSessionInfo = parachains_session_info;
1966 #[runtime::pallet_index(53)]
1967 pub type ParasDisputes = parachains_disputes;
1968 #[runtime::pallet_index(54)]
1969 pub type ParasSlashing = parachains_slashing;
1970 #[runtime::pallet_index(56)]
1971 pub type OnDemandAssignmentProvider = parachains_on_demand;
1972 #[runtime::pallet_index(57)]
1973 pub type CoretimeAssignmentProvider = parachains_assigner_coretime;
1974
1975 #[runtime::pallet_index(60)]
1977 pub type Registrar = paras_registrar;
1978 #[runtime::pallet_index(61)]
1979 pub type Slots = slots;
1980 #[runtime::pallet_index(62)]
1981 pub type ParasSudoWrapper = paras_sudo_wrapper;
1982 #[runtime::pallet_index(63)]
1983 pub type Auctions = auctions;
1984 #[runtime::pallet_index(64)]
1985 pub type Crowdloan = crowdloan;
1986 #[runtime::pallet_index(65)]
1987 pub type AssignedSlots = assigned_slots;
1988 #[runtime::pallet_index(66)]
1989 pub type Coretime = coretime;
1990 #[runtime::pallet_index(67)]
1991 pub type StakingAhClient = pallet_staking_async_ah_client;
1992
1993 #[runtime::pallet_index(98)]
1995 pub type MultiBlockMigrations = pallet_migrations;
1996
1997 #[runtime::pallet_index(99)]
1999 pub type XcmPallet = pallet_xcm;
2000
2001 #[runtime::pallet_index(100)]
2003 pub type MessageQueue = pallet_message_queue;
2004
2005 #[runtime::pallet_index(101)]
2007 pub type AssetRate = pallet_asset_rate;
2008
2009 #[runtime::pallet_index(102)]
2011 pub type RootTesting = pallet_root_testing;
2012
2013 #[runtime::pallet_index(103)]
2014 pub type MetaTx = pallet_meta_tx::Pallet<Runtime>;
2015
2016 #[runtime::pallet_index(104)]
2017 pub type VerifySignature = pallet_verify_signature::Pallet<Runtime>;
2018
2019 #[runtime::pallet_index(200)]
2021 pub type Beefy = pallet_beefy;
2022 #[runtime::pallet_index(201)]
2025 pub type Mmr = pallet_mmr;
2026 #[runtime::pallet_index(202)]
2027 pub type BeefyMmrLeaf = pallet_beefy_mmr;
2028
2029 #[runtime::pallet_index(248)]
2031 pub type IdentityMigrator = identity_migrator;
2032}
2033
2034pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
2036pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
2038pub type Block = generic::Block<Header, UncheckedExtrinsic>;
2040pub type SignedBlock = generic::SignedBlock<Block>;
2042pub type BlockId = generic::BlockId<Block>;
2044pub type TxExtension = (
2046 frame_system::AuthorizeCall<Runtime>,
2047 frame_system::CheckNonZeroSender<Runtime>,
2048 frame_system::CheckSpecVersion<Runtime>,
2049 frame_system::CheckTxVersion<Runtime>,
2050 frame_system::CheckGenesis<Runtime>,
2051 frame_system::CheckMortality<Runtime>,
2052 frame_system::CheckNonce<Runtime>,
2053 frame_system::CheckWeight<Runtime>,
2054 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
2055 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
2056 frame_system::WeightReclaim<Runtime>,
2057);
2058
2059parameter_types! {
2060 pub const MaxAgentsToMigrate: u32 = 300;
2062}
2063
2064pub type Migrations = migrations::Unreleased;
2069
2070#[allow(deprecated, missing_docs)]
2072pub mod migrations {
2073 use super::*;
2074
2075 pub type Unreleased = (
2077 pallet_delegated_staking::migration::unversioned::ProxyDelegatorMigration<
2079 Runtime,
2080 MaxAgentsToMigrate,
2081 >,
2082 parachains_shared::migration::MigrateToV1<Runtime>,
2083 parachains_scheduler::migration::MigrateV2ToV3<Runtime>,
2084 pallet_staking::migrations::v16::MigrateV15ToV16<Runtime>,
2085 pallet_session::migrations::v1::MigrateV0ToV1<
2086 Runtime,
2087 pallet_staking::migrations::v17::MigrateDisabledToSession<Runtime>,
2088 >,
2089 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
2091 );
2092}
2093
2094pub type UncheckedExtrinsic =
2096 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
2097pub type UncheckedSignaturePayload =
2099 generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
2100
2101pub type Executive = frame_executive::Executive<
2103 Runtime,
2104 Block,
2105 frame_system::ChainContext<Runtime>,
2106 Runtime,
2107 AllPalletsWithSystem,
2108 Migrations,
2109>;
2110pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
2112
2113#[cfg(feature = "runtime-benchmarks")]
2114mod benches {
2115 frame_benchmarking::define_benchmarks!(
2116 [polkadot_runtime_common::assigned_slots, AssignedSlots]
2120 [polkadot_runtime_common::auctions, Auctions]
2121 [polkadot_runtime_common::crowdloan, Crowdloan]
2122 [polkadot_runtime_common::identity_migrator, IdentityMigrator]
2123 [polkadot_runtime_common::paras_registrar, Registrar]
2124 [polkadot_runtime_common::slots, Slots]
2125 [polkadot_runtime_parachains::configuration, Configuration]
2126 [polkadot_runtime_parachains::disputes, ParasDisputes]
2127 [polkadot_runtime_parachains::disputes::slashing, ParasSlashing]
2128 [polkadot_runtime_parachains::hrmp, Hrmp]
2129 [polkadot_runtime_parachains::inclusion, ParaInclusion]
2130 [polkadot_runtime_parachains::initializer, Initializer]
2131 [polkadot_runtime_parachains::paras, Paras]
2132 [polkadot_runtime_parachains::paras_inherent, ParaInherent]
2133 [polkadot_runtime_parachains::on_demand, OnDemandAssignmentProvider]
2134 [polkadot_runtime_parachains::coretime, Coretime]
2135 [pallet_bags_list, VoterList]
2137 [pallet_balances, Balances]
2138 [pallet_beefy_mmr, BeefyMmrLeaf]
2139 [pallet_conviction_voting, ConvictionVoting]
2140 [pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
2141 [frame_election_provider_support, ElectionProviderBench::<Runtime>]
2142 [pallet_fast_unstake, FastUnstake]
2143 [pallet_identity, Identity]
2144 [pallet_indices, Indices]
2145 [pallet_message_queue, MessageQueue]
2146 [pallet_migrations, MultiBlockMigrations]
2147 [pallet_mmr, Mmr]
2148 [pallet_multisig, Multisig]
2149 [pallet_nomination_pools, NominationPoolsBench::<Runtime>]
2150 [pallet_offences, OffencesBench::<Runtime>]
2151 [pallet_parameters, Parameters]
2152 [pallet_preimage, Preimage]
2153 [pallet_proxy, Proxy]
2154 [pallet_recovery, Recovery]
2155 [pallet_referenda, Referenda]
2156 [pallet_scheduler, Scheduler]
2157 [pallet_session, SessionBench::<Runtime>]
2158 [pallet_staking, Staking]
2159 [pallet_sudo, Sudo]
2160 [frame_system, SystemBench::<Runtime>]
2161 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
2162 [pallet_timestamp, Timestamp]
2163 [pallet_transaction_payment, TransactionPayment]
2164 [pallet_treasury, Treasury]
2165 [pallet_utility, Utility]
2166 [pallet_vesting, Vesting]
2167 [pallet_whitelist, Whitelist]
2168 [pallet_asset_rate, AssetRate]
2169 [pallet_meta_tx, MetaTx]
2170 [pallet_verify_signature, VerifySignature]
2171 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
2173 [pallet_xcm_benchmarks::fungible, XcmBalances]
2175 [pallet_xcm_benchmarks::generic, XcmGeneric]
2176 );
2177}
2178
2179sp_api::impl_runtime_apis! {
2180 impl sp_api::Core<Block> for Runtime {
2181 fn version() -> RuntimeVersion {
2182 VERSION
2183 }
2184
2185 fn execute_block(block: Block) {
2186 Executive::execute_block(block);
2187 }
2188
2189 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
2190 Executive::initialize_block(header)
2191 }
2192 }
2193
2194 impl sp_api::Metadata<Block> for Runtime {
2195 fn metadata() -> OpaqueMetadata {
2196 OpaqueMetadata::new(Runtime::metadata().into())
2197 }
2198
2199 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
2200 Runtime::metadata_at_version(version)
2201 }
2202
2203 fn metadata_versions() -> alloc::vec::Vec<u32> {
2204 Runtime::metadata_versions()
2205 }
2206 }
2207
2208 impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
2209 fn execute_view_function(id: frame_support::view_functions::ViewFunctionId, input: Vec<u8>) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
2210 Runtime::execute_view_function(id, input)
2211 }
2212 }
2213
2214 impl sp_block_builder::BlockBuilder<Block> for Runtime {
2215 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
2216 Executive::apply_extrinsic(extrinsic)
2217 }
2218
2219 fn finalize_block() -> <Block as BlockT>::Header {
2220 Executive::finalize_block()
2221 }
2222
2223 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
2224 data.create_extrinsics()
2225 }
2226
2227 fn check_inherents(
2228 block: Block,
2229 data: sp_inherents::InherentData,
2230 ) -> sp_inherents::CheckInherentsResult {
2231 data.check_extrinsics(&block)
2232 }
2233 }
2234
2235 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
2236 fn validate_transaction(
2237 source: TransactionSource,
2238 tx: <Block as BlockT>::Extrinsic,
2239 block_hash: <Block as BlockT>::Hash,
2240 ) -> TransactionValidity {
2241 Executive::validate_transaction(source, tx, block_hash)
2242 }
2243 }
2244
2245 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
2246 fn offchain_worker(header: &<Block as BlockT>::Header) {
2247 Executive::offchain_worker(header)
2248 }
2249 }
2250
2251 #[api_version(13)]
2252 impl polkadot_primitives::runtime_api::ParachainHost<Block> for Runtime {
2253 fn validators() -> Vec<ValidatorId> {
2254 parachains_runtime_api_impl::validators::<Runtime>()
2255 }
2256
2257 fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
2258 parachains_runtime_api_impl::validator_groups::<Runtime>()
2259 }
2260
2261 fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>> {
2262 parachains_runtime_api_impl::availability_cores::<Runtime>()
2263 }
2264
2265 fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
2266 -> Option<PersistedValidationData<Hash, BlockNumber>> {
2267 parachains_runtime_api_impl::persisted_validation_data::<Runtime>(para_id, assumption)
2268 }
2269
2270 fn assumed_validation_data(
2271 para_id: ParaId,
2272 expected_persisted_validation_data_hash: Hash,
2273 ) -> Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)> {
2274 parachains_runtime_api_impl::assumed_validation_data::<Runtime>(
2275 para_id,
2276 expected_persisted_validation_data_hash,
2277 )
2278 }
2279
2280 fn check_validation_outputs(
2281 para_id: ParaId,
2282 outputs: polkadot_primitives::CandidateCommitments,
2283 ) -> bool {
2284 parachains_runtime_api_impl::check_validation_outputs::<Runtime>(para_id, outputs)
2285 }
2286
2287 fn session_index_for_child() -> SessionIndex {
2288 parachains_runtime_api_impl::session_index_for_child::<Runtime>()
2289 }
2290
2291 fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
2292 -> Option<ValidationCode> {
2293 parachains_runtime_api_impl::validation_code::<Runtime>(para_id, assumption)
2294 }
2295
2296 fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
2297 #[allow(deprecated)]
2298 parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
2299 }
2300
2301 fn candidate_events() -> Vec<CandidateEvent<Hash>> {
2302 parachains_runtime_api_impl::candidate_events::<Runtime, _>(|ev| {
2303 match ev {
2304 RuntimeEvent::ParaInclusion(ev) => {
2305 Some(ev)
2306 }
2307 _ => None,
2308 }
2309 })
2310 }
2311
2312 fn session_info(index: SessionIndex) -> Option<SessionInfo> {
2313 parachains_runtime_api_impl::session_info::<Runtime>(index)
2314 }
2315
2316 fn session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams> {
2317 parachains_runtime_api_impl::session_executor_params::<Runtime>(session_index)
2318 }
2319
2320 fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<BlockNumber>> {
2321 parachains_runtime_api_impl::dmq_contents::<Runtime>(recipient)
2322 }
2323
2324 fn inbound_hrmp_channels_contents(
2325 recipient: ParaId
2326 ) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
2327 parachains_runtime_api_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
2328 }
2329
2330 fn validation_code_by_hash(hash: ValidationCodeHash) -> Option<ValidationCode> {
2331 parachains_runtime_api_impl::validation_code_by_hash::<Runtime>(hash)
2332 }
2333
2334 fn on_chain_votes() -> Option<ScrapedOnChainVotes<Hash>> {
2335 parachains_runtime_api_impl::on_chain_votes::<Runtime>()
2336 }
2337
2338 fn submit_pvf_check_statement(
2339 stmt: PvfCheckStatement,
2340 signature: ValidatorSignature,
2341 ) {
2342 parachains_runtime_api_impl::submit_pvf_check_statement::<Runtime>(stmt, signature)
2343 }
2344
2345 fn pvfs_require_precheck() -> Vec<ValidationCodeHash> {
2346 parachains_runtime_api_impl::pvfs_require_precheck::<Runtime>()
2347 }
2348
2349 fn validation_code_hash(para_id: ParaId, assumption: OccupiedCoreAssumption)
2350 -> Option<ValidationCodeHash>
2351 {
2352 parachains_runtime_api_impl::validation_code_hash::<Runtime>(para_id, assumption)
2353 }
2354
2355 fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
2356 parachains_runtime_api_impl::get_session_disputes::<Runtime>()
2357 }
2358
2359 fn unapplied_slashes(
2360 ) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
2361 parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
2362 }
2363
2364 fn key_ownership_proof(
2365 validator_id: ValidatorId,
2366 ) -> Option<slashing::OpaqueKeyOwnershipProof> {
2367 use codec::Encode;
2368
2369 Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
2370 .map(|p| p.encode())
2371 .map(slashing::OpaqueKeyOwnershipProof::new)
2372 }
2373
2374 fn submit_report_dispute_lost(
2375 dispute_proof: slashing::DisputeProof,
2376 key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
2377 ) -> Option<()> {
2378 parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
2379 dispute_proof,
2380 key_ownership_proof,
2381 )
2382 }
2383
2384 fn minimum_backing_votes() -> u32 {
2385 parachains_runtime_api_impl::minimum_backing_votes::<Runtime>()
2386 }
2387
2388 fn para_backing_state(para_id: ParaId) -> Option<polkadot_primitives::vstaging::async_backing::BackingState> {
2389 #[allow(deprecated)]
2390 parachains_runtime_api_impl::backing_state::<Runtime>(para_id)
2391 }
2392
2393 fn async_backing_params() -> polkadot_primitives::AsyncBackingParams {
2394 #[allow(deprecated)]
2395 parachains_runtime_api_impl::async_backing_params::<Runtime>()
2396 }
2397
2398 fn approval_voting_params() -> ApprovalVotingParams {
2399 parachains_runtime_api_impl::approval_voting_params::<Runtime>()
2400 }
2401
2402 fn disabled_validators() -> Vec<ValidatorIndex> {
2403 parachains_runtime_api_impl::disabled_validators::<Runtime>()
2404 }
2405
2406 fn node_features() -> NodeFeatures {
2407 parachains_runtime_api_impl::node_features::<Runtime>()
2408 }
2409
2410 fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
2411 parachains_runtime_api_impl::claim_queue::<Runtime>()
2412 }
2413
2414 fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
2415 parachains_runtime_api_impl::candidates_pending_availability::<Runtime>(para_id)
2416 }
2417
2418 fn backing_constraints(para_id: ParaId) -> Option<Constraints> {
2419 parachains_staging_runtime_api_impl::backing_constraints::<Runtime>(para_id)
2420 }
2421
2422 fn scheduling_lookahead() -> u32 {
2423 parachains_staging_runtime_api_impl::scheduling_lookahead::<Runtime>()
2424 }
2425
2426 fn validation_code_bomb_limit() -> u32 {
2427 parachains_staging_runtime_api_impl::validation_code_bomb_limit::<Runtime>()
2428 }
2429 }
2430
2431 #[api_version(5)]
2432 impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
2433 fn beefy_genesis() -> Option<BlockNumber> {
2434 pallet_beefy::GenesisBlock::<Runtime>::get()
2435 }
2436
2437 fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
2438 Beefy::validator_set()
2439 }
2440
2441 fn submit_report_double_voting_unsigned_extrinsic(
2442 equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
2443 BlockNumber,
2444 BeefyId,
2445 BeefySignature,
2446 >,
2447 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2448 ) -> Option<()> {
2449 let key_owner_proof = key_owner_proof.decode()?;
2450
2451 Beefy::submit_unsigned_double_voting_report(
2452 equivocation_proof,
2453 key_owner_proof,
2454 )
2455 }
2456
2457 fn submit_report_fork_voting_unsigned_extrinsic(
2458 equivocation_proof:
2459 sp_consensus_beefy::ForkVotingProof<
2460 <Block as BlockT>::Header,
2461 BeefyId,
2462 sp_runtime::OpaqueValue
2463 >,
2464 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2465 ) -> Option<()> {
2466 Beefy::submit_unsigned_fork_voting_report(
2467 equivocation_proof.try_into()?,
2468 key_owner_proof.decode()?,
2469 )
2470 }
2471
2472 fn submit_report_future_block_voting_unsigned_extrinsic(
2473 equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
2474 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2475 ) -> Option<()> {
2476 Beefy::submit_unsigned_future_block_voting_report(
2477 equivocation_proof,
2478 key_owner_proof.decode()?,
2479 )
2480 }
2481
2482 fn generate_key_ownership_proof(
2483 _set_id: sp_consensus_beefy::ValidatorSetId,
2484 authority_id: BeefyId,
2485 ) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
2486 use codec::Encode;
2487
2488 Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
2489 .map(|p| p.encode())
2490 .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
2491 }
2492
2493 fn generate_ancestry_proof(
2494 prev_block_number: BlockNumber,
2495 best_known_block_number: Option<BlockNumber>,
2496 ) -> Option<sp_runtime::OpaqueValue> {
2497 use sp_consensus_beefy::AncestryHelper;
2498
2499 BeefyMmrLeaf::generate_proof(prev_block_number, best_known_block_number)
2500 .map(|p| p.encode())
2501 .map(sp_runtime::OpaqueValue::new)
2502 }
2503 }
2504
2505 impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
2506 fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
2507 Ok(pallet_mmr::RootHash::<Runtime>::get())
2508 }
2509
2510 fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
2511 Ok(pallet_mmr::NumberOfLeaves::<Runtime>::get())
2512 }
2513
2514 fn generate_proof(
2515 block_numbers: Vec<BlockNumber>,
2516 best_known_block_number: Option<BlockNumber>,
2517 ) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<mmr::Hash>), mmr::Error> {
2518 Mmr::generate_proof(block_numbers, best_known_block_number).map(
2519 |(leaves, proof)| {
2520 (
2521 leaves
2522 .into_iter()
2523 .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
2524 .collect(),
2525 proof,
2526 )
2527 },
2528 )
2529 }
2530
2531 fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::LeafProof<mmr::Hash>)
2532 -> Result<(), mmr::Error>
2533 {
2534 let leaves = leaves.into_iter().map(|leaf|
2535 leaf.into_opaque_leaf()
2536 .try_decode()
2537 .ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;
2538 Mmr::verify_leaves(leaves, proof)
2539 }
2540
2541 fn verify_proof_stateless(
2542 root: mmr::Hash,
2543 leaves: Vec<mmr::EncodableOpaqueLeaf>,
2544 proof: mmr::LeafProof<mmr::Hash>
2545 ) -> Result<(), mmr::Error> {
2546 let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
2547 pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)
2548 }
2549 }
2550
2551 impl pallet_beefy_mmr::BeefyMmrApi<Block, Hash> for RuntimeApi {
2552 fn authority_set_proof() -> sp_consensus_beefy::mmr::BeefyAuthoritySet<Hash> {
2553 BeefyMmrLeaf::authority_set_proof()
2554 }
2555
2556 fn next_authority_set_proof() -> sp_consensus_beefy::mmr::BeefyNextAuthoritySet<Hash> {
2557 BeefyMmrLeaf::next_authority_set_proof()
2558 }
2559 }
2560
2561 impl fg_primitives::GrandpaApi<Block> for Runtime {
2562 fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
2563 Grandpa::grandpa_authorities()
2564 }
2565
2566 fn current_set_id() -> fg_primitives::SetId {
2567 pallet_grandpa::CurrentSetId::<Runtime>::get()
2568 }
2569
2570 fn submit_report_equivocation_unsigned_extrinsic(
2571 equivocation_proof: fg_primitives::EquivocationProof<
2572 <Block as BlockT>::Hash,
2573 sp_runtime::traits::NumberFor<Block>,
2574 >,
2575 key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
2576 ) -> Option<()> {
2577 let key_owner_proof = key_owner_proof.decode()?;
2578
2579 Grandpa::submit_unsigned_equivocation_report(
2580 equivocation_proof,
2581 key_owner_proof,
2582 )
2583 }
2584
2585 fn generate_key_ownership_proof(
2586 _set_id: fg_primitives::SetId,
2587 authority_id: fg_primitives::AuthorityId,
2588 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
2589 use codec::Encode;
2590
2591 Historical::prove((fg_primitives::KEY_TYPE, authority_id))
2592 .map(|p| p.encode())
2593 .map(fg_primitives::OpaqueKeyOwnershipProof::new)
2594 }
2595 }
2596
2597 impl sp_consensus_babe::BabeApi<Block> for Runtime {
2598 fn configuration() -> sp_consensus_babe::BabeConfiguration {
2599 let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
2600 sp_consensus_babe::BabeConfiguration {
2601 slot_duration: Babe::slot_duration(),
2602 epoch_length: EpochDuration::get(),
2603 c: epoch_config.c,
2604 authorities: Babe::authorities().to_vec(),
2605 randomness: Babe::randomness(),
2606 allowed_slots: epoch_config.allowed_slots,
2607 }
2608 }
2609
2610 fn current_epoch_start() -> sp_consensus_babe::Slot {
2611 Babe::current_epoch_start()
2612 }
2613
2614 fn current_epoch() -> sp_consensus_babe::Epoch {
2615 Babe::current_epoch()
2616 }
2617
2618 fn next_epoch() -> sp_consensus_babe::Epoch {
2619 Babe::next_epoch()
2620 }
2621
2622 fn generate_key_ownership_proof(
2623 _slot: sp_consensus_babe::Slot,
2624 authority_id: sp_consensus_babe::AuthorityId,
2625 ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
2626 use codec::Encode;
2627
2628 Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
2629 .map(|p| p.encode())
2630 .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
2631 }
2632
2633 fn submit_report_equivocation_unsigned_extrinsic(
2634 equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
2635 key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
2636 ) -> Option<()> {
2637 let key_owner_proof = key_owner_proof.decode()?;
2638
2639 Babe::submit_unsigned_equivocation_report(
2640 equivocation_proof,
2641 key_owner_proof,
2642 )
2643 }
2644 }
2645
2646 impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
2647 fn authorities() -> Vec<AuthorityDiscoveryId> {
2648 parachains_runtime_api_impl::relevant_authority_ids::<Runtime>()
2649 }
2650 }
2651
2652 impl sp_session::SessionKeys<Block> for Runtime {
2653 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
2654 SessionKeys::generate(seed)
2655 }
2656
2657 fn decode_session_keys(
2658 encoded: Vec<u8>,
2659 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
2660 SessionKeys::decode_into_raw_public_keys(&encoded)
2661 }
2662 }
2663
2664 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
2665 fn account_nonce(account: AccountId) -> Nonce {
2666 System::account_nonce(account)
2667 }
2668 }
2669
2670 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
2671 Block,
2672 Balance,
2673 > for Runtime {
2674 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
2675 TransactionPayment::query_info(uxt, len)
2676 }
2677 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
2678 TransactionPayment::query_fee_details(uxt, len)
2679 }
2680 fn query_weight_to_fee(weight: Weight) -> Balance {
2681 TransactionPayment::weight_to_fee(weight)
2682 }
2683 fn query_length_to_fee(length: u32) -> Balance {
2684 TransactionPayment::length_to_fee(length)
2685 }
2686 }
2687
2688 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
2689 for Runtime
2690 {
2691 fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo<Balance> {
2692 TransactionPayment::query_call_info(call, len)
2693 }
2694 fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails<Balance> {
2695 TransactionPayment::query_call_fee_details(call, len)
2696 }
2697 fn query_weight_to_fee(weight: Weight) -> Balance {
2698 TransactionPayment::weight_to_fee(weight)
2699 }
2700 fn query_length_to_fee(length: u32) -> Balance {
2701 TransactionPayment::length_to_fee(length)
2702 }
2703 }
2704
2705 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
2706 fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
2707 let acceptable_assets = vec![AssetId(xcm_config::TokenLocation::get())];
2708 XcmPallet::query_acceptable_payment_assets(xcm_version, acceptable_assets)
2709 }
2710
2711 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
2712 use crate::xcm_config::XcmConfig;
2713
2714 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
2715
2716 XcmPallet::query_weight_to_asset_fee::<Trader>(weight, asset)
2717 }
2718
2719 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
2720 XcmPallet::query_xcm_weight(message)
2721 }
2722
2723 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
2724 XcmPallet::query_delivery_fees(destination, message)
2725 }
2726 }
2727
2728 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
2729 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
2730 XcmPallet::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
2731 }
2732
2733 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
2734 XcmPallet::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
2735 }
2736 }
2737
2738 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
2739 fn convert_location(location: VersionedLocation) -> Result<
2740 AccountId,
2741 xcm_runtime_apis::conversions::Error
2742 > {
2743 xcm_runtime_apis::conversions::LocationToAccountHelper::<
2744 AccountId,
2745 xcm_config::LocationConverter,
2746 >::convert_location(location)
2747 }
2748 }
2749
2750 impl pallet_nomination_pools_runtime_api::NominationPoolsApi<
2751 Block,
2752 AccountId,
2753 Balance,
2754 > for Runtime {
2755 fn pending_rewards(member: AccountId) -> Balance {
2756 NominationPools::api_pending_rewards(member).unwrap_or_default()
2757 }
2758
2759 fn points_to_balance(pool_id: PoolId, points: Balance) -> Balance {
2760 NominationPools::api_points_to_balance(pool_id, points)
2761 }
2762
2763 fn balance_to_points(pool_id: PoolId, new_funds: Balance) -> Balance {
2764 NominationPools::api_balance_to_points(pool_id, new_funds)
2765 }
2766
2767 fn pool_pending_slash(pool_id: PoolId) -> Balance {
2768 NominationPools::api_pool_pending_slash(pool_id)
2769 }
2770
2771 fn member_pending_slash(member: AccountId) -> Balance {
2772 NominationPools::api_member_pending_slash(member)
2773 }
2774
2775 fn pool_needs_delegate_migration(pool_id: PoolId) -> bool {
2776 NominationPools::api_pool_needs_delegate_migration(pool_id)
2777 }
2778
2779 fn member_needs_delegate_migration(member: AccountId) -> bool {
2780 NominationPools::api_member_needs_delegate_migration(member)
2781 }
2782
2783 fn member_total_balance(member: AccountId) -> Balance {
2784 NominationPools::api_member_total_balance(member)
2785 }
2786
2787 fn pool_balance(pool_id: PoolId) -> Balance {
2788 NominationPools::api_pool_balance(pool_id)
2789 }
2790
2791 fn pool_accounts(pool_id: PoolId) -> (AccountId, AccountId) {
2792 NominationPools::api_pool_accounts(pool_id)
2793 }
2794 }
2795
2796 impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
2797 fn nominations_quota(balance: Balance) -> u32 {
2798 Staking::api_nominations_quota(balance)
2799 }
2800
2801 fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
2802 Staking::api_eras_stakers_page_count(era, account)
2803 }
2804
2805 fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool {
2806 Staking::api_pending_rewards(era, account)
2807 }
2808 }
2809
2810 #[cfg(feature = "try-runtime")]
2811 impl frame_try_runtime::TryRuntime<Block> for Runtime {
2812 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
2813 log::info!("try-runtime::on_runtime_upgrade westend.");
2814 let weight = Executive::try_runtime_upgrade(checks).unwrap();
2815 (weight, BlockWeights::get().max_block)
2816 }
2817
2818 fn execute_block(
2819 block: Block,
2820 state_root_check: bool,
2821 signature_check: bool,
2822 select: frame_try_runtime::TryStateSelect,
2823 ) -> Weight {
2824 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
2827 }
2828 }
2829
2830 #[cfg(feature = "runtime-benchmarks")]
2831 impl frame_benchmarking::Benchmark<Block> for Runtime {
2832 fn benchmark_metadata(extra: bool) -> (
2833 Vec<frame_benchmarking::BenchmarkList>,
2834 Vec<frame_support::traits::StorageInfo>,
2835 ) {
2836 use frame_benchmarking::BenchmarkList;
2837 use frame_support::traits::StorageInfoTrait;
2838
2839 use pallet_session_benchmarking::Pallet as SessionBench;
2840 use pallet_offences_benchmarking::Pallet as OffencesBench;
2841 use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
2842 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2843 use frame_system_benchmarking::Pallet as SystemBench;
2844 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2845 use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
2846
2847 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
2848 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
2849
2850 let mut list = Vec::<BenchmarkList>::new();
2851 list_benchmarks!(list, extra);
2852
2853 let storage_info = AllPalletsWithSystem::storage_info();
2854 return (list, storage_info)
2855 }
2856
2857 #[allow(non_local_definitions)]
2858 fn dispatch_benchmark(
2859 config: frame_benchmarking::BenchmarkConfig,
2860 ) -> Result<
2861 Vec<frame_benchmarking::BenchmarkBatch>,
2862 alloc::string::String,
2863 > {
2864 use frame_support::traits::WhitelistedStorageKeys;
2865 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
2866 use sp_storage::TrackedStorageKey;
2867 use pallet_session_benchmarking::Pallet as SessionBench;
2870 use pallet_offences_benchmarking::Pallet as OffencesBench;
2871 use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
2872 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2873 use frame_system_benchmarking::Pallet as SystemBench;
2874 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2875 use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
2876
2877 impl pallet_session_benchmarking::Config for Runtime {}
2878 impl pallet_offences_benchmarking::Config for Runtime {}
2879 impl pallet_election_provider_support_benchmarking::Config for Runtime {}
2880
2881 use xcm_config::{AssetHub, TokenLocation};
2882
2883 use alloc::boxed::Box;
2884
2885 parameter_types! {
2886 pub ExistentialDepositAsset: Option<Asset> = Some((
2887 TokenLocation::get(),
2888 ExistentialDeposit::get()
2889 ).into());
2890 pub AssetHubParaId: ParaId = westend_runtime_constants::system_parachain::ASSET_HUB_ID.into();
2891 pub const RandomParaId: ParaId = ParaId::new(43211234);
2892 }
2893
2894 impl pallet_xcm::benchmarking::Config for Runtime {
2895 type DeliveryHelper = (
2896 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2897 xcm_config::XcmConfig,
2898 ExistentialDepositAsset,
2899 xcm_config::PriceForChildParachainDelivery,
2900 AssetHubParaId,
2901 Dmp,
2902 >,
2903 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2904 xcm_config::XcmConfig,
2905 ExistentialDepositAsset,
2906 xcm_config::PriceForChildParachainDelivery,
2907 RandomParaId,
2908 Dmp,
2909 >
2910 );
2911
2912 fn reachable_dest() -> Option<Location> {
2913 Some(crate::xcm_config::AssetHub::get())
2914 }
2915
2916 fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
2917 Some((
2919 Asset { fun: Fungible(ExistentialDeposit::get()), id: AssetId(Here.into()) },
2920 crate::xcm_config::AssetHub::get(),
2921 ))
2922 }
2923
2924 fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
2925 None
2926 }
2927
2928 fn set_up_complex_asset_transfer(
2929 ) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
2930 let native_location = Here.into();
2936 let dest = crate::xcm_config::AssetHub::get();
2937 pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
2938 native_location,
2939 dest
2940 )
2941 }
2942
2943 fn get_asset() -> Asset {
2944 Asset {
2945 id: AssetId(Location::here()),
2946 fun: Fungible(ExistentialDeposit::get()),
2947 }
2948 }
2949 }
2950 impl frame_system_benchmarking::Config for Runtime {}
2951 impl pallet_nomination_pools_benchmarking::Config for Runtime {}
2952 impl polkadot_runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {}
2953
2954 use xcm::latest::{
2955 AssetId, Fungibility::*, InteriorLocation, Junction, Junctions::*,
2956 Asset, Assets, Location, NetworkId, Response,
2957 };
2958
2959 impl pallet_xcm_benchmarks::Config for Runtime {
2960 type XcmConfig = xcm_config::XcmConfig;
2961 type AccountIdConverter = xcm_config::LocationConverter;
2962 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2963 xcm_config::XcmConfig,
2964 ExistentialDepositAsset,
2965 xcm_config::PriceForChildParachainDelivery,
2966 AssetHubParaId,
2967 Dmp,
2968 >;
2969 fn valid_destination() -> Result<Location, BenchmarkError> {
2970 Ok(AssetHub::get())
2971 }
2972 fn worst_case_holding(_depositable_count: u32) -> Assets {
2973 vec![Asset{
2975 id: AssetId(TokenLocation::get()),
2976 fun: Fungible(1_000_000 * UNITS),
2977 }].into()
2978 }
2979 }
2980
2981 parameter_types! {
2982 pub TrustedTeleporter: Option<(Location, Asset)> = Some((
2983 AssetHub::get(),
2984 Asset { fun: Fungible(1 * UNITS), id: AssetId(TokenLocation::get()) },
2985 ));
2986 pub const TrustedReserve: Option<(Location, Asset)> = None;
2987 pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
2988 }
2989
2990 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
2991 type TransactAsset = Balances;
2992
2993 type CheckedAccount = CheckedAccount;
2994 type TrustedTeleporter = TrustedTeleporter;
2995 type TrustedReserve = TrustedReserve;
2996
2997 fn get_asset() -> Asset {
2998 Asset {
2999 id: AssetId(TokenLocation::get()),
3000 fun: Fungible(1 * UNITS),
3001 }
3002 }
3003 }
3004
3005 impl pallet_xcm_benchmarks::generic::Config for Runtime {
3006 type TransactAsset = Balances;
3007 type RuntimeCall = RuntimeCall;
3008
3009 fn worst_case_response() -> (u64, Response) {
3010 (0u64, Response::Version(Default::default()))
3011 }
3012
3013 fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
3014 Err(BenchmarkError::Skip)
3016 }
3017
3018 fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
3019 Err(BenchmarkError::Skip)
3021 }
3022
3023 fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
3024 Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
3025 }
3026
3027 fn subscribe_origin() -> Result<Location, BenchmarkError> {
3028 Ok(AssetHub::get())
3029 }
3030
3031 fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
3032 let origin = AssetHub::get();
3033 let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
3034 let ticket = Location { parents: 0, interior: Here };
3035 Ok((origin, ticket, assets))
3036 }
3037
3038 fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
3039 Ok((Asset {
3040 id: AssetId(TokenLocation::get()),
3041 fun: Fungible(1_000_000 * UNITS),
3042 }, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
3043 }
3044
3045 fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
3046 Err(BenchmarkError::Skip)
3048 }
3049
3050 fn export_message_origin_and_destination(
3051 ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
3052 Err(BenchmarkError::Skip)
3054 }
3055
3056 fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
3057 let origin = Location::new(0, [Parachain(1000)]);
3058 let target = Location::new(0, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]);
3059 Ok((origin, target))
3060 }
3061 }
3062
3063 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
3064 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
3065
3066 let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
3067
3068 let mut batches = Vec::<BenchmarkBatch>::new();
3069 let params = (&config, &whitelist);
3070
3071 add_benchmarks!(params, batches);
3072
3073 Ok(batches)
3074 }
3075 }
3076
3077 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
3078 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
3079 build_state::<RuntimeGenesisConfig>(config)
3080 }
3081
3082 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
3083 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
3084 }
3085
3086 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
3087 genesis_config_presets::preset_names()
3088 }
3089 }
3090
3091 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
3092 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
3093 XcmPallet::is_trusted_reserve(asset, location)
3094 }
3095 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
3096 XcmPallet::is_trusted_teleporter(asset, location)
3097 }
3098 }
3099}