1#![cfg_attr(not(feature = "std"), no_std)]
20#![recursion_limit = "512"]
22
23#[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), target_feature = "e"))]
24::core::arch::global_asm!(
29 ".pushsection .polkavm_min_stack_size,\"R\",@note\n",
30 ".4byte 2097152",
31 ".popsection\n",
32);
33
34extern crate alloc;
35
36use alloc::{
37 collections::{btree_map::BTreeMap, vec_deque::VecDeque},
38 vec,
39 vec::Vec,
40};
41use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
42use core::cmp::Ordering;
43use frame_support::{
44 dynamic_params::{dynamic_pallet_params, dynamic_params},
45 traits::FromContains,
46};
47use pallet_balances::WeightInfo;
48use pallet_nis::WithMaximumOf;
49use polkadot_primitives::{
50 async_backing::Constraints, slashing, AccountId, AccountIndex, ApprovalVotingParams, Balance,
51 BlockNumber, CandidateEvent, CandidateHash,
52 CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState,
53 ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage,
54 InboundHrmpMessage, Moment, NodeFeatures, Nonce, OccupiedCoreAssumption,
55 PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode,
56 ValidationCodeHash, ValidatorId, ValidatorIndex, PARACHAIN_KEY_TYPE_ID,
57};
58use polkadot_runtime_common::{
59 assigned_slots, auctions, claims, crowdloan, identity_migrator, impl_runtime_weights,
60 impls::{
61 ContainsParts, LocatableAssetConverter, ToAuthor, VersionedLocatableAsset,
62 VersionedLocationConverter,
63 },
64 paras_registrar, paras_sudo_wrapper, prod_or_fast, slots,
65 traits::OnSwap,
66 BlockHashCount, SlowAdjustingFeeUpdate,
67};
68use polkadot_runtime_parachains::{
69 configuration as parachains_configuration,
70 configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
71 coretime, disputes as parachains_disputes,
72 disputes::slashing as parachains_slashing,
73 dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
74 inclusion::{AggregateMessageOrigin, UmpQueueId},
75 initializer as parachains_initializer, on_demand as parachains_on_demand,
76 origin as parachains_origin, paras as parachains_paras,
77 paras_inherent as parachains_paras_inherent,
78 runtime_api_impl::{
79 v13 as parachains_runtime_api_impl, vstaging as parachains_staging_runtime_api_impl,
80 },
81 scheduler as parachains_scheduler, session_info as parachains_session_info,
82 shared as parachains_shared,
83};
84use rococo_runtime_constants::system_parachain::{coretime::TIMESLICE_PERIOD, BROKER_ID};
85use scale_info::TypeInfo;
86use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
87use sp_consensus_beefy::{
88 ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
89 mmr::{BeefyDataProvider, MmrLeafVersion},
90};
91use sp_genesis_builder::PresetId;
92
93use frame_support::{
94 construct_runtime, derive_impl,
95 genesis_builder_helper::{build_state, get_preset},
96 parameter_types,
97 traits::{
98 fungible::HoldConsideration, tokens::UnityOrOuterConversion, Contains, EitherOf,
99 EitherOfDiverse, EnsureOrigin, EnsureOriginWithArg, EverythingBut, InstanceFilter,
100 KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp, ProcessMessage, ProcessMessageError,
101 StorageMapShim, WithdrawReasons,
102 },
103 weights::{ConstantMultiplier, WeightMeter},
104 PalletId,
105};
106use frame_system::{EnsureRoot, EnsureSigned};
107use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
108use pallet_identity::legacy::IdentityInfo;
109use pallet_session::historical as session_historical;
110use pallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
111use sp_core::{ConstU128, ConstU8, ConstUint, Get, OpaqueMetadata, H256};
112use sp_runtime::{
113 generic, impl_opaque_keys,
114 traits::{
115 AccountIdConversion, BlakeTwo256, Block as BlockT, ConstU32, ConvertInto, IdentityLookup,
116 Keccak256, OpaqueKeys, SaturatedConversion, Verify,
117 },
118 transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
119 ApplyExtrinsicResult, Debug, FixedU128, KeyTypeId, Perbill, Percent, Permill,
120};
121use sp_staking::SessionIndex;
122#[cfg(any(feature = "std", test))]
123use sp_version::NativeVersion;
124use sp_version::RuntimeVersion;
125use xcm::{
126 latest::prelude::*, Version as XcmVersion, VersionedAsset, VersionedAssetId, VersionedAssets,
127 VersionedLocation, VersionedXcm,
128};
129use xcm_builder::PayOverXcm;
130
131pub use frame_system::Call as SystemCall;
132pub use pallet_balances::Call as BalancesCall;
133
134use rococo_runtime_constants::{currency::*, fee::*, time::*};
136
137mod weights;
139
140pub mod xcm_config;
142
143mod impls;
145use impls::ToParachainIdentityReaper;
146
147pub mod governance;
149use governance::{
150 pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin, Treasurer,
151 TreasurySpender,
152};
153use xcm_config::XcmConfig;
154use xcm_runtime_apis::{
155 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
156 fees::Error as XcmPaymentApiError,
157};
158
159#[cfg(test)]
160mod tests;
161
162mod genesis_config_presets;
163mod validator_manager;
164
165impl_runtime_weights!(rococo_runtime_constants);
166
167#[cfg(feature = "std")]
169include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
170
171#[cfg(feature = "std")]
175pub mod fast_runtime_binary {
176 include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
177}
178
179#[sp_version::runtime_version]
181pub const VERSION: RuntimeVersion = RuntimeVersion {
182 spec_name: alloc::borrow::Cow::Borrowed("rococo"),
183 impl_name: alloc::borrow::Cow::Borrowed("parity-rococo-v2.0"),
184 authoring_version: 0,
185 spec_version: 1_024_001,
186 impl_version: 0,
187 apis: RUNTIME_API_VERSIONS,
188 transaction_version: 26,
189 system_version: 1,
190};
191
192pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
194 sp_consensus_babe::BabeEpochConfiguration {
195 c: PRIMARY_PROBABILITY,
196 allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots,
197 };
198
199#[cfg(any(feature = "std", test))]
201pub fn native_version() -> NativeVersion {
202 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
203}
204
205pub struct IsIdentityCall;
210impl Contains<RuntimeCall> for IsIdentityCall {
211 fn contains(c: &RuntimeCall) -> bool {
212 matches!(c, RuntimeCall::Identity(_))
213 }
214}
215
216parameter_types! {
217 pub const Version: RuntimeVersion = VERSION;
218 pub const SS58Prefix: u8 = 42;
219 pub BlockLength: frame_system::limits::BlockLength =
221 frame_system::limits::BlockLength::builder()
222 .max_length(10 * 1024 * 1024)
223 .modify_max_length_for_class(
224 frame_support::dispatch::DispatchClass::Normal,
225 |m| { *m = polkadot_runtime_common::NORMAL_DISPATCH_RATIO * *m },
226 )
227 .build();
228}
229
230#[derive_impl(frame_system::config_preludes::RelayChainDefaultConfig)]
231impl frame_system::Config for Runtime {
232 type BaseCallFilter = EverythingBut<IsIdentityCall>;
233 type BlockWeights = BlockWeights;
234 type BlockLength = BlockLength;
235 type DbWeight = RocksDbWeight;
236 type Nonce = Nonce;
237 type Hash = Hash;
238 type AccountId = AccountId;
239 type Block = Block;
240 type BlockHashCount = BlockHashCount;
241 type Version = Version;
242 type AccountData = pallet_balances::AccountData<Balance>;
243 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
244 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
245 type SS58Prefix = SS58Prefix;
246 type MaxConsumers = frame_support::traits::ConstU32<16>;
247 type MultiBlockMigrator = MultiBlockMigrations;
248 type SingleBlockMigrations = Migrations;
249}
250
251parameter_types! {
252 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
253 BlockWeights::get().max_block;
254 pub const MaxScheduledPerBlock: u32 = 50;
255 pub const NoPreimagePostponement: Option<u32> = Some(10);
256}
257
258pub struct OriginPrivilegeCmp;
260
261impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
262 fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {
263 if left == right {
264 return Some(Ordering::Equal);
265 }
266
267 match (left, right) {
268 (OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater),
270 _ => None,
272 }
273 }
274}
275
276#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
278pub mod dynamic_params {
279 use super::*;
280
281 #[dynamic_pallet_params]
282 #[codec(index = 0)]
283 pub mod nis {
284 use super::*;
285
286 #[codec(index = 0)]
287 pub static Target: Perquintill = Perquintill::zero();
288
289 #[codec(index = 1)]
290 pub static MinBid: Balance = 100 * UNITS;
291 }
292
293 #[dynamic_pallet_params]
294 #[codec(index = 1)]
295 pub mod preimage {
296 use super::*;
297
298 #[codec(index = 0)]
299 pub static BaseDeposit: Balance = deposit(2, 64);
300
301 #[codec(index = 1)]
302 pub static ByteDeposit: Balance = deposit(0, 1);
303 }
304}
305
306#[cfg(feature = "runtime-benchmarks")]
307impl Default for RuntimeParameters {
308 fn default() -> Self {
309 RuntimeParameters::Preimage(dynamic_params::preimage::Parameters::BaseDeposit(
310 dynamic_params::preimage::BaseDeposit,
311 Some(1u32.into()),
312 ))
313 }
314}
315
316pub struct DynamicParameterOrigin;
318impl EnsureOriginWithArg<RuntimeOrigin, RuntimeParametersKey> for DynamicParameterOrigin {
319 type Success = ();
320
321 fn try_origin(
322 origin: RuntimeOrigin,
323 key: &RuntimeParametersKey,
324 ) -> Result<Self::Success, RuntimeOrigin> {
325 use crate::{dynamic_params::*, governance::*, RuntimeParametersKey::*};
326
327 match key {
328 Nis(nis::ParametersKey::MinBid(_)) => StakingAdmin::ensure_origin(origin.clone()),
329 Nis(nis::ParametersKey::Target(_)) => GeneralAdmin::ensure_origin(origin.clone()),
330 Preimage(_) => frame_system::ensure_root(origin.clone()),
331 }
332 .map_err(|_| origin)
333 }
334
335 #[cfg(feature = "runtime-benchmarks")]
336 fn try_successful_origin(_key: &RuntimeParametersKey) -> Result<RuntimeOrigin, ()> {
337 Ok(RuntimeOrigin::root())
339 }
340}
341
342impl pallet_scheduler::Config for Runtime {
343 type RuntimeOrigin = RuntimeOrigin;
344 type RuntimeEvent = RuntimeEvent;
345 type PalletsOrigin = OriginCaller;
346 type RuntimeCall = RuntimeCall;
347 type MaximumWeight = MaximumSchedulerWeight;
348 type ScheduleOrigin = EitherOf<EnsureRoot<AccountId>, AuctionAdmin>;
351 type MaxScheduledPerBlock = MaxScheduledPerBlock;
352 type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
353 type OriginPrivilegeCmp = OriginPrivilegeCmp;
354 type Preimages = Preimage;
355 type BlockNumberProvider = frame_system::Pallet<Runtime>;
356}
357
358parameter_types! {
359 pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
360}
361
362impl pallet_preimage::Config for Runtime {
363 type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
364 type RuntimeEvent = RuntimeEvent;
365 type Currency = Balances;
366 type ManagerOrigin = EnsureRoot<AccountId>;
367 type Consideration = HoldConsideration<
368 AccountId,
369 Balances,
370 PreimageHoldReason,
371 LinearStoragePrice<
372 dynamic_params::preimage::BaseDeposit,
373 dynamic_params::preimage::ByteDeposit,
374 Balance,
375 >,
376 >;
377}
378
379parameter_types! {
380 pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
381 pub ReportLongevity: u64 = EpochDurationInBlocks::get() as u64 * 10;
382}
383
384impl pallet_babe::Config for Runtime {
385 type EpochDuration = EpochDurationInBlocks;
386 type ExpectedBlockTime = ExpectedBlockTime;
387 type EpochChangeTrigger = pallet_babe::ExternalTrigger;
389 type DisabledValidators = Session;
390 type WeightInfo = ();
391 type MaxAuthorities = MaxAuthorities;
392 type MaxNominators = ConstU32<0>;
393 type KeyOwnerProof = sp_session::MembershipProof;
394 type EquivocationReportSystem =
395 pallet_babe::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
396}
397
398parameter_types! {
399 pub const IndexDeposit: Balance = 100 * CENTS;
400}
401
402impl pallet_indices::Config for Runtime {
403 type AccountIndex = AccountIndex;
404 type Currency = Balances;
405 type Deposit = IndexDeposit;
406 type RuntimeEvent = RuntimeEvent;
407 type WeightInfo = weights::pallet_indices::WeightInfo<Runtime>;
408}
409
410parameter_types! {
411 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
412 pub const MaxLocks: u32 = 50;
413 pub const MaxReserves: u32 = 50;
414}
415
416impl pallet_balances::Config for Runtime {
417 type Balance = Balance;
418 type DustRemoval = ();
419 type RuntimeEvent = RuntimeEvent;
420 type ExistentialDeposit = ExistentialDeposit;
421 type AccountStore = System;
422 type MaxLocks = MaxLocks;
423 type MaxReserves = MaxReserves;
424 type ReserveIdentifier = [u8; 8];
425 type WeightInfo = weights::pallet_balances_balances::WeightInfo<Runtime>;
426 type FreezeIdentifier = ();
427 type RuntimeHoldReason = RuntimeHoldReason;
428 type RuntimeFreezeReason = RuntimeFreezeReason;
429 type MaxFreezes = ConstU32<1>;
430 type DoneSlashHandler = ();
431}
432
433parameter_types! {
434 pub const TransactionByteFee: Balance = 10 * MILLICENTS;
435 pub const OperationalFeeMultiplier: u8 = 5;
438}
439
440impl pallet_transaction_payment::Config for Runtime {
441 type RuntimeEvent = RuntimeEvent;
442 type OnChargeTransaction = FungibleAdapter<Balances, ToAuthor<Runtime>>;
443 type OperationalFeeMultiplier = OperationalFeeMultiplier;
444 type WeightToFee = WeightToFee;
445 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
446 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
447 type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
448}
449
450parameter_types! {
451 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
452}
453impl pallet_timestamp::Config for Runtime {
454 type Moment = u64;
455 type OnTimestampSet = Babe;
456 type MinimumPeriod = MinimumPeriod;
457 type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
458}
459
460impl pallet_authorship::Config for Runtime {
461 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
462 type EventHandler = ();
463}
464
465impl_opaque_keys! {
466 pub struct SessionKeys {
467 pub grandpa: Grandpa,
468 pub babe: Babe,
469 pub para_validator: Initializer,
470 pub para_assignment: ParaSessionInfo,
471 pub authority_discovery: AuthorityDiscovery,
472 pub beefy: Beefy,
473 }
474}
475
476pub struct ValidatorIdOf;
478impl sp_runtime::traits::Convert<AccountId, Option<AccountId>> for ValidatorIdOf {
479 fn convert(a: AccountId) -> Option<AccountId> {
480 Some(a)
481 }
482}
483
484impl pallet_session::Config for Runtime {
485 type RuntimeEvent = RuntimeEvent;
486 type ValidatorId = AccountId;
487 type ValidatorIdOf = ValidatorIdOf;
488 type ShouldEndSession = Babe;
489 type NextSessionRotation = Babe;
490 type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, ValidatorManager>;
491 type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
492 type Keys = SessionKeys;
493 type DisablingStrategy = ();
494 type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
495 type Currency = Balances;
496 type KeyDeposit = ();
497}
498
499pub struct FullIdentificationOf;
500impl sp_runtime::traits::Convert<AccountId, Option<()>> for FullIdentificationOf {
501 fn convert(_: AccountId) -> Option<()> {
502 Some(Default::default())
503 }
504}
505
506impl pallet_session::historical::Config for Runtime {
507 type RuntimeEvent = RuntimeEvent;
508 type FullIdentification = ();
509 type FullIdentificationOf = FullIdentificationOf;
510}
511
512parameter_types! {
513 pub const SessionsPerEra: SessionIndex = 6;
514 pub const BondingDuration: sp_staking::EraIndex = 28;
515}
516
517parameter_types! {
518 pub const SpendPeriod: BlockNumber = 6 * DAYS;
519 pub const Burn: Permill = Permill::from_perthousand(2);
520 pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
521 pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
522 pub TreasuryInteriorLocation: InteriorLocation = PalletInstance(18).into();
525
526 pub const TipCountdown: BlockNumber = 1 * DAYS;
527 pub const TipFindersFee: Percent = Percent::from_percent(20);
528 pub const TipReportDepositBase: Balance = 100 * CENTS;
529 pub const DataDepositPerByte: Balance = 1 * CENTS;
530 pub const MaxApprovals: u32 = 100;
531 pub const MaxAuthorities: u32 = 100_000;
532 pub const MaxKeys: u32 = 10_000;
533 pub const MaxPeerInHeartbeats: u32 = 10_000;
534 pub const MaxBalance: Balance = Balance::max_value();
535}
536
537impl pallet_treasury::Config for Runtime {
538 type PalletId = TreasuryPalletId;
539 type Currency = Balances;
540 type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
541 type RuntimeEvent = RuntimeEvent;
542 type SpendPeriod = SpendPeriod;
543 type Burn = Burn;
544 type BurnDestination = Society;
545 type MaxApprovals = MaxApprovals;
546 type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
547 type SpendFunds = Bounties;
548 type SpendOrigin = TreasurySpender;
549 type AssetKind = VersionedLocatableAsset;
550 type Beneficiary = VersionedLocation;
551 type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
552 type Paymaster = PayOverXcm<
553 TreasuryInteriorLocation,
554 crate::xcm_config::XcmConfig,
555 crate::XcmPallet,
556 ConstU32<{ 6 * HOURS }>,
557 Self::Beneficiary,
558 Self::AssetKind,
559 LocatableAssetConverter,
560 VersionedLocationConverter,
561 >;
562 type BalanceConverter = UnityOrOuterConversion<
563 ContainsParts<
564 FromContains<
565 xcm_builder::IsChildSystemParachain<ParaId>,
566 xcm_builder::IsParentsOnly<ConstU8<1>>,
567 >,
568 >,
569 AssetRate,
570 >;
571 type PayoutPeriod = PayoutSpendPeriod;
572 type BlockNumberProvider = System;
573 #[cfg(feature = "runtime-benchmarks")]
574 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments;
575}
576
577parameter_types! {
578 pub const BountyDepositBase: Balance = 100 * CENTS;
579 pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS;
580 pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
581 pub const MaximumReasonLength: u32 = 16384;
582 pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50);
583 pub const CuratorDepositMin: Balance = 10 * CENTS;
584 pub const CuratorDepositMax: Balance = 500 * CENTS;
585 pub const BountyValueMinimum: Balance = 200 * CENTS;
586}
587
588impl pallet_bounties::Config for Runtime {
589 type BountyDepositBase = BountyDepositBase;
590 type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
591 type BountyUpdatePeriod = BountyUpdatePeriod;
592 type CuratorDepositMultiplier = CuratorDepositMultiplier;
593 type CuratorDepositMin = CuratorDepositMin;
594 type CuratorDepositMax = CuratorDepositMax;
595 type BountyValueMinimum = BountyValueMinimum;
596 type ChildBountyManager = ChildBounties;
597 type DataDepositPerByte = DataDepositPerByte;
598 type RuntimeEvent = RuntimeEvent;
599 type MaximumReasonLength = MaximumReasonLength;
600 type WeightInfo = weights::pallet_bounties::WeightInfo<Runtime>;
601 type OnSlash = Treasury;
602 type TransferAllAssets = pallet_bounties::TransferFungible<AccountId, Balances>;
603}
604
605parameter_types! {
606 pub const MaxActiveChildBountyCount: u32 = 100;
607 pub ChildBountyValueMinimum: Balance = BountyValueMinimum::get() / 10;
608}
609
610impl pallet_child_bounties::Config for Runtime {
611 type RuntimeEvent = RuntimeEvent;
612 type MaxActiveChildBountyCount = MaxActiveChildBountyCount;
613 type ChildBountyValueMinimum = ChildBountyValueMinimum;
614 type WeightInfo = weights::pallet_child_bounties::WeightInfo<Runtime>;
615}
616
617impl pallet_offences::Config for Runtime {
618 type RuntimeEvent = RuntimeEvent;
619 type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
620 type OnOffenceHandler = ();
621}
622
623impl pallet_authority_discovery::Config for Runtime {
624 type MaxAuthorities = MaxAuthorities;
625}
626
627parameter_types! {
628 pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
629}
630
631impl pallet_grandpa::Config for Runtime {
632 type RuntimeEvent = RuntimeEvent;
633 type WeightInfo = ();
634 type MaxAuthorities = MaxAuthorities;
635 type MaxNominators = ConstU32<0>;
636 type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
637 type KeyOwnerProof = sp_session::MembershipProof;
638 type EquivocationReportSystem =
639 pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
640}
641
642impl frame_system::offchain::SigningTypes for Runtime {
643 type Public = <Signature as Verify>::Signer;
644 type Signature = Signature;
645}
646
647impl<LocalCall> frame_system::offchain::CreateTransactionBase<LocalCall> for Runtime
648where
649 RuntimeCall: From<LocalCall>,
650{
651 type Extrinsic = UncheckedExtrinsic;
652 type RuntimeCall = RuntimeCall;
653}
654
655impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
658where
659 RuntimeCall: From<LocalCall>,
660{
661 fn create_signed_transaction<
662 C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
663 >(
664 call: RuntimeCall,
665 public: <Signature as Verify>::Signer,
666 account: AccountId,
667 nonce: <Runtime as frame_system::Config>::Nonce,
668 ) -> Option<UncheckedExtrinsic> {
669 use sp_runtime::traits::StaticLookup;
670 let period =
672 BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
673
674 let current_block = System::block_number()
675 .saturated_into::<u64>()
676 .saturating_sub(1);
679 let tip = 0;
680 let tx_ext: TxExtension = (
681 frame_system::AuthorizeCall::<Runtime>::new(),
682 frame_system::CheckNonZeroSender::<Runtime>::new(),
683 frame_system::CheckSpecVersion::<Runtime>::new(),
684 frame_system::CheckTxVersion::<Runtime>::new(),
685 frame_system::CheckGenesis::<Runtime>::new(),
686 frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(
687 period,
688 current_block,
689 )),
690 frame_system::CheckNonce::<Runtime>::from(nonce),
691 frame_system::CheckWeight::<Runtime>::new(),
692 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
693 frame_metadata_hash_extension::CheckMetadataHash::new(true),
694 frame_system::WeightReclaim::<Runtime>::new(),
695 )
696 .into();
697 let raw_payload = SignedPayload::new(call, tx_ext)
698 .map_err(|e| {
699 log::warn!("Unable to create signed payload: {:?}", e);
700 })
701 .ok()?;
702 let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
703 let (call, tx_ext, _) = raw_payload.deconstruct();
704 let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
705 let transaction = UncheckedExtrinsic::new_signed(call, address, signature, tx_ext);
706 Some(transaction)
707 }
708}
709
710impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
711where
712 RuntimeCall: From<LocalCall>,
713{
714 type Extension = TxExtension;
715
716 fn create_transaction(call: RuntimeCall, tx_ext: Self::Extension) -> UncheckedExtrinsic {
717 UncheckedExtrinsic::new_transaction(call, tx_ext)
718 }
719}
720
721impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
722where
723 RuntimeCall: From<LocalCall>,
724{
725 fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
726 UncheckedExtrinsic::new_bare(call)
727 }
728}
729
730impl<LocalCall> frame_system::offchain::CreateAuthorizedTransaction<LocalCall> for Runtime
731where
732 RuntimeCall: From<LocalCall>,
733{
734 fn create_extension() -> Self::Extension {
735 (
736 frame_system::AuthorizeCall::<Runtime>::new(),
737 frame_system::CheckNonZeroSender::<Runtime>::new(),
738 frame_system::CheckSpecVersion::<Runtime>::new(),
739 frame_system::CheckTxVersion::<Runtime>::new(),
740 frame_system::CheckGenesis::<Runtime>::new(),
741 frame_system::CheckMortality::<Runtime>::from(generic::Era::Immortal),
742 frame_system::CheckNonce::<Runtime>::from(0),
743 frame_system::CheckWeight::<Runtime>::new(),
744 pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
745 frame_metadata_hash_extension::CheckMetadataHash::new(false),
746 frame_system::WeightReclaim::<Runtime>::new(),
747 )
748 }
749}
750
751parameter_types! {
752 pub Prefix: &'static [u8] = b"Pay ROCs to the Rococo account:";
753}
754
755impl claims::Config for Runtime {
756 type RuntimeEvent = RuntimeEvent;
757 type VestingSchedule = Vesting;
758 type Prefix = Prefix;
759 type MoveClaimOrigin = EnsureRoot<AccountId>;
760 type WeightInfo = weights::polkadot_runtime_common_claims::WeightInfo<Runtime>;
761}
762
763parameter_types! {
764 pub const BasicDeposit: Balance = 1000 * CENTS; pub const ByteDeposit: Balance = deposit(0, 1);
767 pub const UsernameDeposit: Balance = deposit(0, 32);
768 pub const SubAccountDeposit: Balance = 200 * CENTS; pub const MaxSubAccounts: u32 = 100;
770 pub const MaxAdditionalFields: u32 = 100;
771 pub const MaxRegistrars: u32 = 20;
772}
773
774impl pallet_identity::Config for Runtime {
775 type RuntimeEvent = RuntimeEvent;
776 type Currency = Balances;
777 type BasicDeposit = BasicDeposit;
778 type ByteDeposit = ByteDeposit;
779 type UsernameDeposit = UsernameDeposit;
780 type SubAccountDeposit = SubAccountDeposit;
781 type MaxSubAccounts = MaxSubAccounts;
782 type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
783 type MaxRegistrars = MaxRegistrars;
784 type Slashed = Treasury;
785 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
786 type RegistrarOrigin = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
787 type OffchainSignature = Signature;
788 type SigningPublicKey = <Signature as Verify>::Signer;
789 type UsernameAuthorityOrigin = EnsureRoot<Self::AccountId>;
790 type PendingUsernameExpiration = ConstU32<{ 7 * DAYS }>;
791 type UsernameGracePeriod = ConstU32<{ 30 * DAYS }>;
792 type MaxSuffixLength = ConstU32<7>;
793 type MaxUsernameLength = ConstU32<32>;
794 #[cfg(feature = "runtime-benchmarks")]
795 type BenchmarkHelper = ();
796 type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
797}
798
799impl pallet_utility::Config for Runtime {
800 type RuntimeEvent = RuntimeEvent;
801 type RuntimeCall = RuntimeCall;
802 type PalletsOrigin = OriginCaller;
803 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
804}
805
806parameter_types! {
807 pub const DepositBase: Balance = deposit(1, 88);
809 pub const DepositFactor: Balance = deposit(0, 32);
811 pub const MaxSignatories: u32 = 100;
812}
813
814impl pallet_multisig::Config for Runtime {
815 type RuntimeEvent = RuntimeEvent;
816 type RuntimeCall = RuntimeCall;
817 type Currency = Balances;
818 type DepositBase = DepositBase;
819 type DepositFactor = DepositFactor;
820 type MaxSignatories = MaxSignatories;
821 type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
822 type BlockNumberProvider = frame_system::Pallet<Runtime>;
823}
824
825parameter_types! {
826 pub const ConfigDepositBase: Balance = 500 * CENTS;
827 pub const FriendDepositFactor: Balance = 50 * CENTS;
828 pub const MaxFriends: u16 = 9;
829 pub const RecoveryDeposit: Balance = 500 * CENTS;
830}
831
832impl pallet_recovery::Config for Runtime {
833 type RuntimeCall = RuntimeCall;
834 type RuntimeHoldReason = RuntimeHoldReason;
835 type BlockNumberProvider = frame_system::Pallet<Runtime>;
836 type Currency = Balances;
837 type FriendGroupsConsideration = ();
838 type AttemptConsideration = ();
839 type InheritorConsideration = ();
840 type SecurityDeposit = ();
841 type MaxFriendsPerConfig = ConstU32<100>;
842 type WeightInfo = ();
843 type Slash = (); }
845
846parameter_types! {
847 pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
848}
849
850impl pallet_society::Config for Runtime {
851 type RuntimeEvent = RuntimeEvent;
852 type Currency = Balances;
853 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
854 type GraceStrikes = ConstU32<1>;
855 type PeriodSpend = ConstU128<{ 50_000 * CENTS }>;
856 type VotingPeriod = ConstU32<{ 5 * DAYS }>;
857 type ClaimPeriod = ConstU32<{ 2 * DAYS }>;
858 type MaxLockDuration = ConstU32<{ 36 * 30 * DAYS }>;
859 type FounderSetOrigin = EnsureRoot<AccountId>;
860 type ChallengePeriod = ConstU32<{ 7 * DAYS }>;
861 type MaxPayouts = ConstU32<8>;
862 type MaxBids = ConstU32<512>;
863 type PalletId = SocietyPalletId;
864 type BlockNumberProvider = System;
865 type WeightInfo = ();
866}
867
868parameter_types! {
869 pub const MinVestedTransfer: Balance = 100 * CENTS;
870 pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
871 WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
872}
873
874impl pallet_vesting::Config for Runtime {
875 type RuntimeEvent = RuntimeEvent;
876 type Currency = Balances;
877 type BlockNumberToBalance = ConvertInto;
878 type MinVestedTransfer = MinVestedTransfer;
879 type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
880 type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
881 type BlockNumberProvider = System;
882 const MAX_VESTING_SCHEDULES: u32 = 28;
883}
884
885parameter_types! {
886 pub const ProxyDepositBase: Balance = deposit(1, 8);
888 pub const ProxyDepositFactor: Balance = deposit(0, 33);
890 pub const MaxProxies: u16 = 32;
891 pub const AnnouncementDepositBase: Balance = deposit(1, 8);
892 pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
893 pub const MaxPending: u16 = 32;
894}
895
896#[derive(
898 Copy,
899 Clone,
900 Eq,
901 PartialEq,
902 Ord,
903 PartialOrd,
904 Encode,
905 Decode,
906 DecodeWithMemTracking,
907 Debug,
908 MaxEncodedLen,
909 TypeInfo,
910)]
911pub enum ProxyType {
912 Any,
913 NonTransfer,
914 Governance,
915 IdentityJudgement,
916 CancelProxy,
917 Auction,
918 Society,
919 OnDemandOrdering,
920}
921impl Default for ProxyType {
922 fn default() -> Self {
923 Self::Any
924 }
925}
926impl InstanceFilter<RuntimeCall> for ProxyType {
927 fn filter(&self, c: &RuntimeCall) -> bool {
928 match self {
929 ProxyType::Any => true,
930 ProxyType::NonTransfer => matches!(
931 c,
932 RuntimeCall::System(..) |
933 RuntimeCall::Babe(..) |
934 RuntimeCall::Timestamp(..) |
935 RuntimeCall::Indices(pallet_indices::Call::claim {..}) |
936 RuntimeCall::Indices(pallet_indices::Call::free {..}) |
937 RuntimeCall::Indices(pallet_indices::Call::freeze {..}) |
938 RuntimeCall::Session(..) |
941 RuntimeCall::Grandpa(..) |
942 RuntimeCall::Treasury(..) |
943 RuntimeCall::Bounties(..) |
944 RuntimeCall::ChildBounties(..) |
945 RuntimeCall::ConvictionVoting(..) |
946 RuntimeCall::Referenda(..) |
947 RuntimeCall::FellowshipCollective(..) |
948 RuntimeCall::FellowshipReferenda(..) |
949 RuntimeCall::Whitelist(..) |
950 RuntimeCall::Claims(..) |
951 RuntimeCall::Utility(..) |
952 RuntimeCall::Identity(..) |
953 RuntimeCall::Society(..) |
954 RuntimeCall::Recovery(pallet_recovery::Call::set_friend_groups {..}) |
955 RuntimeCall::Recovery(pallet_recovery::Call::initiate_attempt {..}) |
956 RuntimeCall::Recovery(pallet_recovery::Call::approve_attempt {..}) |
957 RuntimeCall::Recovery(pallet_recovery::Call::finish_attempt {..}) |
958 RuntimeCall::Recovery(pallet_recovery::Call::cancel_attempt {..}) |
959 RuntimeCall::Recovery(pallet_recovery::Call::slash_attempt {..}) |
960 RuntimeCall::Vesting(pallet_vesting::Call::vest {..}) |
962 RuntimeCall::Vesting(pallet_vesting::Call::vest_other {..}) |
963 RuntimeCall::Scheduler(..) |
965 RuntimeCall::Proxy(..) |
966 RuntimeCall::Multisig(..) |
967 RuntimeCall::Nis(..) |
968 RuntimeCall::Registrar(paras_registrar::Call::register {..}) |
969 RuntimeCall::Registrar(paras_registrar::Call::deregister {..}) |
970 RuntimeCall::Registrar(paras_registrar::Call::reserve {..}) |
972 RuntimeCall::Crowdloan(..) |
973 RuntimeCall::Slots(..) |
974 RuntimeCall::Auctions(..) ),
976 ProxyType::Governance => matches!(
977 c,
978 RuntimeCall::Bounties(..) |
979 RuntimeCall::Utility(..) |
980 RuntimeCall::ChildBounties(..) |
981 RuntimeCall::ConvictionVoting(..) |
983 RuntimeCall::Referenda(..) |
984 RuntimeCall::FellowshipCollective(..) |
985 RuntimeCall::FellowshipReferenda(..) |
986 RuntimeCall::Whitelist(..)
987 ),
988 ProxyType::IdentityJudgement => matches!(
989 c,
990 RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
991 RuntimeCall::Utility(..)
992 ),
993 ProxyType::CancelProxy => {
994 matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }))
995 },
996 ProxyType::Auction => matches!(
997 c,
998 RuntimeCall::Auctions { .. } |
999 RuntimeCall::Crowdloan { .. } |
1000 RuntimeCall::Registrar { .. } |
1001 RuntimeCall::Multisig(..) |
1002 RuntimeCall::Slots { .. }
1003 ),
1004 ProxyType::Society => matches!(c, RuntimeCall::Society(..)),
1005 ProxyType::OnDemandOrdering => matches!(c, RuntimeCall::OnDemandAssignmentProvider(..)),
1006 }
1007 }
1008 fn is_superset(&self, o: &Self) -> bool {
1009 match (self, o) {
1010 (x, y) if x == y => true,
1011 (ProxyType::Any, _) => true,
1012 (_, ProxyType::Any) => false,
1013 (ProxyType::NonTransfer, _) => true,
1014 _ => false,
1015 }
1016 }
1017}
1018
1019impl pallet_proxy::Config for Runtime {
1020 type RuntimeEvent = RuntimeEvent;
1021 type RuntimeCall = RuntimeCall;
1022 type Currency = Balances;
1023 type ProxyType = ProxyType;
1024 type ProxyDepositBase = ProxyDepositBase;
1025 type ProxyDepositFactor = ProxyDepositFactor;
1026 type MaxProxies = MaxProxies;
1027 type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
1028 type MaxPending = MaxPending;
1029 type CallHasher = BlakeTwo256;
1030 type AnnouncementDepositBase = AnnouncementDepositBase;
1031 type AnnouncementDepositFactor = AnnouncementDepositFactor;
1032 type BlockNumberProvider = frame_system::Pallet<Runtime>;
1033}
1034
1035impl parachains_origin::Config for Runtime {}
1036
1037impl parachains_configuration::Config for Runtime {
1038 type WeightInfo = weights::polkadot_runtime_parachains_configuration::WeightInfo<Runtime>;
1039}
1040
1041impl parachains_shared::Config for Runtime {
1042 type DisabledValidators = Session;
1043}
1044
1045impl parachains_session_info::Config for Runtime {
1046 type ValidatorSet = Historical;
1047}
1048
1049pub struct RewardValidators;
1051impl polkadot_runtime_parachains::inclusion::RewardValidators for RewardValidators {
1052 fn reward_backing(_: impl IntoIterator<Item = ValidatorIndex>) {}
1053 fn reward_bitfields(_: impl IntoIterator<Item = ValidatorIndex>) {}
1054}
1055
1056impl parachains_inclusion::Config for Runtime {
1057 type RuntimeEvent = RuntimeEvent;
1058 type DisputesHandler = ParasDisputes;
1059 type RewardValidators = RewardValidators;
1060 type MessageQueue = MessageQueue;
1061 type WeightInfo = weights::polkadot_runtime_parachains_inclusion::WeightInfo<Runtime>;
1062}
1063
1064parameter_types! {
1065 pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
1066}
1067
1068impl parachains_paras::Config for Runtime {
1069 type RuntimeEvent = RuntimeEvent;
1070 type WeightInfo = weights::polkadot_runtime_parachains_paras::WeightInfo<Runtime>;
1071 type UnsignedPriority = ParasUnsignedPriority;
1072 type QueueFootprinter = ParaInclusion;
1073 type NextSessionRotation = Babe;
1074 type OnNewHead = Registrar;
1075 type AssignCoretime = ParaScheduler;
1076 type Fungible = Balances;
1077 type CooldownRemovalMultiplier = ConstUint<{ 1000 * UNITS / DAYS as u128 }>;
1079 type AuthorizeCurrentCodeOrigin = EnsureRoot<AccountId>;
1080}
1081
1082parameter_types! {
1083 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(20) * BlockWeights::get().max_block;
1089 pub const MessageQueueHeapSize: u32 = 32 * 1024;
1090 pub const MessageQueueMaxStale: u32 = 96;
1091}
1092
1093pub struct MessageProcessor;
1095impl ProcessMessage for MessageProcessor {
1096 type Origin = AggregateMessageOrigin;
1097
1098 fn process_message(
1099 message: &[u8],
1100 origin: Self::Origin,
1101 meter: &mut WeightMeter,
1102 id: &mut [u8; 32],
1103 ) -> Result<bool, ProcessMessageError> {
1104 let para = match origin {
1105 AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para,
1106 };
1107 xcm_builder::ProcessXcmMessage::<
1108 Junction,
1109 xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
1110 RuntimeCall,
1111 >::process_message(message, Junction::Parachain(para.into()), meter, id)
1112 }
1113}
1114
1115impl pallet_message_queue::Config for Runtime {
1116 type RuntimeEvent = RuntimeEvent;
1117 type Size = u32;
1118 type HeapSize = MessageQueueHeapSize;
1119 type MaxStale = MessageQueueMaxStale;
1120 type ServiceWeight = MessageQueueServiceWeight;
1121 type IdleMaxServiceWeight = MessageQueueServiceWeight;
1122 #[cfg(not(feature = "runtime-benchmarks"))]
1123 type MessageProcessor = MessageProcessor;
1124 #[cfg(feature = "runtime-benchmarks")]
1125 type MessageProcessor =
1126 pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
1127 type QueueChangeHandler = ParaInclusion;
1128 type QueuePausedQuery = ();
1129 type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
1130}
1131
1132impl parachains_dmp::Config for Runtime {
1133 type WeightInfo = ();
1134}
1135
1136parameter_types! {
1137 pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
1138}
1139
1140impl parachains_hrmp::Config for Runtime {
1141 type RuntimeOrigin = RuntimeOrigin;
1142 type RuntimeEvent = RuntimeEvent;
1143 type ChannelManager = EnsureRoot<AccountId>;
1144 type Currency = Balances;
1145 type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
1146 Runtime,
1147 HrmpChannelSizeAndCapacityWithSystemRatio,
1148 >;
1149 type VersionWrapper = crate::XcmPallet;
1150 type WeightInfo = weights::polkadot_runtime_parachains_hrmp::WeightInfo<Runtime>;
1151}
1152
1153impl parachains_paras_inherent::Config for Runtime {
1154 type WeightInfo = weights::polkadot_runtime_parachains_paras_inherent::WeightInfo<Runtime>;
1155}
1156
1157impl parachains_scheduler::Config for Runtime {}
1158
1159parameter_types! {
1160 pub const BrokerId: u32 = BROKER_ID;
1161 pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
1162 pub MaxXcmTransactWeight: Weight = Weight::from_parts(200_000_000, 20_000);
1163}
1164
1165pub struct BrokerPot;
1166impl Get<InteriorLocation> for BrokerPot {
1167 fn get() -> InteriorLocation {
1168 Junction::AccountId32 { network: None, id: BrokerPalletId::get().into_account_truncating() }
1169 .into()
1170 }
1171}
1172
1173impl coretime::Config for Runtime {
1174 type RuntimeOrigin = RuntimeOrigin;
1175 type RuntimeEvent = RuntimeEvent;
1176 type BrokerId = BrokerId;
1177 type BrokerPotLocation = BrokerPot;
1178 type WeightInfo = weights::polkadot_runtime_parachains_coretime::WeightInfo<Runtime>;
1179 type SendXcm = crate::xcm_config::XcmRouter;
1180 type AssetTransactor = crate::xcm_config::LocalAssetTransactor;
1181 type AccountToLocation = xcm_builder::AliasesIntoAccountId32<
1182 xcm_config::ThisNetwork,
1183 <Runtime as frame_system::Config>::AccountId,
1184 >;
1185 type MaxXcmTransactWeight = MaxXcmTransactWeight;
1186}
1187
1188parameter_types! {
1189 pub const OnDemandTrafficDefaultValue: FixedU128 = FixedU128::from_u32(1);
1190 pub const MaxHistoricalRevenue: BlockNumber = 2 * TIMESLICE_PERIOD;
1192 pub const OnDemandPalletId: PalletId = PalletId(*b"py/ondmd");
1193}
1194
1195impl parachains_on_demand::Config for Runtime {
1196 type RuntimeEvent = RuntimeEvent;
1197 type Currency = Balances;
1198 type TrafficDefaultValue = OnDemandTrafficDefaultValue;
1199 type WeightInfo = weights::polkadot_runtime_parachains_on_demand::WeightInfo<Runtime>;
1200 type MaxHistoricalRevenue = MaxHistoricalRevenue;
1201 type PalletId = OnDemandPalletId;
1202}
1203
1204impl parachains_initializer::Config for Runtime {
1205 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1206 type ForceOrigin = EnsureRoot<AccountId>;
1207 type WeightInfo = weights::polkadot_runtime_parachains_initializer::WeightInfo<Runtime>;
1208 type CoretimeOnNewSession = Coretime;
1209}
1210
1211impl parachains_disputes::Config for Runtime {
1212 type RuntimeEvent = RuntimeEvent;
1213 type RewardValidators = ();
1214 type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes<ParasSlashing>;
1215 type WeightInfo = weights::polkadot_runtime_parachains_disputes::WeightInfo<Runtime>;
1216}
1217
1218impl parachains_slashing::Config for Runtime {
1219 type KeyOwnerProofSystem = Historical;
1220 type KeyOwnerProof =
1221 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
1222 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
1223 KeyTypeId,
1224 ValidatorId,
1225 )>>::IdentificationTuple;
1226 type HandleReports = parachains_slashing::SlashingReportHandler<
1227 Self::KeyOwnerIdentification,
1228 Offences,
1229 ReportLongevity,
1230 >;
1231 type WeightInfo = parachains_slashing::TestWeightInfo;
1232 type BenchmarkingConfig = parachains_slashing::BenchConfig<200>;
1233}
1234
1235parameter_types! {
1236 pub const ParaDeposit: Balance = 40 * UNITS;
1237}
1238
1239impl paras_registrar::Config for Runtime {
1240 type RuntimeOrigin = RuntimeOrigin;
1241 type RuntimeEvent = RuntimeEvent;
1242 type Currency = Balances;
1243 type OnSwap = (Crowdloan, Slots, SwapLeases);
1244 type ParaDeposit = ParaDeposit;
1245 type DataDepositPerByte = DataDepositPerByte;
1246 type WeightInfo = weights::polkadot_runtime_common_paras_registrar::WeightInfo<Runtime>;
1247}
1248
1249parameter_types! {
1250 pub LeasePeriod: BlockNumber = prod_or_fast!(1 * DAYS, 1 * DAYS, "ROC_LEASE_PERIOD");
1251}
1252
1253impl slots::Config for Runtime {
1254 type RuntimeEvent = RuntimeEvent;
1255 type Currency = Balances;
1256 type Registrar = Registrar;
1257 type LeasePeriod = LeasePeriod;
1258 type LeaseOffset = ();
1259 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, LeaseAdmin>;
1260 type WeightInfo = weights::polkadot_runtime_common_slots::WeightInfo<Runtime>;
1261}
1262
1263parameter_types! {
1264 pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
1265 pub const SubmissionDeposit: Balance = 3 * GRAND;
1266 pub const MinContribution: Balance = 3_000 * CENTS;
1267 pub const RemoveKeysLimit: u32 = 1000;
1268 pub const MaxMemoLength: u8 = 32;
1270}
1271
1272impl crowdloan::Config for Runtime {
1273 type RuntimeEvent = RuntimeEvent;
1274 type PalletId = CrowdloanId;
1275 type SubmissionDeposit = SubmissionDeposit;
1276 type MinContribution = MinContribution;
1277 type RemoveKeysLimit = RemoveKeysLimit;
1278 type Registrar = Registrar;
1279 type Auctioneer = Auctions;
1280 type MaxMemoLength = MaxMemoLength;
1281 type WeightInfo = weights::polkadot_runtime_common_crowdloan::WeightInfo<Runtime>;
1282}
1283
1284parameter_types! {
1285 pub const EndingPeriod: BlockNumber = 5 * DAYS;
1288 pub const SampleLength: BlockNumber = 2 * MINUTES;
1290}
1291
1292impl auctions::Config for Runtime {
1293 type RuntimeEvent = RuntimeEvent;
1294 type Leaser = Slots;
1295 type Registrar = Registrar;
1296 type EndingPeriod = EndingPeriod;
1297 type SampleLength = SampleLength;
1298 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1299 type InitiateOrigin = EitherOf<EnsureRoot<Self::AccountId>, AuctionAdmin>;
1300 type WeightInfo = weights::polkadot_runtime_common_auctions::WeightInfo<Runtime>;
1301}
1302
1303impl identity_migrator::Config for Runtime {
1304 type RuntimeEvent = RuntimeEvent;
1305 type Reaper = EnsureSigned<AccountId>;
1306 type ReapIdentityHandler = ToParachainIdentityReaper<Runtime, Self::AccountId>;
1307 type WeightInfo = weights::polkadot_runtime_common_identity_migrator::WeightInfo<Runtime>;
1308}
1309
1310type NisCounterpartInstance = pallet_balances::Instance2;
1311impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
1312 type Balance = Balance;
1313 type DustRemoval = ();
1314 type RuntimeEvent = RuntimeEvent;
1315 type ExistentialDeposit = ConstU128<10_000_000_000>; type AccountStore = StorageMapShim<
1317 pallet_balances::Account<Runtime, NisCounterpartInstance>,
1318 AccountId,
1319 pallet_balances::AccountData<u128>,
1320 >;
1321 type MaxLocks = ConstU32<4>;
1322 type MaxReserves = ConstU32<4>;
1323 type ReserveIdentifier = [u8; 8];
1324 type WeightInfo = weights::pallet_balances_nis_counterpart_balances::WeightInfo<Runtime>;
1325 type RuntimeHoldReason = RuntimeHoldReason;
1326 type RuntimeFreezeReason = RuntimeFreezeReason;
1327 type FreezeIdentifier = ();
1328 type MaxFreezes = ConstU32<1>;
1329 type DoneSlashHandler = ();
1330}
1331
1332parameter_types! {
1333 pub const NisBasePeriod: BlockNumber = 30 * DAYS;
1334 pub MinReceipt: Perquintill = Perquintill::from_rational(1u64, 10_000_000u64);
1335 pub const IntakePeriod: BlockNumber = 5 * MINUTES;
1336 pub MaxIntakeWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
1337 pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
1338 pub const NisPalletId: PalletId = PalletId(*b"py/nis ");
1339}
1340
1341impl pallet_nis::Config for Runtime {
1342 type WeightInfo = weights::pallet_nis::WeightInfo<Runtime>;
1343 type RuntimeEvent = RuntimeEvent;
1344 type Currency = Balances;
1345 type CurrencyBalance = Balance;
1346 type FundOrigin = frame_system::EnsureSigned<AccountId>;
1347 type Counterpart = NisCounterpartBalances;
1348 type CounterpartAmount = WithMaximumOf<ConstU128<21_000_000_000_000_000_000u128>>;
1349 type Deficit = (); type IgnoredIssuance = ();
1351 type Target = dynamic_params::nis::Target;
1352 type PalletId = NisPalletId;
1353 type QueueCount = ConstU32<300>;
1354 type MaxQueueLen = ConstU32<1000>;
1355 type FifoQueueLen = ConstU32<250>;
1356 type BasePeriod = NisBasePeriod;
1357 type MinBid = dynamic_params::nis::MinBid;
1358 type MinReceipt = MinReceipt;
1359 type IntakePeriod = IntakePeriod;
1360 type MaxIntakeWeight = MaxIntakeWeight;
1361 type ThawThrottle = ThawThrottle;
1362 type RuntimeHoldReason = RuntimeHoldReason;
1363 #[cfg(feature = "runtime-benchmarks")]
1364 type BenchmarkSetup = ();
1365}
1366
1367impl pallet_parameters::Config for Runtime {
1368 type RuntimeEvent = RuntimeEvent;
1369 type RuntimeParameters = RuntimeParameters;
1370 type AdminOrigin = DynamicParameterOrigin;
1371 type WeightInfo = weights::pallet_parameters::WeightInfo<Runtime>;
1372}
1373
1374parameter_types! {
1375 pub BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
1376}
1377
1378impl pallet_beefy::Config for Runtime {
1379 type BeefyId = BeefyId;
1380 type MaxAuthorities = MaxAuthorities;
1381 type MaxNominators = ConstU32<0>;
1382 type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
1383 type OnNewValidatorSet = MmrLeaf;
1384 type AncestryHelper = MmrLeaf;
1385 type WeightInfo = ();
1386 type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, BeefyId)>>::Proof;
1387 type EquivocationReportSystem =
1388 pallet_beefy::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
1389}
1390
1391mod mmr {
1393 use super::Runtime;
1394 pub use pallet_mmr::primitives::*;
1395
1396 pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
1397 pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
1398 pub type Hash = <Hashing as sp_runtime::traits::Hash>::Output;
1399}
1400
1401impl pallet_mmr::Config for Runtime {
1402 const INDEXING_PREFIX: &'static [u8] = mmr::INDEXING_PREFIX;
1403 type Hashing = Keccak256;
1404 type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
1405 type LeafData = pallet_beefy_mmr::Pallet<Runtime>;
1406 type BlockHashProvider = pallet_mmr::DefaultBlockHashProvider<Runtime>;
1407 type WeightInfo = weights::pallet_mmr::WeightInfo<Runtime>;
1408 #[cfg(feature = "runtime-benchmarks")]
1409 type BenchmarkHelper = parachains_paras::benchmarking::mmr_setup::MmrSetup<Runtime>;
1410}
1411
1412parameter_types! {
1413 pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0);
1414}
1415
1416pub struct ParaHeadsRootProvider;
1417impl BeefyDataProvider<H256> for ParaHeadsRootProvider {
1418 fn extra_data() -> H256 {
1419 let para_heads: Vec<(u32, Vec<u8>)> =
1420 parachains_paras::Pallet::<Runtime>::sorted_para_heads();
1421 binary_merkle_tree::merkle_root::<mmr::Hashing, _>(
1422 para_heads.into_iter().map(|pair| pair.encode()),
1423 )
1424 .into()
1425 }
1426}
1427
1428impl pallet_beefy_mmr::Config for Runtime {
1429 type LeafVersion = LeafVersion;
1430 type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum;
1431 type LeafExtra = H256;
1432 type BeefyDataProvider = ParaHeadsRootProvider;
1433 type WeightInfo = weights::pallet_beefy_mmr::WeightInfo<Runtime>;
1434}
1435
1436impl paras_sudo_wrapper::Config for Runtime {}
1437
1438parameter_types! {
1439 pub const PermanentSlotLeasePeriodLength: u32 = 365;
1440 pub const TemporarySlotLeasePeriodLength: u32 = 5;
1441 pub const MaxTemporarySlotPerLeasePeriod: u32 = 5;
1442}
1443
1444impl assigned_slots::Config for Runtime {
1445 type RuntimeEvent = RuntimeEvent;
1446 type AssignSlotOrigin = EnsureRoot<AccountId>;
1447 type Leaser = Slots;
1448 type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
1449 type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength;
1450 type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod;
1451 type WeightInfo = weights::polkadot_runtime_common_assigned_slots::WeightInfo<Runtime>;
1452}
1453
1454impl validator_manager::Config for Runtime {
1455 type RuntimeEvent = RuntimeEvent;
1456 type PrivilegedOrigin = EnsureRoot<AccountId>;
1457}
1458
1459parameter_types! {
1460 pub MbmServiceWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
1461}
1462
1463impl pallet_migrations::Config for Runtime {
1464 type RuntimeEvent = RuntimeEvent;
1465 #[cfg(not(feature = "runtime-benchmarks"))]
1466 type Migrations = (
1467 pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>,
1468 parachains_dmp::migration::MigrateV0ToV1<Runtime>,
1469 );
1470 #[cfg(feature = "runtime-benchmarks")]
1472 type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
1473 type CursorMaxLen = ConstU32<65_536>;
1474 type IdentifierMaxLen = ConstU32<256>;
1475 type MigrationStatusHandler = ();
1476 type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
1477 type MaxServiceWeight = MbmServiceWeight;
1478 type WeightInfo = weights::pallet_migrations::WeightInfo<Runtime>;
1479}
1480
1481impl pallet_sudo::Config for Runtime {
1482 type RuntimeEvent = RuntimeEvent;
1483 type RuntimeCall = RuntimeCall;
1484 type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
1485}
1486
1487impl pallet_root_testing::Config for Runtime {
1488 type RuntimeEvent = RuntimeEvent;
1489}
1490
1491impl pallet_asset_rate::Config for Runtime {
1492 type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
1493 type RuntimeEvent = RuntimeEvent;
1494 type CreateOrigin = EnsureRoot<AccountId>;
1495 type RemoveOrigin = EnsureRoot<AccountId>;
1496 type UpdateOrigin = EnsureRoot<AccountId>;
1497 type Currency = Balances;
1498 type AssetKind = <Runtime as pallet_treasury::Config>::AssetKind;
1499 #[cfg(feature = "runtime-benchmarks")]
1500 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
1501}
1502
1503pub struct SwapLeases;
1505impl OnSwap for SwapLeases {
1506 fn on_swap(one: ParaId, other: ParaId) {
1507 coretime::Pallet::<Runtime>::on_legacy_lease_swap(one, other);
1508 }
1509}
1510
1511construct_runtime! {
1512 pub enum Runtime
1513 {
1514 System: frame_system = 0,
1516
1517 Babe: pallet_babe = 1,
1519
1520 Timestamp: pallet_timestamp = 2,
1521 Indices: pallet_indices = 3,
1522 Balances: pallet_balances = 4,
1523 Parameters: pallet_parameters = 6,
1524 TransactionPayment: pallet_transaction_payment = 33,
1525
1526 Authorship: pallet_authorship = 5,
1529 Offences: pallet_offences = 7,
1530 Historical: session_historical = 34,
1531
1532 Session: pallet_session = 8,
1533 Grandpa: pallet_grandpa = 10,
1534 AuthorityDiscovery: pallet_authority_discovery = 12,
1535
1536 Treasury: pallet_treasury = 18,
1538 ConvictionVoting: pallet_conviction_voting = 20,
1539 Referenda: pallet_referenda = 21,
1540 FellowshipCollective: pallet_ranked_collective::<Instance1> = 22,
1542 FellowshipReferenda: pallet_referenda::<Instance2> = 23,
1544 Origins: pallet_custom_origins = 43,
1545 Whitelist: pallet_whitelist = 44,
1546 Claims: claims = 19,
1548
1549 Utility: pallet_utility = 24,
1551
1552 Identity: pallet_identity = 25,
1554
1555 Society: pallet_society = 26,
1557
1558 Recovery: pallet_recovery = 27,
1560
1561 Vesting: pallet_vesting = 28,
1563
1564 Scheduler: pallet_scheduler = 29,
1566
1567 Proxy: pallet_proxy = 30,
1569
1570 Multisig: pallet_multisig = 31,
1572
1573 Preimage: pallet_preimage = 32,
1575
1576 AssetRate: pallet_asset_rate = 39,
1578
1579 Bounties: pallet_bounties = 35,
1581 ChildBounties: pallet_child_bounties = 40,
1582
1583 Nis: pallet_nis = 38,
1585 NisCounterpartBalances: pallet_balances::<Instance2> = 45,
1587
1588 ParachainsOrigin: parachains_origin = 50,
1590 Configuration: parachains_configuration = 51,
1591 ParasShared: parachains_shared = 52,
1592 ParaInclusion: parachains_inclusion = 53,
1593 ParaInherent: parachains_paras_inherent = 54,
1594 ParaScheduler: parachains_scheduler = 55,
1595 Paras: parachains_paras = 56,
1596 Initializer: parachains_initializer = 57,
1597 Dmp: parachains_dmp = 58,
1598 Hrmp: parachains_hrmp = 60,
1599 ParaSessionInfo: parachains_session_info = 61,
1600 ParasDisputes: parachains_disputes = 62,
1601 ParasSlashing: parachains_slashing = 63,
1602 MessageQueue: pallet_message_queue = 64,
1603 OnDemandAssignmentProvider: parachains_on_demand = 66,
1604 Registrar: paras_registrar = 70,
1608 Slots: slots = 71,
1609 Auctions: auctions = 72,
1610 Crowdloan: crowdloan = 73,
1611 Coretime: coretime = 74,
1612
1613 MultiBlockMigrations: pallet_migrations = 98,
1615
1616 XcmPallet: pallet_xcm = 99,
1618
1619 Beefy: pallet_beefy = 240,
1621 Mmr: pallet_mmr = 241,
1624 MmrLeaf: pallet_beefy_mmr = 242,
1625
1626 IdentityMigrator: identity_migrator = 248,
1628
1629 ParasSudoWrapper: paras_sudo_wrapper = 250,
1630 AssignedSlots: assigned_slots = 251,
1631
1632 ValidatorManager: validator_manager = 252,
1634
1635 StateTrieMigration: pallet_state_trie_migration = 254,
1637
1638 RootTesting: pallet_root_testing = 249,
1640
1641 Sudo: pallet_sudo = 255,
1643 }
1644}
1645
1646pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
1648pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
1650pub type Block = generic::Block<Header, UncheckedExtrinsic>;
1652pub type SignedBlock = generic::SignedBlock<Block>;
1654pub type BlockId = generic::BlockId<Block>;
1656pub type TxExtension = (
1658 frame_system::AuthorizeCall<Runtime>,
1659 frame_system::CheckNonZeroSender<Runtime>,
1660 frame_system::CheckSpecVersion<Runtime>,
1661 frame_system::CheckTxVersion<Runtime>,
1662 frame_system::CheckGenesis<Runtime>,
1663 frame_system::CheckMortality<Runtime>,
1664 frame_system::CheckNonce<Runtime>,
1665 frame_system::CheckWeight<Runtime>,
1666 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
1667 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
1668 frame_system::WeightReclaim<Runtime>,
1669);
1670
1671pub type UncheckedExtrinsic =
1673 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
1674pub type UncheckedSignaturePayload =
1676 generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
1677
1678pub type Migrations = migrations::Unreleased;
1683
1684#[allow(deprecated, missing_docs)]
1686pub mod migrations {
1687 use super::*;
1688
1689 use frame_support::traits::LockIdentifier;
1690 use frame_system::pallet_prelude::BlockNumberFor;
1691
1692 parameter_types! {
1693 pub const DemocracyPalletName: &'static str = "Democracy";
1694 pub const CouncilPalletName: &'static str = "Council";
1695 pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
1696 pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
1697 pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
1698 pub const TipsPalletName: &'static str = "Tips";
1699 pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
1700 pub BalanceUnreserveWeight: Weight = weights::pallet_balances_balances::WeightInfo::<Runtime>::force_unreserve();
1702 pub BalanceTransferAllowDeath: Weight = weights::pallet_balances_balances::WeightInfo::<Runtime>::transfer_allow_death();
1703 }
1704
1705 pub struct UnlockConfig;
1708 impl pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockConfig for UnlockConfig {
1709 type Currency = Balances;
1710 type MaxVotes = ConstU32<100>;
1711 type MaxDeposits = ConstU32<100>;
1712 type AccountId = AccountId;
1713 type BlockNumber = BlockNumberFor<Runtime>;
1714 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1715 type PalletName = DemocracyPalletName;
1716 }
1717 impl pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockConfig
1718 for UnlockConfig
1719 {
1720 type Currency = Balances;
1721 type MaxVotesPerVoter = ConstU32<16>;
1722 type PalletId = PhragmenElectionPalletId;
1723 type AccountId = AccountId;
1724 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1725 type PalletName = PhragmenElectionPalletName;
1726 }
1727 impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfig {
1728 type Currency = Balances;
1729 type Hash = Hash;
1730 type DataDepositPerByte = DataDepositPerByte;
1731 type TipReportDepositBase = TipReportDepositBase;
1732 type AccountId = AccountId;
1733 type BlockNumber = BlockNumberFor<Runtime>;
1734 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1735 type PalletName = TipsPalletName;
1736 }
1737
1738 const IDENTITY_MIGRATION_KEY_LIMIT: u64 = u64::MAX;
1740
1741 pub type Unreleased = (
1743 pallet_society::migrations::MigrateToV2<Runtime, (), ()>,
1744 parachains_configuration::migration::v7::MigrateToV7<Runtime>,
1745 assigned_slots::migration::v1::MigrateToV1<Runtime>,
1746 parachains_configuration::migration::v8::MigrateToV8<Runtime>,
1747 parachains_configuration::migration::v9::MigrateToV9<Runtime>,
1748 paras_registrar::migration::MigrateToV1<Runtime, ()>,
1749 pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, ()>,
1750 pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, pallet_referenda::Instance2>,
1751 pallet_child_bounties::migration::MigrateV0ToV1<Runtime, BalanceTransferAllowDeath>,
1752
1753 pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
1756 pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
1757 pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfig, ()>,
1758 pallet_treasury::migration::cleanup_proposals::Migration<Runtime, (), BalanceUnreserveWeight>,
1759
1760 frame_support::migrations::RemovePallet<DemocracyPalletName, <Runtime as frame_system::Config>::DbWeight>,
1763 frame_support::migrations::RemovePallet<CouncilPalletName, <Runtime as frame_system::Config>::DbWeight>,
1764 frame_support::migrations::RemovePallet<TechnicalCommitteePalletName, <Runtime as frame_system::Config>::DbWeight>,
1765 frame_support::migrations::RemovePallet<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
1766 frame_support::migrations::RemovePallet<TechnicalMembershipPalletName, <Runtime as frame_system::Config>::DbWeight>,
1767 frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
1768 pallet_grandpa::migrations::MigrateV4ToV5<Runtime>,
1769 parachains_configuration::migration::v10::MigrateToV10<Runtime>,
1770
1771 pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
1773
1774 pallet_session::migrations::v1::MigrateV0ToV1<Runtime, pallet_session::migrations::v1::InitOffenceSeverity<Runtime>>,
1776
1777 parachains_on_demand::migration::MigrateV1ToV2<Runtime>,
1779 parachains_scheduler::migration::MigrateV3ToV4<Runtime>,
1780
1781 parachains_configuration::migration::v13::MigrateToV13<Runtime>,
1782 parachains_shared::migration::MigrateToV2<Runtime>,
1783
1784 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
1786 parachains_inclusion::migration::MigrateToV1<Runtime>,
1787 );
1788}
1789
1790pub type Executive = frame_executive::Executive<
1792 Runtime,
1793 Block,
1794 frame_system::ChainContext<Runtime>,
1795 Runtime,
1796 AllPalletsWithSystem,
1797>;
1798pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
1800
1801parameter_types! {
1802 pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
1804 pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100;
1805 pub const MigrationMaxKeyLen: u32 = 512;
1806}
1807
1808impl pallet_state_trie_migration::Config for Runtime {
1809 type RuntimeEvent = RuntimeEvent;
1810 type Currency = Balances;
1811 type RuntimeHoldReason = RuntimeHoldReason;
1812 type SignedDepositPerItem = MigrationSignedDepositPerItem;
1813 type SignedDepositBase = MigrationSignedDepositBase;
1814 type ControlOrigin = EnsureRoot<AccountId>;
1815 type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
1817
1818 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
1820 type MaxKeyLen = MigrationMaxKeyLen;
1821}
1822
1823frame_support::ord_parameter_types! {
1824 pub const MigController: AccountId = AccountId::from(hex_literal::hex!("52bc71c1eca5353749542dfdf0af97bf764f9c2f44e860cd485f1cd86400f649"));
1825}
1826
1827#[cfg(feature = "runtime-benchmarks")]
1828mod benches {
1829 frame_benchmarking::define_benchmarks!(
1830 [polkadot_runtime_common::assigned_slots, AssignedSlots]
1834 [polkadot_runtime_common::auctions, Auctions]
1835 [polkadot_runtime_common::crowdloan, Crowdloan]
1836 [polkadot_runtime_common::claims, Claims]
1837 [polkadot_runtime_common::identity_migrator, IdentityMigrator]
1838 [polkadot_runtime_common::slots, Slots]
1839 [polkadot_runtime_common::paras_registrar, Registrar]
1840 [polkadot_runtime_parachains::configuration, Configuration]
1841 [polkadot_runtime_parachains::coretime, Coretime]
1842 [polkadot_runtime_parachains::dmp, Dmp]
1843 [polkadot_runtime_parachains::hrmp, Hrmp]
1844 [polkadot_runtime_parachains::disputes, ParasDisputes]
1845 [polkadot_runtime_parachains::inclusion, ParaInclusion]
1846 [polkadot_runtime_parachains::initializer, Initializer]
1847 [polkadot_runtime_parachains::paras_inherent, ParaInherent]
1848 [polkadot_runtime_parachains::paras, Paras]
1849 [polkadot_runtime_parachains::on_demand, OnDemandAssignmentProvider]
1850 [pallet_balances, Balances]
1852 [pallet_balances, NisCounterpartBalances]
1853 [pallet_beefy_mmr, MmrLeaf]
1854 [frame_benchmarking::baseline, Baseline::<Runtime>]
1855 [pallet_bounties, Bounties]
1856 [pallet_child_bounties, ChildBounties]
1857 [pallet_conviction_voting, ConvictionVoting]
1858 [pallet_nis, Nis]
1859 [pallet_identity, Identity]
1860 [pallet_indices, Indices]
1861 [pallet_message_queue, MessageQueue]
1862 [pallet_migrations, MultiBlockMigrations]
1863 [pallet_mmr, Mmr]
1864 [pallet_multisig, Multisig]
1865 [pallet_parameters, Parameters]
1866 [pallet_preimage, Preimage]
1867 [pallet_proxy, Proxy]
1868 [pallet_ranked_collective, FellowshipCollective]
1869 [pallet_recovery, Recovery]
1870 [pallet_referenda, Referenda]
1871 [pallet_referenda, FellowshipReferenda]
1872 [pallet_scheduler, Scheduler]
1873 [pallet_sudo, Sudo]
1874 [frame_system, SystemBench::<Runtime>]
1875 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
1876 [pallet_timestamp, Timestamp]
1877 [pallet_transaction_payment, TransactionPayment]
1878 [pallet_treasury, Treasury]
1879 [pallet_utility, Utility]
1880 [pallet_vesting, Vesting]
1881 [pallet_asset_rate, AssetRate]
1882 [pallet_whitelist, Whitelist]
1883 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
1885 [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
1886 [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
1887 );
1888}
1889
1890sp_api::impl_runtime_apis! {
1891 impl sp_api::Core<Block> for Runtime {
1892 fn version() -> RuntimeVersion {
1893 VERSION
1894 }
1895
1896 fn execute_block(block: <Block as BlockT>::LazyBlock) {
1897 Executive::execute_block(block);
1898 }
1899
1900 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
1901 Executive::initialize_block(header)
1902 }
1903 }
1904
1905 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
1906 fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
1907 let acceptable_assets = vec![AssetId(xcm_config::TokenLocation::get())];
1908 XcmPallet::query_acceptable_payment_assets(xcm_version, acceptable_assets)
1909 }
1910
1911 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
1912 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
1913 XcmPallet::query_weight_to_asset_fee::<Trader>(weight, asset)
1914 }
1915
1916 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
1917 XcmPallet::query_xcm_weight(message)
1918 }
1919
1920 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>, asset_id: VersionedAssetId) -> Result<VersionedAssets, XcmPaymentApiError> {
1921 type AssetExchanger = <XcmConfig as xcm_executor::Config>::AssetExchanger;
1922 XcmPallet::query_delivery_fees::<AssetExchanger>(destination, message, asset_id)
1923 }
1924 }
1925
1926 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
1927 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1928 XcmPallet::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
1929 }
1930
1931 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1932 XcmPallet::dry_run_xcm::<xcm_config::XcmRouter>(origin_location, xcm)
1933 }
1934 }
1935
1936 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
1937 fn convert_location(location: VersionedLocation) -> Result<
1938 AccountId,
1939 xcm_runtime_apis::conversions::Error
1940 > {
1941 xcm_runtime_apis::conversions::LocationToAccountHelper::<
1942 AccountId,
1943 xcm_config::LocationConverter,
1944 >::convert_location(location)
1945 }
1946 }
1947
1948 impl sp_api::Metadata<Block> for Runtime {
1949 fn metadata() -> OpaqueMetadata {
1950 OpaqueMetadata::new(Runtime::metadata().into())
1951 }
1952
1953 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
1954 Runtime::metadata_at_version(version)
1955 }
1956
1957 fn metadata_versions() -> alloc::vec::Vec<u32> {
1958 Runtime::metadata_versions()
1959 }
1960 }
1961
1962 impl sp_block_builder::BlockBuilder<Block> for Runtime {
1963 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
1964 Executive::apply_extrinsic(extrinsic)
1965 }
1966
1967 fn finalize_block() -> <Block as BlockT>::Header {
1968 Executive::finalize_block()
1969 }
1970
1971 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
1972 data.create_extrinsics()
1973 }
1974
1975 fn check_inherents(
1976 block: <Block as BlockT>::LazyBlock,
1977 data: sp_inherents::InherentData,
1978 ) -> sp_inherents::CheckInherentsResult {
1979 data.check_extrinsics(&block)
1980 }
1981 }
1982
1983 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
1984 fn validate_transaction(
1985 source: TransactionSource,
1986 tx: <Block as BlockT>::Extrinsic,
1987 block_hash: <Block as BlockT>::Hash,
1988 ) -> TransactionValidity {
1989 Executive::validate_transaction(source, tx, block_hash)
1990 }
1991 }
1992
1993 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
1994 fn offchain_worker(header: &<Block as BlockT>::Header) {
1995 Executive::offchain_worker(header)
1996 }
1997 }
1998
1999 #[api_version(16)]
2000 impl polkadot_primitives::runtime_api::ParachainHost<Block> for Runtime {
2001 fn validators() -> Vec<ValidatorId> {
2002 parachains_runtime_api_impl::validators::<Runtime>()
2003 }
2004
2005 fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
2006 parachains_runtime_api_impl::validator_groups::<Runtime>()
2007 }
2008
2009 fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>> {
2010 parachains_runtime_api_impl::availability_cores::<Runtime>()
2011 }
2012
2013 fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
2014 -> Option<PersistedValidationData<Hash, BlockNumber>> {
2015 parachains_runtime_api_impl::persisted_validation_data::<Runtime>(para_id, assumption)
2016 }
2017
2018 fn assumed_validation_data(
2019 para_id: ParaId,
2020 expected_persisted_validation_data_hash: Hash,
2021 ) -> Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)> {
2022 parachains_runtime_api_impl::assumed_validation_data::<Runtime>(
2023 para_id,
2024 expected_persisted_validation_data_hash,
2025 )
2026 }
2027
2028 fn check_validation_outputs(
2029 para_id: ParaId,
2030 outputs: polkadot_primitives::CandidateCommitments,
2031 ) -> bool {
2032 parachains_runtime_api_impl::check_validation_outputs::<Runtime>(para_id, outputs)
2033 }
2034
2035 fn session_index_for_child() -> SessionIndex {
2036 parachains_runtime_api_impl::session_index_for_child::<Runtime>()
2037 }
2038
2039 fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
2040 -> Option<ValidationCode> {
2041 parachains_runtime_api_impl::validation_code::<Runtime>(para_id, assumption)
2042 }
2043
2044 fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
2045 #[allow(deprecated)]
2046 parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
2047 }
2048
2049 fn candidate_events() -> Vec<CandidateEvent<Hash>> {
2050 parachains_runtime_api_impl::candidate_events::<Runtime, _>(|ev| {
2051 match ev {
2052 RuntimeEvent::ParaInclusion(ev) => {
2053 Some(ev)
2054 }
2055 _ => None,
2056 }
2057 })
2058 }
2059
2060 fn session_info(index: SessionIndex) -> Option<SessionInfo> {
2061 parachains_runtime_api_impl::session_info::<Runtime>(index)
2062 }
2063
2064 fn session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams> {
2065 parachains_runtime_api_impl::session_executor_params::<Runtime>(session_index)
2066 }
2067
2068 fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<BlockNumber>> {
2069 parachains_runtime_api_impl::dmq_contents::<Runtime>(recipient)
2070 }
2071
2072 fn inbound_hrmp_channels_contents(
2073 recipient: ParaId
2074 ) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
2075 parachains_runtime_api_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
2076 }
2077
2078 fn validation_code_by_hash(hash: ValidationCodeHash) -> Option<ValidationCode> {
2079 parachains_runtime_api_impl::validation_code_by_hash::<Runtime>(hash)
2080 }
2081
2082 fn on_chain_votes() -> Option<ScrapedOnChainVotes<Hash>> {
2083 parachains_runtime_api_impl::on_chain_votes::<Runtime>()
2084 }
2085
2086 fn submit_pvf_check_statement(
2087 stmt: polkadot_primitives::PvfCheckStatement,
2088 signature: polkadot_primitives::ValidatorSignature
2089 ) {
2090 parachains_runtime_api_impl::submit_pvf_check_statement::<Runtime>(stmt, signature)
2091 }
2092
2093 fn pvfs_require_precheck() -> Vec<ValidationCodeHash> {
2094 parachains_runtime_api_impl::pvfs_require_precheck::<Runtime>()
2095 }
2096
2097 fn validation_code_hash(para_id: ParaId, assumption: OccupiedCoreAssumption)
2098 -> Option<ValidationCodeHash>
2099 {
2100 parachains_runtime_api_impl::validation_code_hash::<Runtime>(para_id, assumption)
2101 }
2102
2103 fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
2104 parachains_runtime_api_impl::get_session_disputes::<Runtime>()
2105 }
2106
2107 fn unapplied_slashes(
2108 ) -> Vec<(SessionIndex, CandidateHash, slashing::LegacyPendingSlashes)> {
2109 parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
2110 }
2111
2112 fn unapplied_slashes_v2(
2113 ) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
2114 parachains_runtime_api_impl::unapplied_slashes_v2::<Runtime>()
2115 }
2116
2117 fn key_ownership_proof(
2118 validator_id: ValidatorId,
2119 ) -> Option<slashing::OpaqueKeyOwnershipProof> {
2120 use codec::Encode;
2121
2122 Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
2123 .map(|p| p.encode())
2124 .map(slashing::OpaqueKeyOwnershipProof::new)
2125 }
2126
2127 fn submit_report_dispute_lost(
2128 dispute_proof: slashing::DisputeProof,
2129 key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
2130 ) -> Option<()> {
2131 parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
2132 dispute_proof,
2133 key_ownership_proof,
2134 )
2135 }
2136
2137 fn minimum_backing_votes() -> u32 {
2138 parachains_runtime_api_impl::minimum_backing_votes::<Runtime>()
2139 }
2140
2141 fn para_backing_state(para_id: ParaId) -> Option<polkadot_primitives::async_backing::BackingState> {
2142 #[allow(deprecated)]
2143 parachains_runtime_api_impl::backing_state::<Runtime>(para_id)
2144 }
2145
2146 fn async_backing_params() -> polkadot_primitives::AsyncBackingParams {
2147 #[allow(deprecated)]
2148 parachains_runtime_api_impl::async_backing_params::<Runtime>()
2149 }
2150
2151 fn approval_voting_params() -> ApprovalVotingParams {
2152 parachains_runtime_api_impl::approval_voting_params::<Runtime>()
2153 }
2154
2155 fn disabled_validators() -> Vec<ValidatorIndex> {
2156 parachains_runtime_api_impl::disabled_validators::<Runtime>()
2157 }
2158
2159 fn node_features() -> NodeFeatures {
2160 parachains_runtime_api_impl::node_features::<Runtime>()
2161 }
2162
2163 fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
2164 parachains_runtime_api_impl::claim_queue::<Runtime>()
2165 }
2166
2167 fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
2168 parachains_runtime_api_impl::candidates_pending_availability::<Runtime>(para_id)
2169 }
2170
2171 fn backing_constraints(para_id: ParaId) -> Option<Constraints> {
2172 parachains_runtime_api_impl::backing_constraints::<Runtime>(para_id)
2173 }
2174
2175 fn scheduling_lookahead() -> u32 {
2176 parachains_runtime_api_impl::scheduling_lookahead::<Runtime>()
2177 }
2178
2179 fn validation_code_bomb_limit() -> u32 {
2180 parachains_runtime_api_impl::validation_code_bomb_limit::<Runtime>()
2181 }
2182
2183 fn para_ids() -> Vec<ParaId> {
2184 parachains_staging_runtime_api_impl::para_ids::<Runtime>()
2185 }
2186
2187 fn max_relay_parent_session_age() -> u32 {
2188 parachains_staging_runtime_api_impl::max_relay_parent_session_age::<Runtime>()
2189 }
2190
2191 fn ancestor_relay_parent_info(
2192 session_index: SessionIndex,
2193 relay_parent: Hash,
2194 ) -> Option<polkadot_primitives::vstaging::RelayParentInfo<Hash, BlockNumber>> {
2195 parachains_staging_runtime_api_impl::ancestor_relay_parent_info::<Runtime>(session_index, relay_parent)
2196 }
2197 }
2198
2199 #[api_version(6)]
2200 impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
2201 fn beefy_genesis() -> Option<BlockNumber> {
2202 pallet_beefy::GenesisBlock::<Runtime>::get()
2203 }
2204
2205 fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
2206 Beefy::validator_set()
2207 }
2208
2209 fn submit_report_double_voting_unsigned_extrinsic(
2210 equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
2211 BlockNumber,
2212 BeefyId,
2213 BeefySignature,
2214 >,
2215 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2216 ) -> Option<()> {
2217 let key_owner_proof = key_owner_proof.decode()?;
2218
2219 Beefy::submit_unsigned_double_voting_report(
2220 equivocation_proof,
2221 key_owner_proof,
2222 )
2223 }
2224
2225 fn submit_report_fork_voting_unsigned_extrinsic(
2226 equivocation_proof:
2227 sp_consensus_beefy::ForkVotingProof<
2228 <Block as BlockT>::Header,
2229 BeefyId,
2230 sp_runtime::OpaqueValue
2231 >,
2232 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2233 ) -> Option<()> {
2234 Beefy::submit_unsigned_fork_voting_report(
2235 equivocation_proof.try_into()?,
2236 key_owner_proof.decode()?,
2237 )
2238 }
2239
2240 fn submit_report_future_block_voting_unsigned_extrinsic(
2241 equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
2242 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2243 ) -> Option<()> {
2244 Beefy::submit_unsigned_future_block_voting_report(
2245 equivocation_proof,
2246 key_owner_proof.decode()?,
2247 )
2248 }
2249
2250 fn generate_key_ownership_proof(
2251 _set_id: sp_consensus_beefy::ValidatorSetId,
2252 authority_id: BeefyId,
2253 ) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
2254 use codec::Encode;
2255
2256 Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
2257 .map(|p| p.encode())
2258 .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
2259 }
2260 }
2261
2262 #[api_version(3)]
2263 impl mmr::MmrApi<Block, mmr::Hash, BlockNumber> for Runtime {
2264 fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
2265 Ok(pallet_mmr::RootHash::<Runtime>::get())
2266 }
2267
2268 fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
2269 Ok(pallet_mmr::NumberOfLeaves::<Runtime>::get())
2270 }
2271
2272 fn generate_proof(
2273 block_numbers: Vec<BlockNumber>,
2274 best_known_block_number: Option<BlockNumber>,
2275 ) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<mmr::Hash>), mmr::Error> {
2276 Mmr::generate_proof(block_numbers, best_known_block_number).map(
2277 |(leaves, proof)| {
2278 (
2279 leaves
2280 .into_iter()
2281 .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
2282 .collect(),
2283 proof,
2284 )
2285 },
2286 )
2287 }
2288
2289 fn generate_ancestry_proof(
2290 prev_block_number: BlockNumber,
2291 best_known_block_number: Option<BlockNumber>,
2292 ) -> Result<mmr::AncestryProof<mmr::Hash>, mmr::Error> {
2293 Mmr::generate_ancestry_proof(prev_block_number, best_known_block_number)
2294 }
2295
2296 fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::LeafProof<mmr::Hash>)
2297 -> Result<(), mmr::Error>
2298 {
2299 let leaves = leaves.into_iter().map(|leaf|
2300 leaf.into_opaque_leaf()
2301 .try_decode()
2302 .ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;
2303 Mmr::verify_leaves(leaves, proof)
2304 }
2305
2306 fn verify_proof_stateless(
2307 root: mmr::Hash,
2308 leaves: Vec<mmr::EncodableOpaqueLeaf>,
2309 proof: mmr::LeafProof<mmr::Hash>
2310 ) -> Result<(), mmr::Error> {
2311 let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
2312 pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)
2313 }
2314 }
2315
2316 impl fg_primitives::GrandpaApi<Block> for Runtime {
2317 fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
2318 Grandpa::grandpa_authorities()
2319 }
2320
2321 fn current_set_id() -> fg_primitives::SetId {
2322 pallet_grandpa::CurrentSetId::<Runtime>::get()
2323 }
2324
2325 fn submit_report_equivocation_unsigned_extrinsic(
2326 equivocation_proof: fg_primitives::EquivocationProof<
2327 <Block as BlockT>::Hash,
2328 sp_runtime::traits::NumberFor<Block>,
2329 >,
2330 key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
2331 ) -> Option<()> {
2332 let key_owner_proof = key_owner_proof.decode()?;
2333
2334 Grandpa::submit_unsigned_equivocation_report(
2335 equivocation_proof,
2336 key_owner_proof,
2337 )
2338 }
2339
2340 fn generate_key_ownership_proof(
2341 _set_id: fg_primitives::SetId,
2342 authority_id: fg_primitives::AuthorityId,
2343 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
2344 use codec::Encode;
2345
2346 Historical::prove((fg_primitives::KEY_TYPE, authority_id))
2347 .map(|p| p.encode())
2348 .map(fg_primitives::OpaqueKeyOwnershipProof::new)
2349 }
2350 }
2351
2352 impl sp_consensus_babe::BabeApi<Block> for Runtime {
2353 fn configuration() -> sp_consensus_babe::BabeConfiguration {
2354 let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
2355 sp_consensus_babe::BabeConfiguration {
2356 slot_duration: Babe::slot_duration(),
2357 epoch_length: EpochDurationInBlocks::get().into(),
2358 c: epoch_config.c,
2359 authorities: Babe::authorities().to_vec(),
2360 randomness: Babe::randomness(),
2361 allowed_slots: epoch_config.allowed_slots,
2362 }
2363 }
2364
2365 fn current_epoch_start() -> sp_consensus_babe::Slot {
2366 Babe::current_epoch_start()
2367 }
2368
2369 fn current_epoch() -> sp_consensus_babe::Epoch {
2370 Babe::current_epoch()
2371 }
2372
2373 fn next_epoch() -> sp_consensus_babe::Epoch {
2374 Babe::next_epoch()
2375 }
2376
2377 fn generate_key_ownership_proof(
2378 _slot: sp_consensus_babe::Slot,
2379 authority_id: sp_consensus_babe::AuthorityId,
2380 ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
2381 use codec::Encode;
2382
2383 Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
2384 .map(|p| p.encode())
2385 .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
2386 }
2387
2388 fn submit_report_equivocation_unsigned_extrinsic(
2389 equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
2390 key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
2391 ) -> Option<()> {
2392 let key_owner_proof = key_owner_proof.decode()?;
2393
2394 Babe::submit_unsigned_equivocation_report(
2395 equivocation_proof,
2396 key_owner_proof,
2397 )
2398 }
2399 }
2400
2401 impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
2402 fn authorities() -> Vec<AuthorityDiscoveryId> {
2403 parachains_runtime_api_impl::relevant_authority_ids::<Runtime>()
2404 }
2405 }
2406
2407 impl sp_session::SessionKeys<Block> for Runtime {
2408 fn generate_session_keys(
2409 owner: Vec<u8>,
2410 seed: Option<Vec<u8>>,
2411 ) -> sp_session::OpaqueGeneratedSessionKeys {
2412 SessionKeys::generate(&owner, seed).into()
2413 }
2414
2415 fn decode_session_keys(
2416 encoded: Vec<u8>,
2417 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
2418 SessionKeys::decode_into_raw_public_keys(&encoded)
2419 }
2420 }
2421
2422 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
2423 fn account_nonce(account: AccountId) -> Nonce {
2424 System::account_nonce(account)
2425 }
2426 }
2427
2428 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
2429 Block,
2430 Balance,
2431 > for Runtime {
2432 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
2433 TransactionPayment::query_info(uxt, len)
2434 }
2435 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
2436 TransactionPayment::query_fee_details(uxt, len)
2437 }
2438 fn query_weight_to_fee(weight: Weight) -> Balance {
2439 TransactionPayment::weight_to_fee(weight)
2440 }
2441 fn query_length_to_fee(length: u32) -> Balance {
2442 TransactionPayment::length_to_fee(length)
2443 }
2444 }
2445
2446 impl pallet_beefy_mmr::BeefyMmrApi<Block, Hash> for RuntimeApi {
2447 fn authority_set_proof() -> sp_consensus_beefy::mmr::BeefyAuthoritySet<Hash> {
2448 MmrLeaf::authority_set_proof()
2449 }
2450
2451 fn next_authority_set_proof() -> sp_consensus_beefy::mmr::BeefyNextAuthoritySet<Hash> {
2452 MmrLeaf::next_authority_set_proof()
2453 }
2454 }
2455
2456 #[cfg(feature = "try-runtime")]
2457 impl frame_try_runtime::TryRuntime<Block> for Runtime {
2458 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
2459 log::info!("try-runtime::on_runtime_upgrade rococo.");
2460 let weight = Executive::try_runtime_upgrade(checks).unwrap();
2461 (weight, BlockWeights::get().max_block)
2462 }
2463
2464 fn execute_block(
2465 block: <Block as BlockT>::LazyBlock,
2466 state_root_check: bool,
2467 signature_check: bool,
2468 select: frame_try_runtime::TryStateSelect,
2469 ) -> Weight {
2470 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
2473 }
2474 }
2475
2476 #[cfg(feature = "runtime-benchmarks")]
2477 impl frame_benchmarking::Benchmark<Block> for Runtime {
2478 fn benchmark_metadata(extra: bool) -> (
2479 Vec<frame_benchmarking::BenchmarkList>,
2480 Vec<frame_support::traits::StorageInfo>,
2481 ) {
2482 use frame_benchmarking::BenchmarkList;
2483 use frame_support::traits::StorageInfoTrait;
2484
2485 use frame_system_benchmarking::Pallet as SystemBench;
2486 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2487 use frame_benchmarking::baseline::Pallet as Baseline;
2488
2489 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2490
2491 let mut list = Vec::<BenchmarkList>::new();
2492 list_benchmarks!(list, extra);
2493
2494 let storage_info = AllPalletsWithSystem::storage_info();
2495 return (list, storage_info)
2496 }
2497
2498 #[allow(non_local_definitions)]
2499 fn dispatch_benchmark(
2500 config: frame_benchmarking::BenchmarkConfig,
2501 ) -> Result<
2502 Vec<frame_benchmarking::BenchmarkBatch>,
2503 alloc::string::String,
2504 > {
2505 use frame_support::traits::WhitelistedStorageKeys;
2506 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
2507 use frame_system_benchmarking::Pallet as SystemBench;
2508 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2509 use frame_benchmarking::baseline::Pallet as Baseline;
2510 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2511 use sp_storage::TrackedStorageKey;
2512 use xcm::latest::prelude::*;
2513 use xcm_config::{
2514 AssetHub, LocalCheckAccount, LocationConverter, TokenLocation, XcmConfig,
2515 };
2516
2517 parameter_types! {
2518 pub ExistentialDepositAsset: Option<Asset> = Some((
2519 TokenLocation::get(),
2520 ExistentialDeposit::get()
2521 ).into());
2522 pub AssetHubParaId: ParaId = rococo_runtime_constants::system_parachain::ASSET_HUB_ID.into();
2523 pub const RandomParaId: ParaId = ParaId::new(43211234);
2524 }
2525
2526 impl frame_system_benchmarking::Config for Runtime {}
2527 impl frame_benchmarking::baseline::Config for Runtime {}
2528 impl pallet_transaction_payment::BenchmarkConfig for Runtime {}
2529 impl pallet_xcm::benchmarking::Config for Runtime {
2530 type DeliveryHelper = (
2531 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2532 XcmConfig,
2533 ExistentialDepositAsset,
2534 xcm_config::PriceForChildParachainDelivery,
2535 AssetHubParaId,
2536 Dmp,
2537 >,
2538 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2539 XcmConfig,
2540 ExistentialDepositAsset,
2541 xcm_config::PriceForChildParachainDelivery,
2542 RandomParaId,
2543 Dmp,
2544 >
2545 );
2546
2547 fn reachable_dest() -> Option<Location> {
2548 Some(crate::xcm_config::AssetHub::get())
2549 }
2550
2551 fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
2552 Some((
2554 Asset {
2555 fun: Fungible(ExistentialDeposit::get()),
2556 id: AssetId(Here.into())
2557 },
2558 crate::xcm_config::AssetHub::get(),
2559 ))
2560 }
2561
2562 fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
2563 None
2564 }
2565
2566 fn set_up_complex_asset_transfer(
2567 ) -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
2568 let native_location = Here.into();
2573 let dest = crate::xcm_config::AssetHub::get();
2574 pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
2575 native_location,
2576 dest
2577 )
2578 }
2579
2580 fn get_asset() -> Asset {
2581 Asset {
2582 id: AssetId(Location::here()),
2583 fun: Fungible(ExistentialDeposit::get()),
2584 }
2585 }
2586 }
2587 impl pallet_xcm_benchmarks::Config for Runtime {
2588 type XcmConfig = XcmConfig;
2589 type AccountIdConverter = LocationConverter;
2590 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2591 XcmConfig,
2592 ExistentialDepositAsset,
2593 xcm_config::PriceForChildParachainDelivery,
2594 AssetHubParaId,
2595 Dmp,
2596 >;
2597 fn valid_destination() -> Result<Location, BenchmarkError> {
2598 Ok(AssetHub::get())
2599 }
2600 fn worst_case_holding(_depositable_count: u32) -> xcm_executor::AssetsInHolding {
2601 use pallet_xcm_benchmarks::MockCredit;
2602 let mut holding = xcm_executor::AssetsInHolding::new();
2604 holding.fungible.insert(
2605 AssetId(TokenLocation::get()),
2606 alloc::boxed::Box::new(MockCredit(1_000_000 * UNITS)),
2607 );
2608 holding
2609 }
2610 }
2611
2612 parameter_types! {
2613 pub TrustedTeleporter: Option<(Location, Asset)> = Some((
2614 AssetHub::get(),
2615 Asset { fun: Fungible(1 * UNITS), id: AssetId(TokenLocation::get()) },
2616 ));
2617 pub TrustedReserve: Option<(Location, Asset)> = None;
2618 }
2619
2620 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
2621 type TransactAsset = Balances;
2622
2623 type CheckedAccount = LocalCheckAccount;
2624 type TrustedTeleporter = TrustedTeleporter;
2625 type TrustedReserve = TrustedReserve;
2626
2627 fn get_asset() -> Asset {
2628 Asset {
2629 id: AssetId(TokenLocation::get()),
2630 fun: Fungible(1 * UNITS),
2631 }
2632 }
2633 }
2634
2635 impl pallet_xcm_benchmarks::generic::Config for Runtime {
2636 type TransactAsset = Balances;
2637 type RuntimeCall = RuntimeCall;
2638
2639 fn worst_case_response() -> (u64, Response) {
2640 (0u64, Response::Version(Default::default()))
2641 }
2642
2643 fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
2644 Err(BenchmarkError::Skip)
2646 }
2647
2648 fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
2649 Err(BenchmarkError::Skip)
2651 }
2652
2653 fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
2654 Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
2655 }
2656
2657 fn subscribe_origin() -> Result<Location, BenchmarkError> {
2658 Ok(AssetHub::get())
2659 }
2660
2661 fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
2662 let origin = AssetHub::get();
2663 let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
2664 let ticket = Location { parents: 0, interior: Here };
2665 Ok((origin, ticket, assets))
2666 }
2667
2668 fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
2669 Ok((Asset {
2670 id: AssetId(TokenLocation::get()),
2671 fun: Fungible(1_000_000 * UNITS),
2672 }, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
2673 }
2674
2675 fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
2676 Err(BenchmarkError::Skip)
2678 }
2679
2680 fn export_message_origin_and_destination(
2681 ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
2682 Err(BenchmarkError::Skip)
2684 }
2685
2686 fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
2687 Err(BenchmarkError::Skip)
2689 }
2690 }
2691
2692 let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
2693 let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
2694 whitelist.push(treasury_key.to_vec().into());
2695
2696 let mut batches = Vec::<BenchmarkBatch>::new();
2697 let params = (&config, &whitelist);
2698
2699 add_benchmarks!(params, batches);
2700
2701 Ok(batches)
2702 }
2703 }
2704
2705 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
2706 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
2707 build_state::<RuntimeGenesisConfig>(config)
2708 }
2709
2710 fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
2711 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
2712 }
2713
2714 fn preset_names() -> Vec<PresetId> {
2715 genesis_config_presets::preset_names()
2716 }
2717 }
2718
2719 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
2720 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2721 XcmPallet::is_trusted_reserve(asset, location)
2722 }
2723 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2724 XcmPallet::is_trusted_teleporter(asset, location)
2725 }
2726 }
2727}
2728
2729#[cfg(all(test, feature = "try-runtime"))]
2730mod remote_tests {
2731 use super::*;
2732 use frame_try_runtime::{runtime_decl_for_try_runtime::TryRuntime, UpgradeCheckSelect};
2733 use remote_externalities::{Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig};
2734 use std::env::var;
2735
2736 #[tokio::test]
2737 async fn run_migrations() {
2738 if var("RUN_MIGRATION_TESTS").is_err() {
2739 return;
2740 }
2741
2742 sp_tracing::try_init_simple();
2743 let transport = var("WS").unwrap_or("wss://rococo-rpc.polkadot.io:443".to_string());
2744 let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
2745
2746 let transport_uris = vec![transport];
2747 let mut ext = Builder::<Block>::default()
2748 .mode(if let Some(state_snapshot) = maybe_state_snapshot {
2749 Mode::OfflineOrElseOnline(
2750 OfflineConfig { state_snapshot: state_snapshot.clone() },
2751 OnlineConfig {
2752 transport_uris,
2753 state_snapshot: Some(state_snapshot),
2754 ..Default::default()
2755 },
2756 )
2757 } else {
2758 Mode::Online(OnlineConfig { transport_uris, ..Default::default() })
2759 })
2760 .build()
2761 .await
2762 .unwrap();
2763 ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost));
2764 }
2765}