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