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