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