referrerpolicy=no-referrer-when-downgrade

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