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