Skip to main content

rococo_runtime/
lib.rs

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