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_022_003,
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 = ();
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
1134parameter_types! {
1135 pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
1136}
1137
1138impl parachains_hrmp::Config for Runtime {
1139 type RuntimeOrigin = RuntimeOrigin;
1140 type RuntimeEvent = RuntimeEvent;
1141 type ChannelManager = EnsureRoot<AccountId>;
1142 type Currency = Balances;
1143 type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
1144 Runtime,
1145 HrmpChannelSizeAndCapacityWithSystemRatio,
1146 >;
1147 type VersionWrapper = crate::XcmPallet;
1148 type WeightInfo = weights::polkadot_runtime_parachains_hrmp::WeightInfo<Runtime>;
1149}
1150
1151impl parachains_paras_inherent::Config for Runtime {
1152 type WeightInfo = weights::polkadot_runtime_parachains_paras_inherent::WeightInfo<Runtime>;
1153}
1154
1155impl parachains_scheduler::Config for Runtime {}
1156
1157parameter_types! {
1158 pub const BrokerId: u32 = BROKER_ID;
1159 pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
1160 pub MaxXcmTransactWeight: Weight = Weight::from_parts(200_000_000, 20_000);
1161}
1162
1163pub struct BrokerPot;
1164impl Get<InteriorLocation> for BrokerPot {
1165 fn get() -> InteriorLocation {
1166 Junction::AccountId32 { network: None, id: BrokerPalletId::get().into_account_truncating() }
1167 .into()
1168 }
1169}
1170
1171impl coretime::Config for Runtime {
1172 type RuntimeOrigin = RuntimeOrigin;
1173 type RuntimeEvent = RuntimeEvent;
1174 type BrokerId = BrokerId;
1175 type BrokerPotLocation = BrokerPot;
1176 type WeightInfo = weights::polkadot_runtime_parachains_coretime::WeightInfo<Runtime>;
1177 type SendXcm = crate::xcm_config::XcmRouter;
1178 type AssetTransactor = crate::xcm_config::LocalAssetTransactor;
1179 type AccountToLocation = xcm_builder::AliasesIntoAccountId32<
1180 xcm_config::ThisNetwork,
1181 <Runtime as frame_system::Config>::AccountId,
1182 >;
1183 type MaxXcmTransactWeight = MaxXcmTransactWeight;
1184}
1185
1186parameter_types! {
1187 pub const OnDemandTrafficDefaultValue: FixedU128 = FixedU128::from_u32(1);
1188 pub const MaxHistoricalRevenue: BlockNumber = 2 * TIMESLICE_PERIOD;
1190 pub const OnDemandPalletId: PalletId = PalletId(*b"py/ondmd");
1191}
1192
1193impl parachains_on_demand::Config for Runtime {
1194 type RuntimeEvent = RuntimeEvent;
1195 type Currency = Balances;
1196 type TrafficDefaultValue = OnDemandTrafficDefaultValue;
1197 type WeightInfo = weights::polkadot_runtime_parachains_on_demand::WeightInfo<Runtime>;
1198 type MaxHistoricalRevenue = MaxHistoricalRevenue;
1199 type PalletId = OnDemandPalletId;
1200}
1201
1202impl parachains_initializer::Config for Runtime {
1203 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1204 type ForceOrigin = EnsureRoot<AccountId>;
1205 type WeightInfo = weights::polkadot_runtime_parachains_initializer::WeightInfo<Runtime>;
1206 type CoretimeOnNewSession = Coretime;
1207}
1208
1209impl parachains_disputes::Config for Runtime {
1210 type RuntimeEvent = RuntimeEvent;
1211 type RewardValidators = ();
1212 type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes<ParasSlashing>;
1213 type WeightInfo = weights::polkadot_runtime_parachains_disputes::WeightInfo<Runtime>;
1214}
1215
1216impl parachains_slashing::Config for Runtime {
1217 type KeyOwnerProofSystem = Historical;
1218 type KeyOwnerProof =
1219 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
1220 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
1221 KeyTypeId,
1222 ValidatorId,
1223 )>>::IdentificationTuple;
1224 type HandleReports = parachains_slashing::SlashingReportHandler<
1225 Self::KeyOwnerIdentification,
1226 Offences,
1227 ReportLongevity,
1228 >;
1229 type WeightInfo = parachains_slashing::TestWeightInfo;
1230 type BenchmarkingConfig = parachains_slashing::BenchConfig<200>;
1231}
1232
1233parameter_types! {
1234 pub const ParaDeposit: Balance = 40 * UNITS;
1235}
1236
1237impl paras_registrar::Config for Runtime {
1238 type RuntimeOrigin = RuntimeOrigin;
1239 type RuntimeEvent = RuntimeEvent;
1240 type Currency = Balances;
1241 type OnSwap = (Crowdloan, Slots, SwapLeases);
1242 type ParaDeposit = ParaDeposit;
1243 type DataDepositPerByte = DataDepositPerByte;
1244 type WeightInfo = weights::polkadot_runtime_common_paras_registrar::WeightInfo<Runtime>;
1245}
1246
1247parameter_types! {
1248 pub LeasePeriod: BlockNumber = prod_or_fast!(1 * DAYS, 1 * DAYS, "ROC_LEASE_PERIOD");
1249}
1250
1251impl slots::Config for Runtime {
1252 type RuntimeEvent = RuntimeEvent;
1253 type Currency = Balances;
1254 type Registrar = Registrar;
1255 type LeasePeriod = LeasePeriod;
1256 type LeaseOffset = ();
1257 type ForceOrigin = EitherOf<EnsureRoot<Self::AccountId>, LeaseAdmin>;
1258 type WeightInfo = weights::polkadot_runtime_common_slots::WeightInfo<Runtime>;
1259}
1260
1261parameter_types! {
1262 pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
1263 pub const SubmissionDeposit: Balance = 3 * GRAND;
1264 pub const MinContribution: Balance = 3_000 * CENTS;
1265 pub const RemoveKeysLimit: u32 = 1000;
1266 pub const MaxMemoLength: u8 = 32;
1268}
1269
1270impl crowdloan::Config for Runtime {
1271 type RuntimeEvent = RuntimeEvent;
1272 type PalletId = CrowdloanId;
1273 type SubmissionDeposit = SubmissionDeposit;
1274 type MinContribution = MinContribution;
1275 type RemoveKeysLimit = RemoveKeysLimit;
1276 type Registrar = Registrar;
1277 type Auctioneer = Auctions;
1278 type MaxMemoLength = MaxMemoLength;
1279 type WeightInfo = weights::polkadot_runtime_common_crowdloan::WeightInfo<Runtime>;
1280}
1281
1282parameter_types! {
1283 pub const EndingPeriod: BlockNumber = 5 * DAYS;
1286 pub const SampleLength: BlockNumber = 2 * MINUTES;
1288}
1289
1290impl auctions::Config for Runtime {
1291 type RuntimeEvent = RuntimeEvent;
1292 type Leaser = Slots;
1293 type Registrar = Registrar;
1294 type EndingPeriod = EndingPeriod;
1295 type SampleLength = SampleLength;
1296 type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
1297 type InitiateOrigin = EitherOf<EnsureRoot<Self::AccountId>, AuctionAdmin>;
1298 type WeightInfo = weights::polkadot_runtime_common_auctions::WeightInfo<Runtime>;
1299}
1300
1301impl identity_migrator::Config for Runtime {
1302 type RuntimeEvent = RuntimeEvent;
1303 type Reaper = EnsureSigned<AccountId>;
1304 type ReapIdentityHandler = ToParachainIdentityReaper<Runtime, Self::AccountId>;
1305 type WeightInfo = weights::polkadot_runtime_common_identity_migrator::WeightInfo<Runtime>;
1306}
1307
1308type NisCounterpartInstance = pallet_balances::Instance2;
1309impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
1310 type Balance = Balance;
1311 type DustRemoval = ();
1312 type RuntimeEvent = RuntimeEvent;
1313 type ExistentialDeposit = ConstU128<10_000_000_000>; type AccountStore = StorageMapShim<
1315 pallet_balances::Account<Runtime, NisCounterpartInstance>,
1316 AccountId,
1317 pallet_balances::AccountData<u128>,
1318 >;
1319 type MaxLocks = ConstU32<4>;
1320 type MaxReserves = ConstU32<4>;
1321 type ReserveIdentifier = [u8; 8];
1322 type WeightInfo = weights::pallet_balances_nis_counterpart_balances::WeightInfo<Runtime>;
1323 type RuntimeHoldReason = RuntimeHoldReason;
1324 type RuntimeFreezeReason = RuntimeFreezeReason;
1325 type FreezeIdentifier = ();
1326 type MaxFreezes = ConstU32<1>;
1327 type DoneSlashHandler = ();
1328}
1329
1330parameter_types! {
1331 pub const NisBasePeriod: BlockNumber = 30 * DAYS;
1332 pub MinReceipt: Perquintill = Perquintill::from_rational(1u64, 10_000_000u64);
1333 pub const IntakePeriod: BlockNumber = 5 * MINUTES;
1334 pub MaxIntakeWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
1335 pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
1336 pub const NisPalletId: PalletId = PalletId(*b"py/nis ");
1337}
1338
1339impl pallet_nis::Config for Runtime {
1340 type WeightInfo = weights::pallet_nis::WeightInfo<Runtime>;
1341 type RuntimeEvent = RuntimeEvent;
1342 type Currency = Balances;
1343 type CurrencyBalance = Balance;
1344 type FundOrigin = frame_system::EnsureSigned<AccountId>;
1345 type Counterpart = NisCounterpartBalances;
1346 type CounterpartAmount = WithMaximumOf<ConstU128<21_000_000_000_000_000_000u128>>;
1347 type Deficit = (); type IgnoredIssuance = ();
1349 type Target = dynamic_params::nis::Target;
1350 type PalletId = NisPalletId;
1351 type QueueCount = ConstU32<300>;
1352 type MaxQueueLen = ConstU32<1000>;
1353 type FifoQueueLen = ConstU32<250>;
1354 type BasePeriod = NisBasePeriod;
1355 type MinBid = dynamic_params::nis::MinBid;
1356 type MinReceipt = MinReceipt;
1357 type IntakePeriod = IntakePeriod;
1358 type MaxIntakeWeight = MaxIntakeWeight;
1359 type ThawThrottle = ThawThrottle;
1360 type RuntimeHoldReason = RuntimeHoldReason;
1361 #[cfg(feature = "runtime-benchmarks")]
1362 type BenchmarkSetup = ();
1363}
1364
1365impl pallet_parameters::Config for Runtime {
1366 type RuntimeEvent = RuntimeEvent;
1367 type RuntimeParameters = RuntimeParameters;
1368 type AdminOrigin = DynamicParameterOrigin;
1369 type WeightInfo = weights::pallet_parameters::WeightInfo<Runtime>;
1370}
1371
1372parameter_types! {
1373 pub BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
1374}
1375
1376impl pallet_beefy::Config for Runtime {
1377 type BeefyId = BeefyId;
1378 type MaxAuthorities = MaxAuthorities;
1379 type MaxNominators = ConstU32<0>;
1380 type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
1381 type OnNewValidatorSet = MmrLeaf;
1382 type AncestryHelper = MmrLeaf;
1383 type WeightInfo = ();
1384 type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, BeefyId)>>::Proof;
1385 type EquivocationReportSystem =
1386 pallet_beefy::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
1387}
1388
1389mod mmr {
1391 use super::Runtime;
1392 pub use pallet_mmr::primitives::*;
1393
1394 pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
1395 pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
1396 pub type Hash = <Hashing as sp_runtime::traits::Hash>::Output;
1397}
1398
1399impl pallet_mmr::Config for Runtime {
1400 const INDEXING_PREFIX: &'static [u8] = mmr::INDEXING_PREFIX;
1401 type Hashing = Keccak256;
1402 type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
1403 type LeafData = pallet_beefy_mmr::Pallet<Runtime>;
1404 type BlockHashProvider = pallet_mmr::DefaultBlockHashProvider<Runtime>;
1405 type WeightInfo = weights::pallet_mmr::WeightInfo<Runtime>;
1406 #[cfg(feature = "runtime-benchmarks")]
1407 type BenchmarkHelper = parachains_paras::benchmarking::mmr_setup::MmrSetup<Runtime>;
1408}
1409
1410parameter_types! {
1411 pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0);
1412}
1413
1414pub struct ParaHeadsRootProvider;
1415impl BeefyDataProvider<H256> for ParaHeadsRootProvider {
1416 fn extra_data() -> H256 {
1417 let para_heads: Vec<(u32, Vec<u8>)> =
1418 parachains_paras::Pallet::<Runtime>::sorted_para_heads();
1419 binary_merkle_tree::merkle_root::<mmr::Hashing, _>(
1420 para_heads.into_iter().map(|pair| pair.encode()),
1421 )
1422 .into()
1423 }
1424}
1425
1426impl pallet_beefy_mmr::Config for Runtime {
1427 type LeafVersion = LeafVersion;
1428 type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum;
1429 type LeafExtra = H256;
1430 type BeefyDataProvider = ParaHeadsRootProvider;
1431 type WeightInfo = weights::pallet_beefy_mmr::WeightInfo<Runtime>;
1432}
1433
1434impl paras_sudo_wrapper::Config for Runtime {}
1435
1436parameter_types! {
1437 pub const PermanentSlotLeasePeriodLength: u32 = 365;
1438 pub const TemporarySlotLeasePeriodLength: u32 = 5;
1439 pub const MaxTemporarySlotPerLeasePeriod: u32 = 5;
1440}
1441
1442impl assigned_slots::Config for Runtime {
1443 type RuntimeEvent = RuntimeEvent;
1444 type AssignSlotOrigin = EnsureRoot<AccountId>;
1445 type Leaser = Slots;
1446 type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
1447 type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength;
1448 type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod;
1449 type WeightInfo = weights::polkadot_runtime_common_assigned_slots::WeightInfo<Runtime>;
1450}
1451
1452impl validator_manager::Config for Runtime {
1453 type RuntimeEvent = RuntimeEvent;
1454 type PrivilegedOrigin = EnsureRoot<AccountId>;
1455}
1456
1457parameter_types! {
1458 pub MbmServiceWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
1459}
1460
1461impl pallet_migrations::Config for Runtime {
1462 type RuntimeEvent = RuntimeEvent;
1463 #[cfg(not(feature = "runtime-benchmarks"))]
1464 type Migrations = pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>;
1465 #[cfg(feature = "runtime-benchmarks")]
1467 type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
1468 type CursorMaxLen = ConstU32<65_536>;
1469 type IdentifierMaxLen = ConstU32<256>;
1470 type MigrationStatusHandler = ();
1471 type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
1472 type MaxServiceWeight = MbmServiceWeight;
1473 type WeightInfo = weights::pallet_migrations::WeightInfo<Runtime>;
1474}
1475
1476impl pallet_sudo::Config for Runtime {
1477 type RuntimeEvent = RuntimeEvent;
1478 type RuntimeCall = RuntimeCall;
1479 type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
1480}
1481
1482impl pallet_root_testing::Config for Runtime {
1483 type RuntimeEvent = RuntimeEvent;
1484}
1485
1486impl pallet_asset_rate::Config for Runtime {
1487 type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
1488 type RuntimeEvent = RuntimeEvent;
1489 type CreateOrigin = EnsureRoot<AccountId>;
1490 type RemoveOrigin = EnsureRoot<AccountId>;
1491 type UpdateOrigin = EnsureRoot<AccountId>;
1492 type Currency = Balances;
1493 type AssetKind = <Runtime as pallet_treasury::Config>::AssetKind;
1494 #[cfg(feature = "runtime-benchmarks")]
1495 type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
1496}
1497
1498pub struct SwapLeases;
1500impl OnSwap for SwapLeases {
1501 fn on_swap(one: ParaId, other: ParaId) {
1502 coretime::Pallet::<Runtime>::on_legacy_lease_swap(one, other);
1503 }
1504}
1505
1506construct_runtime! {
1507 pub enum Runtime
1508 {
1509 System: frame_system = 0,
1511
1512 Babe: pallet_babe = 1,
1514
1515 Timestamp: pallet_timestamp = 2,
1516 Indices: pallet_indices = 3,
1517 Balances: pallet_balances = 4,
1518 Parameters: pallet_parameters = 6,
1519 TransactionPayment: pallet_transaction_payment = 33,
1520
1521 Authorship: pallet_authorship = 5,
1524 Offences: pallet_offences = 7,
1525 Historical: session_historical = 34,
1526
1527 Session: pallet_session = 8,
1528 Grandpa: pallet_grandpa = 10,
1529 AuthorityDiscovery: pallet_authority_discovery = 12,
1530
1531 Treasury: pallet_treasury = 18,
1533 ConvictionVoting: pallet_conviction_voting = 20,
1534 Referenda: pallet_referenda = 21,
1535 FellowshipCollective: pallet_ranked_collective::<Instance1> = 22,
1537 FellowshipReferenda: pallet_referenda::<Instance2> = 23,
1539 Origins: pallet_custom_origins = 43,
1540 Whitelist: pallet_whitelist = 44,
1541 Claims: claims = 19,
1543
1544 Utility: pallet_utility = 24,
1546
1547 Identity: pallet_identity = 25,
1549
1550 Society: pallet_society = 26,
1552
1553 Recovery: pallet_recovery = 27,
1555
1556 Vesting: pallet_vesting = 28,
1558
1559 Scheduler: pallet_scheduler = 29,
1561
1562 Proxy: pallet_proxy = 30,
1564
1565 Multisig: pallet_multisig = 31,
1567
1568 Preimage: pallet_preimage = 32,
1570
1571 AssetRate: pallet_asset_rate = 39,
1573
1574 Bounties: pallet_bounties = 35,
1576 ChildBounties: pallet_child_bounties = 40,
1577
1578 Nis: pallet_nis = 38,
1580 NisCounterpartBalances: pallet_balances::<Instance2> = 45,
1582
1583 ParachainsOrigin: parachains_origin = 50,
1585 Configuration: parachains_configuration = 51,
1586 ParasShared: parachains_shared = 52,
1587 ParaInclusion: parachains_inclusion = 53,
1588 ParaInherent: parachains_paras_inherent = 54,
1589 ParaScheduler: parachains_scheduler = 55,
1590 Paras: parachains_paras = 56,
1591 Initializer: parachains_initializer = 57,
1592 Dmp: parachains_dmp = 58,
1593 Hrmp: parachains_hrmp = 60,
1594 ParaSessionInfo: parachains_session_info = 61,
1595 ParasDisputes: parachains_disputes = 62,
1596 ParasSlashing: parachains_slashing = 63,
1597 MessageQueue: pallet_message_queue = 64,
1598 OnDemandAssignmentProvider: parachains_on_demand = 66,
1599 Registrar: paras_registrar = 70,
1603 Slots: slots = 71,
1604 Auctions: auctions = 72,
1605 Crowdloan: crowdloan = 73,
1606 Coretime: coretime = 74,
1607
1608 MultiBlockMigrations: pallet_migrations = 98,
1610
1611 XcmPallet: pallet_xcm = 99,
1613
1614 Beefy: pallet_beefy = 240,
1616 Mmr: pallet_mmr = 241,
1619 MmrLeaf: pallet_beefy_mmr = 242,
1620
1621 IdentityMigrator: identity_migrator = 248,
1623
1624 ParasSudoWrapper: paras_sudo_wrapper = 250,
1625 AssignedSlots: assigned_slots = 251,
1626
1627 ValidatorManager: validator_manager = 252,
1629
1630 StateTrieMigration: pallet_state_trie_migration = 254,
1632
1633 RootTesting: pallet_root_testing = 249,
1635
1636 Sudo: pallet_sudo = 255,
1638 }
1639}
1640
1641pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
1643pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
1645pub type Block = generic::Block<Header, UncheckedExtrinsic>;
1647pub type SignedBlock = generic::SignedBlock<Block>;
1649pub type BlockId = generic::BlockId<Block>;
1651pub type TxExtension = (
1653 frame_system::AuthorizeCall<Runtime>,
1654 frame_system::CheckNonZeroSender<Runtime>,
1655 frame_system::CheckSpecVersion<Runtime>,
1656 frame_system::CheckTxVersion<Runtime>,
1657 frame_system::CheckGenesis<Runtime>,
1658 frame_system::CheckMortality<Runtime>,
1659 frame_system::CheckNonce<Runtime>,
1660 frame_system::CheckWeight<Runtime>,
1661 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
1662 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
1663 frame_system::WeightReclaim<Runtime>,
1664);
1665
1666pub type UncheckedExtrinsic =
1668 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
1669pub type UncheckedSignaturePayload =
1671 generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
1672
1673pub type Migrations = migrations::Unreleased;
1678
1679#[allow(deprecated, missing_docs)]
1681pub mod migrations {
1682 use super::*;
1683
1684 use frame_support::traits::LockIdentifier;
1685 use frame_system::pallet_prelude::BlockNumberFor;
1686
1687 parameter_types! {
1688 pub const DemocracyPalletName: &'static str = "Democracy";
1689 pub const CouncilPalletName: &'static str = "Council";
1690 pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
1691 pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
1692 pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
1693 pub const TipsPalletName: &'static str = "Tips";
1694 pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
1695 pub BalanceUnreserveWeight: Weight = weights::pallet_balances_balances::WeightInfo::<Runtime>::force_unreserve();
1697 pub BalanceTransferAllowDeath: Weight = weights::pallet_balances_balances::WeightInfo::<Runtime>::transfer_allow_death();
1698 }
1699
1700 pub struct UnlockConfig;
1703 impl pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockConfig for UnlockConfig {
1704 type Currency = Balances;
1705 type MaxVotes = ConstU32<100>;
1706 type MaxDeposits = ConstU32<100>;
1707 type AccountId = AccountId;
1708 type BlockNumber = BlockNumberFor<Runtime>;
1709 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1710 type PalletName = DemocracyPalletName;
1711 }
1712 impl pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockConfig
1713 for UnlockConfig
1714 {
1715 type Currency = Balances;
1716 type MaxVotesPerVoter = ConstU32<16>;
1717 type PalletId = PhragmenElectionPalletId;
1718 type AccountId = AccountId;
1719 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1720 type PalletName = PhragmenElectionPalletName;
1721 }
1722 impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfig {
1723 type Currency = Balances;
1724 type Hash = Hash;
1725 type DataDepositPerByte = DataDepositPerByte;
1726 type TipReportDepositBase = TipReportDepositBase;
1727 type AccountId = AccountId;
1728 type BlockNumber = BlockNumberFor<Runtime>;
1729 type DbWeight = <Runtime as frame_system::Config>::DbWeight;
1730 type PalletName = TipsPalletName;
1731 }
1732
1733 const IDENTITY_MIGRATION_KEY_LIMIT: u64 = u64::MAX;
1735
1736 pub type Unreleased = (
1738 pallet_society::migrations::MigrateToV2<Runtime, (), ()>,
1739 parachains_configuration::migration::v7::MigrateToV7<Runtime>,
1740 assigned_slots::migration::v1::MigrateToV1<Runtime>,
1741 parachains_configuration::migration::v8::MigrateToV8<Runtime>,
1742 parachains_configuration::migration::v9::MigrateToV9<Runtime>,
1743 paras_registrar::migration::MigrateToV1<Runtime, ()>,
1744 pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, ()>,
1745 pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, pallet_referenda::Instance2>,
1746 pallet_child_bounties::migration::MigrateV0ToV1<Runtime, BalanceTransferAllowDeath>,
1747
1748 pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
1751 pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
1752 pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfig, ()>,
1753 pallet_treasury::migration::cleanup_proposals::Migration<Runtime, (), BalanceUnreserveWeight>,
1754
1755 frame_support::migrations::RemovePallet<DemocracyPalletName, <Runtime as frame_system::Config>::DbWeight>,
1758 frame_support::migrations::RemovePallet<CouncilPalletName, <Runtime as frame_system::Config>::DbWeight>,
1759 frame_support::migrations::RemovePallet<TechnicalCommitteePalletName, <Runtime as frame_system::Config>::DbWeight>,
1760 frame_support::migrations::RemovePallet<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
1761 frame_support::migrations::RemovePallet<TechnicalMembershipPalletName, <Runtime as frame_system::Config>::DbWeight>,
1762 frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
1763 pallet_grandpa::migrations::MigrateV4ToV5<Runtime>,
1764 parachains_configuration::migration::v10::MigrateToV10<Runtime>,
1765
1766 pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
1768
1769 pallet_session::migrations::v1::MigrateV0ToV1<Runtime, pallet_session::migrations::v1::InitOffenceSeverity<Runtime>>,
1771
1772 parachains_on_demand::migration::MigrateV1ToV2<Runtime>,
1774 parachains_scheduler::migration::MigrateV3ToV4<Runtime>,
1775
1776 parachains_configuration::migration::v13::MigrateToV13<Runtime>,
1777 parachains_shared::migration::MigrateToV2<Runtime>,
1778
1779 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
1781 parachains_inclusion::migration::MigrateToV1<Runtime>,
1782 );
1783}
1784
1785pub type Executive = frame_executive::Executive<
1787 Runtime,
1788 Block,
1789 frame_system::ChainContext<Runtime>,
1790 Runtime,
1791 AllPalletsWithSystem,
1792>;
1793pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
1795
1796parameter_types! {
1797 pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
1799 pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100;
1800 pub const MigrationMaxKeyLen: u32 = 512;
1801}
1802
1803impl pallet_state_trie_migration::Config for Runtime {
1804 type RuntimeEvent = RuntimeEvent;
1805 type Currency = Balances;
1806 type RuntimeHoldReason = RuntimeHoldReason;
1807 type SignedDepositPerItem = MigrationSignedDepositPerItem;
1808 type SignedDepositBase = MigrationSignedDepositBase;
1809 type ControlOrigin = EnsureRoot<AccountId>;
1810 type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
1812
1813 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
1815 type MaxKeyLen = MigrationMaxKeyLen;
1816}
1817
1818frame_support::ord_parameter_types! {
1819 pub const MigController: AccountId = AccountId::from(hex_literal::hex!("52bc71c1eca5353749542dfdf0af97bf764f9c2f44e860cd485f1cd86400f649"));
1820}
1821
1822#[cfg(feature = "runtime-benchmarks")]
1823mod benches {
1824 frame_benchmarking::define_benchmarks!(
1825 [polkadot_runtime_common::assigned_slots, AssignedSlots]
1829 [polkadot_runtime_common::auctions, Auctions]
1830 [polkadot_runtime_common::crowdloan, Crowdloan]
1831 [polkadot_runtime_common::claims, Claims]
1832 [polkadot_runtime_common::identity_migrator, IdentityMigrator]
1833 [polkadot_runtime_common::slots, Slots]
1834 [polkadot_runtime_common::paras_registrar, Registrar]
1835 [polkadot_runtime_parachains::configuration, Configuration]
1836 [polkadot_runtime_parachains::coretime, Coretime]
1837 [polkadot_runtime_parachains::hrmp, Hrmp]
1838 [polkadot_runtime_parachains::disputes, ParasDisputes]
1839 [polkadot_runtime_parachains::inclusion, ParaInclusion]
1840 [polkadot_runtime_parachains::initializer, Initializer]
1841 [polkadot_runtime_parachains::paras_inherent, ParaInherent]
1842 [polkadot_runtime_parachains::paras, Paras]
1843 [polkadot_runtime_parachains::on_demand, OnDemandAssignmentProvider]
1844 [pallet_balances, Balances]
1846 [pallet_balances, NisCounterpartBalances]
1847 [pallet_beefy_mmr, MmrLeaf]
1848 [frame_benchmarking::baseline, Baseline::<Runtime>]
1849 [pallet_bounties, Bounties]
1850 [pallet_child_bounties, ChildBounties]
1851 [pallet_conviction_voting, ConvictionVoting]
1852 [pallet_nis, Nis]
1853 [pallet_identity, Identity]
1854 [pallet_indices, Indices]
1855 [pallet_message_queue, MessageQueue]
1856 [pallet_migrations, MultiBlockMigrations]
1857 [pallet_mmr, Mmr]
1858 [pallet_multisig, Multisig]
1859 [pallet_parameters, Parameters]
1860 [pallet_preimage, Preimage]
1861 [pallet_proxy, Proxy]
1862 [pallet_ranked_collective, FellowshipCollective]
1863 [pallet_recovery, Recovery]
1864 [pallet_referenda, Referenda]
1865 [pallet_referenda, FellowshipReferenda]
1866 [pallet_scheduler, Scheduler]
1867 [pallet_sudo, Sudo]
1868 [frame_system, SystemBench::<Runtime>]
1869 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
1870 [pallet_timestamp, Timestamp]
1871 [pallet_transaction_payment, TransactionPayment]
1872 [pallet_treasury, Treasury]
1873 [pallet_utility, Utility]
1874 [pallet_vesting, Vesting]
1875 [pallet_asset_rate, AssetRate]
1876 [pallet_whitelist, Whitelist]
1877 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
1879 [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
1880 [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
1881 );
1882}
1883
1884sp_api::impl_runtime_apis! {
1885 impl sp_api::Core<Block> for Runtime {
1886 fn version() -> RuntimeVersion {
1887 VERSION
1888 }
1889
1890 fn execute_block(block: <Block as BlockT>::LazyBlock) {
1891 Executive::execute_block(block);
1892 }
1893
1894 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
1895 Executive::initialize_block(header)
1896 }
1897 }
1898
1899 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
1900 fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
1901 let acceptable_assets = vec![AssetId(xcm_config::TokenLocation::get())];
1902 XcmPallet::query_acceptable_payment_assets(xcm_version, acceptable_assets)
1903 }
1904
1905 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
1906 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
1907 XcmPallet::query_weight_to_asset_fee::<Trader>(weight, asset)
1908 }
1909
1910 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
1911 XcmPallet::query_xcm_weight(message)
1912 }
1913
1914 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>, asset_id: VersionedAssetId) -> Result<VersionedAssets, XcmPaymentApiError> {
1915 type AssetExchanger = <XcmConfig as xcm_executor::Config>::AssetExchanger;
1916 XcmPallet::query_delivery_fees::<AssetExchanger>(destination, message, asset_id)
1917 }
1918 }
1919
1920 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
1921 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1922 XcmPallet::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
1923 }
1924
1925 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
1926 XcmPallet::dry_run_xcm::<xcm_config::XcmRouter>(origin_location, xcm)
1927 }
1928 }
1929
1930 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
1931 fn convert_location(location: VersionedLocation) -> Result<
1932 AccountId,
1933 xcm_runtime_apis::conversions::Error
1934 > {
1935 xcm_runtime_apis::conversions::LocationToAccountHelper::<
1936 AccountId,
1937 xcm_config::LocationConverter,
1938 >::convert_location(location)
1939 }
1940 }
1941
1942 impl sp_api::Metadata<Block> for Runtime {
1943 fn metadata() -> OpaqueMetadata {
1944 OpaqueMetadata::new(Runtime::metadata().into())
1945 }
1946
1947 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
1948 Runtime::metadata_at_version(version)
1949 }
1950
1951 fn metadata_versions() -> alloc::vec::Vec<u32> {
1952 Runtime::metadata_versions()
1953 }
1954 }
1955
1956 impl sp_block_builder::BlockBuilder<Block> for Runtime {
1957 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
1958 Executive::apply_extrinsic(extrinsic)
1959 }
1960
1961 fn finalize_block() -> <Block as BlockT>::Header {
1962 Executive::finalize_block()
1963 }
1964
1965 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
1966 data.create_extrinsics()
1967 }
1968
1969 fn check_inherents(
1970 block: <Block as BlockT>::LazyBlock,
1971 data: sp_inherents::InherentData,
1972 ) -> sp_inherents::CheckInherentsResult {
1973 data.check_extrinsics(&block)
1974 }
1975 }
1976
1977 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
1978 fn validate_transaction(
1979 source: TransactionSource,
1980 tx: <Block as BlockT>::Extrinsic,
1981 block_hash: <Block as BlockT>::Hash,
1982 ) -> TransactionValidity {
1983 Executive::validate_transaction(source, tx, block_hash)
1984 }
1985 }
1986
1987 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
1988 fn offchain_worker(header: &<Block as BlockT>::Header) {
1989 Executive::offchain_worker(header)
1990 }
1991 }
1992
1993 #[api_version(16)]
1994 impl polkadot_primitives::runtime_api::ParachainHost<Block> for Runtime {
1995 fn validators() -> Vec<ValidatorId> {
1996 parachains_runtime_api_impl::validators::<Runtime>()
1997 }
1998
1999 fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
2000 parachains_runtime_api_impl::validator_groups::<Runtime>()
2001 }
2002
2003 fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>> {
2004 parachains_runtime_api_impl::availability_cores::<Runtime>()
2005 }
2006
2007 fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
2008 -> Option<PersistedValidationData<Hash, BlockNumber>> {
2009 parachains_runtime_api_impl::persisted_validation_data::<Runtime>(para_id, assumption)
2010 }
2011
2012 fn assumed_validation_data(
2013 para_id: ParaId,
2014 expected_persisted_validation_data_hash: Hash,
2015 ) -> Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)> {
2016 parachains_runtime_api_impl::assumed_validation_data::<Runtime>(
2017 para_id,
2018 expected_persisted_validation_data_hash,
2019 )
2020 }
2021
2022 fn check_validation_outputs(
2023 para_id: ParaId,
2024 outputs: polkadot_primitives::CandidateCommitments,
2025 ) -> bool {
2026 parachains_runtime_api_impl::check_validation_outputs::<Runtime>(para_id, outputs)
2027 }
2028
2029 fn session_index_for_child() -> SessionIndex {
2030 parachains_runtime_api_impl::session_index_for_child::<Runtime>()
2031 }
2032
2033 fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
2034 -> Option<ValidationCode> {
2035 parachains_runtime_api_impl::validation_code::<Runtime>(para_id, assumption)
2036 }
2037
2038 fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
2039 #[allow(deprecated)]
2040 parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
2041 }
2042
2043 fn candidate_events() -> Vec<CandidateEvent<Hash>> {
2044 parachains_runtime_api_impl::candidate_events::<Runtime, _>(|ev| {
2045 match ev {
2046 RuntimeEvent::ParaInclusion(ev) => {
2047 Some(ev)
2048 }
2049 _ => None,
2050 }
2051 })
2052 }
2053
2054 fn session_info(index: SessionIndex) -> Option<SessionInfo> {
2055 parachains_runtime_api_impl::session_info::<Runtime>(index)
2056 }
2057
2058 fn session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams> {
2059 parachains_runtime_api_impl::session_executor_params::<Runtime>(session_index)
2060 }
2061
2062 fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<BlockNumber>> {
2063 parachains_runtime_api_impl::dmq_contents::<Runtime>(recipient)
2064 }
2065
2066 fn inbound_hrmp_channels_contents(
2067 recipient: ParaId
2068 ) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
2069 parachains_runtime_api_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
2070 }
2071
2072 fn validation_code_by_hash(hash: ValidationCodeHash) -> Option<ValidationCode> {
2073 parachains_runtime_api_impl::validation_code_by_hash::<Runtime>(hash)
2074 }
2075
2076 fn on_chain_votes() -> Option<ScrapedOnChainVotes<Hash>> {
2077 parachains_runtime_api_impl::on_chain_votes::<Runtime>()
2078 }
2079
2080 fn submit_pvf_check_statement(
2081 stmt: polkadot_primitives::PvfCheckStatement,
2082 signature: polkadot_primitives::ValidatorSignature
2083 ) {
2084 parachains_runtime_api_impl::submit_pvf_check_statement::<Runtime>(stmt, signature)
2085 }
2086
2087 fn pvfs_require_precheck() -> Vec<ValidationCodeHash> {
2088 parachains_runtime_api_impl::pvfs_require_precheck::<Runtime>()
2089 }
2090
2091 fn validation_code_hash(para_id: ParaId, assumption: OccupiedCoreAssumption)
2092 -> Option<ValidationCodeHash>
2093 {
2094 parachains_runtime_api_impl::validation_code_hash::<Runtime>(para_id, assumption)
2095 }
2096
2097 fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
2098 parachains_runtime_api_impl::get_session_disputes::<Runtime>()
2099 }
2100
2101 fn unapplied_slashes(
2102 ) -> Vec<(SessionIndex, CandidateHash, slashing::LegacyPendingSlashes)> {
2103 parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
2104 }
2105
2106 fn unapplied_slashes_v2(
2107 ) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
2108 parachains_runtime_api_impl::unapplied_slashes_v2::<Runtime>()
2109 }
2110
2111 fn key_ownership_proof(
2112 validator_id: ValidatorId,
2113 ) -> Option<slashing::OpaqueKeyOwnershipProof> {
2114 use codec::Encode;
2115
2116 Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
2117 .map(|p| p.encode())
2118 .map(slashing::OpaqueKeyOwnershipProof::new)
2119 }
2120
2121 fn submit_report_dispute_lost(
2122 dispute_proof: slashing::DisputeProof,
2123 key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
2124 ) -> Option<()> {
2125 parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
2126 dispute_proof,
2127 key_ownership_proof,
2128 )
2129 }
2130
2131 fn minimum_backing_votes() -> u32 {
2132 parachains_runtime_api_impl::minimum_backing_votes::<Runtime>()
2133 }
2134
2135 fn para_backing_state(para_id: ParaId) -> Option<polkadot_primitives::async_backing::BackingState> {
2136 #[allow(deprecated)]
2137 parachains_runtime_api_impl::backing_state::<Runtime>(para_id)
2138 }
2139
2140 fn async_backing_params() -> polkadot_primitives::AsyncBackingParams {
2141 #[allow(deprecated)]
2142 parachains_runtime_api_impl::async_backing_params::<Runtime>()
2143 }
2144
2145 fn approval_voting_params() -> ApprovalVotingParams {
2146 parachains_runtime_api_impl::approval_voting_params::<Runtime>()
2147 }
2148
2149 fn disabled_validators() -> Vec<ValidatorIndex> {
2150 parachains_runtime_api_impl::disabled_validators::<Runtime>()
2151 }
2152
2153 fn node_features() -> NodeFeatures {
2154 parachains_runtime_api_impl::node_features::<Runtime>()
2155 }
2156
2157 fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
2158 parachains_runtime_api_impl::claim_queue::<Runtime>()
2159 }
2160
2161 fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
2162 parachains_runtime_api_impl::candidates_pending_availability::<Runtime>(para_id)
2163 }
2164
2165 fn backing_constraints(para_id: ParaId) -> Option<Constraints> {
2166 parachains_runtime_api_impl::backing_constraints::<Runtime>(para_id)
2167 }
2168
2169 fn scheduling_lookahead() -> u32 {
2170 parachains_runtime_api_impl::scheduling_lookahead::<Runtime>()
2171 }
2172
2173 fn validation_code_bomb_limit() -> u32 {
2174 parachains_runtime_api_impl::validation_code_bomb_limit::<Runtime>()
2175 }
2176
2177 fn para_ids() -> Vec<ParaId> {
2178 parachains_staging_runtime_api_impl::para_ids::<Runtime>()
2179 }
2180
2181 fn max_relay_parent_session_age() -> u32 {
2182 parachains_staging_runtime_api_impl::max_relay_parent_session_age::<Runtime>()
2183 }
2184
2185 fn ancestor_relay_parent_info(
2186 session_index: SessionIndex,
2187 relay_parent: Hash,
2188 ) -> Option<polkadot_primitives::vstaging::RelayParentInfo<Hash, BlockNumber>> {
2189 parachains_staging_runtime_api_impl::ancestor_relay_parent_info::<Runtime>(session_index, relay_parent)
2190 }
2191 }
2192
2193 #[api_version(6)]
2194 impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
2195 fn beefy_genesis() -> Option<BlockNumber> {
2196 pallet_beefy::GenesisBlock::<Runtime>::get()
2197 }
2198
2199 fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
2200 Beefy::validator_set()
2201 }
2202
2203 fn submit_report_double_voting_unsigned_extrinsic(
2204 equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
2205 BlockNumber,
2206 BeefyId,
2207 BeefySignature,
2208 >,
2209 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2210 ) -> Option<()> {
2211 let key_owner_proof = key_owner_proof.decode()?;
2212
2213 Beefy::submit_unsigned_double_voting_report(
2214 equivocation_proof,
2215 key_owner_proof,
2216 )
2217 }
2218
2219 fn submit_report_fork_voting_unsigned_extrinsic(
2220 equivocation_proof:
2221 sp_consensus_beefy::ForkVotingProof<
2222 <Block as BlockT>::Header,
2223 BeefyId,
2224 sp_runtime::OpaqueValue
2225 >,
2226 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2227 ) -> Option<()> {
2228 Beefy::submit_unsigned_fork_voting_report(
2229 equivocation_proof.try_into()?,
2230 key_owner_proof.decode()?,
2231 )
2232 }
2233
2234 fn submit_report_future_block_voting_unsigned_extrinsic(
2235 equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
2236 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
2237 ) -> Option<()> {
2238 Beefy::submit_unsigned_future_block_voting_report(
2239 equivocation_proof,
2240 key_owner_proof.decode()?,
2241 )
2242 }
2243
2244 fn generate_key_ownership_proof(
2245 _set_id: sp_consensus_beefy::ValidatorSetId,
2246 authority_id: BeefyId,
2247 ) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
2248 use codec::Encode;
2249
2250 Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
2251 .map(|p| p.encode())
2252 .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
2253 }
2254 }
2255
2256 #[api_version(3)]
2257 impl mmr::MmrApi<Block, mmr::Hash, BlockNumber> for Runtime {
2258 fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
2259 Ok(pallet_mmr::RootHash::<Runtime>::get())
2260 }
2261
2262 fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
2263 Ok(pallet_mmr::NumberOfLeaves::<Runtime>::get())
2264 }
2265
2266 fn generate_proof(
2267 block_numbers: Vec<BlockNumber>,
2268 best_known_block_number: Option<BlockNumber>,
2269 ) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<mmr::Hash>), mmr::Error> {
2270 Mmr::generate_proof(block_numbers, best_known_block_number).map(
2271 |(leaves, proof)| {
2272 (
2273 leaves
2274 .into_iter()
2275 .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
2276 .collect(),
2277 proof,
2278 )
2279 },
2280 )
2281 }
2282
2283 fn generate_ancestry_proof(
2284 prev_block_number: BlockNumber,
2285 best_known_block_number: Option<BlockNumber>,
2286 ) -> Result<mmr::AncestryProof<mmr::Hash>, mmr::Error> {
2287 Mmr::generate_ancestry_proof(prev_block_number, best_known_block_number)
2288 }
2289
2290 fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::LeafProof<mmr::Hash>)
2291 -> Result<(), mmr::Error>
2292 {
2293 let leaves = leaves.into_iter().map(|leaf|
2294 leaf.into_opaque_leaf()
2295 .try_decode()
2296 .ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;
2297 Mmr::verify_leaves(leaves, proof)
2298 }
2299
2300 fn verify_proof_stateless(
2301 root: mmr::Hash,
2302 leaves: Vec<mmr::EncodableOpaqueLeaf>,
2303 proof: mmr::LeafProof<mmr::Hash>
2304 ) -> Result<(), mmr::Error> {
2305 let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
2306 pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)
2307 }
2308 }
2309
2310 impl fg_primitives::GrandpaApi<Block> for Runtime {
2311 fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
2312 Grandpa::grandpa_authorities()
2313 }
2314
2315 fn current_set_id() -> fg_primitives::SetId {
2316 pallet_grandpa::CurrentSetId::<Runtime>::get()
2317 }
2318
2319 fn submit_report_equivocation_unsigned_extrinsic(
2320 equivocation_proof: fg_primitives::EquivocationProof<
2321 <Block as BlockT>::Hash,
2322 sp_runtime::traits::NumberFor<Block>,
2323 >,
2324 key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
2325 ) -> Option<()> {
2326 let key_owner_proof = key_owner_proof.decode()?;
2327
2328 Grandpa::submit_unsigned_equivocation_report(
2329 equivocation_proof,
2330 key_owner_proof,
2331 )
2332 }
2333
2334 fn generate_key_ownership_proof(
2335 _set_id: fg_primitives::SetId,
2336 authority_id: fg_primitives::AuthorityId,
2337 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
2338 use codec::Encode;
2339
2340 Historical::prove((fg_primitives::KEY_TYPE, authority_id))
2341 .map(|p| p.encode())
2342 .map(fg_primitives::OpaqueKeyOwnershipProof::new)
2343 }
2344 }
2345
2346 impl sp_consensus_babe::BabeApi<Block> for Runtime {
2347 fn configuration() -> sp_consensus_babe::BabeConfiguration {
2348 let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
2349 sp_consensus_babe::BabeConfiguration {
2350 slot_duration: Babe::slot_duration(),
2351 epoch_length: EpochDurationInBlocks::get().into(),
2352 c: epoch_config.c,
2353 authorities: Babe::authorities().to_vec(),
2354 randomness: Babe::randomness(),
2355 allowed_slots: epoch_config.allowed_slots,
2356 }
2357 }
2358
2359 fn current_epoch_start() -> sp_consensus_babe::Slot {
2360 Babe::current_epoch_start()
2361 }
2362
2363 fn current_epoch() -> sp_consensus_babe::Epoch {
2364 Babe::current_epoch()
2365 }
2366
2367 fn next_epoch() -> sp_consensus_babe::Epoch {
2368 Babe::next_epoch()
2369 }
2370
2371 fn generate_key_ownership_proof(
2372 _slot: sp_consensus_babe::Slot,
2373 authority_id: sp_consensus_babe::AuthorityId,
2374 ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
2375 use codec::Encode;
2376
2377 Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
2378 .map(|p| p.encode())
2379 .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
2380 }
2381
2382 fn submit_report_equivocation_unsigned_extrinsic(
2383 equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
2384 key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
2385 ) -> Option<()> {
2386 let key_owner_proof = key_owner_proof.decode()?;
2387
2388 Babe::submit_unsigned_equivocation_report(
2389 equivocation_proof,
2390 key_owner_proof,
2391 )
2392 }
2393 }
2394
2395 impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
2396 fn authorities() -> Vec<AuthorityDiscoveryId> {
2397 parachains_runtime_api_impl::relevant_authority_ids::<Runtime>()
2398 }
2399 }
2400
2401 impl sp_session::SessionKeys<Block> for Runtime {
2402 fn generate_session_keys(
2403 owner: Vec<u8>,
2404 seed: Option<Vec<u8>>,
2405 ) -> sp_session::OpaqueGeneratedSessionKeys {
2406 SessionKeys::generate(&owner, seed).into()
2407 }
2408
2409 fn decode_session_keys(
2410 encoded: Vec<u8>,
2411 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
2412 SessionKeys::decode_into_raw_public_keys(&encoded)
2413 }
2414 }
2415
2416 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
2417 fn account_nonce(account: AccountId) -> Nonce {
2418 System::account_nonce(account)
2419 }
2420 }
2421
2422 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
2423 Block,
2424 Balance,
2425 > for Runtime {
2426 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
2427 TransactionPayment::query_info(uxt, len)
2428 }
2429 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
2430 TransactionPayment::query_fee_details(uxt, len)
2431 }
2432 fn query_weight_to_fee(weight: Weight) -> Balance {
2433 TransactionPayment::weight_to_fee(weight)
2434 }
2435 fn query_length_to_fee(length: u32) -> Balance {
2436 TransactionPayment::length_to_fee(length)
2437 }
2438 }
2439
2440 impl pallet_beefy_mmr::BeefyMmrApi<Block, Hash> for RuntimeApi {
2441 fn authority_set_proof() -> sp_consensus_beefy::mmr::BeefyAuthoritySet<Hash> {
2442 MmrLeaf::authority_set_proof()
2443 }
2444
2445 fn next_authority_set_proof() -> sp_consensus_beefy::mmr::BeefyNextAuthoritySet<Hash> {
2446 MmrLeaf::next_authority_set_proof()
2447 }
2448 }
2449
2450 #[cfg(feature = "try-runtime")]
2451 impl frame_try_runtime::TryRuntime<Block> for Runtime {
2452 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
2453 log::info!("try-runtime::on_runtime_upgrade rococo.");
2454 let weight = Executive::try_runtime_upgrade(checks).unwrap();
2455 (weight, BlockWeights::get().max_block)
2456 }
2457
2458 fn execute_block(
2459 block: <Block as BlockT>::LazyBlock,
2460 state_root_check: bool,
2461 signature_check: bool,
2462 select: frame_try_runtime::TryStateSelect,
2463 ) -> Weight {
2464 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
2467 }
2468 }
2469
2470 #[cfg(feature = "runtime-benchmarks")]
2471 impl frame_benchmarking::Benchmark<Block> for Runtime {
2472 fn benchmark_metadata(extra: bool) -> (
2473 Vec<frame_benchmarking::BenchmarkList>,
2474 Vec<frame_support::traits::StorageInfo>,
2475 ) {
2476 use frame_benchmarking::BenchmarkList;
2477 use frame_support::traits::StorageInfoTrait;
2478
2479 use frame_system_benchmarking::Pallet as SystemBench;
2480 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2481 use frame_benchmarking::baseline::Pallet as Baseline;
2482
2483 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2484
2485 let mut list = Vec::<BenchmarkList>::new();
2486 list_benchmarks!(list, extra);
2487
2488 let storage_info = AllPalletsWithSystem::storage_info();
2489 return (list, storage_info)
2490 }
2491
2492 #[allow(non_local_definitions)]
2493 fn dispatch_benchmark(
2494 config: frame_benchmarking::BenchmarkConfig,
2495 ) -> Result<
2496 Vec<frame_benchmarking::BenchmarkBatch>,
2497 alloc::string::String,
2498 > {
2499 use frame_support::traits::WhitelistedStorageKeys;
2500 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
2501 use frame_system_benchmarking::Pallet as SystemBench;
2502 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
2503 use frame_benchmarking::baseline::Pallet as Baseline;
2504 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
2505 use sp_storage::TrackedStorageKey;
2506 use xcm::latest::prelude::*;
2507 use xcm_config::{
2508 AssetHub, LocalCheckAccount, LocationConverter, TokenLocation, XcmConfig,
2509 };
2510
2511 parameter_types! {
2512 pub ExistentialDepositAsset: Option<Asset> = Some((
2513 TokenLocation::get(),
2514 ExistentialDeposit::get()
2515 ).into());
2516 pub AssetHubParaId: ParaId = rococo_runtime_constants::system_parachain::ASSET_HUB_ID.into();
2517 pub const RandomParaId: ParaId = ParaId::new(43211234);
2518 }
2519
2520 impl frame_system_benchmarking::Config for Runtime {}
2521 impl frame_benchmarking::baseline::Config for Runtime {}
2522 impl pallet_transaction_payment::BenchmarkConfig for Runtime {}
2523 impl pallet_xcm::benchmarking::Config for Runtime {
2524 type DeliveryHelper = (
2525 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2526 XcmConfig,
2527 ExistentialDepositAsset,
2528 xcm_config::PriceForChildParachainDelivery,
2529 AssetHubParaId,
2530 Dmp,
2531 >,
2532 polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2533 XcmConfig,
2534 ExistentialDepositAsset,
2535 xcm_config::PriceForChildParachainDelivery,
2536 RandomParaId,
2537 Dmp,
2538 >
2539 );
2540
2541 fn reachable_dest() -> Option<Location> {
2542 Some(crate::xcm_config::AssetHub::get())
2543 }
2544
2545 fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
2546 Some((
2548 Asset {
2549 fun: Fungible(ExistentialDeposit::get()),
2550 id: AssetId(Here.into())
2551 },
2552 crate::xcm_config::AssetHub::get(),
2553 ))
2554 }
2555
2556 fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
2557 None
2558 }
2559
2560 fn set_up_complex_asset_transfer(
2561 ) -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
2562 let native_location = Here.into();
2567 let dest = crate::xcm_config::AssetHub::get();
2568 pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
2569 native_location,
2570 dest
2571 )
2572 }
2573
2574 fn get_asset() -> Asset {
2575 Asset {
2576 id: AssetId(Location::here()),
2577 fun: Fungible(ExistentialDeposit::get()),
2578 }
2579 }
2580 }
2581 impl pallet_xcm_benchmarks::Config for Runtime {
2582 type XcmConfig = XcmConfig;
2583 type AccountIdConverter = LocationConverter;
2584 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
2585 XcmConfig,
2586 ExistentialDepositAsset,
2587 xcm_config::PriceForChildParachainDelivery,
2588 AssetHubParaId,
2589 Dmp,
2590 >;
2591 fn valid_destination() -> Result<Location, BenchmarkError> {
2592 Ok(AssetHub::get())
2593 }
2594 fn worst_case_holding(_depositable_count: u32) -> xcm_executor::AssetsInHolding {
2595 use pallet_xcm_benchmarks::MockCredit;
2596 let mut holding = xcm_executor::AssetsInHolding::new();
2598 holding.fungible.insert(
2599 AssetId(TokenLocation::get()),
2600 alloc::boxed::Box::new(MockCredit(1_000_000 * UNITS)),
2601 );
2602 holding
2603 }
2604 }
2605
2606 parameter_types! {
2607 pub TrustedTeleporter: Option<(Location, Asset)> = Some((
2608 AssetHub::get(),
2609 Asset { fun: Fungible(1 * UNITS), id: AssetId(TokenLocation::get()) },
2610 ));
2611 pub TrustedReserve: Option<(Location, Asset)> = None;
2612 }
2613
2614 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
2615 type TransactAsset = Balances;
2616
2617 type CheckedAccount = LocalCheckAccount;
2618 type TrustedTeleporter = TrustedTeleporter;
2619 type TrustedReserve = TrustedReserve;
2620
2621 fn get_asset() -> Asset {
2622 Asset {
2623 id: AssetId(TokenLocation::get()),
2624 fun: Fungible(1 * UNITS),
2625 }
2626 }
2627 }
2628
2629 impl pallet_xcm_benchmarks::generic::Config for Runtime {
2630 type TransactAsset = Balances;
2631 type RuntimeCall = RuntimeCall;
2632
2633 fn worst_case_response() -> (u64, Response) {
2634 (0u64, Response::Version(Default::default()))
2635 }
2636
2637 fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
2638 Err(BenchmarkError::Skip)
2640 }
2641
2642 fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
2643 Err(BenchmarkError::Skip)
2645 }
2646
2647 fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
2648 Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
2649 }
2650
2651 fn subscribe_origin() -> Result<Location, BenchmarkError> {
2652 Ok(AssetHub::get())
2653 }
2654
2655 fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
2656 let origin = AssetHub::get();
2657 let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
2658 let ticket = Location { parents: 0, interior: Here };
2659 Ok((origin, ticket, assets))
2660 }
2661
2662 fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
2663 Ok((Asset {
2664 id: AssetId(TokenLocation::get()),
2665 fun: Fungible(1_000_000 * UNITS),
2666 }, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
2667 }
2668
2669 fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
2670 Err(BenchmarkError::Skip)
2672 }
2673
2674 fn export_message_origin_and_destination(
2675 ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
2676 Err(BenchmarkError::Skip)
2678 }
2679
2680 fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
2681 Err(BenchmarkError::Skip)
2683 }
2684 }
2685
2686 let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
2687 let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
2688 whitelist.push(treasury_key.to_vec().into());
2689
2690 let mut batches = Vec::<BenchmarkBatch>::new();
2691 let params = (&config, &whitelist);
2692
2693 add_benchmarks!(params, batches);
2694
2695 Ok(batches)
2696 }
2697 }
2698
2699 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
2700 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
2701 build_state::<RuntimeGenesisConfig>(config)
2702 }
2703
2704 fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
2705 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
2706 }
2707
2708 fn preset_names() -> Vec<PresetId> {
2709 genesis_config_presets::preset_names()
2710 }
2711 }
2712
2713 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
2714 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2715 XcmPallet::is_trusted_reserve(asset, location)
2716 }
2717 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2718 XcmPallet::is_trusted_teleporter(asset, location)
2719 }
2720 }
2721}
2722
2723#[cfg(all(test, feature = "try-runtime"))]
2724mod remote_tests {
2725 use super::*;
2726 use frame_try_runtime::{runtime_decl_for_try_runtime::TryRuntime, UpgradeCheckSelect};
2727 use remote_externalities::{Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig};
2728 use std::env::var;
2729
2730 #[tokio::test]
2731 async fn run_migrations() {
2732 if var("RUN_MIGRATION_TESTS").is_err() {
2733 return;
2734 }
2735
2736 sp_tracing::try_init_simple();
2737 let transport = var("WS").unwrap_or("wss://rococo-rpc.polkadot.io:443".to_string());
2738 let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
2739
2740 let transport_uris = vec![transport];
2741 let mut ext = Builder::<Block>::default()
2742 .mode(if let Some(state_snapshot) = maybe_state_snapshot {
2743 Mode::OfflineOrElseOnline(
2744 OfflineConfig { state_snapshot: state_snapshot.clone() },
2745 OnlineConfig {
2746 transport_uris,
2747 state_snapshot: Some(state_snapshot),
2748 ..Default::default()
2749 },
2750 )
2751 } else {
2752 Mode::Online(OnlineConfig { transport_uris, ..Default::default() })
2753 })
2754 .build()
2755 .await
2756 .unwrap();
2757 ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost));
2758 }
2759}