people_westend_runtime/
lib.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// 	http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#![cfg_attr(not(feature = "std"), no_std)]
17#![recursion_limit = "256"]
18#[cfg(feature = "std")]
19include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
20
21mod genesis_config_presets;
22pub mod people;
23mod weights;
24pub mod xcm_config;
25
26extern crate alloc;
27
28use alloc::{vec, vec::Vec};
29use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
30use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
31use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
32use frame_support::{
33	construct_runtime, derive_impl,
34	dispatch::DispatchClass,
35	genesis_builder_helper::{build_state, get_preset},
36	parameter_types,
37	traits::{
38		ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, InstanceFilter,
39		TransformOrigin,
40	},
41	weights::{ConstantMultiplier, Weight},
42	PalletId,
43};
44use frame_system::{
45	limits::{BlockLength, BlockWeights},
46	EnsureRoot,
47};
48use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
49use parachains_common::{
50	impls::DealWithFees,
51	message_queue::{NarrowOriginToSibling, ParaIdToSibling},
52	AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
53	NORMAL_DISPATCH_RATIO,
54};
55use polkadot_runtime_common::{identity_migrator, BlockHashCount, SlowAdjustingFeeUpdate};
56use sp_api::impl_runtime_apis;
57pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
58use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
59#[cfg(any(feature = "std", test))]
60pub use sp_runtime::BuildStorage;
61use sp_runtime::{
62	generic, impl_opaque_keys,
63	traits::{BlakeTwo256, Block as BlockT},
64	transaction_validity::{TransactionSource, TransactionValidity},
65	ApplyExtrinsicResult,
66};
67pub use sp_runtime::{MultiAddress, Perbill, Permill, RuntimeDebug};
68use sp_statement_store::{
69	runtime_api::{InvalidStatement, StatementSource, ValidStatement},
70	SignatureVerificationResult, Statement,
71};
72#[cfg(feature = "std")]
73use sp_version::NativeVersion;
74use sp_version::RuntimeVersion;
75use testnet_parachains_constants::westend::{consensus::*, currency::*, fee::WeightToFee, time::*};
76use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
77use xcm::{prelude::*, Version as XcmVersion};
78use xcm_config::{
79	FellowshipLocation, GovernanceLocation, PriceForSiblingParachainDelivery, XcmConfig,
80	XcmOriginToTransactDispatchOrigin,
81};
82use xcm_runtime_apis::{
83	dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
84	fees::Error as XcmPaymentApiError,
85};
86
87/// The address format for describing accounts.
88pub type Address = MultiAddress<AccountId, ()>;
89
90/// Block type as expected by this runtime.
91pub type Block = generic::Block<Header, UncheckedExtrinsic>;
92
93/// A Block signed with an [`sp_runtime::Justification`].
94pub type SignedBlock = generic::SignedBlock<Block>;
95
96/// BlockId type as expected by this runtime.
97pub type BlockId = generic::BlockId<Block>;
98
99/// The transactionExtension to the basic transaction logic.
100pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
101	Runtime,
102	(
103		frame_system::AuthorizeCall<Runtime>,
104		frame_system::CheckNonZeroSender<Runtime>,
105		frame_system::CheckSpecVersion<Runtime>,
106		frame_system::CheckTxVersion<Runtime>,
107		frame_system::CheckGenesis<Runtime>,
108		frame_system::CheckEra<Runtime>,
109		frame_system::CheckNonce<Runtime>,
110		frame_system::CheckWeight<Runtime>,
111		pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
112	),
113>;
114
115/// Unchecked extrinsic type as expected by this runtime.
116pub type UncheckedExtrinsic =
117	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
118
119/// Migrations to apply on runtime upgrade.
120pub type Migrations = (
121	pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
122	pallet_session::migrations::v1::MigrateV0ToV1<
123		Runtime,
124		pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
125	>,
126	// permanent
127	pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
128	cumulus_pallet_aura_ext::migration::MigrateV0ToV1<Runtime>,
129);
130
131/// Executive: handles dispatch to the various modules.
132pub type Executive = frame_executive::Executive<
133	Runtime,
134	Block,
135	frame_system::ChainContext<Runtime>,
136	Runtime,
137	AllPalletsWithSystem,
138>;
139
140impl_opaque_keys! {
141	pub struct SessionKeys {
142		pub aura: Aura,
143	}
144}
145
146#[sp_version::runtime_version]
147pub const VERSION: RuntimeVersion = RuntimeVersion {
148	spec_name: alloc::borrow::Cow::Borrowed("people-westend"),
149	impl_name: alloc::borrow::Cow::Borrowed("people-westend"),
150	authoring_version: 1,
151	spec_version: 1_021_000,
152	impl_version: 0,
153	apis: RUNTIME_API_VERSIONS,
154	transaction_version: 2,
155	system_version: 1,
156};
157
158/// The version information used to identify this runtime when compiled natively.
159#[cfg(feature = "std")]
160pub fn native_version() -> NativeVersion {
161	NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
162}
163
164parameter_types! {
165	pub const Version: RuntimeVersion = VERSION;
166	pub RuntimeBlockLength: BlockLength =
167		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
168	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
169		.base_block(BlockExecutionWeight::get())
170		.for_class(DispatchClass::all(), |weights| {
171			weights.base_extrinsic = ExtrinsicBaseWeight::get();
172		})
173		.for_class(DispatchClass::Normal, |weights| {
174			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
175		})
176		.for_class(DispatchClass::Operational, |weights| {
177			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
178			// Operational transactions have some extra reserved space, so that they
179			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
180			weights.reserved = Some(
181				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
182			);
183		})
184		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
185		.build_or_panic();
186	pub const SS58Prefix: u8 = 42;
187}
188
189#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
190impl frame_system::Config for Runtime {
191	type BaseCallFilter = Everything;
192	type BlockWeights = RuntimeBlockWeights;
193	type BlockLength = RuntimeBlockLength;
194	type AccountId = AccountId;
195	type Nonce = Nonce;
196	type Hash = Hash;
197	type Block = Block;
198	type BlockHashCount = BlockHashCount;
199	type DbWeight = RocksDbWeight;
200	type Version = Version;
201	type AccountData = pallet_balances::AccountData<Balance>;
202	type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
203	type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
204	type SS58Prefix = SS58Prefix;
205	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
206	type MaxConsumers = ConstU32<16>;
207	type MultiBlockMigrator = MultiBlockMigrations;
208	type SingleBlockMigrations = Migrations;
209}
210
211impl cumulus_pallet_weight_reclaim::Config for Runtime {
212	type WeightInfo = weights::cumulus_pallet_weight_reclaim::WeightInfo<Runtime>;
213}
214
215impl pallet_timestamp::Config for Runtime {
216	/// A timestamp: milliseconds since the unix epoch.
217	type Moment = u64;
218	type OnTimestampSet = Aura;
219	type MinimumPeriod = ConstU64<0>;
220	type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
221}
222
223impl pallet_authorship::Config for Runtime {
224	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
225	type EventHandler = (CollatorSelection,);
226}
227
228parameter_types! {
229	pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
230}
231
232impl pallet_balances::Config for Runtime {
233	type Balance = Balance;
234	type DustRemoval = ();
235	type RuntimeEvent = RuntimeEvent;
236	type ExistentialDeposit = ExistentialDeposit;
237	type AccountStore = System;
238	type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
239	type MaxLocks = ConstU32<50>;
240	type MaxReserves = ConstU32<50>;
241	type ReserveIdentifier = [u8; 8];
242	type RuntimeFreezeReason = RuntimeFreezeReason;
243	type RuntimeHoldReason = RuntimeHoldReason;
244	type FreezeIdentifier = ();
245	type MaxFreezes = ConstU32<0>;
246	type DoneSlashHandler = ();
247}
248
249parameter_types! {
250	/// Relay Chain `TransactionByteFee` / 10.
251	pub const TransactionByteFee: Balance = MILLICENTS;
252}
253
254impl pallet_transaction_payment::Config for Runtime {
255	type RuntimeEvent = RuntimeEvent;
256	type OnChargeTransaction =
257		pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
258	type OperationalFeeMultiplier = ConstU8<5>;
259	type WeightToFee = WeightToFee;
260	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
261	type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
262	type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
263}
264
265parameter_types! {
266	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
267	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
268	pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
269}
270
271impl cumulus_pallet_parachain_system::Config for Runtime {
272	type RuntimeEvent = RuntimeEvent;
273	type OnSystemEvent = ();
274	type SelfParaId = parachain_info::Pallet<Runtime>;
275	type OutboundXcmpMessageSource = XcmpQueue;
276	type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
277	type ReservedDmpWeight = ReservedDmpWeight;
278	type XcmpMessageHandler = XcmpQueue;
279	type ReservedXcmpWeight = ReservedXcmpWeight;
280	type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
281	type ConsensusHook = ConsensusHook;
282	type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
283	type RelayParentOffset = ConstU32<0>;
284}
285
286type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
287	Runtime,
288	RELAY_CHAIN_SLOT_DURATION_MILLIS,
289	BLOCK_PROCESSING_VELOCITY,
290	UNINCLUDED_SEGMENT_CAPACITY,
291>;
292
293parameter_types! {
294	pub MessageQueueServiceWeight: Weight =
295		Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
296}
297
298impl pallet_message_queue::Config for Runtime {
299	type RuntimeEvent = RuntimeEvent;
300	#[cfg(feature = "runtime-benchmarks")]
301	type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
302		cumulus_primitives_core::AggregateMessageOrigin,
303	>;
304	#[cfg(not(feature = "runtime-benchmarks"))]
305	type MessageProcessor = xcm_builder::ProcessXcmMessage<
306		AggregateMessageOrigin,
307		xcm_executor::XcmExecutor<XcmConfig>,
308		RuntimeCall,
309	>;
310	type Size = u32;
311	// The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin:
312	type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
313	type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
314	type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
315	type MaxStale = sp_core::ConstU32<8>;
316	type ServiceWeight = MessageQueueServiceWeight;
317	type IdleMaxServiceWeight = MessageQueueServiceWeight;
318	type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
319}
320
321impl parachain_info::Config for Runtime {}
322
323impl cumulus_pallet_aura_ext::Config for Runtime {}
324
325parameter_types! {
326	// Fellows pluralistic body.
327	pub const FellowsBodyId: BodyId = BodyId::Technical;
328}
329
330/// Privileged origin that represents Root or Fellows.
331pub type RootOrFellows = EitherOfDiverse<
332	EnsureRoot<AccountId>,
333	EnsureXcm<IsVoiceOfBody<FellowshipLocation, FellowsBodyId>>,
334>;
335
336impl cumulus_pallet_xcmp_queue::Config for Runtime {
337	type RuntimeEvent = RuntimeEvent;
338	type ChannelInfo = ParachainSystem;
339	type VersionWrapper = PolkadotXcm;
340	type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
341	type MaxInboundSuspended = ConstU32<1_000>;
342	type MaxActiveOutboundChannels = ConstU32<128>;
343	// Most on-chain HRMP channels are configured to use 102400 bytes of max message size, so we
344	// need to set the page size larger than that until we reduce the channel size on-chain.
345	type MaxPageSize = ConstU32<{ 103 * 1024 }>;
346	type ControllerOrigin = RootOrFellows;
347	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
348	type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
349	type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
350}
351
352impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
353	// This must be the same as the `ChannelInfo` from the `Config`:
354	type ChannelList = ParachainSystem;
355}
356
357pub const PERIOD: u32 = 6 * HOURS;
358pub const OFFSET: u32 = 0;
359
360impl pallet_session::Config for Runtime {
361	type RuntimeEvent = RuntimeEvent;
362	type ValidatorId = <Self as frame_system::Config>::AccountId;
363	// we don't have stash and controller, thus we don't need the convert as well.
364	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
365	type ShouldEndSession = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
366	type NextSessionRotation = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
367	type SessionManager = CollatorSelection;
368	// Essentially just Aura, but let's be pedantic.
369	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
370	type Keys = SessionKeys;
371	type DisablingStrategy = ();
372	type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
373	type Currency = Balances;
374	type KeyDeposit = ();
375}
376
377impl pallet_aura::Config for Runtime {
378	type AuthorityId = AuraId;
379	type DisabledValidators = ();
380	type MaxAuthorities = ConstU32<100_000>;
381	type AllowMultipleBlocksPerSlot = ConstBool<true>;
382	type SlotDuration = ConstU64<SLOT_DURATION>;
383}
384
385parameter_types! {
386	pub const PotId: PalletId = PalletId(*b"PotStake");
387	pub const SessionLength: BlockNumber = 6 * HOURS;
388	// StakingAdmin pluralistic body.
389	pub const StakingAdminBodyId: BodyId = BodyId::Defense;
390}
391
392/// We allow Root and the `StakingAdmin` to execute privileged collator selection operations.
393pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
394	EnsureRoot<AccountId>,
395	EnsureXcm<IsVoiceOfBody<GovernanceLocation, StakingAdminBodyId>>,
396>;
397
398impl pallet_collator_selection::Config for Runtime {
399	type RuntimeEvent = RuntimeEvent;
400	type Currency = Balances;
401	type UpdateOrigin = CollatorSelectionUpdateOrigin;
402	type PotId = PotId;
403	type MaxCandidates = ConstU32<100>;
404	type MinEligibleCollators = ConstU32<4>;
405	type MaxInvulnerables = ConstU32<20>;
406	// should be a multiple of session or things will get inconsistent
407	type KickThreshold = ConstU32<PERIOD>;
408	type ValidatorId = <Self as frame_system::Config>::AccountId;
409	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
410	type ValidatorRegistration = Session;
411	type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
412}
413
414parameter_types! {
415	// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
416	pub const DepositBase: Balance = deposit(1, 88);
417	// Additional storage item size of 32 bytes.
418	pub const DepositFactor: Balance = deposit(0, 32);
419}
420
421impl pallet_multisig::Config for Runtime {
422	type RuntimeEvent = RuntimeEvent;
423	type RuntimeCall = RuntimeCall;
424	type Currency = Balances;
425	type DepositBase = DepositBase;
426	type DepositFactor = DepositFactor;
427	type MaxSignatories = ConstU32<100>;
428	type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
429	type BlockNumberProvider = frame_system::Pallet<Runtime>;
430}
431
432/// The type used to represent the kinds of proxying allowed.
433#[derive(
434	Copy,
435	Clone,
436	Eq,
437	PartialEq,
438	Ord,
439	PartialOrd,
440	Encode,
441	Decode,
442	DecodeWithMemTracking,
443	RuntimeDebug,
444	MaxEncodedLen,
445	scale_info::TypeInfo,
446)]
447pub enum ProxyType {
448	/// Fully permissioned proxy. Can execute any call on behalf of _proxied_.
449	Any,
450	/// Can execute any call that does not transfer funds or assets.
451	NonTransfer,
452	/// Proxy with the ability to reject time-delay proxy announcements.
453	CancelProxy,
454	/// Proxy for all Identity pallet calls.
455	Identity,
456	/// Proxy for identity registrars.
457	IdentityJudgement,
458	/// Collator selection proxy. Can execute calls related to collator selection mechanism.
459	Collator,
460}
461impl Default for ProxyType {
462	fn default() -> Self {
463		Self::Any
464	}
465}
466
467impl InstanceFilter<RuntimeCall> for ProxyType {
468	fn filter(&self, c: &RuntimeCall) -> bool {
469		match self {
470			ProxyType::Any => true,
471			ProxyType::NonTransfer => !matches!(
472				c,
473				RuntimeCall::Balances { .. } |
474				// `request_judgement` puts up a deposit to transfer to a registrar
475				RuntimeCall::Identity(pallet_identity::Call::request_judgement { .. })
476			),
477			ProxyType::CancelProxy => matches!(
478				c,
479				RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
480					RuntimeCall::Utility { .. } |
481					RuntimeCall::Multisig { .. }
482			),
483			ProxyType::Identity => {
484				matches!(
485					c,
486					RuntimeCall::Identity { .. } |
487						RuntimeCall::Utility { .. } |
488						RuntimeCall::Multisig { .. }
489				)
490			},
491			ProxyType::IdentityJudgement => matches!(
492				c,
493				RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
494					RuntimeCall::Utility(..) |
495					RuntimeCall::Multisig { .. }
496			),
497			ProxyType::Collator => matches!(
498				c,
499				RuntimeCall::CollatorSelection { .. } |
500					RuntimeCall::Utility { .. } |
501					RuntimeCall::Multisig { .. }
502			),
503		}
504	}
505
506	fn is_superset(&self, o: &Self) -> bool {
507		match (self, o) {
508			(x, y) if x == y => true,
509			(ProxyType::Any, _) => true,
510			(_, ProxyType::Any) => false,
511			(ProxyType::Identity, ProxyType::IdentityJudgement) => true,
512			(ProxyType::NonTransfer, ProxyType::IdentityJudgement) => true,
513			(ProxyType::NonTransfer, ProxyType::Collator) => true,
514			_ => false,
515		}
516	}
517}
518
519parameter_types! {
520	// One storage item; key size 32, value size 8.
521	pub const ProxyDepositBase: Balance = deposit(1, 40);
522	// Additional storage item size of 33 bytes.
523	pub const ProxyDepositFactor: Balance = deposit(0, 33);
524	pub const MaxProxies: u16 = 32;
525	// One storage item; key size 32, value size 16.
526	pub const AnnouncementDepositBase: Balance = deposit(1, 48);
527	pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
528	pub const MaxPending: u16 = 32;
529}
530
531impl pallet_proxy::Config for Runtime {
532	type RuntimeEvent = RuntimeEvent;
533	type RuntimeCall = RuntimeCall;
534	type Currency = Balances;
535	type ProxyType = ProxyType;
536	type ProxyDepositBase = ProxyDepositBase;
537	type ProxyDepositFactor = ProxyDepositFactor;
538	type MaxProxies = MaxProxies;
539	type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
540	type MaxPending = MaxPending;
541	type CallHasher = BlakeTwo256;
542	type AnnouncementDepositBase = AnnouncementDepositBase;
543	type AnnouncementDepositFactor = AnnouncementDepositFactor;
544	type BlockNumberProvider = frame_system::Pallet<Runtime>;
545}
546
547impl pallet_utility::Config for Runtime {
548	type RuntimeEvent = RuntimeEvent;
549	type RuntimeCall = RuntimeCall;
550	type PalletsOrigin = OriginCaller;
551	type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
552}
553
554// To be removed after migration is complete.
555impl identity_migrator::Config for Runtime {
556	type RuntimeEvent = RuntimeEvent;
557	type Reaper = EnsureRoot<AccountId>;
558	type ReapIdentityHandler = ();
559	type WeightInfo = weights::polkadot_runtime_common_identity_migrator::WeightInfo<Runtime>;
560}
561
562parameter_types! {
563	pub MbmServiceWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
564}
565
566impl pallet_migrations::Config for Runtime {
567	type RuntimeEvent = RuntimeEvent;
568	#[cfg(not(feature = "runtime-benchmarks"))]
569	type Migrations = pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>;
570	// Benchmarks need mocked migrations to guarantee that they succeed.
571	#[cfg(feature = "runtime-benchmarks")]
572	type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
573	type CursorMaxLen = ConstU32<65_536>;
574	type IdentifierMaxLen = ConstU32<256>;
575	type MigrationStatusHandler = ();
576	type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
577	type MaxServiceWeight = MbmServiceWeight;
578	type WeightInfo = weights::pallet_migrations::WeightInfo<Runtime>;
579}
580
581// Create the runtime by composing the FRAME pallets that were previously configured.
582construct_runtime!(
583	pub enum Runtime
584	{
585		// System support stuff.
586		System: frame_system = 0,
587		ParachainSystem: cumulus_pallet_parachain_system = 1,
588		Timestamp: pallet_timestamp = 2,
589		ParachainInfo: parachain_info = 3,
590		WeightReclaim: cumulus_pallet_weight_reclaim = 4,
591
592		// Monetary stuff.
593		Balances: pallet_balances = 10,
594		TransactionPayment: pallet_transaction_payment = 11,
595
596		// Collator support. The order of these 5 are important and shall not change.
597		Authorship: pallet_authorship = 20,
598		CollatorSelection: pallet_collator_selection = 21,
599		Session: pallet_session = 22,
600		Aura: pallet_aura = 23,
601		AuraExt: cumulus_pallet_aura_ext = 24,
602
603		// XCM helpers.
604		XcmpQueue: cumulus_pallet_xcmp_queue = 30,
605		PolkadotXcm: pallet_xcm = 31,
606		CumulusXcm: cumulus_pallet_xcm = 32,
607		MessageQueue: pallet_message_queue = 34,
608
609		// Handy utilities.
610		Utility: pallet_utility = 40,
611		Multisig: pallet_multisig = 41,
612		Proxy: pallet_proxy = 42,
613
614		// The main stage.
615		Identity: pallet_identity = 50,
616
617		// Migrations pallet
618		MultiBlockMigrations: pallet_migrations = 98,
619
620		// To migrate deposits
621		IdentityMigrator: identity_migrator = 248,
622	}
623);
624
625#[cfg(feature = "runtime-benchmarks")]
626mod benches {
627	frame_benchmarking::define_benchmarks!(
628		// Substrate
629		[frame_system, SystemBench::<Runtime>]
630		[pallet_balances, Balances]
631		[pallet_identity, Identity]
632		[pallet_message_queue, MessageQueue]
633		[pallet_multisig, Multisig]
634		[pallet_proxy, Proxy]
635		[pallet_session, SessionBench::<Runtime>]
636		[pallet_utility, Utility]
637		[pallet_timestamp, Timestamp]
638		[pallet_migrations, MultiBlockMigrations]
639		// Polkadot
640		[polkadot_runtime_common::identity_migrator, IdentityMigrator]
641		// Cumulus
642		[cumulus_pallet_parachain_system, ParachainSystem]
643		[cumulus_pallet_xcmp_queue, XcmpQueue]
644		[pallet_collator_selection, CollatorSelection]
645		// XCM
646		[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
647		[pallet_xcm_benchmarks::fungible, XcmBalances]
648		[pallet_xcm_benchmarks::generic, XcmGeneric]
649		[cumulus_pallet_weight_reclaim, WeightReclaim]
650	);
651}
652
653impl_runtime_apis! {
654	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
655		fn slot_duration() -> sp_consensus_aura::SlotDuration {
656			sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
657		}
658
659		fn authorities() -> Vec<AuraId> {
660			pallet_aura::Authorities::<Runtime>::get().into_inner()
661		}
662	}
663
664	impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
665		fn relay_parent_offset() -> u32 {
666			0
667		}
668	}
669
670	impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
671		fn can_build_upon(
672			included_hash: <Block as BlockT>::Hash,
673			slot: cumulus_primitives_aura::Slot,
674		) -> bool {
675			ConsensusHook::can_build_upon(included_hash, slot)
676		}
677	}
678
679	impl sp_api::Core<Block> for Runtime {
680		fn version() -> RuntimeVersion {
681			VERSION
682		}
683
684		fn execute_block(block: <Block as BlockT>::LazyBlock) {
685			Executive::execute_block(block)
686		}
687
688		fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
689			Executive::initialize_block(header)
690		}
691	}
692
693	impl sp_api::Metadata<Block> for Runtime {
694		fn metadata() -> OpaqueMetadata {
695			OpaqueMetadata::new(Runtime::metadata().into())
696		}
697
698		fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
699			Runtime::metadata_at_version(version)
700		}
701
702		fn metadata_versions() -> alloc::vec::Vec<u32> {
703			Runtime::metadata_versions()
704		}
705	}
706
707	impl sp_block_builder::BlockBuilder<Block> for Runtime {
708		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
709			Executive::apply_extrinsic(extrinsic)
710		}
711
712		fn finalize_block() -> <Block as BlockT>::Header {
713			Executive::finalize_block()
714		}
715
716		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
717			data.create_extrinsics()
718		}
719
720		fn check_inherents(
721			block: <Block as BlockT>::LazyBlock,
722			data: sp_inherents::InherentData,
723		) -> sp_inherents::CheckInherentsResult {
724			data.check_extrinsics(&block)
725		}
726	}
727
728	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
729		fn validate_transaction(
730			source: TransactionSource,
731			tx: <Block as BlockT>::Extrinsic,
732			block_hash: <Block as BlockT>::Hash,
733		) -> TransactionValidity {
734			Executive::validate_transaction(source, tx, block_hash)
735		}
736	}
737
738	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
739		fn offchain_worker(header: &<Block as BlockT>::Header) {
740			Executive::offchain_worker(header)
741		}
742	}
743
744	impl sp_session::SessionKeys<Block> for Runtime {
745		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
746			SessionKeys::generate(seed)
747		}
748
749		fn decode_session_keys(
750			encoded: Vec<u8>,
751		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
752			SessionKeys::decode_into_raw_public_keys(&encoded)
753		}
754	}
755
756	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
757		fn account_nonce(account: AccountId) -> Nonce {
758			System::account_nonce(account)
759		}
760	}
761
762	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
763		fn query_info(
764			uxt: <Block as BlockT>::Extrinsic,
765			len: u32,
766		) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
767			TransactionPayment::query_info(uxt, len)
768		}
769		fn query_fee_details(
770			uxt: <Block as BlockT>::Extrinsic,
771			len: u32,
772		) -> pallet_transaction_payment::FeeDetails<Balance> {
773			TransactionPayment::query_fee_details(uxt, len)
774		}
775		fn query_weight_to_fee(weight: Weight) -> Balance {
776			TransactionPayment::weight_to_fee(weight)
777		}
778		fn query_length_to_fee(length: u32) -> Balance {
779			TransactionPayment::length_to_fee(length)
780		}
781	}
782
783	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
784		for Runtime
785	{
786		fn query_call_info(
787			call: RuntimeCall,
788			len: u32,
789		) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
790			TransactionPayment::query_call_info(call, len)
791		}
792		fn query_call_fee_details(
793			call: RuntimeCall,
794			len: u32,
795		) -> pallet_transaction_payment::FeeDetails<Balance> {
796			TransactionPayment::query_call_fee_details(call, len)
797		}
798		fn query_weight_to_fee(weight: Weight) -> Balance {
799			TransactionPayment::weight_to_fee(weight)
800		}
801		fn query_length_to_fee(length: u32) -> Balance {
802			TransactionPayment::length_to_fee(length)
803		}
804	}
805
806	impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
807		fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
808			let acceptable_assets = vec![AssetId(xcm_config::RelayLocation::get())];
809			PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
810		}
811
812		fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
813			type Trader = <XcmConfig as xcm_executor::Config>::Trader;
814			PolkadotXcm::query_weight_to_asset_fee::<Trader>(weight, asset)
815		}
816
817		fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
818			PolkadotXcm::query_xcm_weight(message)
819		}
820
821		fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>, asset_id: VersionedAssetId) -> Result<VersionedAssets, XcmPaymentApiError> {
822			type AssetExchanger = <XcmConfig as xcm_executor::Config>::AssetExchanger;
823			PolkadotXcm::query_delivery_fees::<AssetExchanger>(destination, message, asset_id)
824		}
825	}
826
827	impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
828		fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
829			PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
830		}
831
832		fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
833			PolkadotXcm::dry_run_xcm::<xcm_config::XcmRouter>(origin_location, xcm)
834		}
835	}
836
837	impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
838		fn convert_location(location: VersionedLocation) -> Result<
839			AccountId,
840			xcm_runtime_apis::conversions::Error
841		> {
842			xcm_runtime_apis::conversions::LocationToAccountHelper::<
843				AccountId,
844				xcm_config::LocationToAccountId,
845			>::convert_location(location)
846		}
847	}
848
849	impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
850		fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
851			PolkadotXcm::is_trusted_reserve(asset, location)
852		}
853		fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
854			PolkadotXcm::is_trusted_teleporter(asset, location)
855		}
856	}
857
858	impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi<Block> for Runtime {
859		fn authorized_aliasers(target: VersionedLocation) -> Result<
860			Vec<xcm_runtime_apis::authorized_aliases::OriginAliaser>,
861			xcm_runtime_apis::authorized_aliases::Error
862		> {
863			PolkadotXcm::authorized_aliasers(target)
864		}
865		fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result<
866			bool,
867			xcm_runtime_apis::authorized_aliases::Error
868		> {
869			PolkadotXcm::is_authorized_alias(origin, target)
870		}
871	}
872
873	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
874		fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
875			ParachainSystem::collect_collation_info(header)
876		}
877	}
878
879	#[cfg(feature = "try-runtime")]
880	impl frame_try_runtime::TryRuntime<Block> for Runtime {
881		fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
882			let weight = Executive::try_runtime_upgrade(checks).unwrap();
883			(weight, RuntimeBlockWeights::get().max_block)
884		}
885
886		fn execute_block(
887			block: <Block as BlockT>::LazyBlock,
888			state_root_check: bool,
889			signature_check: bool,
890			select: frame_try_runtime::TryStateSelect,
891		) -> Weight {
892			// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
893			// have a backtrace here.
894			Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
895		}
896	}
897
898	#[cfg(feature = "runtime-benchmarks")]
899	impl frame_benchmarking::Benchmark<Block> for Runtime {
900		fn benchmark_metadata(extra: bool) -> (
901			Vec<frame_benchmarking::BenchmarkList>,
902			Vec<frame_support::traits::StorageInfo>,
903		) {
904			use frame_benchmarking::BenchmarkList;
905			use frame_support::traits::StorageInfoTrait;
906			use frame_system_benchmarking::Pallet as SystemBench;
907			use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
908			use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
909
910			// This is defined once again in dispatch_benchmark, because list_benchmarks!
911			// and add_benchmarks! are macros exported by define_benchmarks! macros and those types
912			// are referenced in that call.
913			type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
914			type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
915
916			let mut list = Vec::<BenchmarkList>::new();
917			list_benchmarks!(list, extra);
918
919			let storage_info = AllPalletsWithSystem::storage_info();
920			(list, storage_info)
921		}
922
923		#[allow(non_local_definitions)]
924		fn dispatch_benchmark(
925			config: frame_benchmarking::BenchmarkConfig
926		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
927			use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
928			use sp_storage::TrackedStorageKey;
929
930			use frame_system_benchmarking::Pallet as SystemBench;
931			impl frame_system_benchmarking::Config for Runtime {
932				fn setup_set_code_requirements(code: &alloc::vec::Vec<u8>) -> Result<(), BenchmarkError> {
933					ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
934					Ok(())
935				}
936
937				fn verify_set_code() {
938					System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
939				}
940			}
941
942			use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
943			impl cumulus_pallet_session_benchmarking::Config for Runtime {}
944			use xcm_config::RelayLocation;
945			use testnet_parachains_constants::westend::locations::{AssetHubParaId, AssetHubLocation};
946
947			use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
948			impl pallet_xcm::benchmarking::Config for Runtime {
949				type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
950						xcm_config::XcmConfig,
951						ExistentialDepositAsset,
952						PriceForSiblingParachainDelivery,
953						AssetHubParaId,
954						ParachainSystem,
955					>;
956
957				fn reachable_dest() -> Option<Location> {
958					Some(AssetHubLocation::get())
959				}
960
961				fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
962					// Relay/native token can be teleported between People and Relay.
963					Some((
964						Asset {
965							fun: Fungible(ExistentialDeposit::get()),
966							id: AssetId(RelayLocation::get())
967						},
968						AssetHubLocation::get(),
969					))
970				}
971
972				fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
973					None
974				}
975
976				fn set_up_complex_asset_transfer() -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
977					let native_location = Parent.into();
978					let dest = AssetHubLocation::get();
979
980					pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
981						native_location,
982						dest,
983					)
984				}
985
986				fn get_asset() -> Asset {
987					Asset {
988						id: AssetId(RelayLocation::get()),
989						fun: Fungible(ExistentialDeposit::get()),
990					}
991				}
992			}
993
994			use xcm::latest::prelude::*;
995			parameter_types! {
996				pub ExistentialDepositAsset: Option<Asset> = Some((
997					RelayLocation::get(),
998					ExistentialDeposit::get()
999				).into());
1000			}
1001
1002			impl pallet_xcm_benchmarks::Config for Runtime {
1003				type XcmConfig = XcmConfig;
1004				type AccountIdConverter = xcm_config::LocationToAccountId;
1005				type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
1006						xcm_config::XcmConfig,
1007						ExistentialDepositAsset,
1008						PriceForSiblingParachainDelivery,
1009						AssetHubParaId,
1010						ParachainSystem,
1011					>;
1012				fn valid_destination() -> Result<Location, BenchmarkError> {
1013					Ok(AssetHubLocation::get())
1014				}
1015				fn worst_case_holding(_depositable_count: u32) -> Assets {
1016					// just concrete assets according to relay chain.
1017					let assets: Vec<Asset> = vec![
1018						Asset {
1019							id: AssetId(RelayLocation::get()),
1020							fun: Fungible(1_000_000 * UNITS),
1021						}
1022					];
1023					assets.into()
1024				}
1025			}
1026
1027			parameter_types! {
1028				pub TrustedTeleporter: Option<(Location, Asset)> = Some((
1029					AssetHubLocation::get(),
1030					Asset { fun: Fungible(UNITS), id: AssetId(RelayLocation::get()) },
1031				));
1032				pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
1033				pub const TrustedReserve: Option<(Location, Asset)> = None;
1034			}
1035
1036			impl pallet_xcm_benchmarks::fungible::Config for Runtime {
1037				type TransactAsset = Balances;
1038
1039				type CheckedAccount = CheckedAccount;
1040				type TrustedTeleporter = TrustedTeleporter;
1041				type TrustedReserve = TrustedReserve;
1042
1043				fn get_asset() -> Asset {
1044					Asset {
1045						id: AssetId(RelayLocation::get()),
1046						fun: Fungible(UNITS),
1047					}
1048				}
1049			}
1050
1051			impl pallet_xcm_benchmarks::generic::Config for Runtime {
1052				type RuntimeCall = RuntimeCall;
1053				type TransactAsset = Balances;
1054
1055				fn worst_case_response() -> (u64, Response) {
1056					(0u64, Response::Version(Default::default()))
1057				}
1058
1059				fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
1060					Err(BenchmarkError::Skip)
1061				}
1062
1063				fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
1064					Err(BenchmarkError::Skip)
1065				}
1066
1067				fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
1068					Ok((AssetHubLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
1069				}
1070
1071				fn subscribe_origin() -> Result<Location, BenchmarkError> {
1072					Ok(AssetHubLocation::get())
1073				}
1074
1075				fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
1076					let origin = AssetHubLocation::get();
1077					let assets: Assets = (AssetId(RelayLocation::get()), 1_000 * UNITS).into();
1078					let ticket = Location { parents: 0, interior: Here };
1079					Ok((origin, ticket, assets))
1080				}
1081
1082				fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
1083					Ok((Asset {
1084						id: AssetId(RelayLocation::get()),
1085						fun: Fungible(1_000_000 * UNITS),
1086					}, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
1087				}
1088
1089				fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
1090					Err(BenchmarkError::Skip)
1091				}
1092
1093				fn export_message_origin_and_destination(
1094				) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
1095					Err(BenchmarkError::Skip)
1096				}
1097
1098				fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
1099					let origin = Location::new(1, [Parachain(1000)]);
1100					let target = Location::new(1, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]);
1101					Ok((origin, target))
1102				}
1103			}
1104
1105			type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
1106			type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
1107
1108			use frame_support::traits::WhitelistedStorageKeys;
1109			let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
1110
1111			let mut batches = Vec::<BenchmarkBatch>::new();
1112			let params = (&config, &whitelist);
1113			add_benchmarks!(params, batches);
1114
1115			Ok(batches)
1116		}
1117	}
1118
1119	impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1120		fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1121			build_state::<RuntimeGenesisConfig>(config)
1122		}
1123
1124		fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1125			get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
1126		}
1127
1128		fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1129			genesis_config_presets::preset_names()
1130		}
1131	}
1132
1133	impl cumulus_primitives_core::GetParachainInfo<Block> for Runtime {
1134		fn parachain_id() -> ParaId {
1135			ParachainInfo::parachain_id()
1136		}
1137	}
1138
1139	impl cumulus_primitives_core::TargetBlockRate<Block> for Runtime {
1140		fn target_block_rate() -> u32 {
1141			1
1142		}
1143	}
1144
1145	impl sp_statement_store::runtime_api::ValidateStatement<Block> for Runtime {
1146		fn validate_statement(
1147			_source: StatementSource,
1148			statement: Statement,
1149		) -> Result<ValidStatement, InvalidStatement> {
1150			let account = match statement.verify_signature() {
1151				SignatureVerificationResult::Valid(account) => account.into(),
1152				SignatureVerificationResult::Invalid => {
1153					tracing::debug!(target: "runtime", "Bad statement signature.");
1154					return Err(InvalidStatement::BadProof)
1155				},
1156				SignatureVerificationResult::NoSignature => {
1157					tracing::debug!(target: "runtime", "Missing statement signature.");
1158					return Err(InvalidStatement::NoProof)
1159				},
1160			};
1161
1162			// For now just allow validators to store some statements.
1163			// In the future we will allow people.
1164			if pallet_session::Validators::<Runtime>::get().contains(&account) {
1165				Ok(ValidStatement {
1166					max_count: 2,
1167					max_size: 1024,
1168				})
1169			} else {
1170				Ok(ValidStatement {
1171					max_count: 0,
1172					max_size: 0,
1173				})
1174			}
1175		}
1176	}
1177}
1178
1179cumulus_pallet_parachain_system::register_validate_block! {
1180	Runtime = Runtime,
1181	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
1182}