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 async_backing::Constraints, slashing, AccountId, AccountIndex, ApprovalVotingParams, Balance,
58 BlockNumber, CandidateEvent, CandidateHash,
59 CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState,
60 ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage,
61 InboundHrmpMessage, Moment, NodeFeatures, Nonce, OccupiedCoreAssumption,
62 PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, Signature,
63 ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
64 PARACHAIN_KEY_TYPE_ID,
65};
66use polkadot_runtime_common::{
67 assigned_slots, auctions, crowdloan,
68 elections::OnChainAccuracy,
69 identity_migrator, impl_runtime_weights,
70 impls::{
71 ContainsParts, LocatableAssetConverter, ToAuthor, VersionedLocatableAsset,
72 VersionedLocationConverter,
73 },
74 paras_registrar, paras_sudo_wrapper, prod_or_fast, slots,
75 traits::OnSwap,
76 BalanceToU256, BlockHashCount, BlockLength, SlowAdjustingFeeUpdate, U256ToBalance,
77};
78use polkadot_runtime_parachains::{
79 assigner_coretime as parachains_assigner_coretime, configuration as parachains_configuration,
80 configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
81 coretime, disputes as parachains_disputes,
82 disputes::slashing as parachains_slashing,
83 dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
84 inclusion::{AggregateMessageOrigin, UmpQueueId},
85 initializer as parachains_initializer, on_demand as parachains_on_demand,
86 origin as parachains_origin, paras as parachains_paras,
87 paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points,
88 runtime_api_impl::{
89 v13 as parachains_runtime_api_impl, vstaging as parachains_staging_runtime_api_impl,
90 },
91 scheduler as parachains_scheduler, session_info as parachains_session_info,
92 shared as parachains_shared,
93};
94use scale_info::TypeInfo;
95use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
96use sp_consensus_beefy::{
97 ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
98 mmr::{BeefyDataProvider, MmrLeafVersion},
99};
100use sp_core::{ConstBool, ConstU8, ConstUint, OpaqueMetadata, RuntimeDebug, H256};
101#[cfg(any(feature = "std", test))]
102pub use sp_runtime::BuildStorage;
103use sp_runtime::{
104 generic, impl_opaque_keys,
105 traits::{
106 AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, Get, IdentityLookup,
107 Keccak256, OpaqueKeys, SaturatedConversion, Verify,
108 },
109 transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
110 ApplyExtrinsicResult, FixedU128, KeyTypeId, MultiSignature, MultiSigner, Percent,
111};
112use sp_staking::{EraIndex, SessionIndex};
113#[cfg(any(feature = "std", test))]
114use sp_version::NativeVersion;
115use sp_version::RuntimeVersion;
116use xcm::{
117 latest::prelude::*, Version as XcmVersion, VersionedAsset, VersionedAssetId, VersionedAssets,
118 VersionedLocation, VersionedXcm,
119};
120use xcm_builder::PayOverXcm;
121use xcm_runtime_apis::{
122 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
123 fees::Error as XcmPaymentApiError,
124};
125
126pub use frame_system::Call as SystemCall;
127pub use pallet_balances::Call as BalancesCall;
128pub use pallet_election_provider_multi_phase::{Call as EPMCall, GeometricDepositBase};
129pub use pallet_timestamp::Call as TimestampCall;
130
131use westend_runtime_constants::{
133 currency::*,
134 fee::*,
135 system_parachain::{coretime::TIMESLICE_PERIOD, ASSET_HUB_ID, BROKER_ID},
136 time::*,
137};
138
139mod bag_thresholds;
140mod genesis_config_presets;
141mod weights;
142pub mod xcm_config;
143
144mod impls;
146use impls::ToParachainIdentityReaper;
147
148pub mod governance;
150use governance::{
151 pallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin, LeaseAdmin, StakingAdmin,
152 Treasurer, TreasurySpender,
153};
154use xcm_config::XcmConfig;
155
156#[cfg(test)]
157mod tests;
158
159impl_runtime_weights!(westend_runtime_constants);
160
161#[cfg(feature = "std")]
163include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
164
165#[cfg(feature = "std")]
166pub mod fast_runtime_binary {
167 include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
168}
169
170#[sp_version::runtime_version]
172pub const VERSION: RuntimeVersion = RuntimeVersion {
173 spec_name: alloc::borrow::Cow::Borrowed("westend"),
174 impl_name: alloc::borrow::Cow::Borrowed("parity-westend"),
175 authoring_version: 2,
176 spec_version: 1_021_001,
177 impl_version: 0,
178 apis: RUNTIME_API_VERSIONS,
179 transaction_version: 27,
180 system_version: 1,
181};
182
183pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
185 sp_consensus_babe::BabeEpochConfiguration {
186 c: PRIMARY_PROBABILITY,
187 allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots,
188 };
189
190#[cfg(any(feature = "std", test))]
192pub fn native_version() -> NativeVersion {
193 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
194}
195
196pub struct IsIdentityCall;
201impl Contains<RuntimeCall> for IsIdentityCall {
202 fn contains(c: &RuntimeCall) -> bool {
203 matches!(c, RuntimeCall::Identity(_))
204 }
205}
206
207parameter_types! {
208 pub const Version: RuntimeVersion = VERSION;
209 pub const SS58Prefix: u8 = 42;
210}
211
212#[derive_impl(frame_system::config_preludes::RelayChainDefaultConfig)]
213impl frame_system::Config for Runtime {
214 type BlockWeights = BlockWeights;
215 type BlockLength = BlockLength;
216 type Nonce = Nonce;
217 type Hash = Hash;
218 type AccountId = AccountId;
219 type Block = Block;
220 type BlockHashCount = BlockHashCount;
221 type DbWeight = RocksDbWeight;
222 type Version = Version;
223 type AccountData = pallet_balances::AccountData<Balance>;
224 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
225 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
226 type SS58Prefix = SS58Prefix;
227 type MaxConsumers = frame_support::traits::ConstU32<16>;
228 type MultiBlockMigrator = MultiBlockMigrations;
229 type SingleBlockMigrations = Migrations;
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 TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
927 pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
928 pub TreasuryInteriorLocation: InteriorLocation = PalletInstance(37).into();
931
932 pub const TipCountdown: BlockNumber = 1 * DAYS;
933 pub const TipFindersFee: Percent = Percent::from_percent(20);
934 pub const TipReportDepositBase: Balance = 100 * CENTS;
935 pub const DataDepositPerByte: Balance = 1 * CENTS;
936 pub const MaxApprovals: u32 = 100;
937 pub const MaxAuthorities: u32 = 100_000;
938 pub const MaxKeys: u32 = 10_000;
939 pub const MaxPeerInHeartbeats: u32 = 10_000;
940 pub const MaxBalance: Balance = Balance::max_value();
941}
942
943impl pallet_treasury::Config for Runtime {
944 type PalletId = TreasuryPalletId;
945 type Currency = Balances;
946 type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
947 type RuntimeEvent = RuntimeEvent;
948 type SpendPeriod = SpendPeriod;
949 type Burn = ();
950 type BurnDestination = ();
951 type MaxApprovals = MaxApprovals;
952 type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
953 type SpendFunds = ();
954 type SpendOrigin = TreasurySpender;
955 type AssetKind = VersionedLocatableAsset;
956 type Beneficiary = VersionedLocation;
957 type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
958 type Paymaster = PayOverXcm<
959 TreasuryInteriorLocation,
960 crate::xcm_config::XcmRouter,
961 crate::XcmPallet,
962 ConstU32<{ 6 * HOURS }>,
963 Self::Beneficiary,
964 Self::AssetKind,
965 LocatableAssetConverter,
966 VersionedLocationConverter,
967 >;
968 type BalanceConverter = UnityOrOuterConversion<
969 ContainsParts<
970 FromContains<
971 xcm_builder::IsChildSystemParachain<ParaId>,
972 xcm_builder::IsParentsOnly<ConstU8<1>>,
973 >,
974 >,
975 AssetRate,
976 >;
977 type PayoutPeriod = PayoutSpendPeriod;
978 type BlockNumberProvider = System;
979 #[cfg(feature = "runtime-benchmarks")]
980 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments;
981}
982
983impl pallet_offences::Config for Runtime {
984 type RuntimeEvent = RuntimeEvent;
985 type IdentificationTuple = session_historical::IdentificationTuple<Self>;
986 type OnOffenceHandler = StakingAhClient;
987}
988
989impl pallet_authority_discovery::Config for Runtime {
990 type MaxAuthorities = MaxAuthorities;
991}
992
993parameter_types! {
994 pub const NposSolutionPriority: TransactionPriority = TransactionPriority::max_value() / 2;
995}
996
997parameter_types! {
998 pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
999}
1000
1001impl pallet_grandpa::Config for Runtime {
1002 type RuntimeEvent = RuntimeEvent;
1003
1004 type WeightInfo = ();
1005 type MaxAuthorities = MaxAuthorities;
1006 type MaxNominators = MaxNominators;
1007 type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
1008
1009 type KeyOwnerProof = sp_session::MembershipProof;
1010
1011 type EquivocationReportSystem =
1012 pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
1013}
1014
1015impl frame_system::offchain::SigningTypes for Runtime {
1016 type Public = <Signature as Verify>::Signer;
1017 type Signature = Signature;
1018}
1019
1020impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
1021where
1022 RuntimeCall: From<C>,
1023{
1024 type RuntimeCall = RuntimeCall;
1025 type Extrinsic = UncheckedExtrinsic;
1026}
1027
1028impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
1029where
1030 RuntimeCall: From<LocalCall>,
1031{
1032 type Extension = TxExtension;
1033
1034 fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
1035 UncheckedExtrinsic::new_transaction(call, extension)
1036 }
1037}
1038
1039impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
1042where
1043 RuntimeCall: From<LocalCall>,
1044{
1045 fn create_signed_transaction<
1046 C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
1047 >(
1048 call: RuntimeCall,
1049 public: <Signature as Verify>::Signer,
1050 account: AccountId,
1051 nonce: <Runtime as frame_system::Config>::Nonce,
1052 ) -> Option<UncheckedExtrinsic> {
1053 use sp_runtime::traits::StaticLookup;
1054 let period =
1056 BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
1057
1058 let current_block = System::block_number()
1059 .saturated_into::<u64>()
1060 .saturating_sub(1);
1063 let tip = 0;
1064 let tx_ext: TxExtension = (
1065 frame_system::AuthorizeCall::<Runtime>::new(),
1066 frame_system::CheckNonZeroSender::<Runtime>::new(),
1067 frame_system::CheckSpecVersion::<Runtime>::new(),
1068 frame_system::CheckTxVersion::<Runtime>::new(),
1069 frame_system::CheckGenesis::<Runtime>::new(),
1070 frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(
1071 period,
1072 current_block,
1073 )),
1074 frame_system::CheckNonce::<Runtime>::from(nonce),
1075 frame_system::CheckWeight::<Runtime>::new(),
1076 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
1077 frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(true),
1078 frame_system::WeightReclaim::<Runtime>::new(),
1079 )
1080 .into();
1081 let raw_payload = SignedPayload::new(call, tx_ext)
1082 .map_err(|e| {
1083 log::warn!("Unable to create signed payload: {:?}", e);
1084 })
1085 .ok()?;
1086 let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
1087 let (call, tx_ext, _) = raw_payload.deconstruct();
1088 let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
1089 let transaction = UncheckedExtrinsic::new_signed(call, address, signature, tx_ext);
1090 Some(transaction)
1091 }
1092}
1093
1094impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
1095where
1096 RuntimeCall: From<LocalCall>,
1097{
1098 fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
1099 UncheckedExtrinsic::new_bare(call)
1100 }
1101}
1102
1103impl<LocalCall> frame_system::offchain::CreateAuthorizedTransaction<LocalCall> for Runtime
1104where
1105 RuntimeCall: From<LocalCall>,
1106{
1107 fn create_extension() -> Self::Extension {
1108 (
1109 frame_system::AuthorizeCall::<Runtime>::new(),
1110 frame_system::CheckNonZeroSender::<Runtime>::new(),
1111 frame_system::CheckSpecVersion::<Runtime>::new(),
1112 frame_system::CheckTxVersion::<Runtime>::new(),
1113 frame_system::CheckGenesis::<Runtime>::new(),
1114 frame_system::CheckMortality::<Runtime>::from(generic::Era::Immortal),
1115 frame_system::CheckNonce::<Runtime>::from(0),
1116 frame_system::CheckWeight::<Runtime>::new(),
1117 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
1118 frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
1119 frame_system::WeightReclaim::<Runtime>::new(),
1120 )
1121 }
1122}
1123
1124parameter_types! {
1125 pub const BasicDeposit: Balance = 1000 * CENTS; pub const ByteDeposit: Balance = deposit(0, 1);
1128 pub const UsernameDeposit: Balance = deposit(0, 32);
1129 pub const SubAccountDeposit: Balance = 200 * CENTS; pub const MaxSubAccounts: u32 = 100;
1131 pub const MaxAdditionalFields: u32 = 100;
1132 pub const MaxRegistrars: u32 = 20;
1133}
1134
1135impl pallet_identity::Config for Runtime {
1136 type RuntimeEvent = RuntimeEvent;
1137 type Currency = Balances;
1138 type Slashed = ();
1139 type BasicDeposit = BasicDeposit;
1140 type ByteDeposit = ByteDeposit;
1141 type UsernameDeposit = UsernameDeposit;
1142 type SubAccountDeposit = SubAccountDeposit;
1143 type MaxSubAccounts = MaxSubAccounts;
1144 type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
1145 type MaxRegistrars = MaxRegistrars;
1146 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
1147 type RegistrarOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
1148 type OffchainSignature = Signature;
1149 type SigningPublicKey = <Signature as Verify>::Signer;
1150 type UsernameAuthorityOrigin = EnsureRoot<Self::AccountId>;
1151 type PendingUsernameExpiration = ConstU32<{ 7 * DAYS }>;
1152 type UsernameGracePeriod = ConstU32<{ 30 * DAYS }>;
1153 type MaxSuffixLength = ConstU32<7>;
1154 type MaxUsernameLength = ConstU32<32>;
1155 #[cfg(feature = "runtime-benchmarks")]
1156 type BenchmarkHelper = ();
1157 type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
1158}
1159
1160impl pallet_utility::Config for Runtime {
1161 type RuntimeEvent = RuntimeEvent;
1162 type RuntimeCall = RuntimeCall;
1163 type PalletsOrigin = OriginCaller;
1164 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
1165}
1166
1167parameter_types! {
1168 pub const DepositBase: Balance = deposit(1, 88);
1170 pub const DepositFactor: Balance = deposit(0, 32);
1172 pub const MaxSignatories: u32 = 100;
1173}
1174
1175impl pallet_multisig::Config for Runtime {
1176 type RuntimeEvent = RuntimeEvent;
1177 type RuntimeCall = RuntimeCall;
1178 type Currency = Balances;
1179 type DepositBase = DepositBase;
1180 type DepositFactor = DepositFactor;
1181 type MaxSignatories = MaxSignatories;
1182 type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
1183 type BlockNumberProvider = frame_system::Pallet<Runtime>;
1184}
1185
1186parameter_types! {
1187 pub const ConfigDepositBase: Balance = 500 * CENTS;
1188 pub const FriendDepositFactor: Balance = 50 * CENTS;
1189 pub const MaxFriends: u16 = 9;
1190 pub const RecoveryDeposit: Balance = 500 * CENTS;
1191}
1192
1193impl pallet_recovery::Config for Runtime {
1194 type RuntimeEvent = RuntimeEvent;
1195 type WeightInfo = ();
1196 type RuntimeCall = RuntimeCall;
1197 type BlockNumberProvider = System;
1198 type Currency = Balances;
1199 type ConfigDepositBase = ConfigDepositBase;
1200 type FriendDepositFactor = FriendDepositFactor;
1201 type MaxFriends = MaxFriends;
1202 type RecoveryDeposit = RecoveryDeposit;
1203}
1204
1205parameter_types! {
1206 pub const MinVestedTransfer: Balance = 100 * CENTS;
1207 pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
1208 WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
1209}
1210
1211impl pallet_vesting::Config for Runtime {
1212 type RuntimeEvent = RuntimeEvent;
1213 type Currency = Balances;
1214 type BlockNumberToBalance = ConvertInto;
1215 type MinVestedTransfer = MinVestedTransfer;
1216 type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
1217 type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
1218 type BlockNumberProvider = System;
1219 const MAX_VESTING_SCHEDULES: u32 = 28;
1220}
1221
1222impl pallet_sudo::Config for Runtime {
1223 type RuntimeEvent = RuntimeEvent;
1224 type RuntimeCall = RuntimeCall;
1225 type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
1226}
1227
1228parameter_types! {
1229 pub const ProxyDepositBase: Balance = deposit(1, 8);
1231 pub const ProxyDepositFactor: Balance = deposit(0, 33);
1233 pub const MaxProxies: u16 = 32;
1234 pub const AnnouncementDepositBase: Balance = deposit(1, 8);
1235 pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
1236 pub const MaxPending: u16 = 32;
1237}
1238
1239#[derive(
1241 Copy,
1242 Clone,
1243 Eq,
1244 PartialEq,
1245 Ord,
1246 PartialOrd,
1247 Encode,
1248 Decode,
1249 DecodeWithMemTracking,
1250 RuntimeDebug,
1251 MaxEncodedLen,
1252 TypeInfo,
1253)]
1254pub enum ProxyType {
1255 Any,
1256 NonTransfer,
1257 Governance,
1258 Staking,
1259 SudoBalances,
1260 IdentityJudgement,
1261 CancelProxy,
1262 Auction,
1263 NominationPools,
1264 ParaRegistration,
1265}
1266impl Default for ProxyType {
1267 fn default() -> Self {
1268 Self::Any
1269 }
1270}
1271impl InstanceFilter<RuntimeCall> for ProxyType {
1272 fn filter(&self, c: &RuntimeCall) -> bool {
1273 match self {
1274 ProxyType::Any => true,
1275 ProxyType::NonTransfer => matches!(
1276 c,
1277 RuntimeCall::System(..) |
1278 RuntimeCall::Babe(..) |
1279 RuntimeCall::Timestamp(..) |
1280 RuntimeCall::Indices(pallet_indices::Call::claim{..}) |
1281 RuntimeCall::Indices(pallet_indices::Call::free{..}) |
1282 RuntimeCall::Indices(pallet_indices::Call::freeze{..}) |
1283 RuntimeCall::Staking(..) |
1286 RuntimeCall::Session(..) |
1287 RuntimeCall::Grandpa(..) |
1288 RuntimeCall::Utility(..) |
1289 RuntimeCall::Identity(..) |
1290 RuntimeCall::ConvictionVoting(..) |
1291 RuntimeCall::Referenda(..) |
1292 RuntimeCall::Whitelist(..) |
1293 RuntimeCall::Recovery(pallet_recovery::Call::as_recovered{..}) |
1294 RuntimeCall::Recovery(pallet_recovery::Call::vouch_recovery{..}) |
1295 RuntimeCall::Recovery(pallet_recovery::Call::claim_recovery{..}) |
1296 RuntimeCall::Recovery(pallet_recovery::Call::close_recovery{..}) |
1297 RuntimeCall::Recovery(pallet_recovery::Call::remove_recovery{..}) |
1298 RuntimeCall::Recovery(pallet_recovery::Call::cancel_recovered{..}) |
1299 RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) |
1301 RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) |
1302 RuntimeCall::Scheduler(..) |
1304 RuntimeCall::Proxy(..) |
1306 RuntimeCall::Multisig(..) |
1307 RuntimeCall::Registrar(paras_registrar::Call::register{..}) |
1308 RuntimeCall::Registrar(paras_registrar::Call::deregister{..}) |
1309 RuntimeCall::Registrar(paras_registrar::Call::reserve{..}) |
1311 RuntimeCall::Crowdloan(..) |
1312 RuntimeCall::Slots(..) |
1313 RuntimeCall::Auctions(..) | RuntimeCall::VoterList(..) |
1315 RuntimeCall::NominationPools(..) |
1316 RuntimeCall::FastUnstake(..)
1317 ),
1318 ProxyType::Staking => {
1319 matches!(
1320 c,
1321 RuntimeCall::Staking(..) |
1322 RuntimeCall::Session(..) |
1323 RuntimeCall::Utility(..) |
1324 RuntimeCall::FastUnstake(..) |
1325 RuntimeCall::VoterList(..) |
1326 RuntimeCall::NominationPools(..)
1327 )
1328 },
1329 ProxyType::NominationPools => {
1330 matches!(c, RuntimeCall::NominationPools(..) | RuntimeCall::Utility(..))
1331 },
1332 ProxyType::SudoBalances => match c {
1333 RuntimeCall::Sudo(pallet_sudo::Call::sudo { call: ref x }) => {
1334 matches!(x.as_ref(), &RuntimeCall::Balances(..))
1335 },
1336 RuntimeCall::Utility(..) => true,
1337 _ => false,
1338 },
1339 ProxyType::Governance => matches!(
1340 c,
1341 RuntimeCall::ConvictionVoting(..) |
1343 RuntimeCall::Referenda(..) |
1344 RuntimeCall::Whitelist(..)
1345 ),
1346 ProxyType::IdentityJudgement => matches!(
1347 c,
1348 RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
1349 RuntimeCall::Utility(..)
1350 ),
1351 ProxyType::CancelProxy => {
1352 matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }))
1353 },
1354 ProxyType::Auction => matches!(
1355 c,
1356 RuntimeCall::Auctions(..) |
1357 RuntimeCall::Crowdloan(..) |
1358 RuntimeCall::Registrar(..) |
1359 RuntimeCall::Slots(..)
1360 ),
1361 ProxyType::ParaRegistration => matches!(
1362 c,
1363 RuntimeCall::Registrar(paras_registrar::Call::reserve { .. }) |
1364 RuntimeCall::Registrar(paras_registrar::Call::register { .. }) |
1365 RuntimeCall::Utility(pallet_utility::Call::batch { .. }) |
1366 RuntimeCall::Utility(pallet_utility::Call::batch_all { .. }) |
1367 RuntimeCall::Utility(pallet_utility::Call::force_batch { .. }) |
1368 RuntimeCall::Proxy(pallet_proxy::Call::remove_proxy { .. })
1369 ),
1370 }
1371 }
1372 fn is_superset(&self, o: &Self) -> bool {
1373 match (self, o) {
1374 (x, y) if x == y => true,
1375 (ProxyType::Any, _) => true,
1376 (_, ProxyType::Any) => false,
1377 (ProxyType::NonTransfer, _) => true,
1378 _ => false,
1379 }
1380 }
1381}
1382
1383impl pallet_proxy::Config for Runtime {
1384 type RuntimeEvent = RuntimeEvent;
1385 type RuntimeCall = RuntimeCall;
1386 type Currency = Balances;
1387 type ProxyType = ProxyType;
1388 type ProxyDepositBase = ProxyDepositBase;
1389 type ProxyDepositFactor = ProxyDepositFactor;
1390 type MaxProxies = MaxProxies;
1391 type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
1392 type MaxPending = MaxPending;
1393 type CallHasher = BlakeTwo256;
1394 type AnnouncementDepositBase = AnnouncementDepositBase;
1395 type AnnouncementDepositFactor = AnnouncementDepositFactor;
1396 type BlockNumberProvider = frame_system::Pallet<Runtime>;
1397}
1398
1399impl parachains_origin::Config for Runtime {}
1400
1401impl parachains_configuration::Config for Runtime {
1402 type WeightInfo = weights::polkadot_runtime_parachains_configuration::WeightInfo<Runtime>;
1403}
1404
1405impl parachains_shared::Config for Runtime {
1406 type DisabledValidators = Session;
1407}
1408
1409impl parachains_session_info::Config for Runtime {
1410 type ValidatorSet = Historical;
1411}
1412
1413impl parachains_inclusion::Config for Runtime {
1414 type RuntimeEvent = RuntimeEvent;
1415 type DisputesHandler = ParasDisputes;
1416 type RewardValidators =
1417 parachains_reward_points::RewardValidatorsWithEraPoints<Runtime, StakingAhClient>;
1418 type MessageQueue = MessageQueue;
1419 type WeightInfo = weights::polkadot_runtime_parachains_inclusion::WeightInfo<Runtime>;
1420}
1421
1422parameter_types! {
1423 pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
1424}
1425
1426impl parachains_paras::Config for Runtime {
1427 type RuntimeEvent = RuntimeEvent;
1428 type WeightInfo = weights::polkadot_runtime_parachains_paras::WeightInfo<Runtime>;
1429 type UnsignedPriority = ParasUnsignedPriority;
1430 type QueueFootprinter = ParaInclusion;
1431 type NextSessionRotation = Babe;
1432 type OnNewHead = ();
1433 type AssignCoretime = CoretimeAssignmentProvider;
1434 type Fungible = Balances;
1435 type CooldownRemovalMultiplier = ConstUint<{ 1000 * UNITS / DAYS as u128 }>;
1437 type AuthorizeCurrentCodeOrigin = EitherOfDiverse<
1438 EnsureRoot<AccountId>,
1439 AsEnsureOriginWithArg<
1441 EnsureXcm<IsVoiceOfBody<xcm_config::Collectives, xcm_config::DDayBodyId>>,
1442 >,
1443 >;
1444}
1445
1446parameter_types! {
1447 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(20) * BlockWeights::get().max_block;
1453 pub const MessageQueueHeapSize: u32 = 128 * 1024;
1454 pub const MessageQueueMaxStale: u32 = 48;
1455}
1456
1457pub struct MessageProcessor;
1459impl ProcessMessage for MessageProcessor {
1460 type Origin = AggregateMessageOrigin;
1461
1462 fn process_message(
1463 message: &[u8],
1464 origin: Self::Origin,
1465 meter: &mut WeightMeter,
1466 id: &mut [u8; 32],
1467 ) -> Result<bool, ProcessMessageError> {
1468 let para = match origin {
1469 AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para,
1470 };
1471 xcm_builder::ProcessXcmMessage::<
1472 Junction,
1473 xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
1474 RuntimeCall,
1475 >::process_message(message, Junction::Parachain(para.into()), meter, id)
1476 }
1477}
1478
1479impl pallet_message_queue::Config for Runtime {
1480 type RuntimeEvent = RuntimeEvent;
1481 type Size = u32;
1482 type HeapSize = MessageQueueHeapSize;
1483 type MaxStale = MessageQueueMaxStale;
1484 type ServiceWeight = MessageQueueServiceWeight;
1485 type IdleMaxServiceWeight = MessageQueueServiceWeight;
1486 #[cfg(not(feature = "runtime-benchmarks"))]
1487 type MessageProcessor = MessageProcessor;
1488 #[cfg(feature = "runtime-benchmarks")]
1489 type MessageProcessor =
1490 pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
1491 type QueueChangeHandler = ParaInclusion;
1492 type QueuePausedQuery = ();
1493 type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
1494}
1495
1496impl parachains_dmp::Config for Runtime {}
1497
1498parameter_types! {
1499 pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
1500}
1501
1502impl parachains_hrmp::Config for Runtime {
1503 type RuntimeOrigin = RuntimeOrigin;
1504 type RuntimeEvent = RuntimeEvent;
1505 type ChannelManager = EnsureRoot<AccountId>;
1506 type Currency = Balances;
1507 type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
1508 Runtime,
1509 HrmpChannelSizeAndCapacityWithSystemRatio,
1510 >;
1511 type VersionWrapper = crate::XcmPallet;
1512 type WeightInfo = weights::polkadot_runtime_parachains_hrmp::WeightInfo<Self>;
1513}
1514
1515impl parachains_paras_inherent::Config for Runtime {
1516 type WeightInfo = weights::polkadot_runtime_parachains_paras_inherent::WeightInfo<Runtime>;
1517}
1518
1519impl parachains_scheduler::Config for Runtime {
1520 type AssignmentProvider = CoretimeAssignmentProvider;
1523}
1524
1525parameter_types! {
1526 pub const BrokerId: u32 = BROKER_ID;
1527 pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
1528 pub MaxXcmTransactWeight: Weight = Weight::from_parts(200_000_000, 20_000);
1529}
1530
1531pub struct BrokerPot;
1532impl Get<InteriorLocation> for BrokerPot {
1533 fn get() -> InteriorLocation {
1534 Junction::AccountId32 { network: None, id: BrokerPalletId::get().into_account_truncating() }
1535 .into()
1536 }
1537}
1538
1539impl coretime::Config for Runtime {
1540 type RuntimeOrigin = RuntimeOrigin;
1541 type RuntimeEvent = RuntimeEvent;
1542 type BrokerId = BrokerId;
1543 type BrokerPotLocation = BrokerPot;
1544 type WeightInfo = weights::polkadot_runtime_parachains_coretime::WeightInfo<Runtime>;
1545 type SendXcm = crate::xcm_config::XcmRouter;
1546 type AssetTransactor = crate::xcm_config::LocalAssetTransactor;
1547 type AccountToLocation = xcm_builder::AliasesIntoAccountId32<
1548 xcm_config::ThisNetwork,
1549 <Runtime as frame_system::Config>::AccountId,
1550 >;
1551 type MaxXcmTransactWeight = MaxXcmTransactWeight;
1552}
1553
1554parameter_types! {
1555 pub const OnDemandTrafficDefaultValue: FixedU128 = FixedU128::from_u32(1);
1556 pub const MaxHistoricalRevenue: BlockNumber = 2 * TIMESLICE_PERIOD;
1558 pub const OnDemandPalletId: PalletId = PalletId(*b"py/ondmd");
1559}
1560
1561impl parachains_on_demand::Config for Runtime {
1562 type RuntimeEvent = RuntimeEvent;
1563 type Currency = Balances;
1564 type TrafficDefaultValue = OnDemandTrafficDefaultValue;
1565 type WeightInfo = weights::polkadot_runtime_parachains_on_demand::WeightInfo<Runtime>;
1566 type MaxHistoricalRevenue = MaxHistoricalRevenue;
1567 type PalletId = OnDemandPalletId;
1568}
1569
1570impl parachains_assigner_coretime::Config for Runtime {}
1571
1572impl parachains_initializer::Config for Runtime {
1573 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1574 type ForceOrigin = EnsureRoot<AccountId>;
1575 type WeightInfo = weights::polkadot_runtime_parachains_initializer::WeightInfo<Runtime>;
1576 type CoretimeOnNewSession = Coretime;
1577}
1578
1579impl paras_sudo_wrapper::Config for Runtime {}
1580
1581parameter_types! {
1582 pub const PermanentSlotLeasePeriodLength: u32 = 26;
1583 pub const TemporarySlotLeasePeriodLength: u32 = 1;
1584 pub const MaxTemporarySlotPerLeasePeriod: u32 = 5;
1585}
1586
1587impl assigned_slots::Config for Runtime {
1588 type RuntimeEvent = RuntimeEvent;
1589 type AssignSlotOrigin = EnsureRoot<AccountId>;
1590 type Leaser = Slots;
1591 type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
1592 type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength;
1593 type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod;
1594 type WeightInfo = weights::polkadot_runtime_common_assigned_slots::WeightInfo<Runtime>;
1595}
1596
1597impl parachains_disputes::Config for Runtime {
1598 type RuntimeEvent = RuntimeEvent;
1599 type RewardValidators =
1600 parachains_reward_points::RewardValidatorsWithEraPoints<Runtime, StakingAhClient>;
1601 type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes<ParasSlashing>;
1602 type WeightInfo = weights::polkadot_runtime_parachains_disputes::WeightInfo<Runtime>;
1603}
1604
1605impl parachains_slashing::Config for Runtime {
1606 type KeyOwnerProofSystem = Historical;
1607 type KeyOwnerProof =
1608 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
1609 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
1610 KeyTypeId,
1611 ValidatorId,
1612 )>>::IdentificationTuple;
1613 type HandleReports = parachains_slashing::SlashingReportHandler<
1614 Self::KeyOwnerIdentification,
1615 Offences,
1616 ReportLongevity,
1617 >;
1618 type WeightInfo = weights::polkadot_runtime_parachains_disputes_slashing::WeightInfo<Runtime>;
1619 type BenchmarkingConfig = parachains_slashing::BenchConfig<300>;
1620}
1621
1622parameter_types! {
1623 pub const ParaDeposit: Balance = 2000 * CENTS;
1624 pub const RegistrarDataDepositPerByte: Balance = deposit(0, 1);
1625}
1626
1627impl paras_registrar::Config for Runtime {
1628 type RuntimeOrigin = RuntimeOrigin;
1629 type RuntimeEvent = RuntimeEvent;
1630 type Currency = Balances;
1631 type OnSwap = (Crowdloan, Slots, SwapLeases);
1632 type ParaDeposit = ParaDeposit;
1633 type DataDepositPerByte = RegistrarDataDepositPerByte;
1634 type WeightInfo = weights::polkadot_runtime_common_paras_registrar::WeightInfo<Runtime>;
1635}
1636
1637parameter_types! {
1638 pub const LeasePeriod: BlockNumber = 28 * DAYS;
1639}
1640
1641impl slots::Config for Runtime {
1642 type RuntimeEvent = RuntimeEvent;
1643 type Currency = Balances;
1644 type Registrar = Registrar;
1645 type LeasePeriod = LeasePeriod;
1646 type LeaseOffset = ();
1647 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, LeaseAdmin>;
1648 type WeightInfo = weights::polkadot_runtime_common_slots::WeightInfo<Runtime>;
1649}
1650
1651parameter_types! {
1652 pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
1653 pub const SubmissionDeposit: Balance = 100 * 100 * CENTS;
1654 pub const MinContribution: Balance = 100 * CENTS;
1655 pub const RemoveKeysLimit: u32 = 500;
1656 pub const MaxMemoLength: u8 = 32;
1658}
1659
1660impl crowdloan::Config for Runtime {
1661 type RuntimeEvent = RuntimeEvent;
1662 type PalletId = CrowdloanId;
1663 type SubmissionDeposit = SubmissionDeposit;
1664 type MinContribution = MinContribution;
1665 type RemoveKeysLimit = RemoveKeysLimit;
1666 type Registrar = Registrar;
1667 type Auctioneer = Auctions;
1668 type MaxMemoLength = MaxMemoLength;
1669 type WeightInfo = weights::polkadot_runtime_common_crowdloan::WeightInfo<Runtime>;
1670}
1671
1672parameter_types! {
1673 pub const EndingPeriod: BlockNumber = 5 * DAYS;
1676 pub const SampleLength: BlockNumber = 2 * MINUTES;
1678}
1679
1680impl auctions::Config for Runtime {
1681 type RuntimeEvent = RuntimeEvent;
1682 type Leaser = Slots;
1683 type Registrar = Registrar;
1684 type EndingPeriod = EndingPeriod;
1685 type SampleLength = SampleLength;
1686 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1687 type InitiateOrigin = EitherOf<EnsureRoot<Self::AccountId>, AuctionAdmin>;
1688 type WeightInfo = weights::polkadot_runtime_common_auctions::WeightInfo<Runtime>;
1689}
1690
1691impl identity_migrator::Config for Runtime {
1692 type RuntimeEvent = RuntimeEvent;
1693 type Reaper = EnsureSigned<AccountId>;
1694 type ReapIdentityHandler = ToParachainIdentityReaper<Runtime, Self::AccountId>;
1695 type WeightInfo = weights::polkadot_runtime_common_identity_migrator::WeightInfo<Runtime>;
1696}
1697
1698parameter_types! {
1699 pub const PoolsPalletId: PalletId = PalletId(*b"py/nopls");
1700 pub const MaxPointsToBalance: u8 = 10;
1701}
1702
1703impl pallet_nomination_pools::Config for Runtime {
1704 type RuntimeEvent = RuntimeEvent;
1705 type WeightInfo = weights::pallet_nomination_pools::WeightInfo<Self>;
1706 type Currency = Balances;
1707 type RuntimeFreezeReason = RuntimeFreezeReason;
1708 type RewardCounter = FixedU128;
1709 type BalanceToU256 = BalanceToU256;
1710 type U256ToBalance = U256ToBalance;
1711 type StakeAdapter =
1712 pallet_nomination_pools::adapter::DelegateStake<Self, Staking, DelegatedStaking>;
1713 type PostUnbondingPoolsWindow = ConstU32<4>;
1714 type MaxMetadataLen = ConstU32<256>;
1715 type MaxUnbonding = <Self as pallet_staking::Config>::MaxUnlockingChunks;
1717 type PalletId = PoolsPalletId;
1718 type MaxPointsToBalance = MaxPointsToBalance;
1719 type AdminOrigin = EitherOf<EnsureRoot<AccountId>, StakingAdmin>;
1720 type BlockNumberProvider = System;
1721 type Filter = Nothing;
1722}
1723
1724parameter_types! {
1725 pub const DelegatedStakingPalletId: PalletId = PalletId(*b"py/dlstk");
1726 pub const SlashRewardFraction: Perbill = Perbill::from_percent(1);
1727}
1728
1729impl pallet_delegated_staking::Config for Runtime {
1730 type RuntimeEvent = RuntimeEvent;
1731 type PalletId = DelegatedStakingPalletId;
1732 type Currency = Balances;
1733 type OnSlash = ();
1734 type SlashRewardFraction = SlashRewardFraction;
1735 type RuntimeHoldReason = RuntimeHoldReason;
1736 type CoreStaking = Staking;
1737}
1738
1739impl pallet_root_testing::Config for Runtime {
1740 type RuntimeEvent = RuntimeEvent;
1741}
1742
1743impl pallet_root_offences::Config for Runtime {
1744 type RuntimeEvent = RuntimeEvent;
1745 type OffenceHandler = StakingAhClient;
1746 type ReportOffence = Offences;
1747}
1748
1749parameter_types! {
1750 pub MbmServiceWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
1751}
1752
1753impl pallet_migrations::Config for Runtime {
1754 type RuntimeEvent = RuntimeEvent;
1755 #[cfg(not(feature = "runtime-benchmarks"))]
1756 type Migrations = pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>;
1757 #[cfg(feature = "runtime-benchmarks")]
1759 type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
1760 type CursorMaxLen = ConstU32<65_536>;
1761 type IdentifierMaxLen = ConstU32<256>;
1762 type MigrationStatusHandler = ();
1763 type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
1764 type MaxServiceWeight = MbmServiceWeight;
1765 type WeightInfo = weights::pallet_migrations::WeightInfo<Runtime>;
1766}
1767
1768parameter_types! {
1769 pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
1771 pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100;
1772 pub const MigrationMaxKeyLen: u32 = 512;
1773}
1774
1775impl pallet_asset_rate::Config for Runtime {
1776 type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
1777 type RuntimeEvent = RuntimeEvent;
1778 type CreateOrigin = EnsureRoot<AccountId>;
1779 type RemoveOrigin = EnsureRoot<AccountId>;
1780 type UpdateOrigin = EnsureRoot<AccountId>;
1781 type Currency = Balances;
1782 type AssetKind = <Runtime as pallet_treasury::Config>::AssetKind;
1783 #[cfg(feature = "runtime-benchmarks")]
1784 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
1785}
1786
1787pub struct SwapLeases;
1789impl OnSwap for SwapLeases {
1790 fn on_swap(one: ParaId, other: ParaId) {
1791 coretime::Pallet::<Runtime>::on_legacy_lease_swap(one, other);
1792 }
1793}
1794
1795pub type MetaTxExtension = (
1796 pallet_verify_signature::VerifySignature<Runtime>,
1797 pallet_meta_tx::MetaTxMarker<Runtime>,
1798 frame_system::CheckNonZeroSender<Runtime>,
1799 frame_system::CheckSpecVersion<Runtime>,
1800 frame_system::CheckTxVersion<Runtime>,
1801 frame_system::CheckGenesis<Runtime>,
1802 frame_system::CheckMortality<Runtime>,
1803 frame_system::CheckNonce<Runtime>,
1804 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
1805);
1806
1807impl pallet_meta_tx::Config for Runtime {
1808 type WeightInfo = weights::pallet_meta_tx::WeightInfo<Runtime>;
1809 type RuntimeEvent = RuntimeEvent;
1810 #[cfg(not(feature = "runtime-benchmarks"))]
1811 type Extension = MetaTxExtension;
1812 #[cfg(feature = "runtime-benchmarks")]
1813 type Extension = pallet_meta_tx::WeightlessExtension<Runtime>;
1814}
1815
1816impl pallet_verify_signature::Config for Runtime {
1817 type Signature = MultiSignature;
1818 type AccountIdentifier = MultiSigner;
1819 type WeightInfo = weights::pallet_verify_signature::WeightInfo<Runtime>;
1820 #[cfg(feature = "runtime-benchmarks")]
1821 type BenchmarkHelper = ();
1822}
1823
1824#[frame_support::runtime(legacy_ordering)]
1825mod runtime {
1826 #[runtime::runtime]
1827 #[runtime::derive(
1828 RuntimeCall,
1829 RuntimeEvent,
1830 RuntimeError,
1831 RuntimeOrigin,
1832 RuntimeFreezeReason,
1833 RuntimeHoldReason,
1834 RuntimeSlashReason,
1835 RuntimeLockId,
1836 RuntimeTask,
1837 RuntimeViewFunction
1838 )]
1839 pub struct Runtime;
1840
1841 #[runtime::pallet_index(0)]
1843 pub type System = frame_system;
1844
1845 #[runtime::pallet_index(1)]
1847 pub type Babe = pallet_babe;
1848
1849 #[runtime::pallet_index(2)]
1850 pub type Timestamp = pallet_timestamp;
1851 #[runtime::pallet_index(3)]
1852 pub type Indices = pallet_indices;
1853 #[runtime::pallet_index(4)]
1854 pub type Balances = pallet_balances;
1855 #[runtime::pallet_index(26)]
1856 pub type TransactionPayment = pallet_transaction_payment;
1857
1858 #[runtime::pallet_index(5)]
1861 pub type Authorship = pallet_authorship;
1862 #[runtime::pallet_index(6)]
1863 pub type Staking = pallet_staking;
1864 #[runtime::pallet_index(7)]
1865 pub type Offences = pallet_offences;
1866 #[runtime::pallet_index(27)]
1867 pub type Historical = session_historical;
1868 #[runtime::pallet_index(70)]
1869 pub type Parameters = pallet_parameters;
1870
1871 #[runtime::pallet_index(8)]
1872 pub type Session = pallet_session;
1873 #[runtime::pallet_index(10)]
1874 pub type Grandpa = pallet_grandpa;
1875 #[runtime::pallet_index(12)]
1876 pub type AuthorityDiscovery = pallet_authority_discovery;
1877
1878 #[runtime::pallet_index(16)]
1880 pub type Utility = pallet_utility;
1881
1882 #[runtime::pallet_index(17)]
1884 pub type Identity = pallet_identity;
1885
1886 #[runtime::pallet_index(18)]
1888 pub type Recovery = pallet_recovery;
1889
1890 #[runtime::pallet_index(19)]
1892 pub type Vesting = pallet_vesting;
1893
1894 #[runtime::pallet_index(20)]
1896 pub type Scheduler = pallet_scheduler;
1897
1898 #[runtime::pallet_index(28)]
1900 pub type Preimage = pallet_preimage;
1901
1902 #[runtime::pallet_index(21)]
1904 pub type Sudo = pallet_sudo;
1905
1906 #[runtime::pallet_index(22)]
1908 pub type Proxy = pallet_proxy;
1909
1910 #[runtime::pallet_index(23)]
1912 pub type Multisig = pallet_multisig;
1913
1914 #[runtime::pallet_index(24)]
1916 pub type ElectionProviderMultiPhase = pallet_election_provider_multi_phase;
1917
1918 #[runtime::pallet_index(25)]
1920 pub type VoterList = pallet_bags_list<Instance1>;
1921
1922 #[runtime::pallet_index(29)]
1924 pub type NominationPools = pallet_nomination_pools;
1925
1926 #[runtime::pallet_index(30)]
1928 pub type FastUnstake = pallet_fast_unstake;
1929
1930 #[runtime::pallet_index(31)]
1932 pub type ConvictionVoting = pallet_conviction_voting;
1933 #[runtime::pallet_index(32)]
1934 pub type Referenda = pallet_referenda;
1935 #[runtime::pallet_index(35)]
1936 pub type Origins = pallet_custom_origins;
1937 #[runtime::pallet_index(36)]
1938 pub type Whitelist = pallet_whitelist;
1939
1940 #[runtime::pallet_index(37)]
1942 pub type Treasury = pallet_treasury;
1943
1944 #[runtime::pallet_index(38)]
1946 pub type DelegatedStaking = pallet_delegated_staking;
1947
1948 #[runtime::pallet_index(41)]
1950 pub type ParachainsOrigin = parachains_origin;
1951 #[runtime::pallet_index(42)]
1952 pub type Configuration = parachains_configuration;
1953 #[runtime::pallet_index(43)]
1954 pub type ParasShared = parachains_shared;
1955 #[runtime::pallet_index(44)]
1956 pub type ParaInclusion = parachains_inclusion;
1957 #[runtime::pallet_index(45)]
1958 pub type ParaInherent = parachains_paras_inherent;
1959 #[runtime::pallet_index(46)]
1960 pub type ParaScheduler = parachains_scheduler;
1961 #[runtime::pallet_index(47)]
1962 pub type Paras = parachains_paras;
1963 #[runtime::pallet_index(48)]
1964 pub type Initializer = parachains_initializer;
1965 #[runtime::pallet_index(49)]
1966 pub type Dmp = parachains_dmp;
1967 #[runtime::pallet_index(51)]
1969 pub type Hrmp = parachains_hrmp;
1970 #[runtime::pallet_index(52)]
1971 pub type ParaSessionInfo = parachains_session_info;
1972 #[runtime::pallet_index(53)]
1973 pub type ParasDisputes = parachains_disputes;
1974 #[runtime::pallet_index(54)]
1975 pub type ParasSlashing = parachains_slashing;
1976 #[runtime::pallet_index(56)]
1977 pub type OnDemandAssignmentProvider = parachains_on_demand;
1978 #[runtime::pallet_index(57)]
1979 pub type CoretimeAssignmentProvider = parachains_assigner_coretime;
1980
1981 #[runtime::pallet_index(60)]
1983 pub type Registrar = paras_registrar;
1984 #[runtime::pallet_index(61)]
1985 pub type Slots = slots;
1986 #[runtime::pallet_index(62)]
1987 pub type ParasSudoWrapper = paras_sudo_wrapper;
1988 #[runtime::pallet_index(63)]
1989 pub type Auctions = auctions;
1990 #[runtime::pallet_index(64)]
1991 pub type Crowdloan = crowdloan;
1992 #[runtime::pallet_index(65)]
1993 pub type AssignedSlots = assigned_slots;
1994 #[runtime::pallet_index(66)]
1995 pub type Coretime = coretime;
1996 #[runtime::pallet_index(67)]
1997 pub type StakingAhClient = pallet_staking_async_ah_client;
1998
1999 #[runtime::pallet_index(98)]
2001 pub type MultiBlockMigrations = pallet_migrations;
2002
2003 #[runtime::pallet_index(99)]
2005 pub type XcmPallet = pallet_xcm;
2006
2007 #[runtime::pallet_index(100)]
2009 pub type MessageQueue = pallet_message_queue;
2010
2011 #[runtime::pallet_index(101)]
2013 pub type AssetRate = pallet_asset_rate;
2014
2015 #[runtime::pallet_index(102)]
2017 pub type RootTesting = pallet_root_testing;
2018
2019 #[runtime::pallet_index(103)]
2020 pub type MetaTx = pallet_meta_tx::Pallet<Runtime>;
2021
2022 #[runtime::pallet_index(104)]
2023 pub type VerifySignature = pallet_verify_signature::Pallet<Runtime>;
2024
2025 #[runtime::pallet_index(105)]
2027 pub type RootOffences = pallet_root_offences;
2028
2029 #[runtime::pallet_index(200)]
2031 pub type Beefy = pallet_beefy;
2032 #[runtime::pallet_index(201)]
2035 pub type Mmr = pallet_mmr;
2036 #[runtime::pallet_index(202)]
2037 pub type BeefyMmrLeaf = pallet_beefy_mmr;
2038
2039 #[runtime::pallet_index(248)]
2041 pub type IdentityMigrator = identity_migrator;
2042}
2043
2044pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
2046pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
2048pub type Block = generic::Block<Header, UncheckedExtrinsic>;
2050pub type SignedBlock = generic::SignedBlock<Block>;
2052pub type BlockId = generic::BlockId<Block>;
2054pub type TxExtension = (
2056 frame_system::AuthorizeCall<Runtime>,
2057 frame_system::CheckNonZeroSender<Runtime>,
2058 frame_system::CheckSpecVersion<Runtime>,
2059 frame_system::CheckTxVersion<Runtime>,
2060 frame_system::CheckGenesis<Runtime>,
2061 frame_system::CheckMortality<Runtime>,
2062 frame_system::CheckNonce<Runtime>,
2063 frame_system::CheckWeight<Runtime>,
2064 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
2065 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
2066 frame_system::WeightReclaim<Runtime>,
2067);
2068
2069parameter_types! {
2070 pub const MaxAgentsToMigrate: u32 = 300;
2072}
2073
2074pub type Migrations = migrations::Unreleased;
2079
2080#[allow(deprecated, missing_docs)]
2082pub mod migrations {
2083 use super::*;
2084
2085 pub type Unreleased = (
2087 pallet_delegated_staking::migration::unversioned::ProxyDelegatorMigration<
2089 Runtime,
2090 MaxAgentsToMigrate,
2091 >,
2092 parachains_shared::migration::MigrateToV1<Runtime>,
2093 parachains_scheduler::migration::MigrateV2ToV3<Runtime>,
2094 pallet_staking::migrations::v16::MigrateV15ToV16<Runtime>,
2095 pallet_session::migrations::v1::MigrateV0ToV1<
2096 Runtime,
2097 pallet_staking::migrations::v17::MigrateDisabledToSession<Runtime>,
2098 >,
2099 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
2101 );
2102}
2103
2104pub type UncheckedExtrinsic =
2106 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
2107pub type UncheckedSignaturePayload =
2109 generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
2110
2111pub type Executive = frame_executive::Executive<
2113 Runtime,
2114 Block,
2115 frame_system::ChainContext<Runtime>,
2116 Runtime,
2117 AllPalletsWithSystem,
2118>;
2119pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
2121
2122#[cfg(feature = "runtime-benchmarks")]
2123mod benches {
2124 frame_benchmarking::define_benchmarks!(
2125 [polkadot_runtime_common::assigned_slots, AssignedSlots]
2129 [polkadot_runtime_common::auctions, Auctions]
2130 [polkadot_runtime_common::crowdloan, Crowdloan]
2131 [polkadot_runtime_common::identity_migrator, IdentityMigrator]
2132 [polkadot_runtime_common::paras_registrar, Registrar]
2133 [polkadot_runtime_common::slots, Slots]
2134 [polkadot_runtime_parachains::configuration, Configuration]
2135 [polkadot_runtime_parachains::disputes, ParasDisputes]
2136 [polkadot_runtime_parachains::disputes::slashing, ParasSlashing]
2137 [polkadot_runtime_parachains::hrmp, Hrmp]
2138 [polkadot_runtime_parachains::inclusion, ParaInclusion]
2139 [polkadot_runtime_parachains::initializer, Initializer]
2140 [polkadot_runtime_parachains::paras, Paras]
2141 [polkadot_runtime_parachains::paras_inherent, ParaInherent]
2142 [polkadot_runtime_parachains::on_demand, OnDemandAssignmentProvider]
2143 [polkadot_runtime_parachains::coretime, Coretime]
2144 [pallet_bags_list, VoterList]
2146 [pallet_balances, Balances]
2147 [pallet_beefy_mmr, BeefyMmrLeaf]
2148 [pallet_conviction_voting, ConvictionVoting]
2149 [pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
2150 [frame_election_provider_support, ElectionProviderBench::<Runtime>]
2151 [pallet_fast_unstake, FastUnstake]
2152 [pallet_identity, Identity]
2153 [pallet_indices, Indices]
2154 [pallet_message_queue, MessageQueue]
2155 [pallet_migrations, MultiBlockMigrations]
2156 [pallet_mmr, Mmr]
2157 [pallet_multisig, Multisig]
2158 [pallet_nomination_pools, NominationPoolsBench::<Runtime>]
2159 [pallet_offences, OffencesBench::<Runtime>]
2160 [pallet_parameters, Parameters]
2161 [pallet_preimage, Preimage]
2162 [pallet_proxy, Proxy]
2163 [pallet_recovery, Recovery]
2164 [pallet_referenda, Referenda]
2165 [pallet_scheduler, Scheduler]
2166 [pallet_session, SessionBench::<Runtime>]
2167 [pallet_staking, Staking]
2168 [pallet_sudo, Sudo]
2169 [frame_system, SystemBench::<Runtime>]
2170 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
2171 [pallet_timestamp, Timestamp]
2172 [pallet_transaction_payment, TransactionPayment]
2173 [pallet_treasury, Treasury]
2174 [pallet_utility, Utility]
2175 [pallet_vesting, Vesting]
2176 [pallet_whitelist, Whitelist]
2177 [pallet_asset_rate, AssetRate]
2178 [pallet_meta_tx, MetaTx]
2179 [pallet_verify_signature, VerifySignature]
2180 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
2182 [pallet_xcm_benchmarks::fungible, XcmBalances]
2184 [pallet_xcm_benchmarks::generic, XcmGeneric]
2185 );
2186}
2187
2188sp_api::impl_runtime_apis! {
2189 impl sp_api::Core<Block> for Runtime {
2190 fn version() -> RuntimeVersion {
2191 VERSION
2192 }
2193
2194 fn execute_block(block: <Block as BlockT>::LazyBlock) {
2195 Executive::execute_block(block);
2196 }
2197
2198 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
2199 Executive::initialize_block(header)
2200 }
2201 }
2202
2203 impl sp_api::Metadata<Block> for Runtime {
2204 fn metadata() -> OpaqueMetadata {
2205 OpaqueMetadata::new(Runtime::metadata().into())
2206 }
2207
2208 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
2209 Runtime::metadata_at_version(version)
2210 }
2211
2212 fn metadata_versions() -> alloc::vec::Vec<u32> {
2213 Runtime::metadata_versions()
2214 }
2215 }
2216
2217 impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
2218 fn execute_view_function(id: frame_support::view_functions::ViewFunctionId, input: Vec<u8>) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
2219 Runtime::execute_view_function(id, input)
2220 }
2221 }
2222
2223 impl sp_block_builder::BlockBuilder<Block> for Runtime {
2224 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
2225 Executive::apply_extrinsic(extrinsic)
2226 }
2227
2228 fn finalize_block() -> <Block as BlockT>::Header {
2229 Executive::finalize_block()
2230 }
2231
2232 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
2233 data.create_extrinsics()
2234 }
2235
2236 fn check_inherents(
2237 block: <Block as BlockT>::LazyBlock,
2238 data: sp_inherents::InherentData,
2239 ) -> sp_inherents::CheckInherentsResult {
2240 data.check_extrinsics(&block)
2241 }
2242 }
2243
2244 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
2245 fn validate_transaction(
2246 source: TransactionSource,
2247 tx: <Block as BlockT>::Extrinsic,
2248 block_hash: <Block as BlockT>::Hash,
2249 ) -> TransactionValidity {
2250 Executive::validate_transaction(source, tx, block_hash)
2251 }
2252 }
2253
2254 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
2255 fn offchain_worker(header: &<Block as BlockT>::Header) {
2256 Executive::offchain_worker(header)
2257 }
2258 }
2259
2260 #[api_version(15)]
2261 impl polkadot_primitives::runtime_api::ParachainHost<Block> for Runtime {
2262 fn validators() -> Vec<ValidatorId> {
2263 parachains_runtime_api_impl::validators::<Runtime>()
2264 }
2265
2266 fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
2267 parachains_runtime_api_impl::validator_groups::<Runtime>()
2268 }
2269
2270 fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>> {
2271 parachains_runtime_api_impl::availability_cores::<Runtime>()
2272 }
2273
2274 fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
2275 -> Option<PersistedValidationData<Hash, BlockNumber>> {
2276 parachains_runtime_api_impl::persisted_validation_data::<Runtime>(para_id, assumption)
2277 }
2278
2279 fn assumed_validation_data(
2280 para_id: ParaId,
2281 expected_persisted_validation_data_hash: Hash,
2282 ) -> Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)> {
2283 parachains_runtime_api_impl::assumed_validation_data::<Runtime>(
2284 para_id,
2285 expected_persisted_validation_data_hash,
2286 )
2287 }
2288
2289 fn check_validation_outputs(
2290 para_id: ParaId,
2291 outputs: polkadot_primitives::CandidateCommitments,
2292 ) -> bool {
2293 parachains_runtime_api_impl::check_validation_outputs::<Runtime>(para_id, outputs)
2294 }
2295
2296 fn session_index_for_child() -> SessionIndex {
2297 parachains_runtime_api_impl::session_index_for_child::<Runtime>()
2298 }
2299
2300 fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
2301 -> Option<ValidationCode> {
2302 parachains_runtime_api_impl::validation_code::<Runtime>(para_id, assumption)
2303 }
2304
2305 fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
2306 #[allow(deprecated)]
2307 parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
2308 }
2309
2310 fn candidate_events() -> Vec<CandidateEvent<Hash>> {
2311 parachains_runtime_api_impl::candidate_events::<Runtime, _>(|ev| {
2312 match ev {
2313 RuntimeEvent::ParaInclusion(ev) => {
2314 Some(ev)
2315 }
2316 _ => None,
2317 }
2318 })
2319 }
2320
2321 fn session_info(index: SessionIndex) -> Option<SessionInfo> {
2322 parachains_runtime_api_impl::session_info::<Runtime>(index)
2323 }
2324
2325 fn session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams> {
2326 parachains_runtime_api_impl::session_executor_params::<Runtime>(session_index)
2327 }
2328
2329 fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<BlockNumber>> {
2330 parachains_runtime_api_impl::dmq_contents::<Runtime>(recipient)
2331 }
2332
2333 fn inbound_hrmp_channels_contents(
2334 recipient: ParaId
2335 ) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
2336 parachains_runtime_api_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
2337 }
2338
2339 fn validation_code_by_hash(hash: ValidationCodeHash) -> Option<ValidationCode> {
2340 parachains_runtime_api_impl::validation_code_by_hash::<Runtime>(hash)
2341 }
2342
2343 fn on_chain_votes() -> Option<ScrapedOnChainVotes<Hash>> {
2344 parachains_runtime_api_impl::on_chain_votes::<Runtime>()
2345 }
2346
2347 fn submit_pvf_check_statement(
2348 stmt: PvfCheckStatement,
2349 signature: ValidatorSignature,
2350 ) {
2351 parachains_runtime_api_impl::submit_pvf_check_statement::<Runtime>(stmt, signature)
2352 }
2353
2354 fn pvfs_require_precheck() -> Vec<ValidationCodeHash> {
2355 parachains_runtime_api_impl::pvfs_require_precheck::<Runtime>()
2356 }
2357
2358 fn validation_code_hash(para_id: ParaId, assumption: OccupiedCoreAssumption)
2359 -> Option<ValidationCodeHash>
2360 {
2361 parachains_runtime_api_impl::validation_code_hash::<Runtime>(para_id, assumption)
2362 }
2363
2364 fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
2365 parachains_runtime_api_impl::get_session_disputes::<Runtime>()
2366 }
2367
2368 fn unapplied_slashes(
2369 ) -> Vec<(SessionIndex, CandidateHash, slashing::LegacyPendingSlashes)> {
2370 parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
2371 }
2372
2373 fn unapplied_slashes_v2(
2374 ) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
2375 parachains_runtime_api_impl::unapplied_slashes_v2::<Runtime>()
2376 }
2377
2378 fn key_ownership_proof(
2379 validator_id: ValidatorId,
2380 ) -> Option<slashing::OpaqueKeyOwnershipProof> {
2381 use codec::Encode;
2382
2383 Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
2384 .map(|p| p.encode())
2385 .map(slashing::OpaqueKeyOwnershipProof::new)
2386 }
2387
2388 fn submit_report_dispute_lost(
2389 dispute_proof: slashing::DisputeProof,
2390 key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
2391 ) -> Option<()> {
2392 parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
2393 dispute_proof,
2394 key_ownership_proof,
2395 )
2396 }
2397
2398 fn minimum_backing_votes() -> u32 {
2399 parachains_runtime_api_impl::minimum_backing_votes::<Runtime>()
2400 }
2401
2402 fn para_backing_state(para_id: ParaId) -> Option<polkadot_primitives::async_backing::BackingState> {
2403 #[allow(deprecated)]
2404 parachains_runtime_api_impl::backing_state::<Runtime>(para_id)
2405 }
2406
2407 fn async_backing_params() -> polkadot_primitives::AsyncBackingParams {
2408 #[allow(deprecated)]
2409 parachains_runtime_api_impl::async_backing_params::<Runtime>()
2410 }
2411
2412 fn approval_voting_params() -> ApprovalVotingParams {
2413 parachains_runtime_api_impl::approval_voting_params::<Runtime>()
2414 }
2415
2416 fn disabled_validators() -> Vec<ValidatorIndex> {
2417 parachains_runtime_api_impl::disabled_validators::<Runtime>()
2418 }
2419
2420 fn node_features() -> NodeFeatures {
2421 parachains_runtime_api_impl::node_features::<Runtime>()
2422 }
2423
2424 fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
2425 parachains_runtime_api_impl::claim_queue::<Runtime>()
2426 }
2427
2428 fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
2429 parachains_runtime_api_impl::candidates_pending_availability::<Runtime>(para_id)
2430 }
2431
2432 fn backing_constraints(para_id: ParaId) -> Option<Constraints> {
2433 parachains_runtime_api_impl::backing_constraints::<Runtime>(para_id)
2434 }
2435
2436 fn scheduling_lookahead() -> u32 {
2437 parachains_runtime_api_impl::scheduling_lookahead::<Runtime>()
2438 }
2439
2440 fn validation_code_bomb_limit() -> u32 {
2441 parachains_runtime_api_impl::validation_code_bomb_limit::<Runtime>()
2442 }
2443
2444 fn para_ids() -> Vec<ParaId> {
2445 parachains_staging_runtime_api_impl::para_ids::<Runtime>()
2446 }
2447 }
2448
2449 #[api_version(6)]
2450 impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
2451 fn beefy_genesis() -> Option<BlockNumber> {
2452 pallet_beefy::GenesisBlock::<Runtime>::get()
2453 }
2454
2455 fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
2456 Beefy::validator_set()
2457 }
2458
2459 fn submit_report_double_voting_unsigned_extrinsic(
2460 equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
2461 BlockNumber,
2462 BeefyId,
2463 BeefySignature,
2464 >,
2465 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2466 ) -> Option<()> {
2467 let key_owner_proof = key_owner_proof.decode()?;
2468
2469 Beefy::submit_unsigned_double_voting_report(
2470 equivocation_proof,
2471 key_owner_proof,
2472 )
2473 }
2474
2475 fn submit_report_fork_voting_unsigned_extrinsic(
2476 equivocation_proof:
2477 sp_consensus_beefy::ForkVotingProof<
2478 <Block as BlockT>::Header,
2479 BeefyId,
2480 sp_runtime::OpaqueValue
2481 >,
2482 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2483 ) -> Option<()> {
2484 Beefy::submit_unsigned_fork_voting_report(
2485 equivocation_proof.try_into()?,
2486 key_owner_proof.decode()?,
2487 )
2488 }
2489
2490 fn submit_report_future_block_voting_unsigned_extrinsic(
2491 equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
2492 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2493 ) -> Option<()> {
2494 Beefy::submit_unsigned_future_block_voting_report(
2495 equivocation_proof,
2496 key_owner_proof.decode()?,
2497 )
2498 }
2499
2500 fn generate_key_ownership_proof(
2501 _set_id: sp_consensus_beefy::ValidatorSetId,
2502 authority_id: BeefyId,
2503 ) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
2504 use codec::Encode;
2505
2506 Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
2507 .map(|p| p.encode())
2508 .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
2509 }
2510 }
2511
2512 #[api_version(3)]
2513 impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
2514 fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
2515 Ok(pallet_mmr::RootHash::<Runtime>::get())
2516 }
2517
2518 fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
2519 Ok(pallet_mmr::NumberOfLeaves::<Runtime>::get())
2520 }
2521
2522 fn generate_proof(
2523 block_numbers: Vec<BlockNumber>,
2524 best_known_block_number: Option<BlockNumber>,
2525 ) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<mmr::Hash>), mmr::Error> {
2526 Mmr::generate_proof(block_numbers, best_known_block_number).map(
2527 |(leaves, proof)| {
2528 (
2529 leaves
2530 .into_iter()
2531 .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
2532 .collect(),
2533 proof,
2534 )
2535 },
2536 )
2537 }
2538
2539 fn generate_ancestry_proof(
2540 prev_block_number: BlockNumber,
2541 best_known_block_number: Option<BlockNumber>,
2542 ) -> Result<mmr::AncestryProof<mmr::Hash>, mmr::Error> {
2543 Mmr::generate_ancestry_proof(prev_block_number, best_known_block_number)
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 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
2728 XcmPallet::query_weight_to_asset_fee::<Trader>(weight, asset)
2729 }
2730
2731 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
2732 XcmPallet::query_xcm_weight(message)
2733 }
2734
2735 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>, asset_id: VersionedAssetId) -> Result<VersionedAssets, XcmPaymentApiError> {
2736 type AssetExchanger = <XcmConfig as xcm_executor::Config>::AssetExchanger;
2737 XcmPallet::query_delivery_fees::<AssetExchanger>(destination, message, asset_id)
2738 }
2739 }
2740
2741 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
2742 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
2743 XcmPallet::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
2744 }
2745
2746 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
2747 XcmPallet::dry_run_xcm::<xcm_config::XcmRouter>(origin_location, xcm)
2748 }
2749 }
2750
2751 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
2752 fn convert_location(location: VersionedLocation) -> Result<
2753 AccountId,
2754 xcm_runtime_apis::conversions::Error
2755 > {
2756 xcm_runtime_apis::conversions::LocationToAccountHelper::<
2757 AccountId,
2758 xcm_config::LocationConverter,
2759 >::convert_location(location)
2760 }
2761 }
2762
2763 impl pallet_nomination_pools_runtime_api::NominationPoolsApi<
2764 Block,
2765 AccountId,
2766 Balance,
2767 > for Runtime {
2768 fn pending_rewards(member: AccountId) -> Balance {
2769 NominationPools::api_pending_rewards(member).unwrap_or_default()
2770 }
2771
2772 fn points_to_balance(pool_id: PoolId, points: Balance) -> Balance {
2773 NominationPools::api_points_to_balance(pool_id, points)
2774 }
2775
2776 fn balance_to_points(pool_id: PoolId, new_funds: Balance) -> Balance {
2777 NominationPools::api_balance_to_points(pool_id, new_funds)
2778 }
2779
2780 fn pool_pending_slash(pool_id: PoolId) -> Balance {
2781 NominationPools::api_pool_pending_slash(pool_id)
2782 }
2783
2784 fn member_pending_slash(member: AccountId) -> Balance {
2785 NominationPools::api_member_pending_slash(member)
2786 }
2787
2788 fn pool_needs_delegate_migration(pool_id: PoolId) -> bool {
2789 NominationPools::api_pool_needs_delegate_migration(pool_id)
2790 }
2791
2792 fn member_needs_delegate_migration(member: AccountId) -> bool {
2793 NominationPools::api_member_needs_delegate_migration(member)
2794 }
2795
2796 fn member_total_balance(member: AccountId) -> Balance {
2797 NominationPools::api_member_total_balance(member)
2798 }
2799
2800 fn pool_balance(pool_id: PoolId) -> Balance {
2801 NominationPools::api_pool_balance(pool_id)
2802 }
2803
2804 fn pool_accounts(pool_id: PoolId) -> (AccountId, AccountId) {
2805 NominationPools::api_pool_accounts(pool_id)
2806 }
2807 }
2808
2809 impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
2810 fn nominations_quota(balance: Balance) -> u32 {
2811 Staking::api_nominations_quota(balance)
2812 }
2813
2814 fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
2815 Staking::api_eras_stakers_page_count(era, account)
2816 }
2817
2818 fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool {
2819 Staking::api_pending_rewards(era, account)
2820 }
2821 }
2822
2823 #[cfg(feature = "try-runtime")]
2824 impl frame_try_runtime::TryRuntime<Block> for Runtime {
2825 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
2826 log::info!("try-runtime::on_runtime_upgrade westend.");
2827 let excluded_pallets = vec![
2829 b"Staking".to_vec(), b"NominationPools".to_vec(), b"FastUnstake".to_vec(), b"DelegatedStaking".to_vec(), ];
2834 let config = frame_executive::TryRuntimeUpgradeConfig::new(checks)
2835 .with_try_state_select(frame_try_runtime::TryStateSelect::AllExcept(
2836 excluded_pallets,
2837 ));
2838 let weight = Executive::try_runtime_upgrade_with_config(config).unwrap();
2839 (weight, BlockWeights::get().max_block)
2840 }
2841
2842 fn execute_block(
2843 block: <Block as BlockT>::LazyBlock,
2844 state_root_check: bool,
2845 signature_check: bool,
2846 select: frame_try_runtime::TryStateSelect,
2847 ) -> Weight {
2848 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
2851 }
2852 }
2853
2854 #[cfg(feature = "runtime-benchmarks")]
2855 impl frame_benchmarking::Benchmark<Block> for Runtime {
2856 fn benchmark_metadata(extra: bool) -> (
2857 Vec<frame_benchmarking::BenchmarkList>,
2858 Vec<frame_support::traits::StorageInfo>,
2859 ) {
2860 use frame_benchmarking::BenchmarkList;
2861 use frame_support::traits::StorageInfoTrait;
2862
2863 use pallet_session_benchmarking::Pallet as SessionBench;
2864 use pallet_offences_benchmarking::Pallet as OffencesBench;
2865 use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
2866 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2867 use frame_system_benchmarking::Pallet as SystemBench;
2868 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2869 use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
2870
2871 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
2872 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
2873
2874 let mut list = Vec::<BenchmarkList>::new();
2875 list_benchmarks!(list, extra);
2876
2877 let storage_info = AllPalletsWithSystem::storage_info();
2878 return (list, storage_info)
2879 }
2880
2881 #[allow(non_local_definitions)]
2882 fn dispatch_benchmark(
2883 config: frame_benchmarking::BenchmarkConfig,
2884 ) -> Result<
2885 Vec<frame_benchmarking::BenchmarkBatch>,
2886 alloc::string::String,
2887 > {
2888 use frame_support::traits::WhitelistedStorageKeys;
2889 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
2890 use sp_storage::TrackedStorageKey;
2891 use pallet_session_benchmarking::Pallet as SessionBench;
2894 use pallet_offences_benchmarking::Pallet as OffencesBench;
2895 use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
2896 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2897 use frame_system_benchmarking::Pallet as SystemBench;
2898 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2899 use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
2900
2901 impl pallet_session_benchmarking::Config for Runtime {}
2902 impl pallet_offences_benchmarking::Config for Runtime {}
2903 impl pallet_election_provider_support_benchmarking::Config for Runtime {}
2904
2905 use xcm_config::{AssetHub, TokenLocation};
2906
2907 use alloc::boxed::Box;
2908
2909 parameter_types! {
2910 pub ExistentialDepositAsset: Option<Asset> = Some((
2911 TokenLocation::get(),
2912 ExistentialDeposit::get()
2913 ).into());
2914 pub AssetHubParaId: ParaId = westend_runtime_constants::system_parachain::ASSET_HUB_ID.into();
2915 pub const RandomParaId: ParaId = ParaId::new(43211234);
2916 }
2917
2918 impl pallet_xcm::benchmarking::Config for Runtime {
2919 type DeliveryHelper = (
2920 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2921 xcm_config::XcmConfig,
2922 ExistentialDepositAsset,
2923 xcm_config::PriceForChildParachainDelivery,
2924 AssetHubParaId,
2925 Dmp,
2926 >,
2927 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2928 xcm_config::XcmConfig,
2929 ExistentialDepositAsset,
2930 xcm_config::PriceForChildParachainDelivery,
2931 RandomParaId,
2932 Dmp,
2933 >
2934 );
2935
2936 fn reachable_dest() -> Option<Location> {
2937 Some(crate::xcm_config::AssetHub::get())
2938 }
2939
2940 fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
2941 Some((
2943 Asset { fun: Fungible(ExistentialDeposit::get()), id: AssetId(Here.into()) },
2944 crate::xcm_config::AssetHub::get(),
2945 ))
2946 }
2947
2948 fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
2949 None
2950 }
2951
2952 fn set_up_complex_asset_transfer(
2953 ) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
2954 let native_location = Here.into();
2960 let dest = crate::xcm_config::AssetHub::get();
2961 pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
2962 native_location,
2963 dest
2964 )
2965 }
2966
2967 fn get_asset() -> Asset {
2968 Asset {
2969 id: AssetId(Location::here()),
2970 fun: Fungible(ExistentialDeposit::get()),
2971 }
2972 }
2973 }
2974 impl frame_system_benchmarking::Config for Runtime {}
2975 impl pallet_nomination_pools_benchmarking::Config for Runtime {}
2976 impl polkadot_runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {}
2977
2978 use xcm::latest::{
2979 AssetId, Fungibility::*, InteriorLocation, Junction, Junctions::*,
2980 Asset, Assets, Location, NetworkId, Response,
2981 };
2982
2983 impl pallet_xcm_benchmarks::Config for Runtime {
2984 type XcmConfig = xcm_config::XcmConfig;
2985 type AccountIdConverter = xcm_config::LocationConverter;
2986 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2987 xcm_config::XcmConfig,
2988 ExistentialDepositAsset,
2989 xcm_config::PriceForChildParachainDelivery,
2990 AssetHubParaId,
2991 Dmp,
2992 >;
2993 fn valid_destination() -> Result<Location, BenchmarkError> {
2994 Ok(AssetHub::get())
2995 }
2996 fn worst_case_holding(_depositable_count: u32) -> Assets {
2997 vec![Asset{
2999 id: AssetId(TokenLocation::get()),
3000 fun: Fungible(1_000_000 * UNITS),
3001 }].into()
3002 }
3003 }
3004
3005 parameter_types! {
3006 pub TrustedTeleporter: Option<(Location, Asset)> = Some((
3007 AssetHub::get(),
3008 Asset { fun: Fungible(1 * UNITS), id: AssetId(TokenLocation::get()) },
3009 ));
3010 pub const TrustedReserve: Option<(Location, Asset)> = None;
3011 pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
3012 }
3013
3014 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
3015 type TransactAsset = Balances;
3016
3017 type CheckedAccount = CheckedAccount;
3018 type TrustedTeleporter = TrustedTeleporter;
3019 type TrustedReserve = TrustedReserve;
3020
3021 fn get_asset() -> Asset {
3022 Asset {
3023 id: AssetId(TokenLocation::get()),
3024 fun: Fungible(1 * UNITS),
3025 }
3026 }
3027 }
3028
3029 impl pallet_xcm_benchmarks::generic::Config for Runtime {
3030 type TransactAsset = Balances;
3031 type RuntimeCall = RuntimeCall;
3032
3033 fn worst_case_response() -> (u64, Response) {
3034 (0u64, Response::Version(Default::default()))
3035 }
3036
3037 fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
3038 Err(BenchmarkError::Skip)
3040 }
3041
3042 fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
3043 Err(BenchmarkError::Skip)
3045 }
3046
3047 fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
3048 Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
3049 }
3050
3051 fn subscribe_origin() -> Result<Location, BenchmarkError> {
3052 Ok(AssetHub::get())
3053 }
3054
3055 fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
3056 let origin = AssetHub::get();
3057 let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
3058 let ticket = Location { parents: 0, interior: Here };
3059 Ok((origin, ticket, assets))
3060 }
3061
3062 fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
3063 Ok((Asset {
3064 id: AssetId(TokenLocation::get()),
3065 fun: Fungible(1_000_000 * UNITS),
3066 }, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
3067 }
3068
3069 fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
3070 Err(BenchmarkError::Skip)
3072 }
3073
3074 fn export_message_origin_and_destination(
3075 ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
3076 Err(BenchmarkError::Skip)
3078 }
3079
3080 fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
3081 let origin = Location::new(0, [Parachain(1000)]);
3082 let target = Location::new(0, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]);
3083 Ok((origin, target))
3084 }
3085 }
3086
3087 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
3088 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
3089
3090 let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
3091
3092 let mut batches = Vec::<BenchmarkBatch>::new();
3093 let params = (&config, &whitelist);
3094
3095 add_benchmarks!(params, batches);
3096
3097 Ok(batches)
3098 }
3099 }
3100
3101 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
3102 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
3103 build_state::<RuntimeGenesisConfig>(config)
3104 }
3105
3106 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
3107 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
3108 }
3109
3110 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
3111 genesis_config_presets::preset_names()
3112 }
3113 }
3114
3115 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
3116 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
3117 XcmPallet::is_trusted_reserve(asset, location)
3118 }
3119 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
3120 XcmPallet::is_trusted_teleporter(asset, location)
3121 }
3122 }
3123}