referrerpolicy=no-referrer-when-downgrade

kitchensink_runtime/
lib.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! The Substrate runtime. This can be compiled with `#[no_std]`, ready for Wasm.
19
20#![cfg_attr(not(feature = "std"), no_std)]
21// `construct_runtime!` does a lot of recursion and requires us to increase the limits.
22#![recursion_limit = "1024"]
23
24extern crate alloc;
25
26#[cfg(feature = "runtime-benchmarks")]
27use pallet_asset_rate::AssetKindFactory;
28#[cfg(feature = "runtime-benchmarks")]
29use pallet_treasury::ArgumentsFactory;
30#[cfg(feature = "runtime-benchmarks")]
31use polkadot_sdk::sp_core::crypto::FromEntropy;
32
33use polkadot_sdk::*;
34
35use alloc::{vec, vec::Vec};
36use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
37use frame_election_provider_support::{
38	bounds::{ElectionBounds, ElectionBoundsBuilder},
39	onchain, BalancingConfig, ElectionDataProvider, SequentialPhragmen, VoteWeight,
40};
41use frame_support::{
42	derive_impl,
43	dispatch::DispatchClass,
44	dynamic_params::{dynamic_pallet_params, dynamic_params},
45	genesis_builder_helper::{build_state, get_preset},
46	instances::{Instance1, Instance2},
47	ord_parameter_types,
48	pallet_prelude::Get,
49	parameter_types,
50	traits::{
51		fungible::{
52			Balanced, Credit, HoldConsideration, ItemOf, NativeFromLeft, NativeOrWithId, UnionOf,
53		},
54		tokens::{
55			imbalance::{ResolveAssetTo, ResolveTo},
56			nonfungibles_v2::Inspect,
57			pay::PayAssetFromAccount,
58			GetSalary, PayFromAccount,
59		},
60		AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32, ConstU64,
61		ConstantStoragePrice, Contains, Currency, EitherOfDiverse, EnsureOriginWithArg,
62		EqualPrivilegeOnly, Imbalance, InsideBoth, InstanceFilter, KeyOwnerProofSystem,
63		LinearStoragePrice, LockIdentifier, Nothing, OnUnbalanced, VariantCountOf, WithdrawReasons,
64	},
65	weights::{
66		constants::{
67			BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND,
68		},
69		ConstantMultiplier, IdentityFee, Weight,
70	},
71	BoundedVec, PalletId,
72};
73use frame_system::{
74	limits::{BlockLength, BlockWeights},
75	EnsureRoot, EnsureRootWithSuccess, EnsureSigned, EnsureSignedBy, EnsureWithSuccess,
76};
77pub use node_primitives::{AccountId, Signature};
78use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Moment, Nonce};
79use pallet_asset_conversion::{AccountIdConverter, Ascending, Chain, WithFirstAsset};
80use pallet_asset_conversion_tx_payment::SwapAssetAdapter;
81use pallet_assets::precompiles::{InlineIdConfig, ERC20};
82use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600};
83use pallet_election_provider_multi_phase::{GeometricDepositBase, SolutionAccuracyOf};
84use pallet_identity::legacy::IdentityInfo;
85use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
86use pallet_nfts::PalletFeatures;
87use pallet_nis::WithMaximumOf;
88use pallet_nomination_pools::PoolId;
89use pallet_revive::evm::runtime::EthExtra;
90use pallet_session::historical as pallet_session_historical;
91// Can't use `FungibleAdapter` here until Treasury pallet migrates to fungibles
92// <https://github.com/paritytech/polkadot-sdk/issues/226>
93use pallet_broker::TaskId;
94#[allow(deprecated)]
95pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment};
96use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
97use pallet_tx_pause::RuntimeCallNameOf;
98use sp_api::impl_runtime_apis;
99use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
100use sp_consensus_beefy::{
101	ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
102	mmr::MmrLeafVersion,
103};
104use sp_consensus_grandpa::AuthorityId as GrandpaId;
105use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
106use sp_inherents::{CheckInherentsResult, InherentData};
107use sp_runtime::{
108	curve::PiecewiseLinear,
109	generic, impl_opaque_keys, str_array as s,
110	traits::{
111		self, AccountIdConversion, BlakeTwo256, Block as BlockT, Bounded, ConvertInto,
112		MaybeConvert, NumberFor, OpaqueKeys, SaturatedConversion, StaticLookup,
113	},
114	transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
115	ApplyExtrinsicResult, FixedPointNumber, FixedU128, MultiSignature, MultiSigner, Perbill,
116	Percent, Permill, Perquintill, RuntimeDebug,
117};
118use sp_std::{borrow::Cow, prelude::*};
119#[cfg(any(feature = "std", test))]
120use sp_version::NativeVersion;
121use sp_version::RuntimeVersion;
122use static_assertions::const_assert;
123
124#[cfg(any(feature = "std", test))]
125pub use frame_system::Call as SystemCall;
126#[cfg(any(feature = "std", test))]
127pub use pallet_balances::Call as BalancesCall;
128#[cfg(any(feature = "std", test))]
129pub use pallet_sudo::Call as SudoCall;
130#[cfg(any(feature = "std", test))]
131pub use sp_runtime::BuildStorage;
132
133pub use pallet_staking::StakerStatus;
134
135/// Implementations of some helper traits passed into runtime modules as associated types.
136pub mod impls;
137#[cfg(not(feature = "runtime-benchmarks"))]
138use impls::AllianceIdentityVerifier;
139use impls::{AllianceProposalProvider, Author};
140
141/// Constant values used within the runtime.
142pub mod constants;
143use constants::{currency::*, time::*};
144use sp_runtime::generic::Era;
145
146/// Generated voter bag information.
147mod voter_bags;
148
149/// Runtime API definition for assets.
150pub mod assets_api;
151
152/// Genesis presets used by this runtime.
153pub mod genesis_config_presets;
154
155// Make the WASM binary available.
156#[cfg(feature = "std")]
157include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
158
159/// Max size for serialized extrinsic params for this testing runtime.
160/// This is a quite arbitrary but empirically battle tested value.
161#[cfg(test)]
162pub const CALL_PARAMS_MAX_SIZE: usize = 244;
163
164/// Wasm binary unwrapped. If built with `SKIP_WASM_BUILD`, the function panics.
165#[cfg(feature = "std")]
166pub fn wasm_binary_unwrap() -> &'static [u8] {
167	WASM_BINARY.expect(
168		"Development wasm binary is not available. This means the client is built with \
169		 `SKIP_WASM_BUILD` flag and it is only usable for production chains. Please rebuild with \
170		 the flag disabled.",
171	)
172}
173
174/// Runtime version.
175#[sp_version::runtime_version]
176pub const VERSION: RuntimeVersion = RuntimeVersion {
177	spec_name: alloc::borrow::Cow::Borrowed("node"),
178	impl_name: alloc::borrow::Cow::Borrowed("substrate-node"),
179	authoring_version: 10,
180	// Per convention: if the runtime behavior changes, increment spec_version
181	// and set impl_version to 0. If only runtime
182	// implementation changes and behavior does not, then leave spec_version as
183	// is and increment impl_version.
184	spec_version: 268,
185	impl_version: 0,
186	apis: RUNTIME_API_VERSIONS,
187	transaction_version: 2,
188	system_version: 1,
189};
190
191/// The BABE epoch configuration at genesis.
192pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
193	sp_consensus_babe::BabeEpochConfiguration {
194		c: PRIMARY_PROBABILITY,
195		allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots,
196	};
197
198/// Native version.
199#[cfg(any(feature = "std", test))]
200pub fn native_version() -> NativeVersion {
201	NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
202}
203
204type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
205
206pub struct DealWithFees;
207impl OnUnbalanced<NegativeImbalance> for DealWithFees {
208	fn on_unbalanceds(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
209		if let Some(fees) = fees_then_tips.next() {
210			// for fees, 80% to treasury, 20% to author
211			let mut split = fees.ration(80, 20);
212			if let Some(tips) = fees_then_tips.next() {
213				// for tips, if any, 80% to treasury, 20% to author (though this can be anything)
214				tips.ration_merge_into(80, 20, &mut split);
215			}
216			Treasury::on_unbalanced(split.0);
217			Author::on_unbalanced(split.1);
218		}
219	}
220}
221
222/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers.
223/// This is used to limit the maximal weight of a single extrinsic.
224const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
225/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
226/// by  Operational  extrinsics.
227const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
228/// We allow for 2 seconds of compute with a 6 second average block time, with maximum proof size.
229const MAXIMUM_BLOCK_WEIGHT: Weight =
230	Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX);
231
232parameter_types! {
233	pub const BlockHashCount: BlockNumber = 2400;
234	pub const Version: RuntimeVersion = VERSION;
235	pub RuntimeBlockLength: BlockLength =
236		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
237	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
238		.base_block(BlockExecutionWeight::get())
239		.for_class(DispatchClass::all(), |weights| {
240			weights.base_extrinsic = ExtrinsicBaseWeight::get();
241		})
242		.for_class(DispatchClass::Normal, |weights| {
243			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
244		})
245		.for_class(DispatchClass::Operational, |weights| {
246			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
247			// Operational transactions have some extra reserved space, so that they
248			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
249			weights.reserved = Some(
250				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
251			);
252		})
253		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
254		.build_or_panic();
255	pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
256}
257
258const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct());
259
260/// Calls that can bypass the safe-mode pallet.
261pub struct SafeModeWhitelistedCalls;
262impl Contains<RuntimeCall> for SafeModeWhitelistedCalls {
263	fn contains(call: &RuntimeCall) -> bool {
264		match call {
265			RuntimeCall::System(_) | RuntimeCall::SafeMode(_) | RuntimeCall::TxPause(_) => true,
266			_ => false,
267		}
268	}
269}
270
271/// Calls that cannot be paused by the tx-pause pallet.
272pub struct TxPauseWhitelistedCalls;
273/// Whitelist `Balances::transfer_keep_alive`, all others are pauseable.
274impl Contains<RuntimeCallNameOf<Runtime>> for TxPauseWhitelistedCalls {
275	fn contains(full_name: &RuntimeCallNameOf<Runtime>) -> bool {
276		match (full_name.0.as_slice(), full_name.1.as_slice()) {
277			(b"Balances", b"transfer_keep_alive") => true,
278			_ => false,
279		}
280	}
281}
282
283#[cfg(feature = "runtime-benchmarks")]
284pub struct AssetRateArguments;
285#[cfg(feature = "runtime-benchmarks")]
286impl AssetKindFactory<NativeOrWithId<u32>> for AssetRateArguments {
287	fn create_asset_kind(seed: u32) -> NativeOrWithId<u32> {
288		if seed % 2 > 0 {
289			NativeOrWithId::Native
290		} else {
291			NativeOrWithId::WithId(seed / 2)
292		}
293	}
294}
295
296#[cfg(feature = "runtime-benchmarks")]
297pub struct PalletTreasuryArguments;
298#[cfg(feature = "runtime-benchmarks")]
299impl ArgumentsFactory<NativeOrWithId<u32>, AccountId> for PalletTreasuryArguments {
300	fn create_asset_kind(seed: u32) -> NativeOrWithId<u32> {
301		if seed % 2 > 0 {
302			NativeOrWithId::Native
303		} else {
304			NativeOrWithId::WithId(seed / 2)
305		}
306	}
307
308	fn create_beneficiary(seed: [u8; 32]) -> AccountId {
309		AccountId::from_entropy(&mut seed.as_slice()).unwrap()
310	}
311}
312
313impl pallet_tx_pause::Config for Runtime {
314	type RuntimeEvent = RuntimeEvent;
315	type RuntimeCall = RuntimeCall;
316	type PauseOrigin = EnsureRoot<AccountId>;
317	type UnpauseOrigin = EnsureRoot<AccountId>;
318	type WhitelistedCalls = TxPauseWhitelistedCalls;
319	type MaxNameLen = ConstU32<256>;
320	type WeightInfo = pallet_tx_pause::weights::SubstrateWeight<Runtime>;
321}
322
323parameter_types! {
324	pub const EnterDuration: BlockNumber = 4 * HOURS;
325	pub const EnterDepositAmount: Balance = 2_000_000 * DOLLARS;
326	pub const ExtendDuration: BlockNumber = 2 * HOURS;
327	pub const ExtendDepositAmount: Balance = 1_000_000 * DOLLARS;
328	pub const ReleaseDelay: u32 = 2 * DAYS;
329}
330
331impl pallet_safe_mode::Config for Runtime {
332	type RuntimeEvent = RuntimeEvent;
333	type Currency = Balances;
334	type RuntimeHoldReason = RuntimeHoldReason;
335	type WhitelistedCalls = SafeModeWhitelistedCalls;
336	type EnterDuration = EnterDuration;
337	type EnterDepositAmount = EnterDepositAmount;
338	type ExtendDuration = ExtendDuration;
339	type ExtendDepositAmount = ExtendDepositAmount;
340	type ForceEnterOrigin = EnsureRootWithSuccess<AccountId, ConstU32<9>>;
341	type ForceExtendOrigin = EnsureRootWithSuccess<AccountId, ConstU32<11>>;
342	type ForceExitOrigin = EnsureRoot<AccountId>;
343	type ForceDepositOrigin = EnsureRoot<AccountId>;
344	type ReleaseDelay = ReleaseDelay;
345	type Notify = ();
346	type WeightInfo = pallet_safe_mode::weights::SubstrateWeight<Runtime>;
347}
348
349#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
350impl frame_system::Config for Runtime {
351	type BaseCallFilter = InsideBoth<SafeMode, TxPause>;
352	type BlockWeights = RuntimeBlockWeights;
353	type BlockLength = RuntimeBlockLength;
354	type DbWeight = RocksDbWeight;
355	type Nonce = Nonce;
356	type Hash = Hash;
357	type AccountId = AccountId;
358	type Lookup = Indices;
359	type Block = Block;
360	type BlockHashCount = BlockHashCount;
361	type Version = Version;
362	type AccountData = pallet_balances::AccountData<Balance>;
363	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Runtime>;
364	type SS58Prefix = ConstU16<42>;
365	type MaxConsumers = ConstU32<16>;
366	type MultiBlockMigrator = MultiBlockMigrations;
367	type SingleBlockMigrations = Migrations;
368}
369
370impl pallet_insecure_randomness_collective_flip::Config for Runtime {}
371
372impl pallet_example_tasks::Config for Runtime {
373	type RuntimeTask = RuntimeTask;
374	type WeightInfo = pallet_example_tasks::weights::SubstrateWeight<Runtime>;
375}
376
377impl pallet_example_mbm::Config for Runtime {}
378
379impl pallet_utility::Config for Runtime {
380	type RuntimeEvent = RuntimeEvent;
381	type RuntimeCall = RuntimeCall;
382	type PalletsOrigin = OriginCaller;
383	type WeightInfo = pallet_utility::weights::SubstrateWeight<Runtime>;
384}
385
386parameter_types! {
387	// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
388	pub const DepositBase: Balance = deposit(1, 88);
389	// Additional storage item size of 32 bytes.
390	pub const DepositFactor: Balance = deposit(0, 32);
391}
392
393impl pallet_multisig::Config for Runtime {
394	type RuntimeEvent = RuntimeEvent;
395	type RuntimeCall = RuntimeCall;
396	type Currency = Balances;
397	type DepositBase = DepositBase;
398	type DepositFactor = DepositFactor;
399	type MaxSignatories = ConstU32<100>;
400	type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
401	type BlockNumberProvider = frame_system::Pallet<Runtime>;
402}
403
404parameter_types! {
405	// One storage item; key size 32, value size 8; .
406	pub const ProxyDepositBase: Balance = deposit(1, 8);
407	// Additional storage item size of 33 bytes.
408	pub const ProxyDepositFactor: Balance = deposit(0, 33);
409	pub const AnnouncementDepositBase: Balance = deposit(1, 8);
410	pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
411}
412
413/// The type used to represent the kinds of proxying allowed.
414#[derive(
415	Copy,
416	Clone,
417	Eq,
418	PartialEq,
419	Ord,
420	PartialOrd,
421	Encode,
422	Decode,
423	DecodeWithMemTracking,
424	RuntimeDebug,
425	MaxEncodedLen,
426	scale_info::TypeInfo,
427)]
428pub enum ProxyType {
429	Any,
430	NonTransfer,
431	Governance,
432	Staking,
433}
434impl Default for ProxyType {
435	fn default() -> Self {
436		Self::Any
437	}
438}
439impl InstanceFilter<RuntimeCall> for ProxyType {
440	fn filter(&self, c: &RuntimeCall) -> bool {
441		match self {
442			ProxyType::Any => true,
443			ProxyType::NonTransfer => !matches!(
444				c,
445				RuntimeCall::Balances(..) |
446					RuntimeCall::Assets(..) |
447					RuntimeCall::Uniques(..) |
448					RuntimeCall::Nfts(..) |
449					RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) |
450					RuntimeCall::Indices(pallet_indices::Call::transfer { .. })
451			),
452			ProxyType::Governance => matches!(
453				c,
454				RuntimeCall::Democracy(..) |
455					RuntimeCall::Council(..) |
456					RuntimeCall::Society(..) |
457					RuntimeCall::TechnicalCommittee(..) |
458					RuntimeCall::Elections(..) |
459					RuntimeCall::Treasury(..)
460			),
461			ProxyType::Staking => {
462				matches!(c, RuntimeCall::Staking(..) | RuntimeCall::FastUnstake(..))
463			},
464		}
465	}
466	fn is_superset(&self, o: &Self) -> bool {
467		match (self, o) {
468			(x, y) if x == y => true,
469			(ProxyType::Any, _) => true,
470			(_, ProxyType::Any) => false,
471			(ProxyType::NonTransfer, _) => true,
472			_ => false,
473		}
474	}
475}
476
477impl pallet_proxy::Config for Runtime {
478	type RuntimeEvent = RuntimeEvent;
479	type RuntimeCall = RuntimeCall;
480	type Currency = Balances;
481	type ProxyType = ProxyType;
482	type ProxyDepositBase = ProxyDepositBase;
483	type ProxyDepositFactor = ProxyDepositFactor;
484	type MaxProxies = ConstU32<32>;
485	type WeightInfo = pallet_proxy::weights::SubstrateWeight<Runtime>;
486	type MaxPending = ConstU32<32>;
487	type CallHasher = BlakeTwo256;
488	type AnnouncementDepositBase = AnnouncementDepositBase;
489	type AnnouncementDepositFactor = AnnouncementDepositFactor;
490	type BlockNumberProvider = frame_system::Pallet<Runtime>;
491}
492
493parameter_types! {
494	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
495		RuntimeBlockWeights::get().max_block;
496}
497
498impl pallet_scheduler::Config for Runtime {
499	type RuntimeEvent = RuntimeEvent;
500	type RuntimeOrigin = RuntimeOrigin;
501	type PalletsOrigin = OriginCaller;
502	type RuntimeCall = RuntimeCall;
503	type MaximumWeight = MaximumSchedulerWeight;
504	type ScheduleOrigin = EnsureRoot<AccountId>;
505	#[cfg(feature = "runtime-benchmarks")]
506	type MaxScheduledPerBlock = ConstU32<512>;
507	#[cfg(not(feature = "runtime-benchmarks"))]
508	type MaxScheduledPerBlock = ConstU32<50>;
509	type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
510	type OriginPrivilegeCmp = EqualPrivilegeOnly;
511	type Preimages = Preimage;
512	type BlockNumberProvider = frame_system::Pallet<Runtime>;
513}
514
515impl pallet_glutton::Config for Runtime {
516	type RuntimeEvent = RuntimeEvent;
517	type AdminOrigin = EnsureRoot<AccountId>;
518	type WeightInfo = pallet_glutton::weights::SubstrateWeight<Runtime>;
519}
520
521parameter_types! {
522	pub const PreimageHoldReason: RuntimeHoldReason =
523		RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
524}
525
526impl pallet_preimage::Config for Runtime {
527	type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
528	type RuntimeEvent = RuntimeEvent;
529	type Currency = Balances;
530	type ManagerOrigin = EnsureRoot<AccountId>;
531	type Consideration = HoldConsideration<
532		AccountId,
533		Balances,
534		PreimageHoldReason,
535		LinearStoragePrice<
536			dynamic_params::storage::BaseDeposit,
537			dynamic_params::storage::ByteDeposit,
538			Balance,
539		>,
540	>;
541}
542
543parameter_types! {
544	// NOTE: Currently it is not possible to change the epoch duration after the chain has started.
545	//       Attempting to do so will brick block production.
546	pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS;
547	pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
548	pub const ReportLongevity: u64 =
549		BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get();
550}
551
552impl pallet_babe::Config for Runtime {
553	type EpochDuration = EpochDuration;
554	type ExpectedBlockTime = ExpectedBlockTime;
555	type EpochChangeTrigger = pallet_babe::ExternalTrigger;
556	type DisabledValidators = Session;
557	type WeightInfo = ();
558	type MaxAuthorities = MaxAuthorities;
559	type MaxNominators = MaxNominators;
560	type KeyOwnerProof = sp_session::MembershipProof;
561	type EquivocationReportSystem =
562		pallet_babe::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
563}
564
565parameter_types! {
566	pub const IndexDeposit: Balance = 1 * DOLLARS;
567}
568
569impl pallet_indices::Config for Runtime {
570	type AccountIndex = AccountIndex;
571	type Currency = Balances;
572	type Deposit = IndexDeposit;
573	type RuntimeEvent = RuntimeEvent;
574	type WeightInfo = pallet_indices::weights::SubstrateWeight<Runtime>;
575}
576
577parameter_types! {
578	pub const ExistentialDeposit: Balance = 1 * DOLLARS;
579	// For weight estimation, we assume that the most locks on an individual account will be 50.
580	// This number may need to be adjusted in the future if this assumption no longer holds true.
581	pub const MaxLocks: u32 = 50;
582	pub const MaxReserves: u32 = 50;
583}
584
585impl pallet_balances::Config for Runtime {
586	type RuntimeHoldReason = RuntimeHoldReason;
587	type RuntimeFreezeReason = RuntimeFreezeReason;
588	type MaxLocks = MaxLocks;
589	type MaxReserves = MaxReserves;
590	type ReserveIdentifier = [u8; 8];
591	type Balance = Balance;
592	type DustRemoval = ();
593	type RuntimeEvent = RuntimeEvent;
594	type ExistentialDeposit = ExistentialDeposit;
595	type AccountStore = frame_system::Pallet<Runtime>;
596	type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
597	type FreezeIdentifier = RuntimeFreezeReason;
598	type MaxFreezes = VariantCountOf<RuntimeFreezeReason>;
599	type DoneSlashHandler = ();
600}
601
602parameter_types! {
603	pub const TransactionByteFee: Balance = 10 * MILLICENTS;
604	pub const OperationalFeeMultiplier: u8 = 5;
605	pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
606	pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000);
607	pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128);
608	pub MaximumMultiplier: Multiplier = Bounded::max_value();
609}
610
611// Can't use `FungibleAdapter` here until Treasury pallet migrates to fungibles
612// <https://github.com/paritytech/polkadot-sdk/issues/226>
613#[allow(deprecated)]
614impl pallet_transaction_payment::Config for Runtime {
615	type RuntimeEvent = RuntimeEvent;
616	type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;
617	type OperationalFeeMultiplier = OperationalFeeMultiplier;
618	type WeightToFee = IdentityFee<Balance>;
619	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
620	type FeeMultiplierUpdate = TargetedFeeAdjustment<
621		Self,
622		TargetBlockFullness,
623		AdjustmentVariable,
624		MinimumMultiplier,
625		MaximumMultiplier,
626	>;
627	type WeightInfo = pallet_transaction_payment::weights::SubstrateWeight<Runtime>;
628}
629
630pub type AssetsFreezerInstance = pallet_assets_freezer::Instance1;
631impl pallet_assets_freezer::Config<AssetsFreezerInstance> for Runtime {
632	type RuntimeFreezeReason = RuntimeFreezeReason;
633	type RuntimeEvent = RuntimeEvent;
634}
635
636impl pallet_asset_conversion_tx_payment::Config for Runtime {
637	type RuntimeEvent = RuntimeEvent;
638	type AssetId = NativeOrWithId<u32>;
639	type OnChargeAssetTransaction = SwapAssetAdapter<
640		Native,
641		NativeAndAssets,
642		AssetConversion,
643		ResolveAssetTo<TreasuryAccount, NativeAndAssets>,
644	>;
645	type WeightInfo = pallet_asset_conversion_tx_payment::weights::SubstrateWeight<Runtime>;
646	#[cfg(feature = "runtime-benchmarks")]
647	type BenchmarkHelper = AssetConversionTxHelper;
648}
649
650impl pallet_skip_feeless_payment::Config for Runtime {
651	type RuntimeEvent = RuntimeEvent;
652}
653
654parameter_types! {
655	pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
656}
657
658impl pallet_timestamp::Config for Runtime {
659	type Moment = Moment;
660	type OnTimestampSet = Babe;
661	type MinimumPeriod = MinimumPeriod;
662	type WeightInfo = pallet_timestamp::weights::SubstrateWeight<Runtime>;
663}
664
665impl pallet_authorship::Config for Runtime {
666	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
667	type EventHandler = (Staking, ImOnline);
668}
669
670impl_opaque_keys! {
671	pub struct SessionKeys {
672		pub grandpa: Grandpa,
673		pub babe: Babe,
674		pub im_online: ImOnline,
675		pub authority_discovery: AuthorityDiscovery,
676		pub mixnet: Mixnet,
677		pub beefy: Beefy,
678	}
679}
680
681impl pallet_session::Config for Runtime {
682	type RuntimeEvent = RuntimeEvent;
683	type ValidatorId = <Self as frame_system::Config>::AccountId;
684	type ValidatorIdOf = sp_runtime::traits::ConvertInto;
685	type ShouldEndSession = Babe;
686	type NextSessionRotation = Babe;
687	type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
688	type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
689	type Keys = SessionKeys;
690	type DisablingStrategy = pallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy;
691	type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
692	type Currency = Balances;
693	type KeyDeposit = ();
694}
695
696impl pallet_session::historical::Config for Runtime {
697	type RuntimeEvent = RuntimeEvent;
698	type FullIdentification = ();
699	type FullIdentificationOf = pallet_staking::UnitIdentificationOf<Self>;
700}
701
702pallet_staking_reward_curve::build! {
703	const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
704		min_inflation: 0_025_000,
705		max_inflation: 0_100_000,
706		ideal_stake: 0_500_000,
707		falloff: 0_050_000,
708		max_piece_count: 40,
709		test_precision: 0_005_000,
710	);
711}
712
713parameter_types! {
714	pub const SessionsPerEra: sp_staking::SessionIndex = 6;
715	pub const BondingDuration: sp_staking::EraIndex = 24 * 28;
716	pub const SlashDeferDuration: sp_staking::EraIndex = 24 * 7; // 1/4 the bonding duration.
717	pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
718	pub const MaxNominators: u32 = 64;
719	pub const MaxControllersInDeprecationBatch: u32 = 5900;
720	pub OffchainRepeat: BlockNumber = 5;
721	pub HistoryDepth: u32 = 84;
722}
723
724/// Upper limit on the number of NPOS nominations.
725const MAX_QUOTA_NOMINATIONS: u32 = 16;
726
727pub struct StakingBenchmarkingConfig;
728impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
729	type MaxNominators = ConstU32<5000>;
730	type MaxValidators = ConstU32<1000>;
731}
732
733impl pallet_staking::Config for Runtime {
734	type OldCurrency = Balances;
735	type Currency = Balances;
736	type CurrencyBalance = Balance;
737	type UnixTime = Timestamp;
738	type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
739	type RewardRemainder = ResolveTo<TreasuryAccount, Balances>;
740	type RuntimeEvent = RuntimeEvent;
741	type RuntimeHoldReason = RuntimeHoldReason;
742	type Slash = ResolveTo<TreasuryAccount, Balances>; // send the slashed funds to the treasury.
743	type Reward = (); // rewards are minted from the void
744	type SessionsPerEra = SessionsPerEra;
745	type BondingDuration = BondingDuration;
746	type SlashDeferDuration = SlashDeferDuration;
747	/// A super-majority of the council can cancel the slash.
748	type AdminOrigin = EitherOfDiverse<
749		EnsureRoot<AccountId>,
750		pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>,
751	>;
752	type SessionInterface = Self;
753	type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
754	type NextNewSession = Session;
755	type MaxExposurePageSize = ConstU32<256>;
756	type ElectionProvider = ElectionProviderMultiPhase;
757	type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
758	type VoterList = VoterList;
759	type NominationsQuota = pallet_staking::FixedNominationsQuota<MAX_QUOTA_NOMINATIONS>;
760	// This a placeholder, to be introduced in the next PR as an instance of bags-list
761	type TargetList = pallet_staking::UseValidatorsMap<Self>;
762	type MaxUnlockingChunks = ConstU32<32>;
763	type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
764	type HistoryDepth = HistoryDepth;
765	type EventListeners = (NominationPools, DelegatedStaking);
766	type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
767	type BenchmarkingConfig = StakingBenchmarkingConfig;
768	type Filter = Nothing;
769	type MaxValidatorSet = ConstU32<1000>;
770}
771
772impl pallet_fast_unstake::Config for Runtime {
773	type RuntimeEvent = RuntimeEvent;
774	type ControlOrigin = frame_system::EnsureRoot<AccountId>;
775	type BatchSize = ConstU32<64>;
776	type Deposit = ConstU128<{ DOLLARS }>;
777	type Currency = Balances;
778	type Staking = Staking;
779	type MaxErasToCheckPerBlock = ConstU32<1>;
780	type WeightInfo = ();
781}
782parameter_types! {
783	// phase durations. 1/4 of the last session for each.
784	pub const SignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;
785	pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;
786
787	// signed config
788	pub const SignedRewardBase: Balance = 1 * DOLLARS;
789	pub const SignedFixedDeposit: Balance = 1 * DOLLARS;
790	pub const SignedDepositIncreaseFactor: Percent = Percent::from_percent(10);
791	pub const SignedDepositByte: Balance = 1 * CENTS;
792
793	// miner configs
794	pub const MultiPhaseUnsignedPriority: TransactionPriority = StakingUnsignedPriority::get() - 1u64;
795	pub MinerMaxWeight: Weight = RuntimeBlockWeights::get()
796		.get(DispatchClass::Normal)
797		.max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed")
798		.saturating_sub(BlockExecutionWeight::get());
799	// Solution can occupy 90% of normal block size
800	pub MinerMaxLength: u32 = Perbill::from_rational(9u32, 10) *
801		*RuntimeBlockLength::get()
802		.max
803		.get(DispatchClass::Normal);
804}
805
806frame_election_provider_support::generate_solution_type!(
807	#[compact]
808	pub struct NposSolution16::<
809		VoterIndex = u32,
810		TargetIndex = u16,
811		Accuracy = sp_runtime::PerU16,
812		MaxVoters = MaxElectingVotersSolution,
813	>(16)
814);
815
816parameter_types! {
817	// Note: the EPM in this runtime runs the election on-chain. The election bounds must be
818	// carefully set so that an election round fits in one block.
819	pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::default()
820		.voters_count(10_000.into()).targets_count(1_500.into()).build();
821	pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default()
822		.voters_count(5_000.into()).targets_count(1_250.into()).build();
823
824	pub MaxNominations: u32 = <NposSolution16 as frame_election_provider_support::NposSolution>::LIMIT as u32;
825	pub MaxElectingVotersSolution: u32 = 40_000;
826	// The maximum winners that can be elected by the Election pallet which is equivalent to the
827	// maximum active validators the staking pallet can have.
828	pub MaxActiveValidators: u32 = 1000;
829}
830
831/// The numbers configured here could always be more than the the maximum limits of staking pallet
832/// to ensure election snapshot will not run out of memory. For now, we set them to smaller values
833/// since the staking is bounded and the weight pipeline takes hours for this single pallet.
834pub struct ElectionProviderBenchmarkConfig;
835impl pallet_election_provider_multi_phase::BenchmarkingConfig for ElectionProviderBenchmarkConfig {
836	const VOTERS: [u32; 2] = [1000, 2000];
837	const TARGETS: [u32; 2] = [500, 1000];
838	const ACTIVE_VOTERS: [u32; 2] = [500, 800];
839	const DESIRED_TARGETS: [u32; 2] = [200, 400];
840	const SNAPSHOT_MAXIMUM_VOTERS: u32 = 1000;
841	const MINER_MAXIMUM_VOTERS: u32 = 1000;
842	const MAXIMUM_TARGETS: u32 = 300;
843}
844
845/// Maximum number of iterations for balancing that will be executed in the embedded OCW
846/// miner of election provider multi phase.
847pub const MINER_MAX_ITERATIONS: u32 = 10;
848
849/// A source of random balance for NposSolver, which is meant to be run by the OCW election miner.
850pub struct OffchainRandomBalancing;
851impl Get<Option<BalancingConfig>> for OffchainRandomBalancing {
852	fn get() -> Option<BalancingConfig> {
853		use sp_runtime::traits::TrailingZeroInput;
854		let iterations = match MINER_MAX_ITERATIONS {
855			0 => 0,
856			max => {
857				let seed = sp_io::offchain::random_seed();
858				let random = <u32>::decode(&mut TrailingZeroInput::new(&seed))
859					.expect("input is padded with zeroes; qed") %
860					max.saturating_add(1);
861				random as usize
862			},
863		};
864
865		let config = BalancingConfig { iterations, tolerance: 0 };
866		Some(config)
867	}
868}
869
870pub struct OnChainSeqPhragmen;
871impl onchain::Config for OnChainSeqPhragmen {
872	type Sort = ConstBool<true>;
873	type System = Runtime;
874	type Solver = SequentialPhragmen<AccountId, SolutionAccuracyOf<Runtime>>;
875	type DataProvider = Staking;
876	type WeightInfo = frame_election_provider_support::weights::SubstrateWeight<Runtime>;
877	type Bounds = ElectionBoundsOnChain;
878	type MaxBackersPerWinner = MaxElectingVotersSolution;
879	type MaxWinnersPerPage = MaxActiveValidators;
880}
881
882impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
883	type AccountId = AccountId;
884	type MaxLength = MinerMaxLength;
885	type MaxWeight = MinerMaxWeight;
886	type Solution = NposSolution16;
887	type MaxVotesPerVoter =
888	<<Self as pallet_election_provider_multi_phase::Config>::DataProvider as ElectionDataProvider>::MaxVotesPerVoter;
889	type MaxWinners = MaxActiveValidators;
890	type MaxBackersPerWinner = MaxElectingVotersSolution;
891
892	// The unsigned submissions have to respect the weight of the submit_unsigned call, thus their
893	// weight estimate function is wired to this call's weight.
894	fn solution_weight(v: u32, t: u32, a: u32, d: u32) -> Weight {
895		<
896			<Self as pallet_election_provider_multi_phase::Config>::WeightInfo
897			as
898			pallet_election_provider_multi_phase::WeightInfo
899		>::submit_unsigned(v, t, a, d)
900	}
901}
902
903impl pallet_election_provider_multi_phase::Config for Runtime {
904	type RuntimeEvent = RuntimeEvent;
905	type Currency = Balances;
906	type EstimateCallFee = TransactionPayment;
907	type SignedPhase = SignedPhase;
908	type UnsignedPhase = UnsignedPhase;
909	type BetterSignedThreshold = ();
910	type OffchainRepeat = OffchainRepeat;
911	type MinerTxPriority = MultiPhaseUnsignedPriority;
912	type MinerConfig = Self;
913	type SignedMaxSubmissions = ConstU32<10>;
914	type SignedRewardBase = SignedRewardBase;
915	type SignedDepositBase =
916		GeometricDepositBase<Balance, SignedFixedDeposit, SignedDepositIncreaseFactor>;
917	type SignedDepositByte = SignedDepositByte;
918	type SignedMaxRefunds = ConstU32<3>;
919	type SignedDepositWeight = ();
920	type SignedMaxWeight = MinerMaxWeight;
921	type SlashHandler = (); // burn slashes
922	type RewardHandler = (); // rewards are minted from the void
923	type DataProvider = Staking;
924	type Fallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
925	type GovernanceFallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
926	type Solver = SequentialPhragmen<AccountId, SolutionAccuracyOf<Self>, OffchainRandomBalancing>;
927	type ForceOrigin = EnsureRootOrHalfCouncil;
928	type MaxWinners = MaxActiveValidators;
929	type ElectionBounds = ElectionBoundsMultiPhase;
930	type BenchmarkingConfig = ElectionProviderBenchmarkConfig;
931	type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
932	type MaxBackersPerWinner = MaxElectingVotersSolution;
933}
934
935parameter_types! {
936	pub const BagThresholds: &'static [u64] = &voter_bags::THRESHOLDS;
937	pub const AutoRebagNumber: u32 = 10;
938}
939
940type VoterBagsListInstance = pallet_bags_list::Instance1;
941impl pallet_bags_list::Config<VoterBagsListInstance> for Runtime {
942	type RuntimeEvent = RuntimeEvent;
943	type WeightInfo = pallet_bags_list::weights::SubstrateWeight<Runtime>;
944	/// The voter bags-list is loosely kept up to date, and the real source of truth for the score
945	/// of each node is the staking pallet.
946	type ScoreProvider = Staking;
947	type BagThresholds = BagThresholds;
948	type MaxAutoRebagPerBlock = AutoRebagNumber;
949	type Score = VoteWeight;
950}
951
952parameter_types! {
953	pub const DelegatedStakingPalletId: PalletId = PalletId(*b"py/dlstk");
954	pub const SlashRewardFraction: Perbill = Perbill::from_percent(1);
955}
956
957impl pallet_delegated_staking::Config for Runtime {
958	type RuntimeEvent = RuntimeEvent;
959	type PalletId = DelegatedStakingPalletId;
960	type Currency = Balances;
961	type OnSlash = ();
962	type SlashRewardFraction = SlashRewardFraction;
963	type RuntimeHoldReason = RuntimeHoldReason;
964	type CoreStaking = Staking;
965}
966
967parameter_types! {
968	pub const PostUnbondPoolsWindow: u32 = 4;
969	pub const NominationPoolsPalletId: PalletId = PalletId(*b"py/nopls");
970	pub const MaxPointsToBalance: u8 = 10;
971}
972
973use sp_runtime::traits::{Convert, Keccak256};
974pub struct BalanceToU256;
975impl Convert<Balance, sp_core::U256> for BalanceToU256 {
976	fn convert(balance: Balance) -> sp_core::U256 {
977		sp_core::U256::from(balance)
978	}
979}
980pub struct U256ToBalance;
981impl Convert<sp_core::U256, Balance> for U256ToBalance {
982	fn convert(n: sp_core::U256) -> Balance {
983		n.try_into().unwrap_or(Balance::max_value())
984	}
985}
986
987impl pallet_nomination_pools::Config for Runtime {
988	type WeightInfo = ();
989	type RuntimeEvent = RuntimeEvent;
990	type Currency = Balances;
991	type RuntimeFreezeReason = RuntimeFreezeReason;
992	type RewardCounter = FixedU128;
993	type BalanceToU256 = BalanceToU256;
994	type U256ToBalance = U256ToBalance;
995	type StakeAdapter =
996		pallet_nomination_pools::adapter::DelegateStake<Self, Staking, DelegatedStaking>;
997	type PostUnbondingPoolsWindow = PostUnbondPoolsWindow;
998	type MaxMetadataLen = ConstU32<256>;
999	type MaxUnbonding = ConstU32<8>;
1000	type PalletId = NominationPoolsPalletId;
1001	type MaxPointsToBalance = MaxPointsToBalance;
1002	type AdminOrigin = EitherOfDiverse<
1003		EnsureRoot<AccountId>,
1004		pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>,
1005	>;
1006	type BlockNumberProvider = System;
1007	type Filter = Nothing;
1008}
1009
1010parameter_types! {
1011	pub const VoteLockingPeriod: BlockNumber = 30 * DAYS;
1012}
1013
1014impl pallet_conviction_voting::Config for Runtime {
1015	type WeightInfo = pallet_conviction_voting::weights::SubstrateWeight<Self>;
1016	type RuntimeEvent = RuntimeEvent;
1017	type Currency = Balances;
1018	type VoteLockingPeriod = VoteLockingPeriod;
1019	type MaxVotes = ConstU32<512>;
1020	type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>;
1021	type Polls = Referenda;
1022	type BlockNumberProvider = System;
1023	type VotingHooks = ();
1024}
1025
1026parameter_types! {
1027	pub const AlarmInterval: BlockNumber = 1;
1028	pub const SubmissionDeposit: Balance = 100 * DOLLARS;
1029	pub const UndecidingTimeout: BlockNumber = 28 * DAYS;
1030}
1031
1032pub struct TracksInfo;
1033impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
1034	type Id = u16;
1035	type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;
1036
1037	fn tracks(
1038	) -> impl Iterator<Item = Cow<'static, pallet_referenda::Track<Self::Id, Balance, BlockNumber>>>
1039	{
1040		dynamic_params::referenda::Tracks::get().into_iter().map(Cow::Owned)
1041	}
1042	fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> {
1043		dynamic_params::referenda::Origins::get()
1044			.iter()
1045			.find(|(o, _)| id == o)
1046			.map(|(_, track_id)| *track_id)
1047			.ok_or(())
1048	}
1049}
1050
1051impl pallet_referenda::Config for Runtime {
1052	type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
1053	type RuntimeCall = RuntimeCall;
1054	type RuntimeEvent = RuntimeEvent;
1055	type Scheduler = Scheduler;
1056	type Currency = pallet_balances::Pallet<Self>;
1057	type SubmitOrigin = EnsureSigned<AccountId>;
1058	type CancelOrigin = EnsureRoot<AccountId>;
1059	type KillOrigin = EnsureRoot<AccountId>;
1060	type Slash = ();
1061	type Votes = pallet_conviction_voting::VotesOf<Runtime>;
1062	type Tally = pallet_conviction_voting::TallyOf<Runtime>;
1063	type SubmissionDeposit = SubmissionDeposit;
1064	type MaxQueued = ConstU32<100>;
1065	type UndecidingTimeout = UndecidingTimeout;
1066	type AlarmInterval = AlarmInterval;
1067	type Tracks = TracksInfo;
1068	type Preimages = Preimage;
1069	type BlockNumberProvider = System;
1070}
1071
1072impl pallet_referenda::Config<pallet_referenda::Instance2> for Runtime {
1073	type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
1074	type RuntimeCall = RuntimeCall;
1075	type RuntimeEvent = RuntimeEvent;
1076	type Scheduler = Scheduler;
1077	type Currency = pallet_balances::Pallet<Self>;
1078	type SubmitOrigin = EnsureSigned<AccountId>;
1079	type CancelOrigin = EnsureRoot<AccountId>;
1080	type KillOrigin = EnsureRoot<AccountId>;
1081	type Slash = ();
1082	type Votes = pallet_ranked_collective::Votes;
1083	type Tally = pallet_ranked_collective::TallyOf<Runtime>;
1084	type SubmissionDeposit = SubmissionDeposit;
1085	type MaxQueued = ConstU32<100>;
1086	type UndecidingTimeout = UndecidingTimeout;
1087	type AlarmInterval = AlarmInterval;
1088	type Tracks = TracksInfo;
1089	type Preimages = Preimage;
1090	type BlockNumberProvider = System;
1091}
1092
1093impl pallet_ranked_collective::Config for Runtime {
1094	type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight<Self>;
1095	type RuntimeEvent = RuntimeEvent;
1096	type AddOrigin = EnsureRoot<AccountId>;
1097	type RemoveOrigin = Self::DemoteOrigin;
1098	type PromoteOrigin = EnsureRootWithSuccess<AccountId, ConstU16<65535>>;
1099	type DemoteOrigin = EnsureRootWithSuccess<AccountId, ConstU16<65535>>;
1100	type ExchangeOrigin = EnsureRootWithSuccess<AccountId, ConstU16<65535>>;
1101	type Polls = RankedPolls;
1102	type MinRankOfClass = traits::Identity;
1103	type VoteWeight = pallet_ranked_collective::Geometric;
1104	type MemberSwappedHandler = (CoreFellowship, Salary);
1105	type MaxMemberCount = ();
1106	#[cfg(feature = "runtime-benchmarks")]
1107	type BenchmarkSetup = (CoreFellowship, Salary);
1108}
1109
1110impl pallet_remark::Config for Runtime {
1111	type WeightInfo = pallet_remark::weights::SubstrateWeight<Self>;
1112	type RuntimeEvent = RuntimeEvent;
1113}
1114
1115impl pallet_root_testing::Config for Runtime {
1116	type RuntimeEvent = RuntimeEvent;
1117}
1118
1119parameter_types! {
1120	pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
1121	pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
1122	pub const FastTrackVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES;
1123	pub const MinimumDeposit: Balance = 100 * DOLLARS;
1124	pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
1125	pub const CooloffPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
1126	pub const MaxProposals: u32 = 100;
1127}
1128
1129impl pallet_democracy::Config for Runtime {
1130	type RuntimeEvent = RuntimeEvent;
1131	type Currency = Balances;
1132	type EnactmentPeriod = EnactmentPeriod;
1133	type LaunchPeriod = LaunchPeriod;
1134	type VotingPeriod = VotingPeriod;
1135	type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod
1136	type MinimumDeposit = MinimumDeposit;
1137	/// A straight majority of the council can decide what their next motion is.
1138	type ExternalOrigin =
1139		pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;
1140	/// A super-majority can have the next scheduled referendum be a straight majority-carries vote.
1141	type ExternalMajorityOrigin =
1142		pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>;
1143	/// A unanimous council can have the next scheduled referendum be a straight default-carries
1144	/// (NTB) vote.
1145	type ExternalDefaultOrigin =
1146		pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;
1147	type SubmitOrigin = EnsureSigned<AccountId>;
1148	/// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote
1149	/// be tabled immediately and with a shorter voting/enactment period.
1150	type FastTrackOrigin =
1151		pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 2, 3>;
1152	type InstantOrigin =
1153		pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>;
1154	type InstantAllowed = ConstBool<true>;
1155	type FastTrackVotingPeriod = FastTrackVotingPeriod;
1156	// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
1157	type CancellationOrigin =
1158		pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>;
1159	// To cancel a proposal before it has been passed, the technical committee must be unanimous or
1160	// Root must agree.
1161	type CancelProposalOrigin = EitherOfDiverse<
1162		EnsureRoot<AccountId>,
1163		pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>,
1164	>;
1165	type BlacklistOrigin = EnsureRoot<AccountId>;
1166	// Any single technical committee member may veto a coming council proposal, however they can
1167	// only do it once and it lasts only for the cool-off period.
1168	type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
1169	type CooloffPeriod = CooloffPeriod;
1170	type Slash = Treasury;
1171	type Scheduler = Scheduler;
1172	type PalletsOrigin = OriginCaller;
1173	type MaxVotes = ConstU32<100>;
1174	type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
1175	type MaxProposals = MaxProposals;
1176	type Preimages = Preimage;
1177	type MaxDeposits = ConstU32<100>;
1178	type MaxBlacklisted = ConstU32<100>;
1179}
1180
1181parameter_types! {
1182	pub const CouncilMotionDuration: BlockNumber = 5 * DAYS;
1183	pub const CouncilMaxProposals: u32 = 100;
1184	pub const CouncilMaxMembers: u32 = 100;
1185	pub const ProposalDepositOffset: Balance = ExistentialDeposit::get() + ExistentialDeposit::get();
1186	pub const ProposalHoldReason: RuntimeHoldReason =
1187		RuntimeHoldReason::Council(pallet_collective::HoldReason::ProposalSubmission);
1188}
1189
1190type CouncilCollective = pallet_collective::Instance1;
1191impl pallet_collective::Config<CouncilCollective> for Runtime {
1192	type RuntimeOrigin = RuntimeOrigin;
1193	type Proposal = RuntimeCall;
1194	type RuntimeEvent = RuntimeEvent;
1195	type MotionDuration = CouncilMotionDuration;
1196	type MaxProposals = CouncilMaxProposals;
1197	type MaxMembers = CouncilMaxMembers;
1198	type DefaultVote = pallet_collective::PrimeDefaultVote;
1199	type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
1200	type SetMembersOrigin = EnsureRoot<Self::AccountId>;
1201	type MaxProposalWeight = MaxCollectivesProposalWeight;
1202	type DisapproveOrigin = EnsureRoot<Self::AccountId>;
1203	type KillOrigin = EnsureRoot<Self::AccountId>;
1204	type Consideration = HoldConsideration<
1205		AccountId,
1206		Balances,
1207		ProposalHoldReason,
1208		pallet_collective::deposit::Delayed<
1209			ConstU32<2>,
1210			pallet_collective::deposit::Linear<ConstU32<2>, ProposalDepositOffset>,
1211		>,
1212		u32,
1213	>;
1214}
1215
1216parameter_types! {
1217	pub const CandidacyBond: Balance = 10 * DOLLARS;
1218	// 1 storage item created, key size is 32 bytes, value size is 16+16.
1219	pub const VotingBondBase: Balance = deposit(1, 64);
1220	// additional data per vote is 32 bytes (account id).
1221	pub const VotingBondFactor: Balance = deposit(0, 32);
1222	pub const TermDuration: BlockNumber = 7 * DAYS;
1223	pub const DesiredMembers: u32 = 13;
1224	pub const DesiredRunnersUp: u32 = 7;
1225	pub const MaxVotesPerVoter: u32 = 16;
1226	pub const MaxVoters: u32 = 256;
1227	pub const MaxCandidates: u32 = 128;
1228	pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
1229}
1230
1231// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen.
1232const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());
1233
1234impl pallet_elections_phragmen::Config for Runtime {
1235	type RuntimeEvent = RuntimeEvent;
1236	type PalletId = ElectionsPhragmenPalletId;
1237	type Currency = Balances;
1238	type ChangeMembers = Council;
1239	// NOTE: this implies that council's genesis members cannot be set directly and must come from
1240	// this module.
1241	type InitializeMembers = Council;
1242	type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
1243	type CandidacyBond = CandidacyBond;
1244	type VotingBondBase = VotingBondBase;
1245	type VotingBondFactor = VotingBondFactor;
1246	type LoserCandidate = ();
1247	type KickedMember = ();
1248	type DesiredMembers = DesiredMembers;
1249	type DesiredRunnersUp = DesiredRunnersUp;
1250	type TermDuration = TermDuration;
1251	type MaxVoters = MaxVoters;
1252	type MaxVotesPerVoter = MaxVotesPerVoter;
1253	type MaxCandidates = MaxCandidates;
1254	type WeightInfo = pallet_elections_phragmen::weights::SubstrateWeight<Runtime>;
1255}
1256
1257parameter_types! {
1258	pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS;
1259	pub const TechnicalMaxProposals: u32 = 100;
1260	pub const TechnicalMaxMembers: u32 = 100;
1261}
1262
1263type TechnicalCollective = pallet_collective::Instance2;
1264impl pallet_collective::Config<TechnicalCollective> for Runtime {
1265	type RuntimeOrigin = RuntimeOrigin;
1266	type Proposal = RuntimeCall;
1267	type RuntimeEvent = RuntimeEvent;
1268	type MotionDuration = TechnicalMotionDuration;
1269	type MaxProposals = TechnicalMaxProposals;
1270	type MaxMembers = TechnicalMaxMembers;
1271	type DefaultVote = pallet_collective::PrimeDefaultVote;
1272	type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
1273	type SetMembersOrigin = EnsureRoot<Self::AccountId>;
1274	type MaxProposalWeight = MaxCollectivesProposalWeight;
1275	type DisapproveOrigin = EnsureRoot<Self::AccountId>;
1276	type KillOrigin = EnsureRoot<Self::AccountId>;
1277	type Consideration = ();
1278}
1279
1280type EnsureRootOrHalfCouncil = EitherOfDiverse<
1281	EnsureRoot<AccountId>,
1282	pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
1283>;
1284impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
1285	type RuntimeEvent = RuntimeEvent;
1286	type AddOrigin = EnsureRootOrHalfCouncil;
1287	type RemoveOrigin = EnsureRootOrHalfCouncil;
1288	type SwapOrigin = EnsureRootOrHalfCouncil;
1289	type ResetOrigin = EnsureRootOrHalfCouncil;
1290	type PrimeOrigin = EnsureRootOrHalfCouncil;
1291	type MembershipInitialized = TechnicalCommittee;
1292	type MembershipChanged = TechnicalCommittee;
1293	type MaxMembers = TechnicalMaxMembers;
1294	type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;
1295}
1296
1297parameter_types! {
1298	pub const SpendPeriod: BlockNumber = 1 * DAYS;
1299	pub const Burn: Permill = Permill::from_percent(50);
1300	pub const TipCountdown: BlockNumber = 1 * DAYS;
1301	pub const TipFindersFee: Percent = Percent::from_percent(20);
1302	pub const TipReportDepositBase: Balance = 1 * DOLLARS;
1303	pub const DataDepositPerByte: Balance = 1 * CENTS;
1304	pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
1305	pub const MaximumReasonLength: u32 = 300;
1306	pub const MaxApprovals: u32 = 100;
1307	pub const MaxBalance: Balance = Balance::max_value();
1308	pub const SpendPayoutPeriod: BlockNumber = 30 * DAYS;
1309}
1310
1311impl pallet_treasury::Config for Runtime {
1312	type PalletId = TreasuryPalletId;
1313	type Currency = Balances;
1314	type RejectOrigin = EitherOfDiverse<
1315		EnsureRoot<AccountId>,
1316		pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
1317	>;
1318	type RuntimeEvent = RuntimeEvent;
1319	type SpendPeriod = SpendPeriod;
1320	type Burn = Burn;
1321	type BurnDestination = ();
1322	type SpendFunds = Bounties;
1323	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
1324	type MaxApprovals = MaxApprovals;
1325	type SpendOrigin = EnsureWithSuccess<EnsureRoot<AccountId>, AccountId, MaxBalance>;
1326	type AssetKind = NativeOrWithId<u32>;
1327	type Beneficiary = AccountId;
1328	type BeneficiaryLookup = Indices;
1329	type Paymaster = PayAssetFromAccount<NativeAndAssets, TreasuryAccount>;
1330	type BalanceConverter = AssetRate;
1331	type PayoutPeriod = SpendPayoutPeriod;
1332	type BlockNumberProvider = System;
1333	#[cfg(feature = "runtime-benchmarks")]
1334	type BenchmarkHelper = PalletTreasuryArguments;
1335}
1336
1337impl pallet_asset_rate::Config for Runtime {
1338	type CreateOrigin = EnsureRoot<AccountId>;
1339	type RemoveOrigin = EnsureRoot<AccountId>;
1340	type UpdateOrigin = EnsureRoot<AccountId>;
1341	type Currency = Balances;
1342	type AssetKind = NativeOrWithId<u32>;
1343	type RuntimeEvent = RuntimeEvent;
1344	type WeightInfo = pallet_asset_rate::weights::SubstrateWeight<Runtime>;
1345	#[cfg(feature = "runtime-benchmarks")]
1346	type BenchmarkHelper = AssetRateArguments;
1347}
1348
1349parameter_types! {
1350	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
1351	pub const BountyValueMinimum: Balance = 5 * DOLLARS;
1352	pub const BountyDepositBase: Balance = 1 * DOLLARS;
1353	pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50);
1354	pub const CuratorDepositMin: Balance = 1 * DOLLARS;
1355	pub const CuratorDepositMax: Balance = 100 * DOLLARS;
1356	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
1357	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
1358}
1359
1360impl pallet_bounties::Config for Runtime {
1361	type RuntimeEvent = RuntimeEvent;
1362	type BountyDepositBase = BountyDepositBase;
1363	type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
1364	type BountyUpdatePeriod = BountyUpdatePeriod;
1365	type CuratorDepositMultiplier = CuratorDepositMultiplier;
1366	type CuratorDepositMin = CuratorDepositMin;
1367	type CuratorDepositMax = CuratorDepositMax;
1368	type BountyValueMinimum = BountyValueMinimum;
1369	type DataDepositPerByte = DataDepositPerByte;
1370	type MaximumReasonLength = MaximumReasonLength;
1371	type WeightInfo = pallet_bounties::weights::SubstrateWeight<Runtime>;
1372	type ChildBountyManager = ChildBounties;
1373	type OnSlash = Treasury;
1374}
1375
1376parameter_types! {
1377	/// Allocate at most 20% of each block for message processing.
1378	///
1379	/// Is set to 20% since the scheduler can already consume a maximum of 80%.
1380	pub MessageQueueServiceWeight: Option<Weight> = Some(Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block);
1381}
1382
1383impl pallet_message_queue::Config for Runtime {
1384	type RuntimeEvent = RuntimeEvent;
1385	type WeightInfo = ();
1386	/// NOTE: Always set this to `NoopMessageProcessor` for benchmarking.
1387	type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<u32>;
1388	type Size = u32;
1389	type QueueChangeHandler = ();
1390	type QueuePausedQuery = ();
1391	type HeapSize = ConstU32<{ 64 * 1024 }>;
1392	type MaxStale = ConstU32<128>;
1393	type ServiceWeight = MessageQueueServiceWeight;
1394	type IdleMaxServiceWeight = ();
1395}
1396
1397parameter_types! {
1398	pub const ChildBountyValueMinimum: Balance = 1 * DOLLARS;
1399}
1400
1401impl pallet_child_bounties::Config for Runtime {
1402	type RuntimeEvent = RuntimeEvent;
1403	type MaxActiveChildBountyCount = ConstU32<5>;
1404	type ChildBountyValueMinimum = ChildBountyValueMinimum;
1405	type WeightInfo = pallet_child_bounties::weights::SubstrateWeight<Runtime>;
1406}
1407
1408impl pallet_tips::Config for Runtime {
1409	type RuntimeEvent = RuntimeEvent;
1410	type DataDepositPerByte = DataDepositPerByte;
1411	type MaximumReasonLength = MaximumReasonLength;
1412	type Tippers = Elections;
1413	type TipCountdown = TipCountdown;
1414	type TipFindersFee = TipFindersFee;
1415	type TipReportDepositBase = TipReportDepositBase;
1416	type MaxTipAmount = ConstU128<{ 500 * DOLLARS }>;
1417	type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
1418	type OnSlash = Treasury;
1419}
1420
1421parameter_types! {
1422	pub const DepositPerItem: Balance = deposit(1, 0);
1423	pub const DepositPerByte: Balance = deposit(0, 1);
1424	pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
1425	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
1426	pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
1427}
1428
1429impl pallet_contracts::Config for Runtime {
1430	type Time = Timestamp;
1431	type Randomness = RandomnessCollectiveFlip;
1432	type Currency = Balances;
1433	type RuntimeEvent = RuntimeEvent;
1434	type RuntimeCall = RuntimeCall;
1435	/// The safest default is to allow no calls at all.
1436	///
1437	/// Runtimes should whitelist dispatchables that are allowed to be called from contracts
1438	/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to
1439	/// change because that would break already deployed contracts. The `Call` structure itself
1440	/// is not allowed to change the indices of existing pallets, too.
1441	type CallFilter = Nothing;
1442	type DepositPerItem = DepositPerItem;
1443	type DepositPerByte = DepositPerByte;
1444	type DefaultDepositLimit = DefaultDepositLimit;
1445	type CallStack = [pallet_contracts::Frame<Self>; 5];
1446	type WeightPrice = pallet_transaction_payment::Pallet<Self>;
1447	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
1448	type ChainExtension = ();
1449	type Schedule = Schedule;
1450	type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
1451	type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
1452	type MaxStorageKeyLen = ConstU32<128>;
1453	type UnsafeUnstableInterface = ConstBool<false>;
1454	type UploadOrigin = EnsureSigned<Self::AccountId>;
1455	type InstantiateOrigin = EnsureSigned<Self::AccountId>;
1456	type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
1457	type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
1458	type RuntimeHoldReason = RuntimeHoldReason;
1459	#[cfg(not(feature = "runtime-benchmarks"))]
1460	type Migrations = ();
1461	#[cfg(feature = "runtime-benchmarks")]
1462	type Migrations = pallet_contracts::migration::codegen::BenchMigrations;
1463	type MaxDelegateDependencies = ConstU32<32>;
1464	type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
1465	type Debug = ();
1466	type Environment = ();
1467	type ApiVersion = ();
1468	type Xcm = ();
1469}
1470
1471impl pallet_revive::Config for Runtime {
1472	type Time = Timestamp;
1473	type Currency = Balances;
1474	type RuntimeEvent = RuntimeEvent;
1475	type RuntimeCall = RuntimeCall;
1476	type DepositPerItem = DepositPerItem;
1477	type DepositPerByte = DepositPerByte;
1478	type WeightPrice = pallet_transaction_payment::Pallet<Self>;
1479	type WeightInfo = pallet_revive::weights::SubstrateWeight<Self>;
1480	type Precompiles =
1481		(ERC20<Self, InlineIdConfig<0x1>, Instance1>, ERC20<Self, InlineIdConfig<0x2>, Instance2>);
1482	type AddressMapper = pallet_revive::AccountId32Mapper<Self>;
1483	type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;
1484	type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>;
1485	type UnsafeUnstableInterface = ConstBool<false>;
1486	type UploadOrigin = EnsureSigned<Self::AccountId>;
1487	type InstantiateOrigin = EnsureSigned<Self::AccountId>;
1488	type RuntimeHoldReason = RuntimeHoldReason;
1489	type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
1490	type ChainId = ConstU64<420_420_420>;
1491	type NativeToEthRatio = ConstU32<1_000_000>; // 10^(18 - 12) Eth is 10^18, Native is 10^12.
1492	type EthGasEncoder = ();
1493	type FindAuthor = <Runtime as pallet_authorship::Config>::FindAuthor;
1494	type AllowEVMBytecode = ConstBool<true>;
1495}
1496
1497impl pallet_sudo::Config for Runtime {
1498	type RuntimeEvent = RuntimeEvent;
1499	type RuntimeCall = RuntimeCall;
1500	type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
1501}
1502
1503parameter_types! {
1504	pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
1505	/// We prioritize im-online heartbeats over election solution submission.
1506	pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2;
1507	pub const MaxAuthorities: u32 = 1000;
1508	pub const MaxKeys: u32 = 10_000;
1509	pub const MaxPeerInHeartbeats: u32 = 10_000;
1510}
1511
1512impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
1513where
1514	RuntimeCall: From<LocalCall>,
1515{
1516	type Extension = TxExtension;
1517
1518	fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
1519		generic::UncheckedExtrinsic::new_transaction(call, extension).into()
1520	}
1521}
1522
1523impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
1524where
1525	RuntimeCall: From<LocalCall>,
1526{
1527	fn create_signed_transaction<
1528		C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
1529	>(
1530		call: RuntimeCall,
1531		public: <Signature as traits::Verify>::Signer,
1532		account: AccountId,
1533		nonce: Nonce,
1534	) -> Option<UncheckedExtrinsic> {
1535		let tip = 0;
1536		// take the biggest period possible.
1537		let period =
1538			BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
1539		let current_block = System::block_number()
1540			.saturated_into::<u64>()
1541			// The `System::block_number` is initialized with `n+1`,
1542			// so the actual block number is `n`.
1543			.saturating_sub(1);
1544		let era = Era::mortal(period, current_block);
1545		let tx_ext: TxExtension = (
1546			frame_system::AuthorizeCall::<Runtime>::new(),
1547			frame_system::CheckNonZeroSender::<Runtime>::new(),
1548			frame_system::CheckSpecVersion::<Runtime>::new(),
1549			frame_system::CheckTxVersion::<Runtime>::new(),
1550			frame_system::CheckGenesis::<Runtime>::new(),
1551			frame_system::CheckEra::<Runtime>::from(era),
1552			frame_system::CheckNonce::<Runtime>::from(nonce),
1553			frame_system::CheckWeight::<Runtime>::new(),
1554			pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
1555				pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(
1556					tip, None,
1557				),
1558			),
1559			frame_metadata_hash_extension::CheckMetadataHash::new(false),
1560			frame_system::WeightReclaim::<Runtime>::new(),
1561		);
1562
1563		let raw_payload = SignedPayload::new(call, tx_ext)
1564			.map_err(|e| {
1565				log::warn!("Unable to create signed payload: {:?}", e);
1566			})
1567			.ok()?;
1568		let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
1569		let address = Indices::unlookup(account);
1570		let (call, tx_ext, _) = raw_payload.deconstruct();
1571		let transaction =
1572			generic::UncheckedExtrinsic::new_signed(call, address, signature, tx_ext).into();
1573		Some(transaction)
1574	}
1575}
1576
1577impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
1578where
1579	RuntimeCall: From<LocalCall>,
1580{
1581	fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
1582		generic::UncheckedExtrinsic::new_bare(call).into()
1583	}
1584}
1585
1586impl frame_system::offchain::SigningTypes for Runtime {
1587	type Public = <Signature as traits::Verify>::Signer;
1588	type Signature = Signature;
1589}
1590
1591impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
1592where
1593	RuntimeCall: From<C>,
1594{
1595	type Extrinsic = UncheckedExtrinsic;
1596	type RuntimeCall = RuntimeCall;
1597}
1598
1599impl<C> frame_system::offchain::CreateAuthorizedTransaction<C> for Runtime
1600where
1601	RuntimeCall: From<C>,
1602{
1603	fn create_extension() -> Self::Extension {
1604		(
1605			frame_system::AuthorizeCall::<Runtime>::new(),
1606			frame_system::CheckNonZeroSender::<Runtime>::new(),
1607			frame_system::CheckSpecVersion::<Runtime>::new(),
1608			frame_system::CheckTxVersion::<Runtime>::new(),
1609			frame_system::CheckGenesis::<Runtime>::new(),
1610			frame_system::CheckEra::<Runtime>::from(Era::Immortal),
1611			frame_system::CheckNonce::<Runtime>::from(0),
1612			frame_system::CheckWeight::<Runtime>::new(),
1613			pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
1614				pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(0, None),
1615			),
1616			frame_metadata_hash_extension::CheckMetadataHash::new(false),
1617			frame_system::WeightReclaim::<Runtime>::new(),
1618		)
1619	}
1620}
1621
1622impl pallet_im_online::Config for Runtime {
1623	type AuthorityId = ImOnlineId;
1624	type RuntimeEvent = RuntimeEvent;
1625	type NextSessionRotation = Babe;
1626	type ValidatorSet = Historical;
1627	type ReportUnresponsiveness = Offences;
1628	type UnsignedPriority = ImOnlineUnsignedPriority;
1629	type WeightInfo = pallet_im_online::weights::SubstrateWeight<Runtime>;
1630	type MaxKeys = MaxKeys;
1631	type MaxPeerInHeartbeats = MaxPeerInHeartbeats;
1632}
1633
1634impl pallet_offences::Config for Runtime {
1635	type RuntimeEvent = RuntimeEvent;
1636	type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
1637	type OnOffenceHandler = Staking;
1638}
1639
1640impl pallet_authority_discovery::Config for Runtime {
1641	type MaxAuthorities = MaxAuthorities;
1642}
1643
1644parameter_types! {
1645	pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
1646}
1647
1648impl pallet_grandpa::Config for Runtime {
1649	type RuntimeEvent = RuntimeEvent;
1650	type WeightInfo = ();
1651	type MaxAuthorities = MaxAuthorities;
1652	type MaxNominators = MaxNominators;
1653	type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
1654	type KeyOwnerProof = sp_session::MembershipProof;
1655	type EquivocationReportSystem =
1656		pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
1657}
1658
1659parameter_types! {
1660	// difference of 26 bytes on-chain for the registration and 9 bytes on-chain for the identity
1661	// information, already accounted for by the byte deposit
1662	pub const BasicDeposit: Balance = deposit(1, 17);
1663	pub const ByteDeposit: Balance = deposit(0, 1);
1664	pub const UsernameDeposit: Balance = deposit(0, 32);
1665	pub const SubAccountDeposit: Balance = 2 * DOLLARS;   // 53 bytes on-chain
1666	pub const MaxSubAccounts: u32 = 100;
1667	pub const MaxAdditionalFields: u32 = 100;
1668	pub const MaxRegistrars: u32 = 20;
1669}
1670
1671impl pallet_identity::Config for Runtime {
1672	type RuntimeEvent = RuntimeEvent;
1673	type Currency = Balances;
1674	type BasicDeposit = BasicDeposit;
1675	type ByteDeposit = ByteDeposit;
1676	type UsernameDeposit = UsernameDeposit;
1677	type SubAccountDeposit = SubAccountDeposit;
1678	type MaxSubAccounts = MaxSubAccounts;
1679	type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
1680	type MaxRegistrars = MaxRegistrars;
1681	type Slashed = Treasury;
1682	type ForceOrigin = EnsureRootOrHalfCouncil;
1683	type RegistrarOrigin = EnsureRootOrHalfCouncil;
1684	type OffchainSignature = Signature;
1685	type SigningPublicKey = <Signature as traits::Verify>::Signer;
1686	type UsernameAuthorityOrigin = EnsureRoot<Self::AccountId>;
1687	type PendingUsernameExpiration = ConstU32<{ 7 * DAYS }>;
1688	type UsernameGracePeriod = ConstU32<{ 30 * DAYS }>;
1689	type MaxSuffixLength = ConstU32<7>;
1690	type MaxUsernameLength = ConstU32<32>;
1691	#[cfg(feature = "runtime-benchmarks")]
1692	type BenchmarkHelper = ();
1693	type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;
1694}
1695
1696parameter_types! {
1697	pub const ConfigDepositBase: Balance = 5 * DOLLARS;
1698	pub const FriendDepositFactor: Balance = 50 * CENTS;
1699	pub const MaxFriends: u16 = 9;
1700	pub const RecoveryDeposit: Balance = 5 * DOLLARS;
1701}
1702
1703impl pallet_recovery::Config for Runtime {
1704	type RuntimeEvent = RuntimeEvent;
1705	type WeightInfo = pallet_recovery::weights::SubstrateWeight<Runtime>;
1706	type RuntimeCall = RuntimeCall;
1707	type BlockNumberProvider = System;
1708	type Currency = Balances;
1709	type ConfigDepositBase = ConfigDepositBase;
1710	type FriendDepositFactor = FriendDepositFactor;
1711	type MaxFriends = MaxFriends;
1712	type RecoveryDeposit = RecoveryDeposit;
1713}
1714
1715parameter_types! {
1716	pub const GraceStrikes: u32 = 10;
1717	pub const SocietyVotingPeriod: BlockNumber = 80 * HOURS;
1718	pub const ClaimPeriod: BlockNumber = 80 * HOURS;
1719	pub const PeriodSpend: Balance = 500 * DOLLARS;
1720	pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS;
1721	pub const ChallengePeriod: BlockNumber = 7 * DAYS;
1722	pub const MaxPayouts: u32 = 10;
1723	pub const MaxBids: u32 = 10;
1724	pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
1725}
1726
1727impl pallet_society::Config for Runtime {
1728	type RuntimeEvent = RuntimeEvent;
1729	type PalletId = SocietyPalletId;
1730	type Currency = Balances;
1731	type Randomness = RandomnessCollectiveFlip;
1732	type GraceStrikes = GraceStrikes;
1733	type PeriodSpend = PeriodSpend;
1734	type VotingPeriod = SocietyVotingPeriod;
1735	type ClaimPeriod = ClaimPeriod;
1736	type MaxLockDuration = MaxLockDuration;
1737	type FounderSetOrigin =
1738		pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>;
1739	type ChallengePeriod = ChallengePeriod;
1740	type MaxPayouts = MaxPayouts;
1741	type MaxBids = MaxBids;
1742	type BlockNumberProvider = System;
1743	type WeightInfo = pallet_society::weights::SubstrateWeight<Runtime>;
1744}
1745
1746parameter_types! {
1747	pub const MinVestedTransfer: Balance = 100 * DOLLARS;
1748	pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
1749		WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
1750}
1751
1752impl pallet_vesting::Config for Runtime {
1753	type RuntimeEvent = RuntimeEvent;
1754	type Currency = Balances;
1755	type BlockNumberToBalance = ConvertInto;
1756	type MinVestedTransfer = MinVestedTransfer;
1757	type WeightInfo = pallet_vesting::weights::SubstrateWeight<Runtime>;
1758	type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
1759	type BlockNumberProvider = System;
1760	// `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the
1761	// highest number of schedules that encodes less than 2^10.
1762	const MAX_VESTING_SCHEDULES: u32 = 28;
1763}
1764
1765impl pallet_mmr::Config for Runtime {
1766	const INDEXING_PREFIX: &'static [u8] = b"mmr";
1767	type Hashing = Keccak256;
1768	type LeafData = pallet_mmr::ParentNumberAndHash<Self>;
1769	type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
1770	type BlockHashProvider = pallet_mmr::DefaultBlockHashProvider<Runtime>;
1771	type WeightInfo = ();
1772	#[cfg(feature = "runtime-benchmarks")]
1773	type BenchmarkHelper = ();
1774}
1775
1776parameter_types! {
1777	pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0);
1778}
1779
1780impl pallet_beefy_mmr::Config for Runtime {
1781	type LeafVersion = LeafVersion;
1782	type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum;
1783	type LeafExtra = Vec<u8>;
1784	type BeefyDataProvider = ();
1785	type WeightInfo = ();
1786}
1787
1788parameter_types! {
1789	pub const LotteryPalletId: PalletId = PalletId(*b"py/lotto");
1790	pub const MaxCalls: u32 = 10;
1791	pub const MaxGenerateRandom: u32 = 10;
1792}
1793
1794impl pallet_lottery::Config for Runtime {
1795	type PalletId = LotteryPalletId;
1796	type RuntimeCall = RuntimeCall;
1797	type Currency = Balances;
1798	type Randomness = RandomnessCollectiveFlip;
1799	type RuntimeEvent = RuntimeEvent;
1800	type ManagerOrigin = EnsureRoot<AccountId>;
1801	type MaxCalls = MaxCalls;
1802	type ValidateCall = Lottery;
1803	type MaxGenerateRandom = MaxGenerateRandom;
1804	type WeightInfo = pallet_lottery::weights::SubstrateWeight<Runtime>;
1805}
1806
1807parameter_types! {
1808	pub const AssetDeposit: Balance = 100 * DOLLARS;
1809	pub const ApprovalDeposit: Balance = 1 * DOLLARS;
1810	pub const StringLimit: u32 = 50;
1811	pub const MetadataDepositBase: Balance = 10 * DOLLARS;
1812	pub const MetadataDepositPerByte: Balance = 1 * DOLLARS;
1813}
1814
1815impl pallet_assets::Config<Instance1> for Runtime {
1816	type RuntimeEvent = RuntimeEvent;
1817	type Balance = u128;
1818	type AssetId = u32;
1819	type AssetIdParameter = codec::Compact<u32>;
1820	type Currency = Balances;
1821	type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
1822	type ForceOrigin = EnsureRoot<AccountId>;
1823	type AssetDeposit = AssetDeposit;
1824	type AssetAccountDeposit = ConstU128<DOLLARS>;
1825	type MetadataDepositBase = MetadataDepositBase;
1826	type MetadataDepositPerByte = MetadataDepositPerByte;
1827	type ApprovalDeposit = ApprovalDeposit;
1828	type StringLimit = StringLimit;
1829	type Holder = ();
1830	type Freezer = ();
1831	type Extra = ();
1832	type CallbackHandle = ();
1833	type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
1834	type RemoveItemsLimit = ConstU32<1000>;
1835	#[cfg(feature = "runtime-benchmarks")]
1836	type BenchmarkHelper = ();
1837}
1838
1839ord_parameter_types! {
1840	pub const AssetConversionOrigin: AccountId = AccountIdConversion::<AccountId>::into_account_truncating(&AssetConversionPalletId::get());
1841}
1842
1843impl pallet_assets::Config<Instance2> for Runtime {
1844	type RuntimeEvent = RuntimeEvent;
1845	type Balance = u128;
1846	type AssetId = u32;
1847	type AssetIdParameter = codec::Compact<u32>;
1848	type Currency = Balances;
1849	type CreateOrigin = AsEnsureOriginWithArg<EnsureSignedBy<AssetConversionOrigin, AccountId>>;
1850	type ForceOrigin = EnsureRoot<AccountId>;
1851	type AssetDeposit = AssetDeposit;
1852	type AssetAccountDeposit = ConstU128<DOLLARS>;
1853	type MetadataDepositBase = MetadataDepositBase;
1854	type MetadataDepositPerByte = MetadataDepositPerByte;
1855	type ApprovalDeposit = ApprovalDeposit;
1856	type StringLimit = StringLimit;
1857	type Holder = ();
1858	type Freezer = ();
1859	type Extra = ();
1860	type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
1861	type RemoveItemsLimit = ConstU32<1000>;
1862	type CallbackHandle = ();
1863	#[cfg(feature = "runtime-benchmarks")]
1864	type BenchmarkHelper = ();
1865}
1866
1867parameter_types! {
1868	pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
1869	pub const PoolSetupFee: Balance = 1 * DOLLARS; // should be more or equal to the existential deposit
1870	pub const MintMinLiquidity: Balance = 100;  // 100 is good enough when the main currency has 10-12 decimals.
1871	pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
1872	pub const Native: NativeOrWithId<u32> = NativeOrWithId::Native;
1873}
1874
1875pub type NativeAndAssets =
1876	UnionOf<Balances, Assets, NativeFromLeft, NativeOrWithId<u32>, AccountId>;
1877
1878impl pallet_asset_conversion::Config for Runtime {
1879	type RuntimeEvent = RuntimeEvent;
1880	type Balance = u128;
1881	type HigherPrecisionBalance = sp_core::U256;
1882	type AssetKind = NativeOrWithId<u32>;
1883	type Assets = NativeAndAssets;
1884	type PoolId = (Self::AssetKind, Self::AssetKind);
1885	type PoolLocator = Chain<
1886		WithFirstAsset<
1887			Native,
1888			AccountId,
1889			NativeOrWithId<u32>,
1890			AccountIdConverter<AssetConversionPalletId, Self::PoolId>,
1891		>,
1892		Ascending<
1893			AccountId,
1894			NativeOrWithId<u32>,
1895			AccountIdConverter<AssetConversionPalletId, Self::PoolId>,
1896		>,
1897	>;
1898	type PoolAssetId = <Self as pallet_assets::Config<Instance2>>::AssetId;
1899	type PoolAssets = PoolAssets;
1900	type PoolSetupFee = PoolSetupFee;
1901	type PoolSetupFeeAsset = Native;
1902	type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
1903	type PalletId = AssetConversionPalletId;
1904	type LPFee = ConstU32<3>; // means 0.3%
1905	type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
1906	type WeightInfo = pallet_asset_conversion::weights::SubstrateWeight<Runtime>;
1907	type MaxSwapPathLength = ConstU32<4>;
1908	type MintMinLiquidity = MintMinLiquidity;
1909	#[cfg(feature = "runtime-benchmarks")]
1910	type BenchmarkHelper = ();
1911}
1912
1913pub type NativeAndAssetsFreezer =
1914	UnionOf<Balances, AssetsFreezer, NativeFromLeft, NativeOrWithId<u32>, AccountId>;
1915
1916/// Benchmark Helper
1917#[cfg(feature = "runtime-benchmarks")]
1918pub struct AssetRewardsBenchmarkHelper;
1919
1920#[cfg(feature = "runtime-benchmarks")]
1921impl pallet_asset_rewards::benchmarking::BenchmarkHelper<NativeOrWithId<u32>>
1922	for AssetRewardsBenchmarkHelper
1923{
1924	fn staked_asset() -> NativeOrWithId<u32> {
1925		NativeOrWithId::<u32>::WithId(100)
1926	}
1927	fn reward_asset() -> NativeOrWithId<u32> {
1928		NativeOrWithId::<u32>::WithId(101)
1929	}
1930}
1931
1932parameter_types! {
1933	pub const StakingRewardsPalletId: PalletId = PalletId(*b"py/stkrd");
1934	pub const CreationHoldReason: RuntimeHoldReason =
1935		RuntimeHoldReason::AssetRewards(pallet_asset_rewards::HoldReason::PoolCreation);
1936	// 1 item, 135 bytes into the storage on pool creation.
1937	pub const StakePoolCreationDeposit: Balance = deposit(1, 135);
1938}
1939
1940impl pallet_asset_rewards::Config for Runtime {
1941	type RuntimeEvent = RuntimeEvent;
1942	type RuntimeFreezeReason = RuntimeFreezeReason;
1943	type AssetId = NativeOrWithId<u32>;
1944	type Balance = Balance;
1945	type Assets = NativeAndAssets;
1946	type PalletId = StakingRewardsPalletId;
1947	type CreatePoolOrigin = EnsureSigned<AccountId>;
1948	type WeightInfo = ();
1949	type AssetsFreezer = NativeAndAssetsFreezer;
1950	type Consideration = HoldConsideration<
1951		AccountId,
1952		Balances,
1953		CreationHoldReason,
1954		ConstantStoragePrice<StakePoolCreationDeposit, Balance>,
1955	>;
1956	#[cfg(feature = "runtime-benchmarks")]
1957	type BenchmarkHelper = AssetRewardsBenchmarkHelper;
1958}
1959
1960impl pallet_asset_conversion_ops::Config for Runtime {
1961	type RuntimeEvent = RuntimeEvent;
1962	type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<(
1963		NativeOrWithId<u32>,
1964		NativeOrWithId<u32>,
1965	)>;
1966	type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
1967	type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
1968	type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
1969	type DepositAsset = Balances;
1970	type WeightInfo = pallet_asset_conversion_ops::weights::SubstrateWeight<Runtime>;
1971}
1972
1973parameter_types! {
1974	pub const QueueCount: u32 = 300;
1975	pub const MaxQueueLen: u32 = 1000;
1976	pub const FifoQueueLen: u32 = 500;
1977	pub const NisBasePeriod: BlockNumber = 30 * DAYS;
1978	pub const MinBid: Balance = 100 * DOLLARS;
1979	pub const MinReceipt: Perquintill = Perquintill::from_percent(1);
1980	pub const IntakePeriod: BlockNumber = 10;
1981	pub MaxIntakeWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
1982	pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
1983	pub Target: Perquintill = Perquintill::zero();
1984	pub const NisPalletId: PalletId = PalletId(*b"py/nis  ");
1985}
1986
1987impl pallet_nis::Config for Runtime {
1988	type WeightInfo = pallet_nis::weights::SubstrateWeight<Runtime>;
1989	type RuntimeEvent = RuntimeEvent;
1990	type Currency = Balances;
1991	type CurrencyBalance = Balance;
1992	type FundOrigin = frame_system::EnsureSigned<AccountId>;
1993	type Counterpart = ItemOf<Assets, ConstU32<9u32>, AccountId>;
1994	type CounterpartAmount = WithMaximumOf<ConstU128<21_000_000_000_000_000_000u128>>;
1995	type Deficit = ();
1996	type IgnoredIssuance = ();
1997	type Target = Target;
1998	type PalletId = NisPalletId;
1999	type QueueCount = QueueCount;
2000	type MaxQueueLen = MaxQueueLen;
2001	type FifoQueueLen = FifoQueueLen;
2002	type BasePeriod = NisBasePeriod;
2003	type MinBid = MinBid;
2004	type MinReceipt = MinReceipt;
2005	type IntakePeriod = IntakePeriod;
2006	type MaxIntakeWeight = MaxIntakeWeight;
2007	type ThawThrottle = ThawThrottle;
2008	type RuntimeHoldReason = RuntimeHoldReason;
2009	#[cfg(feature = "runtime-benchmarks")]
2010	type BenchmarkSetup = SetupAsset;
2011}
2012
2013#[cfg(feature = "runtime-benchmarks")]
2014pub struct SetupAsset;
2015#[cfg(feature = "runtime-benchmarks")]
2016impl pallet_nis::BenchmarkSetup for SetupAsset {
2017	fn create_counterpart_asset() {
2018		let owner = AccountId::from([0u8; 32]);
2019		// this may or may not fail depending on if the chain spec or runtime genesis is used.
2020		let _ = Assets::force_create(
2021			RuntimeOrigin::root(),
2022			9u32.into(),
2023			sp_runtime::MultiAddress::Id(owner),
2024			true,
2025			1,
2026		);
2027	}
2028}
2029
2030parameter_types! {
2031	pub const CollectionDeposit: Balance = 100 * DOLLARS;
2032	pub const ItemDeposit: Balance = 1 * DOLLARS;
2033	pub const ApprovalsLimit: u32 = 20;
2034	pub const ItemAttributesApprovalsLimit: u32 = 20;
2035	pub const MaxTips: u32 = 10;
2036	pub const MaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
2037}
2038
2039impl pallet_uniques::Config for Runtime {
2040	type RuntimeEvent = RuntimeEvent;
2041	type CollectionId = u32;
2042	type ItemId = u32;
2043	type Currency = Balances;
2044	type ForceOrigin = frame_system::EnsureRoot<AccountId>;
2045	type CollectionDeposit = CollectionDeposit;
2046	type ItemDeposit = ItemDeposit;
2047	type MetadataDepositBase = MetadataDepositBase;
2048	type AttributeDepositBase = MetadataDepositBase;
2049	type DepositPerByte = MetadataDepositPerByte;
2050	type StringLimit = ConstU32<128>;
2051	type KeyLimit = ConstU32<32>;
2052	type ValueLimit = ConstU32<64>;
2053	type WeightInfo = pallet_uniques::weights::SubstrateWeight<Runtime>;
2054	#[cfg(feature = "runtime-benchmarks")]
2055	type Helper = ();
2056	type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
2057	type Locker = ();
2058}
2059
2060parameter_types! {
2061	pub const Budget: Balance = 10_000 * DOLLARS;
2062	pub TreasuryAccount: AccountId = Treasury::account_id();
2063}
2064
2065pub struct SalaryForRank;
2066impl GetSalary<u16, AccountId, Balance> for SalaryForRank {
2067	fn get_salary(a: u16, _: &AccountId) -> Balance {
2068		Balance::from(a) * 1000 * DOLLARS
2069	}
2070}
2071
2072impl pallet_salary::Config for Runtime {
2073	type WeightInfo = ();
2074	type RuntimeEvent = RuntimeEvent;
2075	type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
2076	type Members = RankedCollective;
2077	type Salary = SalaryForRank;
2078	type RegistrationPeriod = ConstU32<200>;
2079	type PayoutPeriod = ConstU32<200>;
2080	type Budget = Budget;
2081}
2082
2083impl pallet_core_fellowship::Config for Runtime {
2084	type WeightInfo = ();
2085	type RuntimeEvent = RuntimeEvent;
2086	type Members = RankedCollective;
2087	type Balance = Balance;
2088	type ParamsOrigin = frame_system::EnsureRoot<AccountId>;
2089	type InductOrigin = pallet_core_fellowship::EnsureInducted<Runtime, (), 1>;
2090	type ApproveOrigin = EnsureRootWithSuccess<AccountId, ConstU16<9>>;
2091	type PromoteOrigin = EnsureRootWithSuccess<AccountId, ConstU16<9>>;
2092	type FastPromoteOrigin = Self::PromoteOrigin;
2093	type EvidenceSize = ConstU32<16_384>;
2094	type MaxRank = ConstU16<9>;
2095}
2096
2097parameter_types! {
2098	pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction");
2099	pub NewAssetSymbol: BoundedVec<u8, StringLimit> = (*b"FRAC").to_vec().try_into().unwrap();
2100	pub NewAssetName: BoundedVec<u8, StringLimit> = (*b"Frac").to_vec().try_into().unwrap();
2101}
2102
2103impl pallet_nft_fractionalization::Config for Runtime {
2104	type RuntimeEvent = RuntimeEvent;
2105	type Deposit = AssetDeposit;
2106	type Currency = Balances;
2107	type NewAssetSymbol = NewAssetSymbol;
2108	type NewAssetName = NewAssetName;
2109	type StringLimit = StringLimit;
2110	type NftCollectionId = <Self as pallet_nfts::Config>::CollectionId;
2111	type NftId = <Self as pallet_nfts::Config>::ItemId;
2112	type AssetBalance = <Self as pallet_balances::Config>::Balance;
2113	type AssetId = <Self as pallet_assets::Config<Instance1>>::AssetId;
2114	type Assets = Assets;
2115	type Nfts = Nfts;
2116	type PalletId = NftFractionalizationPalletId;
2117	type WeightInfo = pallet_nft_fractionalization::weights::SubstrateWeight<Runtime>;
2118	type RuntimeHoldReason = RuntimeHoldReason;
2119	#[cfg(feature = "runtime-benchmarks")]
2120	type BenchmarkHelper = ();
2121}
2122
2123parameter_types! {
2124	pub Features: PalletFeatures = PalletFeatures::all_enabled();
2125	pub const MaxAttributesPerCall: u32 = 10;
2126}
2127
2128impl pallet_nfts::Config for Runtime {
2129	type RuntimeEvent = RuntimeEvent;
2130	type CollectionId = u32;
2131	type ItemId = u32;
2132	type Currency = Balances;
2133	type ForceOrigin = frame_system::EnsureRoot<AccountId>;
2134	type CollectionDeposit = CollectionDeposit;
2135	type ItemDeposit = ItemDeposit;
2136	type MetadataDepositBase = MetadataDepositBase;
2137	type AttributeDepositBase = MetadataDepositBase;
2138	type DepositPerByte = MetadataDepositPerByte;
2139	type StringLimit = ConstU32<256>;
2140	type KeyLimit = ConstU32<64>;
2141	type ValueLimit = ConstU32<256>;
2142	type ApprovalsLimit = ApprovalsLimit;
2143	type ItemAttributesApprovalsLimit = ItemAttributesApprovalsLimit;
2144	type MaxTips = MaxTips;
2145	type MaxDeadlineDuration = MaxDeadlineDuration;
2146	type MaxAttributesPerCall = MaxAttributesPerCall;
2147	type Features = Features;
2148	type OffchainSignature = Signature;
2149	type OffchainPublic = <Signature as traits::Verify>::Signer;
2150	type WeightInfo = pallet_nfts::weights::SubstrateWeight<Runtime>;
2151	#[cfg(feature = "runtime-benchmarks")]
2152	type Helper = ();
2153	type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
2154	type Locker = ();
2155	type BlockNumberProvider = frame_system::Pallet<Runtime>;
2156}
2157
2158impl pallet_transaction_storage::Config for Runtime {
2159	type RuntimeEvent = RuntimeEvent;
2160	type Currency = Balances;
2161	type RuntimeHoldReason = RuntimeHoldReason;
2162	type RuntimeCall = RuntimeCall;
2163	type FeeDestination = ();
2164	type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight<Runtime>;
2165	type MaxBlockTransactions =
2166		ConstU32<{ pallet_transaction_storage::DEFAULT_MAX_BLOCK_TRANSACTIONS }>;
2167	type MaxTransactionSize =
2168		ConstU32<{ pallet_transaction_storage::DEFAULT_MAX_TRANSACTION_SIZE }>;
2169}
2170
2171impl pallet_verify_signature::Config for Runtime {
2172	type Signature = MultiSignature;
2173	type AccountIdentifier = MultiSigner;
2174	type WeightInfo = pallet_verify_signature::weights::SubstrateWeight<Runtime>;
2175	#[cfg(feature = "runtime-benchmarks")]
2176	type BenchmarkHelper = ();
2177}
2178
2179impl pallet_whitelist::Config for Runtime {
2180	type RuntimeEvent = RuntimeEvent;
2181	type RuntimeCall = RuntimeCall;
2182	type WhitelistOrigin = EnsureRoot<AccountId>;
2183	type DispatchWhitelistedOrigin = EnsureRoot<AccountId>;
2184	type Preimages = Preimage;
2185	type WeightInfo = pallet_whitelist::weights::SubstrateWeight<Runtime>;
2186}
2187
2188parameter_types! {
2189	pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
2190	pub const MigrationSignedDepositBase: Balance = 20 * DOLLARS;
2191	pub const MigrationMaxKeyLen: u32 = 512;
2192}
2193
2194impl pallet_state_trie_migration::Config for Runtime {
2195	type RuntimeEvent = RuntimeEvent;
2196	type ControlOrigin = EnsureRoot<AccountId>;
2197	type Currency = Balances;
2198	type RuntimeHoldReason = RuntimeHoldReason;
2199	type MaxKeyLen = MigrationMaxKeyLen;
2200	type SignedDepositPerItem = MigrationSignedDepositPerItem;
2201	type SignedDepositBase = MigrationSignedDepositBase;
2202	// Warning: this is not advised, as it might allow the chain to be temporarily DOS-ed.
2203	// Preferably, if the chain's governance/maintenance team is planning on using a specific
2204	// account for the migration, put it here to make sure only that account can trigger the signed
2205	// migrations.
2206	type SignedFilter = EnsureSigned<Self::AccountId>;
2207	type WeightInfo = ();
2208}
2209
2210const ALLIANCE_MOTION_DURATION_IN_BLOCKS: BlockNumber = 5 * DAYS;
2211
2212parameter_types! {
2213	pub const AllianceMotionDuration: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS;
2214	pub const AllianceMaxProposals: u32 = 100;
2215	pub const AllianceMaxMembers: u32 = 100;
2216}
2217
2218type AllianceCollective = pallet_collective::Instance3;
2219impl pallet_collective::Config<AllianceCollective> for Runtime {
2220	type RuntimeOrigin = RuntimeOrigin;
2221	type Proposal = RuntimeCall;
2222	type RuntimeEvent = RuntimeEvent;
2223	type MotionDuration = AllianceMotionDuration;
2224	type MaxProposals = AllianceMaxProposals;
2225	type MaxMembers = AllianceMaxMembers;
2226	type DefaultVote = pallet_collective::PrimeDefaultVote;
2227	type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
2228	type SetMembersOrigin = EnsureRoot<Self::AccountId>;
2229	type MaxProposalWeight = MaxCollectivesProposalWeight;
2230	type DisapproveOrigin = EnsureRoot<Self::AccountId>;
2231	type KillOrigin = EnsureRoot<Self::AccountId>;
2232	type Consideration = ();
2233}
2234
2235parameter_types! {
2236	pub const MaxFellows: u32 = AllianceMaxMembers::get();
2237	pub const MaxAllies: u32 = 100;
2238	pub const AllyDeposit: Balance = 10 * DOLLARS;
2239	pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS + (1 * DAYS);
2240}
2241
2242impl pallet_alliance::Config for Runtime {
2243	type RuntimeEvent = RuntimeEvent;
2244	type Proposal = RuntimeCall;
2245	type AdminOrigin = EitherOfDiverse<
2246		EnsureRoot<AccountId>,
2247		pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
2248	>;
2249	type MembershipManager = EitherOfDiverse<
2250		EnsureRoot<AccountId>,
2251		pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
2252	>;
2253	type AnnouncementOrigin = EitherOfDiverse<
2254		EnsureRoot<AccountId>,
2255		pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
2256	>;
2257	type Currency = Balances;
2258	type Slashed = Treasury;
2259	type InitializeMembers = AllianceMotion;
2260	type MembershipChanged = AllianceMotion;
2261	#[cfg(not(feature = "runtime-benchmarks"))]
2262	type IdentityVerifier = AllianceIdentityVerifier;
2263	#[cfg(feature = "runtime-benchmarks")]
2264	type IdentityVerifier = ();
2265	type ProposalProvider = AllianceProposalProvider;
2266	type MaxProposals = AllianceMaxProposals;
2267	type MaxFellows = MaxFellows;
2268	type MaxAllies = MaxAllies;
2269	type MaxUnscrupulousItems = ConstU32<100>;
2270	type MaxWebsiteUrlLength = ConstU32<255>;
2271	type MaxAnnouncementsCount = ConstU32<100>;
2272	type MaxMembersCount = AllianceMaxMembers;
2273	type AllyDeposit = AllyDeposit;
2274	type WeightInfo = pallet_alliance::weights::SubstrateWeight<Runtime>;
2275	type RetirementPeriod = RetirementPeriod;
2276}
2277
2278impl frame_benchmarking_pallet_pov::Config for Runtime {
2279	type RuntimeEvent = RuntimeEvent;
2280}
2281
2282parameter_types! {
2283	pub StatementCost: Balance = 1 * DOLLARS;
2284	pub StatementByteCost: Balance = 100 * MILLICENTS;
2285	pub const MinAllowedStatements: u32 = 4;
2286	pub const MaxAllowedStatements: u32 = 10;
2287	pub const MinAllowedBytes: u32 = 1024;
2288	pub const MaxAllowedBytes: u32 = 4096;
2289}
2290
2291impl pallet_statement::Config for Runtime {
2292	type RuntimeEvent = RuntimeEvent;
2293	type Currency = Balances;
2294	type StatementCost = StatementCost;
2295	type ByteCost = StatementByteCost;
2296	type MinAllowedStatements = MinAllowedStatements;
2297	type MaxAllowedStatements = MaxAllowedStatements;
2298	type MinAllowedBytes = MinAllowedBytes;
2299	type MaxAllowedBytes = MaxAllowedBytes;
2300}
2301
2302parameter_types! {
2303	pub MbmServiceWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
2304}
2305
2306impl pallet_migrations::Config for Runtime {
2307	type RuntimeEvent = RuntimeEvent;
2308	#[cfg(not(feature = "runtime-benchmarks"))]
2309	type Migrations = ();
2310	// Benchmarks need mocked migrations to guarantee that they succeed.
2311	#[cfg(feature = "runtime-benchmarks")]
2312	type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
2313	type CursorMaxLen = ConstU32<65_536>;
2314	type IdentifierMaxLen = ConstU32<256>;
2315	type MigrationStatusHandler = ();
2316	type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
2317	type MaxServiceWeight = MbmServiceWeight;
2318	type WeightInfo = pallet_migrations::weights::SubstrateWeight<Runtime>;
2319}
2320
2321parameter_types! {
2322	pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
2323	pub const MinimumCreditPurchase: Balance =  100 * MILLICENTS;
2324}
2325
2326pub struct IntoAuthor;
2327impl OnUnbalanced<Credit<AccountId, Balances>> for IntoAuthor {
2328	fn on_nonzero_unbalanced(credit: Credit<AccountId, Balances>) {
2329		if let Some(author) = Authorship::author() {
2330			let _ = <Balances as Balanced<_>>::resolve(&author, credit);
2331		}
2332	}
2333}
2334
2335pub struct CoretimeProvider;
2336impl CoretimeInterface for CoretimeProvider {
2337	type AccountId = AccountId;
2338	type Balance = Balance;
2339	type RelayChainBlockNumberProvider = System;
2340	fn request_core_count(_count: CoreIndex) {}
2341	fn request_revenue_info_at(_when: u32) {}
2342	fn credit_account(_who: Self::AccountId, _amount: Self::Balance) {}
2343	fn assign_core(
2344		_core: CoreIndex,
2345		_begin: u32,
2346		_assignment: Vec<(CoreAssignment, PartsOf57600)>,
2347		_end_hint: Option<u32>,
2348	) {
2349	}
2350}
2351
2352pub struct SovereignAccountOf;
2353// Dummy implementation which converts `TaskId` to `AccountId`.
2354impl MaybeConvert<TaskId, AccountId> for SovereignAccountOf {
2355	fn maybe_convert(task: TaskId) -> Option<AccountId> {
2356		let mut account: [u8; 32] = [0; 32];
2357		account[..4].copy_from_slice(&task.to_le_bytes());
2358		Some(account.into())
2359	}
2360}
2361impl pallet_broker::Config for Runtime {
2362	type RuntimeEvent = RuntimeEvent;
2363	type Currency = Balances;
2364	type OnRevenue = IntoAuthor;
2365	type TimeslicePeriod = ConstU32<2>;
2366	type MaxLeasedCores = ConstU32<5>;
2367	type MaxReservedCores = ConstU32<5>;
2368	type Coretime = CoretimeProvider;
2369	type ConvertBalance = traits::Identity;
2370	type WeightInfo = ();
2371	type PalletId = BrokerPalletId;
2372	type AdminOrigin = EnsureRoot<AccountId>;
2373	type SovereignAccountOf = SovereignAccountOf;
2374	type MaxAutoRenewals = ConstU32<10>;
2375	type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
2376	type MinimumCreditPurchase = MinimumCreditPurchase;
2377}
2378
2379parameter_types! {
2380	pub const MixnetNumCoverToCurrentBlocks: BlockNumber = 3;
2381	pub const MixnetNumRequestsToCurrentBlocks: BlockNumber = 3;
2382	pub const MixnetNumCoverToPrevBlocks: BlockNumber = 3;
2383	pub const MixnetNumRegisterStartSlackBlocks: BlockNumber = 3;
2384	pub const MixnetNumRegisterEndSlackBlocks: BlockNumber = 3;
2385	pub const MixnetRegistrationPriority: TransactionPriority = ImOnlineUnsignedPriority::get() - 1;
2386}
2387
2388impl pallet_mixnet::Config for Runtime {
2389	type MaxAuthorities = MaxAuthorities;
2390	type MaxExternalAddressSize = ConstU32<128>;
2391	type MaxExternalAddressesPerMixnode = ConstU32<16>;
2392	type NextSessionRotation = Babe;
2393	type NumCoverToCurrentBlocks = MixnetNumCoverToCurrentBlocks;
2394	type NumRequestsToCurrentBlocks = MixnetNumRequestsToCurrentBlocks;
2395	type NumCoverToPrevBlocks = MixnetNumCoverToPrevBlocks;
2396	type NumRegisterStartSlackBlocks = MixnetNumRegisterStartSlackBlocks;
2397	type NumRegisterEndSlackBlocks = MixnetNumRegisterEndSlackBlocks;
2398	type RegistrationPriority = MixnetRegistrationPriority;
2399	type MinMixnodes = ConstU32<7>; // Low to allow small testing networks
2400}
2401
2402/// Dynamic parameters that can be changed at runtime through the
2403/// `pallet_parameters::set_parameter`.
2404#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
2405pub mod dynamic_params {
2406	use super::*;
2407
2408	#[dynamic_pallet_params]
2409	#[codec(index = 0)]
2410	pub mod storage {
2411		/// Configures the base deposit of storing some data.
2412		#[codec(index = 0)]
2413		pub static BaseDeposit: Balance = 1 * DOLLARS;
2414
2415		/// Configures the per-byte deposit of storing some data.
2416		#[codec(index = 1)]
2417		pub static ByteDeposit: Balance = 1 * CENTS;
2418	}
2419
2420	#[dynamic_pallet_params]
2421	#[codec(index = 1)]
2422	pub mod referenda {
2423		/// The configuration for the tracks
2424		#[codec(index = 0)]
2425		pub static Tracks: BoundedVec<
2426			pallet_referenda::Track<u16, Balance, BlockNumber>,
2427			ConstU32<100>,
2428		> = BoundedVec::truncate_from(vec![pallet_referenda::Track {
2429			id: 0u16,
2430			info: pallet_referenda::TrackInfo {
2431				name: s("root"),
2432				max_deciding: 1,
2433				decision_deposit: 10,
2434				prepare_period: 4,
2435				decision_period: 4,
2436				confirm_period: 2,
2437				min_enactment_period: 4,
2438				min_approval: pallet_referenda::Curve::LinearDecreasing {
2439					length: Perbill::from_percent(100),
2440					floor: Perbill::from_percent(50),
2441					ceil: Perbill::from_percent(100),
2442				},
2443				min_support: pallet_referenda::Curve::LinearDecreasing {
2444					length: Perbill::from_percent(100),
2445					floor: Perbill::from_percent(0),
2446					ceil: Perbill::from_percent(100),
2447				},
2448			},
2449		}]);
2450
2451		/// A list mapping every origin with a track Id
2452		#[codec(index = 1)]
2453		pub static Origins: BoundedVec<(OriginCaller, u16), ConstU32<100>> =
2454			BoundedVec::truncate_from(vec![(
2455				OriginCaller::system(frame_system::RawOrigin::Root),
2456				0,
2457			)]);
2458	}
2459}
2460
2461#[cfg(feature = "runtime-benchmarks")]
2462impl Default for RuntimeParameters {
2463	fn default() -> Self {
2464		RuntimeParameters::Storage(dynamic_params::storage::Parameters::BaseDeposit(
2465			dynamic_params::storage::BaseDeposit,
2466			Some(1 * DOLLARS),
2467		))
2468	}
2469}
2470
2471pub struct DynamicParametersManagerOrigin;
2472impl EnsureOriginWithArg<RuntimeOrigin, RuntimeParametersKey> for DynamicParametersManagerOrigin {
2473	type Success = ();
2474
2475	fn try_origin(
2476		origin: RuntimeOrigin,
2477		key: &RuntimeParametersKey,
2478	) -> Result<Self::Success, RuntimeOrigin> {
2479		match key {
2480			RuntimeParametersKey::Storage(_) => {
2481				frame_system::ensure_root(origin.clone()).map_err(|_| origin)?;
2482				return Ok(())
2483			},
2484			RuntimeParametersKey::Referenda(_) => {
2485				frame_system::ensure_root(origin.clone()).map_err(|_| origin)?;
2486				return Ok(())
2487			},
2488		}
2489	}
2490
2491	#[cfg(feature = "runtime-benchmarks")]
2492	fn try_successful_origin(_key: &RuntimeParametersKey) -> Result<RuntimeOrigin, ()> {
2493		Ok(RuntimeOrigin::root())
2494	}
2495}
2496
2497impl pallet_parameters::Config for Runtime {
2498	type RuntimeParameters = RuntimeParameters;
2499	type RuntimeEvent = RuntimeEvent;
2500	type AdminOrigin = DynamicParametersManagerOrigin;
2501	type WeightInfo = ();
2502}
2503
2504pub type MetaTxExtension = (
2505	pallet_verify_signature::VerifySignature<Runtime>,
2506	pallet_meta_tx::MetaTxMarker<Runtime>,
2507	frame_system::CheckNonZeroSender<Runtime>,
2508	frame_system::CheckSpecVersion<Runtime>,
2509	frame_system::CheckTxVersion<Runtime>,
2510	frame_system::CheckGenesis<Runtime>,
2511	frame_system::CheckEra<Runtime>,
2512	frame_system::CheckNonce<Runtime>,
2513	frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
2514);
2515
2516impl pallet_meta_tx::Config for Runtime {
2517	type WeightInfo = ();
2518	type RuntimeEvent = RuntimeEvent;
2519	#[cfg(not(feature = "runtime-benchmarks"))]
2520	type Extension = MetaTxExtension;
2521	#[cfg(feature = "runtime-benchmarks")]
2522	type Extension = pallet_meta_tx::WeightlessExtension<Runtime>;
2523}
2524
2525#[frame_support::runtime]
2526mod runtime {
2527	use super::*;
2528
2529	#[runtime::runtime]
2530	#[runtime::derive(
2531		RuntimeCall,
2532		RuntimeEvent,
2533		RuntimeError,
2534		RuntimeOrigin,
2535		RuntimeFreezeReason,
2536		RuntimeHoldReason,
2537		RuntimeSlashReason,
2538		RuntimeLockId,
2539		RuntimeTask,
2540		RuntimeViewFunction
2541	)]
2542	pub struct Runtime;
2543
2544	#[runtime::pallet_index(0)]
2545	pub type System = frame_system::Pallet<Runtime>;
2546
2547	#[runtime::pallet_index(1)]
2548	pub type Utility = pallet_utility::Pallet<Runtime>;
2549
2550	#[runtime::pallet_index(2)]
2551	pub type Babe = pallet_babe::Pallet<Runtime>;
2552
2553	#[runtime::pallet_index(3)]
2554	pub type Timestamp = pallet_timestamp::Pallet<Runtime>;
2555
2556	// Authorship must be before session in order to note author in the correct session and era
2557	// for im-online and staking.
2558	#[runtime::pallet_index(4)]
2559	pub type Authorship = pallet_authorship::Pallet<Runtime>;
2560
2561	#[runtime::pallet_index(5)]
2562	pub type Indices = pallet_indices::Pallet<Runtime>;
2563
2564	#[runtime::pallet_index(6)]
2565	pub type Balances = pallet_balances::Pallet<Runtime>;
2566
2567	#[runtime::pallet_index(7)]
2568	pub type TransactionPayment = pallet_transaction_payment::Pallet<Runtime>;
2569
2570	#[runtime::pallet_index(9)]
2571	pub type AssetConversionTxPayment = pallet_asset_conversion_tx_payment::Pallet<Runtime>;
2572
2573	#[runtime::pallet_index(10)]
2574	pub type ElectionProviderMultiPhase = pallet_election_provider_multi_phase::Pallet<Runtime>;
2575
2576	#[runtime::pallet_index(11)]
2577	pub type Staking = pallet_staking::Pallet<Runtime>;
2578
2579	#[runtime::pallet_index(12)]
2580	pub type Session = pallet_session::Pallet<Runtime>;
2581
2582	#[runtime::pallet_index(13)]
2583	pub type Democracy = pallet_democracy::Pallet<Runtime>;
2584
2585	#[runtime::pallet_index(14)]
2586	pub type Council = pallet_collective::Pallet<Runtime, Instance1>;
2587
2588	#[runtime::pallet_index(15)]
2589	pub type TechnicalCommittee = pallet_collective::Pallet<Runtime, Instance2>;
2590
2591	#[runtime::pallet_index(16)]
2592	pub type Elections = pallet_elections_phragmen::Pallet<Runtime>;
2593
2594	#[runtime::pallet_index(17)]
2595	pub type TechnicalMembership = pallet_membership::Pallet<Runtime, Instance1>;
2596
2597	#[runtime::pallet_index(18)]
2598	pub type Grandpa = pallet_grandpa::Pallet<Runtime>;
2599
2600	#[runtime::pallet_index(19)]
2601	pub type Treasury = pallet_treasury::Pallet<Runtime>;
2602
2603	#[runtime::pallet_index(20)]
2604	pub type AssetRate = pallet_asset_rate::Pallet<Runtime>;
2605
2606	#[runtime::pallet_index(21)]
2607	pub type Contracts = pallet_contracts::Pallet<Runtime>;
2608
2609	#[runtime::pallet_index(22)]
2610	pub type Sudo = pallet_sudo::Pallet<Runtime>;
2611
2612	#[runtime::pallet_index(23)]
2613	pub type ImOnline = pallet_im_online::Pallet<Runtime>;
2614
2615	#[runtime::pallet_index(24)]
2616	pub type AuthorityDiscovery = pallet_authority_discovery::Pallet<Runtime>;
2617
2618	#[runtime::pallet_index(25)]
2619	pub type Offences = pallet_offences::Pallet<Runtime>;
2620
2621	#[runtime::pallet_index(26)]
2622	pub type Historical = pallet_session_historical::Pallet<Runtime>;
2623
2624	#[runtime::pallet_index(27)]
2625	pub type RandomnessCollectiveFlip = pallet_insecure_randomness_collective_flip::Pallet<Runtime>;
2626
2627	#[runtime::pallet_index(28)]
2628	pub type Identity = pallet_identity::Pallet<Runtime>;
2629
2630	#[runtime::pallet_index(29)]
2631	pub type Society = pallet_society::Pallet<Runtime>;
2632
2633	#[runtime::pallet_index(30)]
2634	pub type Recovery = pallet_recovery::Pallet<Runtime>;
2635
2636	#[runtime::pallet_index(31)]
2637	pub type Vesting = pallet_vesting::Pallet<Runtime>;
2638
2639	#[runtime::pallet_index(32)]
2640	pub type Scheduler = pallet_scheduler::Pallet<Runtime>;
2641
2642	#[runtime::pallet_index(33)]
2643	pub type Glutton = pallet_glutton::Pallet<Runtime>;
2644
2645	#[runtime::pallet_index(34)]
2646	pub type Preimage = pallet_preimage::Pallet<Runtime>;
2647
2648	#[runtime::pallet_index(35)]
2649	pub type Proxy = pallet_proxy::Pallet<Runtime>;
2650
2651	#[runtime::pallet_index(36)]
2652	pub type Multisig = pallet_multisig::Pallet<Runtime>;
2653
2654	#[runtime::pallet_index(37)]
2655	pub type Bounties = pallet_bounties::Pallet<Runtime>;
2656
2657	#[runtime::pallet_index(38)]
2658	pub type Tips = pallet_tips::Pallet<Runtime>;
2659
2660	#[runtime::pallet_index(39)]
2661	pub type Assets = pallet_assets::Pallet<Runtime, Instance1>;
2662
2663	#[runtime::pallet_index(40)]
2664	pub type PoolAssets = pallet_assets::Pallet<Runtime, Instance2>;
2665
2666	#[runtime::pallet_index(41)]
2667	pub type Beefy = pallet_beefy::Pallet<Runtime>;
2668
2669	// MMR leaf construction must be after session in order to have a leaf's next_auth_set
2670	// refer to block<N>. See issue polkadot-fellows/runtimes#160 for details.
2671	#[runtime::pallet_index(42)]
2672	pub type Mmr = pallet_mmr::Pallet<Runtime>;
2673
2674	#[runtime::pallet_index(43)]
2675	pub type MmrLeaf = pallet_beefy_mmr::Pallet<Runtime>;
2676
2677	#[runtime::pallet_index(44)]
2678	pub type Lottery = pallet_lottery::Pallet<Runtime>;
2679
2680	#[runtime::pallet_index(45)]
2681	pub type Nis = pallet_nis::Pallet<Runtime>;
2682
2683	#[runtime::pallet_index(46)]
2684	pub type Uniques = pallet_uniques::Pallet<Runtime>;
2685
2686	#[runtime::pallet_index(47)]
2687	pub type Nfts = pallet_nfts::Pallet<Runtime>;
2688
2689	#[runtime::pallet_index(48)]
2690	pub type NftFractionalization = pallet_nft_fractionalization::Pallet<Runtime>;
2691
2692	#[runtime::pallet_index(49)]
2693	pub type Salary = pallet_salary::Pallet<Runtime>;
2694
2695	#[runtime::pallet_index(50)]
2696	pub type CoreFellowship = pallet_core_fellowship::Pallet<Runtime>;
2697
2698	#[runtime::pallet_index(51)]
2699	pub type TransactionStorage = pallet_transaction_storage::Pallet<Runtime>;
2700
2701	#[runtime::pallet_index(52)]
2702	pub type VoterList = pallet_bags_list::Pallet<Runtime, Instance1>;
2703
2704	#[runtime::pallet_index(53)]
2705	pub type StateTrieMigration = pallet_state_trie_migration::Pallet<Runtime>;
2706
2707	#[runtime::pallet_index(54)]
2708	pub type ChildBounties = pallet_child_bounties::Pallet<Runtime>;
2709
2710	#[runtime::pallet_index(55)]
2711	pub type Referenda = pallet_referenda::Pallet<Runtime>;
2712
2713	#[runtime::pallet_index(56)]
2714	pub type Remark = pallet_remark::Pallet<Runtime>;
2715
2716	#[runtime::pallet_index(57)]
2717	pub type RootTesting = pallet_root_testing::Pallet<Runtime>;
2718
2719	#[runtime::pallet_index(58)]
2720	pub type ConvictionVoting = pallet_conviction_voting::Pallet<Runtime>;
2721
2722	#[runtime::pallet_index(59)]
2723	pub type Whitelist = pallet_whitelist::Pallet<Runtime>;
2724
2725	#[runtime::pallet_index(60)]
2726	pub type AllianceMotion = pallet_collective::Pallet<Runtime, Instance3>;
2727
2728	#[runtime::pallet_index(61)]
2729	pub type Alliance = pallet_alliance::Pallet<Runtime>;
2730
2731	#[runtime::pallet_index(62)]
2732	pub type NominationPools = pallet_nomination_pools::Pallet<Runtime>;
2733
2734	#[runtime::pallet_index(63)]
2735	pub type RankedPolls = pallet_referenda::Pallet<Runtime, Instance2>;
2736
2737	#[runtime::pallet_index(64)]
2738	pub type RankedCollective = pallet_ranked_collective::Pallet<Runtime>;
2739
2740	#[runtime::pallet_index(65)]
2741	pub type AssetConversion = pallet_asset_conversion::Pallet<Runtime>;
2742
2743	#[runtime::pallet_index(66)]
2744	pub type FastUnstake = pallet_fast_unstake::Pallet<Runtime>;
2745
2746	#[runtime::pallet_index(67)]
2747	pub type MessageQueue = pallet_message_queue::Pallet<Runtime>;
2748
2749	#[runtime::pallet_index(68)]
2750	pub type Pov = frame_benchmarking_pallet_pov::Pallet<Runtime>;
2751
2752	#[runtime::pallet_index(69)]
2753	pub type TxPause = pallet_tx_pause::Pallet<Runtime>;
2754
2755	#[runtime::pallet_index(70)]
2756	pub type SafeMode = pallet_safe_mode::Pallet<Runtime>;
2757
2758	#[runtime::pallet_index(71)]
2759	pub type Statement = pallet_statement::Pallet<Runtime>;
2760
2761	#[runtime::pallet_index(72)]
2762	pub type MultiBlockMigrations = pallet_migrations::Pallet<Runtime>;
2763
2764	#[runtime::pallet_index(73)]
2765	pub type Broker = pallet_broker::Pallet<Runtime>;
2766
2767	#[runtime::pallet_index(74)]
2768	pub type TasksExample = pallet_example_tasks::Pallet<Runtime>;
2769
2770	#[runtime::pallet_index(75)]
2771	pub type Mixnet = pallet_mixnet::Pallet<Runtime>;
2772
2773	#[runtime::pallet_index(76)]
2774	pub type Parameters = pallet_parameters::Pallet<Runtime>;
2775
2776	#[runtime::pallet_index(77)]
2777	pub type SkipFeelessPayment = pallet_skip_feeless_payment::Pallet<Runtime>;
2778
2779	#[runtime::pallet_index(78)]
2780	pub type PalletExampleMbms = pallet_example_mbm::Pallet<Runtime>;
2781
2782	#[runtime::pallet_index(79)]
2783	pub type AssetConversionMigration = pallet_asset_conversion_ops::Pallet<Runtime>;
2784
2785	#[runtime::pallet_index(80)]
2786	pub type Revive = pallet_revive::Pallet<Runtime>;
2787
2788	#[runtime::pallet_index(81)]
2789	pub type VerifySignature = pallet_verify_signature::Pallet<Runtime>;
2790
2791	#[runtime::pallet_index(82)]
2792	pub type DelegatedStaking = pallet_delegated_staking::Pallet<Runtime>;
2793
2794	#[runtime::pallet_index(83)]
2795	pub type AssetRewards = pallet_asset_rewards::Pallet<Runtime>;
2796
2797	#[runtime::pallet_index(84)]
2798	pub type AssetsFreezer = pallet_assets_freezer::Pallet<Runtime, Instance1>;
2799
2800	#[runtime::pallet_index(89)]
2801	pub type MetaTx = pallet_meta_tx::Pallet<Runtime>;
2802}
2803
2804/// The address format for describing accounts.
2805pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
2806/// Block header type as expected by this runtime.
2807pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
2808/// Block type as expected by this runtime.
2809pub type Block = generic::Block<Header, UncheckedExtrinsic>;
2810/// A Block signed with a Justification
2811pub type SignedBlock = generic::SignedBlock<Block>;
2812/// BlockId type as expected by this runtime.
2813pub type BlockId = generic::BlockId<Block>;
2814/// The TransactionExtension to the basic transaction logic.
2815///
2816/// When you change this, you **MUST** modify [`sign`] in `bin/node/testing/src/keyring.rs`!
2817///
2818/// [`sign`]: <../../testing/src/keyring.rs.html>
2819pub type TxExtension = (
2820	frame_system::AuthorizeCall<Runtime>,
2821	frame_system::CheckNonZeroSender<Runtime>,
2822	frame_system::CheckSpecVersion<Runtime>,
2823	frame_system::CheckTxVersion<Runtime>,
2824	frame_system::CheckGenesis<Runtime>,
2825	frame_system::CheckEra<Runtime>,
2826	frame_system::CheckNonce<Runtime>,
2827	frame_system::CheckWeight<Runtime>,
2828	pallet_skip_feeless_payment::SkipCheckIfFeeless<
2829		Runtime,
2830		pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
2831	>,
2832	frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
2833	frame_system::WeightReclaim<Runtime>,
2834);
2835
2836#[derive(Clone, PartialEq, Eq, Debug)]
2837pub struct EthExtraImpl;
2838
2839impl EthExtra for EthExtraImpl {
2840	type Config = Runtime;
2841	type Extension = TxExtension;
2842
2843	fn get_eth_extension(nonce: u32, tip: Balance) -> Self::Extension {
2844		(
2845			frame_system::AuthorizeCall::<Runtime>::new(),
2846			frame_system::CheckNonZeroSender::<Runtime>::new(),
2847			frame_system::CheckSpecVersion::<Runtime>::new(),
2848			frame_system::CheckTxVersion::<Runtime>::new(),
2849			frame_system::CheckGenesis::<Runtime>::new(),
2850			frame_system::CheckEra::from(crate::generic::Era::Immortal),
2851			frame_system::CheckNonce::<Runtime>::from(nonce),
2852			frame_system::CheckWeight::<Runtime>::new(),
2853			pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(tip, None)
2854				.into(),
2855			frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
2856			frame_system::WeightReclaim::<Runtime>::new(),
2857		)
2858	}
2859}
2860
2861/// Unchecked extrinsic type as expected by this runtime.
2862pub type UncheckedExtrinsic =
2863	pallet_revive::evm::runtime::UncheckedExtrinsic<Address, Signature, EthExtraImpl>;
2864/// Unchecked signature payload type as expected by this runtime.
2865pub type UncheckedSignaturePayload =
2866	generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
2867/// The payload being signed in transactions.
2868pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
2869/// Extrinsic type that has already been checked.
2870pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, TxExtension>;
2871/// Executive: handles dispatch to the various modules.
2872pub type Executive = frame_executive::Executive<
2873	Runtime,
2874	Block,
2875	frame_system::ChainContext<Runtime>,
2876	Runtime,
2877	AllPalletsWithSystem,
2878>;
2879
2880// We don't have a limit in the Relay Chain.
2881const IDENTITY_MIGRATION_KEY_LIMIT: u64 = u64::MAX;
2882
2883// All migrations executed on runtime upgrade as a nested tuple of types implementing
2884// `OnRuntimeUpgrade`. Note: These are examples and do not need to be run directly
2885// after the genesis block.
2886type Migrations = (
2887	pallet_nomination_pools::migration::versioned::V6ToV7<Runtime>,
2888	pallet_alliance::migration::Migration<Runtime>,
2889	pallet_contracts::Migration<Runtime>,
2890	pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
2891);
2892
2893type EventRecord = frame_system::EventRecord<
2894	<Runtime as frame_system::Config>::RuntimeEvent,
2895	<Runtime as frame_system::Config>::Hash,
2896>;
2897
2898parameter_types! {
2899	pub const BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
2900}
2901
2902impl pallet_beefy::Config for Runtime {
2903	type BeefyId = BeefyId;
2904	type MaxAuthorities = MaxAuthorities;
2905	type MaxNominators = ConstU32<0>;
2906	type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
2907	type OnNewValidatorSet = MmrLeaf;
2908	type AncestryHelper = MmrLeaf;
2909	type WeightInfo = ();
2910	type KeyOwnerProof = sp_session::MembershipProof;
2911	type EquivocationReportSystem =
2912		pallet_beefy::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
2913}
2914
2915/// MMR helper types.
2916mod mmr {
2917	use super::*;
2918	pub use pallet_mmr::primitives::*;
2919
2920	pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
2921	pub type Hash = <Hashing as sp_runtime::traits::Hash>::Output;
2922	pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
2923}
2924
2925#[cfg(feature = "runtime-benchmarks")]
2926pub struct AssetConversionTxHelper;
2927
2928#[cfg(feature = "runtime-benchmarks")]
2929impl
2930	pallet_asset_conversion_tx_payment::BenchmarkHelperTrait<
2931		AccountId,
2932		NativeOrWithId<u32>,
2933		NativeOrWithId<u32>,
2934	> for AssetConversionTxHelper
2935{
2936	fn create_asset_id_parameter(seed: u32) -> (NativeOrWithId<u32>, NativeOrWithId<u32>) {
2937		(NativeOrWithId::WithId(seed), NativeOrWithId::WithId(seed))
2938	}
2939
2940	fn setup_balances_and_pool(asset_id: NativeOrWithId<u32>, account: AccountId) {
2941		use frame_support::{assert_ok, traits::fungibles::Mutate};
2942		let NativeOrWithId::WithId(asset_idx) = asset_id.clone() else { unimplemented!() };
2943		assert_ok!(Assets::force_create(
2944			RuntimeOrigin::root(),
2945			asset_idx.into(),
2946			account.clone().into(), /* owner */
2947			true,                   /* is_sufficient */
2948			1,
2949		));
2950
2951		let lp_provider = account.clone();
2952		let _ = Balances::deposit_creating(&lp_provider, ((u64::MAX as u128) * 100).into());
2953		assert_ok!(Assets::mint_into(
2954			asset_idx.into(),
2955			&lp_provider,
2956			((u64::MAX as u128) * 100).into()
2957		));
2958
2959		let token_native = alloc::boxed::Box::new(NativeOrWithId::Native);
2960		let token_second = alloc::boxed::Box::new(asset_id);
2961
2962		assert_ok!(AssetConversion::create_pool(
2963			RuntimeOrigin::signed(lp_provider.clone()),
2964			token_native.clone(),
2965			token_second.clone()
2966		));
2967
2968		assert_ok!(AssetConversion::add_liquidity(
2969			RuntimeOrigin::signed(lp_provider.clone()),
2970			token_native,
2971			token_second,
2972			u64::MAX.into(), // 1 desired
2973			u64::MAX.into(), // 2 desired
2974			1,               // 1 min
2975			1,               // 2 min
2976			lp_provider,
2977		));
2978	}
2979}
2980
2981#[cfg(feature = "runtime-benchmarks")]
2982mod benches {
2983	polkadot_sdk::frame_benchmarking::define_benchmarks!(
2984		[frame_benchmarking, BaselineBench::<Runtime>]
2985		[frame_benchmarking_pallet_pov, Pov]
2986		[pallet_alliance, Alliance]
2987		[pallet_assets, Assets]
2988		[pallet_babe, Babe]
2989		[pallet_bags_list, VoterList]
2990		[pallet_balances, Balances]
2991		[pallet_beefy_mmr, MmrLeaf]
2992		[pallet_bounties, Bounties]
2993		[pallet_broker, Broker]
2994		[pallet_child_bounties, ChildBounties]
2995		[pallet_collective, Council]
2996		[pallet_conviction_voting, ConvictionVoting]
2997		[pallet_contracts, Contracts]
2998		[pallet_revive, Revive]
2999		[pallet_core_fellowship, CoreFellowship]
3000		[pallet_example_tasks, TasksExample]
3001		[pallet_democracy, Democracy]
3002		[pallet_asset_conversion, AssetConversion]
3003		[pallet_asset_rewards, AssetRewards]
3004		[pallet_asset_conversion_tx_payment, AssetConversionTxPayment]
3005		[pallet_transaction_payment, TransactionPayment]
3006		[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
3007		[pallet_election_provider_support_benchmarking, EPSBench::<Runtime>]
3008		[pallet_elections_phragmen, Elections]
3009		[pallet_fast_unstake, FastUnstake]
3010		[pallet_nis, Nis]
3011		[pallet_parameters, Parameters]
3012		[pallet_grandpa, Grandpa]
3013		[pallet_identity, Identity]
3014		[pallet_im_online, ImOnline]
3015		[pallet_indices, Indices]
3016		[pallet_lottery, Lottery]
3017		[pallet_membership, TechnicalMembership]
3018		[pallet_message_queue, MessageQueue]
3019		[pallet_migrations, MultiBlockMigrations]
3020		[pallet_mmr, Mmr]
3021		[pallet_multisig, Multisig]
3022		[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
3023		[pallet_offences, OffencesBench::<Runtime>]
3024		[pallet_preimage, Preimage]
3025		[pallet_proxy, Proxy]
3026		[pallet_ranked_collective, RankedCollective]
3027		[pallet_referenda, Referenda]
3028		[pallet_recovery, Recovery]
3029		[pallet_remark, Remark]
3030		[pallet_salary, Salary]
3031		[pallet_scheduler, Scheduler]
3032		[pallet_glutton, Glutton]
3033		[pallet_session, SessionBench::<Runtime>]
3034		[pallet_society, Society]
3035		[pallet_staking, Staking]
3036		[pallet_state_trie_migration, StateTrieMigration]
3037		[pallet_sudo, Sudo]
3038		[frame_system, SystemBench::<Runtime>]
3039		[frame_system_extensions, SystemExtensionsBench::<Runtime>]
3040		[pallet_timestamp, Timestamp]
3041		[pallet_tips, Tips]
3042		[pallet_transaction_storage, TransactionStorage]
3043		[pallet_treasury, Treasury]
3044		[pallet_asset_rate, AssetRate]
3045		[pallet_uniques, Uniques]
3046		[pallet_nfts, Nfts]
3047		[pallet_nft_fractionalization, NftFractionalization]
3048		[pallet_utility, Utility]
3049		[pallet_vesting, Vesting]
3050		[pallet_whitelist, Whitelist]
3051		[pallet_tx_pause, TxPause]
3052		[pallet_safe_mode, SafeMode]
3053		[pallet_example_mbm, PalletExampleMbms]
3054		[pallet_asset_conversion_ops, AssetConversionMigration]
3055		[pallet_verify_signature, VerifySignature]
3056		[pallet_meta_tx, MetaTx]
3057	);
3058}
3059
3060pallet_revive::impl_runtime_apis_plus_revive!(
3061	Runtime,
3062	Executive,
3063	EthExtraImpl,
3064
3065	impl sp_api::Core<Block> for Runtime {
3066		fn version() -> RuntimeVersion {
3067			VERSION
3068		}
3069
3070		fn execute_block(block: Block) {
3071			Executive::execute_block(block);
3072		}
3073
3074		fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
3075			Executive::initialize_block(header)
3076		}
3077	}
3078
3079	impl sp_api::Metadata<Block> for Runtime {
3080		fn metadata() -> OpaqueMetadata {
3081			OpaqueMetadata::new(Runtime::metadata().into())
3082		}
3083
3084		fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
3085			Runtime::metadata_at_version(version)
3086		}
3087
3088		fn metadata_versions() -> alloc::vec::Vec<u32> {
3089			Runtime::metadata_versions()
3090		}
3091	}
3092
3093	impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
3094		fn execute_view_function(id: frame_support::view_functions::ViewFunctionId, input: Vec<u8>) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
3095			Runtime::execute_view_function(id, input)
3096		}
3097	}
3098
3099	impl sp_block_builder::BlockBuilder<Block> for Runtime {
3100		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
3101			Executive::apply_extrinsic(extrinsic)
3102		}
3103
3104		fn finalize_block() -> <Block as BlockT>::Header {
3105			Executive::finalize_block()
3106		}
3107
3108		fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
3109			data.create_extrinsics()
3110		}
3111
3112		fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
3113			data.check_extrinsics(&block)
3114		}
3115	}
3116
3117	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
3118		fn validate_transaction(
3119			source: TransactionSource,
3120			tx: <Block as BlockT>::Extrinsic,
3121			block_hash: <Block as BlockT>::Hash,
3122		) -> TransactionValidity {
3123			Executive::validate_transaction(source, tx, block_hash)
3124		}
3125	}
3126
3127	impl sp_statement_store::runtime_api::ValidateStatement<Block> for Runtime {
3128		fn validate_statement(
3129			source: sp_statement_store::runtime_api::StatementSource,
3130			statement: sp_statement_store::Statement,
3131		) -> Result<sp_statement_store::runtime_api::ValidStatement, sp_statement_store::runtime_api::InvalidStatement> {
3132			Statement::validate_statement(source, statement)
3133		}
3134	}
3135
3136	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
3137		fn offchain_worker(header: &<Block as BlockT>::Header) {
3138			Executive::offchain_worker(header)
3139		}
3140	}
3141
3142	impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
3143		fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
3144			Grandpa::grandpa_authorities()
3145		}
3146
3147		fn current_set_id() -> sp_consensus_grandpa::SetId {
3148			pallet_grandpa::CurrentSetId::<Runtime>::get()
3149		}
3150
3151		fn submit_report_equivocation_unsigned_extrinsic(
3152			equivocation_proof: sp_consensus_grandpa::EquivocationProof<
3153				<Block as BlockT>::Hash,
3154				NumberFor<Block>,
3155			>,
3156			key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
3157		) -> Option<()> {
3158			let key_owner_proof = key_owner_proof.decode()?;
3159
3160			Grandpa::submit_unsigned_equivocation_report(
3161				equivocation_proof,
3162				key_owner_proof,
3163			)
3164		}
3165
3166		fn generate_key_ownership_proof(
3167			_set_id: sp_consensus_grandpa::SetId,
3168			authority_id: GrandpaId,
3169		) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
3170			use codec::Encode;
3171
3172			Historical::prove((sp_consensus_grandpa::KEY_TYPE, authority_id))
3173				.map(|p| p.encode())
3174				.map(sp_consensus_grandpa::OpaqueKeyOwnershipProof::new)
3175		}
3176	}
3177
3178	impl pallet_nomination_pools_runtime_api::NominationPoolsApi<Block, AccountId, Balance> for Runtime {
3179		fn pending_rewards(who: AccountId) -> Balance {
3180			NominationPools::api_pending_rewards(who).unwrap_or_default()
3181		}
3182
3183		fn points_to_balance(pool_id: PoolId, points: Balance) -> Balance {
3184			NominationPools::api_points_to_balance(pool_id, points)
3185		}
3186
3187		fn balance_to_points(pool_id: PoolId, new_funds: Balance) -> Balance {
3188			NominationPools::api_balance_to_points(pool_id, new_funds)
3189		}
3190
3191		fn pool_pending_slash(pool_id: PoolId) -> Balance {
3192			NominationPools::api_pool_pending_slash(pool_id)
3193		}
3194
3195		fn member_pending_slash(member: AccountId) -> Balance {
3196			NominationPools::api_member_pending_slash(member)
3197		}
3198
3199		fn pool_needs_delegate_migration(pool_id: PoolId) -> bool {
3200			NominationPools::api_pool_needs_delegate_migration(pool_id)
3201		}
3202
3203		fn member_needs_delegate_migration(member: AccountId) -> bool {
3204			NominationPools::api_member_needs_delegate_migration(member)
3205		}
3206
3207		fn member_total_balance(member: AccountId) -> Balance {
3208			NominationPools::api_member_total_balance(member)
3209		}
3210
3211		fn pool_balance(pool_id: PoolId) -> Balance {
3212			NominationPools::api_pool_balance(pool_id)
3213		}
3214
3215		fn pool_accounts(pool_id: PoolId) -> (AccountId, AccountId) {
3216			NominationPools::api_pool_accounts(pool_id)
3217		}
3218	}
3219
3220	impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
3221		fn nominations_quota(balance: Balance) -> u32 {
3222			Staking::api_nominations_quota(balance)
3223		}
3224
3225		fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
3226			Staking::api_eras_stakers_page_count(era, account)
3227		}
3228
3229		fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool {
3230			Staking::api_pending_rewards(era, account)
3231		}
3232	}
3233
3234	impl sp_consensus_babe::BabeApi<Block> for Runtime {
3235		fn configuration() -> sp_consensus_babe::BabeConfiguration {
3236			let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
3237			sp_consensus_babe::BabeConfiguration {
3238				slot_duration: Babe::slot_duration(),
3239				epoch_length: EpochDuration::get(),
3240				c: epoch_config.c,
3241				authorities: Babe::authorities().to_vec(),
3242				randomness: Babe::randomness(),
3243				allowed_slots: epoch_config.allowed_slots,
3244			}
3245		}
3246
3247		fn current_epoch_start() -> sp_consensus_babe::Slot {
3248			Babe::current_epoch_start()
3249		}
3250
3251		fn current_epoch() -> sp_consensus_babe::Epoch {
3252			Babe::current_epoch()
3253		}
3254
3255		fn next_epoch() -> sp_consensus_babe::Epoch {
3256			Babe::next_epoch()
3257		}
3258
3259		fn generate_key_ownership_proof(
3260			_slot: sp_consensus_babe::Slot,
3261			authority_id: sp_consensus_babe::AuthorityId,
3262		) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
3263			use codec::Encode;
3264
3265			Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
3266				.map(|p| p.encode())
3267				.map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
3268		}
3269
3270		fn submit_report_equivocation_unsigned_extrinsic(
3271			equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
3272			key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
3273		) -> Option<()> {
3274			let key_owner_proof = key_owner_proof.decode()?;
3275
3276			Babe::submit_unsigned_equivocation_report(
3277				equivocation_proof,
3278				key_owner_proof,
3279			)
3280		}
3281	}
3282
3283	impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
3284		fn authorities() -> Vec<AuthorityDiscoveryId> {
3285			AuthorityDiscovery::authorities()
3286		}
3287	}
3288
3289	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
3290		fn account_nonce(account: AccountId) -> Nonce {
3291			System::account_nonce(account)
3292		}
3293	}
3294
3295	impl assets_api::AssetsApi<
3296		Block,
3297		AccountId,
3298		Balance,
3299		u32,
3300	> for Runtime
3301	{
3302		fn account_balances(account: AccountId) -> Vec<(u32, Balance)> {
3303			Assets::account_balances(account)
3304		}
3305	}
3306
3307	impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash, EventRecord> for Runtime
3308	{
3309		fn call(
3310			origin: AccountId,
3311			dest: AccountId,
3312			value: Balance,
3313			gas_limit: Option<Weight>,
3314			storage_deposit_limit: Option<Balance>,
3315			input_data: Vec<u8>,
3316		) -> pallet_contracts::ContractExecResult<Balance, EventRecord> {
3317			let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
3318			Contracts::bare_call(
3319				origin,
3320				dest,
3321				value,
3322				gas_limit,
3323				storage_deposit_limit,
3324				input_data,
3325				pallet_contracts::DebugInfo::UnsafeDebug,
3326				pallet_contracts::CollectEvents::UnsafeCollect,
3327				pallet_contracts::Determinism::Enforced,
3328			)
3329		}
3330
3331		fn instantiate(
3332			origin: AccountId,
3333			value: Balance,
3334			gas_limit: Option<Weight>,
3335			storage_deposit_limit: Option<Balance>,
3336			code: pallet_contracts::Code<Hash>,
3337			data: Vec<u8>,
3338			salt: Vec<u8>,
3339		) -> pallet_contracts::ContractInstantiateResult<AccountId, Balance, EventRecord>
3340		{
3341			let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
3342			Contracts::bare_instantiate(
3343				origin,
3344				value,
3345				gas_limit,
3346				storage_deposit_limit,
3347				code,
3348				data,
3349				salt,
3350				pallet_contracts::DebugInfo::UnsafeDebug,
3351				pallet_contracts::CollectEvents::UnsafeCollect,
3352			)
3353		}
3354
3355		fn upload_code(
3356			origin: AccountId,
3357			code: Vec<u8>,
3358			storage_deposit_limit: Option<Balance>,
3359			determinism: pallet_contracts::Determinism,
3360		) -> pallet_contracts::CodeUploadResult<Hash, Balance>
3361		{
3362			Contracts::bare_upload_code(
3363				origin,
3364				code,
3365				storage_deposit_limit,
3366				determinism,
3367			)
3368		}
3369
3370		fn get_storage(
3371			address: AccountId,
3372			key: Vec<u8>,
3373		) -> pallet_contracts::GetStorageResult {
3374			Contracts::get_storage(
3375				address,
3376				key
3377			)
3378		}
3379	}
3380
3381	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
3382		Block,
3383		Balance,
3384	> for Runtime {
3385		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
3386			TransactionPayment::query_info(uxt, len)
3387		}
3388		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
3389			TransactionPayment::query_fee_details(uxt, len)
3390		}
3391		fn query_weight_to_fee(weight: Weight) -> Balance {
3392			TransactionPayment::weight_to_fee(weight)
3393		}
3394		fn query_length_to_fee(length: u32) -> Balance {
3395			TransactionPayment::length_to_fee(length)
3396		}
3397	}
3398
3399	impl pallet_asset_conversion::AssetConversionApi<
3400		Block,
3401		Balance,
3402		NativeOrWithId<u32>
3403	> for Runtime
3404	{
3405		fn quote_price_exact_tokens_for_tokens(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>, amount: Balance, include_fee: bool) -> Option<Balance> {
3406			AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
3407		}
3408
3409		fn quote_price_tokens_for_exact_tokens(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>, amount: Balance, include_fee: bool) -> Option<Balance> {
3410			AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
3411		}
3412
3413		fn get_reserves(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>) -> Option<(Balance, Balance)> {
3414			AssetConversion::get_reserves(asset1, asset2).ok()
3415		}
3416	}
3417
3418	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
3419		for Runtime
3420	{
3421		fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo<Balance> {
3422			TransactionPayment::query_call_info(call, len)
3423		}
3424		fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails<Balance> {
3425			TransactionPayment::query_call_fee_details(call, len)
3426		}
3427		fn query_weight_to_fee(weight: Weight) -> Balance {
3428			TransactionPayment::weight_to_fee(weight)
3429		}
3430		fn query_length_to_fee(length: u32) -> Balance {
3431			TransactionPayment::length_to_fee(length)
3432		}
3433	}
3434
3435	impl pallet_nfts_runtime_api::NftsApi<Block, AccountId, u32, u32> for Runtime {
3436		fn owner(collection: u32, item: u32) -> Option<AccountId> {
3437			<Nfts as Inspect<AccountId>>::owner(&collection, &item)
3438		}
3439
3440		fn collection_owner(collection: u32) -> Option<AccountId> {
3441			<Nfts as Inspect<AccountId>>::collection_owner(&collection)
3442		}
3443
3444		fn attribute(
3445			collection: u32,
3446			item: u32,
3447			key: Vec<u8>,
3448		) -> Option<Vec<u8>> {
3449			<Nfts as Inspect<AccountId>>::attribute(&collection, &item, &key)
3450		}
3451
3452		fn custom_attribute(
3453			account: AccountId,
3454			collection: u32,
3455			item: u32,
3456			key: Vec<u8>,
3457		) -> Option<Vec<u8>> {
3458			<Nfts as Inspect<AccountId>>::custom_attribute(
3459				&account,
3460				&collection,
3461				&item,
3462				&key,
3463			)
3464		}
3465
3466		fn system_attribute(
3467			collection: u32,
3468			item: Option<u32>,
3469			key: Vec<u8>,
3470		) -> Option<Vec<u8>> {
3471			<Nfts as Inspect<AccountId>>::system_attribute(&collection, item.as_ref(), &key)
3472		}
3473
3474		fn collection_attribute(collection: u32, key: Vec<u8>) -> Option<Vec<u8>> {
3475			<Nfts as Inspect<AccountId>>::collection_attribute(&collection, &key)
3476		}
3477	}
3478
3479	#[api_version(5)]
3480	impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
3481		fn beefy_genesis() -> Option<BlockNumber> {
3482			pallet_beefy::GenesisBlock::<Runtime>::get()
3483		}
3484
3485		fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
3486			Beefy::validator_set()
3487		}
3488
3489		fn submit_report_double_voting_unsigned_extrinsic(
3490			equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
3491				BlockNumber,
3492				BeefyId,
3493				BeefySignature,
3494			>,
3495			key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3496		) -> Option<()> {
3497			let key_owner_proof = key_owner_proof.decode()?;
3498
3499			Beefy::submit_unsigned_double_voting_report(
3500				equivocation_proof,
3501				key_owner_proof,
3502			)
3503		}
3504
3505		fn submit_report_fork_voting_unsigned_extrinsic(
3506			equivocation_proof:
3507				sp_consensus_beefy::ForkVotingProof<
3508					<Block as BlockT>::Header,
3509					BeefyId,
3510					sp_runtime::OpaqueValue
3511				>,
3512			key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3513		) -> Option<()> {
3514			Beefy::submit_unsigned_fork_voting_report(
3515				equivocation_proof.try_into()?,
3516				key_owner_proof.decode()?,
3517			)
3518		}
3519
3520		fn submit_report_future_block_voting_unsigned_extrinsic(
3521			equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
3522			key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3523		) -> Option<()> {
3524			Beefy::submit_unsigned_future_block_voting_report(
3525				equivocation_proof,
3526				key_owner_proof.decode()?,
3527			)
3528		}
3529
3530		fn generate_key_ownership_proof(
3531			_set_id: sp_consensus_beefy::ValidatorSetId,
3532			authority_id: BeefyId,
3533		) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
3534			Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
3535				.map(|p| p.encode())
3536				.map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
3537		}
3538
3539		fn generate_ancestry_proof(
3540			prev_block_number: BlockNumber,
3541			best_known_block_number: Option<BlockNumber>,
3542		) -> Option<sp_runtime::OpaqueValue> {
3543			use sp_consensus_beefy::AncestryHelper;
3544
3545			MmrLeaf::generate_proof(prev_block_number, best_known_block_number)
3546				.map(|p| p.encode())
3547				.map(sp_runtime::OpaqueValue::new)
3548		}
3549	}
3550
3551	impl pallet_mmr::primitives::MmrApi<
3552		Block,
3553		mmr::Hash,
3554		BlockNumber,
3555	> for Runtime {
3556		fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
3557			Ok(pallet_mmr::RootHash::<Runtime>::get())
3558		}
3559
3560		fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
3561			Ok(pallet_mmr::NumberOfLeaves::<Runtime>::get())
3562		}
3563
3564		fn generate_proof(
3565			block_numbers: Vec<BlockNumber>,
3566			best_known_block_number: Option<BlockNumber>,
3567		) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<mmr::Hash>), mmr::Error> {
3568			Mmr::generate_proof(block_numbers, best_known_block_number).map(
3569				|(leaves, proof)| {
3570					(
3571						leaves
3572							.into_iter()
3573							.map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
3574							.collect(),
3575						proof,
3576					)
3577				},
3578			)
3579		}
3580
3581		fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::LeafProof<mmr::Hash>)
3582			-> Result<(), mmr::Error>
3583		{
3584			let leaves = leaves.into_iter().map(|leaf|
3585				leaf.into_opaque_leaf()
3586				.try_decode()
3587				.ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;
3588			Mmr::verify_leaves(leaves, proof)
3589		}
3590
3591		fn verify_proof_stateless(
3592			root: mmr::Hash,
3593			leaves: Vec<mmr::EncodableOpaqueLeaf>,
3594			proof: mmr::LeafProof<mmr::Hash>
3595		) -> Result<(), mmr::Error> {
3596			let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
3597			pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)
3598		}
3599	}
3600
3601	impl sp_mixnet::runtime_api::MixnetApi<Block> for Runtime {
3602		fn session_status() -> sp_mixnet::types::SessionStatus {
3603			Mixnet::session_status()
3604		}
3605
3606		fn prev_mixnodes() -> Result<Vec<sp_mixnet::types::Mixnode>, sp_mixnet::types::MixnodesErr> {
3607			Mixnet::prev_mixnodes()
3608		}
3609
3610		fn current_mixnodes() -> Result<Vec<sp_mixnet::types::Mixnode>, sp_mixnet::types::MixnodesErr> {
3611			Mixnet::current_mixnodes()
3612		}
3613
3614		fn maybe_register(session_index: sp_mixnet::types::SessionIndex, mixnode: sp_mixnet::types::Mixnode) -> bool {
3615			Mixnet::maybe_register(session_index, mixnode)
3616		}
3617	}
3618
3619	impl sp_session::SessionKeys<Block> for Runtime {
3620		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
3621			SessionKeys::generate(seed)
3622		}
3623
3624		fn decode_session_keys(
3625			encoded: Vec<u8>,
3626		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
3627			SessionKeys::decode_into_raw_public_keys(&encoded)
3628		}
3629	}
3630
3631	impl pallet_asset_rewards::AssetRewards<Block, Balance> for Runtime {
3632		fn pool_creation_cost() -> Balance {
3633			StakePoolCreationDeposit::get()
3634		}
3635	}
3636
3637	#[cfg(feature = "try-runtime")]
3638	impl frame_try_runtime::TryRuntime<Block> for Runtime {
3639		fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
3640			// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
3641			// have a backtrace here. If any of the pre/post migration checks fail, we shall stop
3642			// right here and right now.
3643			let weight = Executive::try_runtime_upgrade(checks).unwrap();
3644			(weight, RuntimeBlockWeights::get().max_block)
3645		}
3646
3647		fn execute_block(
3648			block: Block,
3649			state_root_check: bool,
3650			signature_check: bool,
3651			select: frame_try_runtime::TryStateSelect
3652		) -> Weight {
3653			// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
3654			// have a backtrace here.
3655			Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
3656		}
3657	}
3658
3659	#[cfg(feature = "runtime-benchmarks")]
3660	impl frame_benchmarking::Benchmark<Block> for Runtime {
3661		fn benchmark_metadata(extra: bool) -> (
3662			Vec<frame_benchmarking::BenchmarkList>,
3663			Vec<frame_support::traits::StorageInfo>,
3664		) {
3665			use frame_benchmarking::{baseline, BenchmarkList};
3666			use frame_support::traits::StorageInfoTrait;
3667
3668			// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency
3669			// issues. To get around that, we separated the Session benchmarks into its own crate,
3670			// which is why we need these two lines below.
3671			use pallet_session_benchmarking::Pallet as SessionBench;
3672			use pallet_offences_benchmarking::Pallet as OffencesBench;
3673			use pallet_election_provider_support_benchmarking::Pallet as EPSBench;
3674			use frame_system_benchmarking::Pallet as SystemBench;
3675			use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
3676			use baseline::Pallet as BaselineBench;
3677			use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
3678
3679			let mut list = Vec::<BenchmarkList>::new();
3680			list_benchmarks!(list, extra);
3681
3682			let storage_info = AllPalletsWithSystem::storage_info();
3683
3684			(list, storage_info)
3685		}
3686
3687		#[allow(non_local_definitions)]
3688		fn dispatch_benchmark(
3689			config: frame_benchmarking::BenchmarkConfig
3690		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
3691			use frame_benchmarking::{baseline, BenchmarkBatch};
3692			use sp_storage::TrackedStorageKey;
3693
3694			// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency
3695			// issues. To get around that, we separated the Session benchmarks into its own crate,
3696			// which is why we need these two lines below.
3697			use pallet_session_benchmarking::Pallet as SessionBench;
3698			use pallet_offences_benchmarking::Pallet as OffencesBench;
3699			use pallet_election_provider_support_benchmarking::Pallet as EPSBench;
3700			use frame_system_benchmarking::Pallet as SystemBench;
3701			use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
3702			use baseline::Pallet as BaselineBench;
3703			use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
3704
3705			impl pallet_session_benchmarking::Config for Runtime {}
3706			impl pallet_offences_benchmarking::Config for Runtime {}
3707			impl pallet_election_provider_support_benchmarking::Config for Runtime {}
3708			impl frame_system_benchmarking::Config for Runtime {}
3709			impl baseline::Config for Runtime {}
3710			impl pallet_nomination_pools_benchmarking::Config for Runtime {}
3711
3712			use frame_support::traits::WhitelistedStorageKeys;
3713			let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
3714
3715			// Treasury Account
3716			// TODO: this is manual for now, someday we might be able to use a
3717			// macro for this particular key
3718			let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
3719			whitelist.push(treasury_key.to_vec().into());
3720
3721			let mut batches = Vec::<BenchmarkBatch>::new();
3722			let params = (&config, &whitelist);
3723			add_benchmarks!(params, batches);
3724			Ok(batches)
3725		}
3726	}
3727
3728	impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
3729		fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
3730			build_state::<RuntimeGenesisConfig>(config)
3731		}
3732
3733		fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
3734			get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
3735		}
3736
3737		fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
3738			genesis_config_presets::preset_names()
3739		}
3740	}
3741
3742);
3743
3744#[cfg(test)]
3745mod tests {
3746	use super::*;
3747	use frame_system::offchain::CreateSignedTransaction;
3748
3749	#[test]
3750	fn validate_transaction_submitter_bounds() {
3751		fn is_submit_signed_transaction<T>()
3752		where
3753			T: CreateSignedTransaction<RuntimeCall>,
3754		{
3755		}
3756
3757		is_submit_signed_transaction::<Runtime>();
3758	}
3759
3760	#[test]
3761	fn call_size() {
3762		let size = core::mem::size_of::<RuntimeCall>();
3763		assert!(
3764			size <= CALL_PARAMS_MAX_SIZE,
3765			"size of RuntimeCall {} is more than {CALL_PARAMS_MAX_SIZE} bytes.
3766			 Some calls have too big arguments, use Box to reduce the size of RuntimeCall.
3767			 If the limit is too strong, maybe consider increase the limit.",
3768			size,
3769		);
3770	}
3771}