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