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