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_multi_asset_bounties::ArgumentsFactory as PalletMultiAssetBountiesArgumentsFactory;
30#[cfg(feature = "runtime-benchmarks")]
31use pallet_treasury::ArgumentsFactory as PalletTreasuryArgumentsFactory;
32#[cfg(feature = "runtime-benchmarks")]
33use polkadot_sdk::sp_core::crypto::FromEntropy;
34
35use polkadot_sdk::*;
36
37use alloc::{vec, vec::Vec};
38use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
39use frame_election_provider_support::{
40 bounds::{ElectionBounds, ElectionBoundsBuilder},
41 onchain, BalancingConfig, ElectionDataProvider, SequentialPhragmen, VoteWeight,
42};
43use frame_support::{
44 derive_impl,
45 dispatch::DispatchClass,
46 dynamic_params::{dynamic_pallet_params, dynamic_params},
47 genesis_builder_helper::{build_state, get_preset},
48 instances::{Instance1, Instance2},
49 ord_parameter_types,
50 pallet_prelude::Get,
51 parameter_types,
52 traits::{
53 fungible::{
54 Balanced, Credit, HoldConsideration, ItemOf, NativeFromLeft, NativeOrWithId, UnionOf,
55 },
56 tokens::{
57 imbalance::{ResolveAssetTo, ResolveTo},
58 nonfungibles_v2::Inspect,
59 pay::PayAssetFromAccount,
60 GetSalary, PayFromAccount, PayWithFungibles,
61 },
62 AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32, ConstU64,
63 ConstantStoragePrice, Contains, Currency, EitherOfDiverse, EnsureOriginWithArg,
64 EqualPrivilegeOnly, InsideBoth, InstanceFilter, KeyOwnerProofSystem, LinearStoragePrice,
65 LockIdentifier, Nothing, OnUnbalanced, WithdrawReasons,
66 },
67 weights::{
68 constants::{
69 BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND,
70 },
71 ConstantMultiplier, Weight,
72 },
73 BoundedVec, PalletId,
74};
75use frame_system::{
76 limits::{BlockLength, BlockWeights},
77 EnsureAuthorized, EnsureRoot, EnsureRootWithSuccess, EnsureSigned, EnsureSignedBy,
78 EnsureWithSuccess,
79};
80pub use node_primitives::{AccountId, Signature};
81use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Moment, Nonce};
82use pallet_asset_conversion::{AccountIdConverter, Ascending, Chain, WithFirstAsset};
83use pallet_asset_conversion_tx_payment::SwapAssetAdapter;
84use pallet_assets_precompiles::{InlineIdConfig, ERC20};
85use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, TaskId};
86use pallet_election_provider_multi_phase::{GeometricDepositBase, SolutionAccuracyOf};
87use pallet_identity::legacy::IdentityInfo;
88use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
89use pallet_nfts::PalletFeatures;
90use pallet_nis::WithMaximumOf;
91use pallet_nomination_pools::PoolId;
92use pallet_revive::evm::runtime::EthExtra;
93use pallet_session::historical as pallet_session_historical;
94use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
95pub use pallet_transaction_payment::{FungibleAdapter, Multiplier, TargetedFeeAdjustment};
96use pallet_tx_pause::RuntimeCallNameOf;
97use pallet_vesting_precompiles::Vesting as VestingPrecompile;
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, Debug, FixedPointNumber, FixedU128, MultiSignature, MultiSigner, Perbill,
116 Percent, Permill, Perquintill,
117};
118use sp_std::{borrow::Cow, prelude::*};
119use sp_version::RuntimeVersion;
120use static_assertions::const_assert;
121
122#[cfg(any(feature = "std", test))]
123pub use frame_system::Call as SystemCall;
124#[cfg(any(feature = "std", test))]
125pub use pallet_balances::Call as BalancesCall;
126#[cfg(any(feature = "std", test))]
127pub use pallet_sudo::Call as SudoCall;
128#[cfg(any(feature = "std", test))]
129pub use sp_runtime::BuildStorage;
130
131pub use pallet_staking::StakerStatus;
132
133pub mod impls;
135#[cfg(not(feature = "runtime-benchmarks"))]
136use impls::AllianceIdentityVerifier;
137use impls::AllianceProposalProvider;
138
139pub mod constants;
141use constants::{currency::*, time::*};
142use sp_runtime::generic::Era;
143
144mod voter_bags;
146
147pub mod assets_api;
149
150pub mod genesis_config_presets;
152
153#[cfg(feature = "std")]
155include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
156
157#[cfg(test)]
160pub const CALL_PARAMS_MAX_SIZE: usize = 512;
161
162#[cfg(feature = "std")]
164pub fn wasm_binary_unwrap() -> &'static [u8] {
165 WASM_BINARY.expect(
166 "Development wasm binary is not available. This means the client is built with \
167 `SKIP_WASM_BUILD` flag and it is only usable for production chains. Please rebuild with \
168 the flag disabled.",
169 )
170}
171
172#[sp_version::runtime_version]
174pub const VERSION: RuntimeVersion = RuntimeVersion {
175 spec_name: alloc::borrow::Cow::Borrowed("node"),
176 impl_name: alloc::borrow::Cow::Borrowed("substrate-node"),
177 authoring_version: 10,
178 spec_version: 271,
183 impl_version: 0,
184 apis: RUNTIME_API_VERSIONS,
185 transaction_version: 2,
186 system_version: 1,
187};
188
189pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
191 sp_consensus_babe::BabeEpochConfiguration {
192 c: PRIMARY_PROBABILITY,
193 allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots,
194 };
195
196type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
197
198const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
201const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(95);
204const MAXIMUM_BLOCK_WEIGHT: Weight =
206 Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX);
207
208parameter_types! {
209 pub const BlockHashCount: BlockNumber = 2400;
210 pub const Version: RuntimeVersion = VERSION;
211 pub RuntimeBlockLength: BlockLength = BlockLength::builder()
212 .max_length(15 * 1024 * 1024)
213 .modify_max_length_for_class(DispatchClass::Normal, |m| {
214 *m = NORMAL_DISPATCH_RATIO * *m
215 })
216 .build();
217 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
218 .base_block(BlockExecutionWeight::get())
219 .for_class(DispatchClass::all(), |weights| {
220 weights.base_extrinsic = ExtrinsicBaseWeight::get();
221 })
222 .for_class(DispatchClass::Normal, |weights| {
223 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
224 })
225 .for_class(DispatchClass::Operational, |weights| {
226 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
227 weights.reserved = Some(
230 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
231 );
232 })
233 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
234 .build_or_panic();
235 pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
236}
237
238const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct());
239
240pub struct SafeModeWhitelistedCalls;
242impl Contains<RuntimeCall> for SafeModeWhitelistedCalls {
243 fn contains(call: &RuntimeCall) -> bool {
244 match call {
245 RuntimeCall::System(_) | RuntimeCall::SafeMode(_) | RuntimeCall::TxPause(_) => true,
246 _ => false,
247 }
248 }
249}
250
251pub struct TxPauseWhitelistedCalls;
253impl Contains<RuntimeCallNameOf<Runtime>> for TxPauseWhitelistedCalls {
255 fn contains(full_name: &RuntimeCallNameOf<Runtime>) -> bool {
256 match (full_name.0.as_slice(), full_name.1.as_slice()) {
257 (b"Balances", b"transfer_keep_alive") => true,
258 _ => false,
259 }
260 }
261}
262
263#[cfg(feature = "runtime-benchmarks")]
264pub struct AssetRateArguments;
265#[cfg(feature = "runtime-benchmarks")]
266impl AssetKindFactory<NativeOrWithId<u32>> for AssetRateArguments {
267 fn create_asset_kind(seed: u32) -> NativeOrWithId<u32> {
268 if !seed.is_multiple_of(2) {
269 NativeOrWithId::Native
270 } else {
271 NativeOrWithId::WithId(seed / 2)
272 }
273 }
274}
275
276#[cfg(feature = "runtime-benchmarks")]
277pub struct PalletTreasuryArguments;
278#[cfg(feature = "runtime-benchmarks")]
279impl PalletTreasuryArgumentsFactory<NativeOrWithId<u32>, AccountId> for PalletTreasuryArguments {
280 fn create_asset_kind(seed: u32) -> NativeOrWithId<u32> {
281 if !seed.is_multiple_of(2) {
282 NativeOrWithId::Native
283 } else {
284 NativeOrWithId::WithId(seed / 2)
285 }
286 }
287
288 fn create_beneficiary(seed: [u8; 32]) -> AccountId {
289 AccountId::from_entropy(&mut seed.as_slice()).unwrap()
290 }
291}
292
293#[cfg(feature = "runtime-benchmarks")]
294pub struct PalletMultiAssetBountiesArguments;
295#[cfg(feature = "runtime-benchmarks")]
296impl PalletMultiAssetBountiesArgumentsFactory<NativeOrWithId<u32>, AccountId, u128>
297 for PalletMultiAssetBountiesArguments
298{
299 fn create_asset_kind(seed: u32) -> NativeOrWithId<u32> {
300 if !seed.is_multiple_of(2) {
301 NativeOrWithId::Native
302 } else {
303 NativeOrWithId::WithId(seed / 2)
304 }
305 }
306
307 fn create_beneficiary(seed: [u8; 32]) -> AccountId {
308 AccountId::from_entropy(&mut seed.as_slice()).unwrap()
309 }
310}
311
312impl pallet_tx_pause::Config for Runtime {
313 type RuntimeEvent = RuntimeEvent;
314 type RuntimeCall = RuntimeCall;
315 type PauseOrigin = EnsureRoot<AccountId>;
316 type UnpauseOrigin = EnsureRoot<AccountId>;
317 type WhitelistedCalls = TxPauseWhitelistedCalls;
318 type MaxNameLen = ConstU32<256>;
319 type WeightInfo = pallet_tx_pause::weights::SubstrateWeight<Runtime>;
320}
321
322parameter_types! {
323 pub const EnterDuration: BlockNumber = 4 * HOURS;
324 pub const EnterDepositAmount: Balance = 2_000_000 * DOLLARS;
325 pub const ExtendDuration: BlockNumber = 2 * HOURS;
326 pub const ExtendDepositAmount: Balance = 1_000_000 * DOLLARS;
327 pub const ReleaseDelay: u32 = 2 * DAYS;
328}
329
330impl pallet_safe_mode::Config for Runtime {
331 type RuntimeEvent = RuntimeEvent;
332 type Currency = Balances;
333 type RuntimeHoldReason = RuntimeHoldReason;
334 type WhitelistedCalls = SafeModeWhitelistedCalls;
335 type EnterDuration = EnterDuration;
336 type EnterDepositAmount = EnterDepositAmount;
337 type ExtendDuration = ExtendDuration;
338 type ExtendDepositAmount = ExtendDepositAmount;
339 type ForceEnterOrigin = EnsureRootWithSuccess<AccountId, ConstU32<9>>;
340 type ForceExtendOrigin = EnsureRootWithSuccess<AccountId, ConstU32<11>>;
341 type ForceExitOrigin = EnsureRoot<AccountId>;
342 type ForceDepositOrigin = EnsureRoot<AccountId>;
343 type ReleaseDelay = ReleaseDelay;
344 type Notify = ();
345 type WeightInfo = pallet_safe_mode::weights::SubstrateWeight<Runtime>;
346}
347
348#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
349impl frame_system::Config for Runtime {
350 type BaseCallFilter = InsideBoth<SafeMode, TxPause>;
351 type BlockWeights = RuntimeBlockWeights;
352 type BlockLength = RuntimeBlockLength;
353 type DbWeight = RocksDbWeight;
354 type Nonce = Nonce;
355 type Hash = Hash;
356 type AccountId = AccountId;
357 type Lookup = Indices;
358 type Block = Block;
359 type BlockHashCount = BlockHashCount;
360 type Version = Version;
361 type AccountData = pallet_balances::AccountData<Balance>;
362 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Runtime>;
363 type SS58Prefix = ConstU16<42>;
364 type MaxConsumers = ConstU32<16>;
365 type MultiBlockMigrator = MultiBlockMigrations;
366 type SingleBlockMigrations = Migrations;
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 Debug,
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 DoneSlashHandler = ();
597}
598
599parameter_types! {
600 pub const TransactionByteFee: Balance = 10 * MILLICENTS;
601 pub const OperationalFeeMultiplier: u8 = 5;
602 pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
603 pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000);
604 pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 10u128);
605 pub MaximumMultiplier: Multiplier = Bounded::max_value();
606}
607
608impl pallet_transaction_payment::Config for Runtime {
609 type RuntimeEvent = RuntimeEvent;
610 type OnChargeTransaction = FungibleAdapter<Balances, ResolveTo<TreasuryAccount, Balances>>;
611 type OperationalFeeMultiplier = OperationalFeeMultiplier;
612 type WeightToFee = pallet_revive::evm::fees::BlockRatioFee<1, 1, Self, Balance>;
613 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
614 type FeeMultiplierUpdate = TargetedFeeAdjustment<
615 Self,
616 TargetBlockFullness,
617 AdjustmentVariable,
618 MinimumMultiplier,
619 MaximumMultiplier,
620 >;
621 type WeightInfo = pallet_transaction_payment::weights::SubstrateWeight<Runtime>;
622}
623
624pub type AssetsFreezerInstance = pallet_assets_freezer::Instance1;
625impl pallet_assets_freezer::Config<AssetsFreezerInstance> for Runtime {
626 type RuntimeFreezeReason = RuntimeFreezeReason;
627 type RuntimeEvent = RuntimeEvent;
628}
629
630impl pallet_asset_conversion_tx_payment::Config for Runtime {
631 type RuntimeEvent = RuntimeEvent;
632 type AssetId = NativeOrWithId<u32>;
633 type OnChargeAssetTransaction = SwapAssetAdapter<
634 Native,
635 NativeAndAssets,
636 AssetConversion,
637 ResolveAssetTo<TreasuryAccount, NativeAndAssets>,
638 >;
639 type WeightInfo = pallet_asset_conversion_tx_payment::weights::SubstrateWeight<Runtime>;
640 #[cfg(feature = "runtime-benchmarks")]
641 type BenchmarkHelper = AssetConversionTxHelper;
642}
643
644impl pallet_skip_feeless_payment::Config for Runtime {
645 type RuntimeEvent = RuntimeEvent;
646}
647
648parameter_types! {
649 pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
650}
651
652impl pallet_timestamp::Config for Runtime {
653 type Moment = Moment;
654 type OnTimestampSet = Babe;
655 type MinimumPeriod = MinimumPeriod;
656 type WeightInfo = pallet_timestamp::weights::SubstrateWeight<Runtime>;
657}
658
659impl pallet_authorship::Config for Runtime {
660 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
661 type EventHandler = (Staking, ImOnline);
662}
663
664impl_opaque_keys! {
665 pub struct SessionKeys {
666 pub grandpa: Grandpa,
667 pub babe: Babe,
668 pub im_online: ImOnline,
669 pub authority_discovery: AuthorityDiscovery,
670 pub mixnet: Mixnet,
671 pub beefy: Beefy,
672 }
673}
674
675impl pallet_session::Config for Runtime {
676 type RuntimeEvent = RuntimeEvent;
677 type ValidatorId = <Self as frame_system::Config>::AccountId;
678 type ValidatorIdOf = sp_runtime::traits::ConvertInto;
679 type ShouldEndSession = Babe;
680 type NextSessionRotation = Babe;
681 type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
682 type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
683 type Keys = SessionKeys;
684 type DisablingStrategy = pallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy;
685 type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
686 type Currency = Balances;
687 type KeyDeposit = ();
688}
689
690impl pallet_session::historical::Config for Runtime {
691 type RuntimeEvent = RuntimeEvent;
692 type FullIdentification = ();
693 type FullIdentificationOf = pallet_staking::UnitIdentificationOf<Self>;
694}
695
696pallet_staking_reward_curve::build! {
697 const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
698 min_inflation: 0_025_000,
699 max_inflation: 0_100_000,
700 ideal_stake: 0_500_000,
701 falloff: 0_050_000,
702 max_piece_count: 40,
703 test_precision: 0_005_000,
704 );
705}
706
707parameter_types! {
708 pub const SessionsPerEra: sp_staking::SessionIndex = 6;
709 pub const BondingDuration: sp_staking::EraIndex = 24 * 28;
710 pub const SlashDeferDuration: sp_staking::EraIndex = 24 * 7; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
712 pub const MaxNominators: u32 = 64;
713 pub const MaxControllersInDeprecationBatch: u32 = 5900;
714 pub OffchainRepeat: BlockNumber = 5;
715 pub HistoryDepth: u32 = 84;
716}
717
718const MAX_QUOTA_NOMINATIONS: u32 = 16;
720
721pub struct StakingBenchmarkingConfig;
722impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
723 type MaxNominators = ConstU32<5000>;
724 type MaxValidators = ConstU32<1000>;
725}
726
727impl pallet_staking::Config for Runtime {
728 type OldCurrency = Balances;
729 type Currency = Balances;
730 type CurrencyBalance = Balance;
731 type UnixTime = Timestamp;
732 type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
733 type RewardRemainder = ResolveTo<TreasuryAccount, Balances>;
734 type RuntimeEvent = RuntimeEvent;
735 type RuntimeHoldReason = RuntimeHoldReason;
736 type Slash = ResolveTo<TreasuryAccount, Balances>; type Reward = (); type SessionsPerEra = SessionsPerEra;
739 type BondingDuration = BondingDuration;
740 type SlashDeferDuration = SlashDeferDuration;
741 type AdminOrigin = EitherOfDiverse<
743 EnsureRoot<AccountId>,
744 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>,
745 >;
746 type SessionInterface = Self;
747 type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
748 type NextNewSession = Session;
749 type MaxExposurePageSize = ConstU32<256>;
750 type ElectionProvider = ElectionProviderMultiPhase;
751 type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
752 type VoterList = VoterList;
753 type NominationsQuota = pallet_staking::FixedNominationsQuota<MAX_QUOTA_NOMINATIONS>;
754 type TargetList = pallet_staking::UseValidatorsMap<Self>;
756 type MaxUnlockingChunks = ConstU32<32>;
757 type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
758 type HistoryDepth = HistoryDepth;
759 type EventListeners = (NominationPools, DelegatedStaking);
760 type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
761 type BenchmarkingConfig = StakingBenchmarkingConfig;
762 type Filter = Nothing;
763 type MaxValidatorSet = ConstU32<1000>;
764}
765
766parameter_types! {
767 pub const DapPalletId: PalletId = pallet_dap::DAP_PALLET_ID;
768 pub const DapIssuanceCadence: u64 = 0; pub const DapMaxElapsedPerDrip: u64 = 600_000;
770}
771
772impl pallet_dap::Config for Runtime {
773 type Currency = Balances;
774 type PalletId = DapPalletId;
775 type IssuanceCurve = ();
776 type BudgetRecipients = (pallet_dap::Pallet<Runtime>,);
777 type Time = Timestamp;
778 type IssuanceCadence = DapIssuanceCadence;
779 type MaxElapsedPerDrip = DapMaxElapsedPerDrip;
780 type BudgetOrigin = EnsureRoot<AccountId>;
781 type WeightInfo = ();
782}
783
784impl pallet_fast_unstake::Config for Runtime {
785 type RuntimeEvent = RuntimeEvent;
786 type ControlOrigin = frame_system::EnsureRoot<AccountId>;
787 type BatchSize = ConstU32<64>;
788 type Deposit = ConstU128<{ DOLLARS }>;
789 type Currency = Balances;
790 type Staking = Staking;
791 type MaxErasToCheckPerBlock = ConstU32<1>;
792 type WeightInfo = ();
793}
794parameter_types! {
795 pub const SignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;
797 pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;
798
799 pub const SignedRewardBase: Balance = 1 * DOLLARS;
801 pub const SignedFixedDeposit: Balance = 1 * DOLLARS;
802 pub const SignedDepositIncreaseFactor: Percent = Percent::from_percent(10);
803 pub const SignedDepositByte: Balance = 1 * CENTS;
804
805 pub const MultiPhaseUnsignedPriority: TransactionPriority = StakingUnsignedPriority::get() - 1u64;
807 pub MinerMaxWeight: Weight = RuntimeBlockWeights::get()
808 .get(DispatchClass::Normal)
809 .max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed")
810 .saturating_sub(BlockExecutionWeight::get());
811 pub MinerMaxLength: u32 = Perbill::from_rational(9u32, 10) *
813 *RuntimeBlockLength::get()
814 .max
815 .get(DispatchClass::Normal);
816}
817
818frame_election_provider_support::generate_solution_type!(
819 #[compact]
820 pub struct NposSolution16::<
821 VoterIndex = u32,
822 TargetIndex = u16,
823 Accuracy = sp_runtime::PerU16,
824 MaxVoters = MaxElectingVotersSolution,
825 >(16)
826);
827
828parameter_types! {
829 pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::default()
832 .voters_count(10_000.into()).targets_count(1_500.into()).build();
833 pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default()
834 .voters_count(5_000.into()).targets_count(1_250.into()).build();
835
836 pub MaxNominations: u32 = <NposSolution16 as frame_election_provider_support::NposSolution>::LIMIT as u32;
837 pub MaxElectingVotersSolution: u32 = 40_000;
838 pub MaxActiveValidators: u32 = 1000;
841}
842
843pub struct ElectionProviderBenchmarkConfig;
847impl pallet_election_provider_multi_phase::BenchmarkingConfig for ElectionProviderBenchmarkConfig {
848 const VOTERS: [u32; 2] = [1000, 2000];
849 const TARGETS: [u32; 2] = [500, 1000];
850 const ACTIVE_VOTERS: [u32; 2] = [500, 800];
851 const DESIRED_TARGETS: [u32; 2] = [200, 400];
852 const SNAPSHOT_MAXIMUM_VOTERS: u32 = 1000;
853 const MINER_MAXIMUM_VOTERS: u32 = 1000;
854 const MAXIMUM_TARGETS: u32 = 300;
855}
856
857pub const MINER_MAX_ITERATIONS: u32 = 10;
860
861pub struct OffchainRandomBalancing;
863impl Get<Option<BalancingConfig>> for OffchainRandomBalancing {
864 fn get() -> Option<BalancingConfig> {
865 use sp_runtime::traits::TrailingZeroInput;
866 let iterations = match MINER_MAX_ITERATIONS {
867 0 => 0,
868 max => {
869 let seed = sp_io::offchain::random_seed();
870 let random = <u32>::decode(&mut TrailingZeroInput::new(&seed))
871 .expect("input is padded with zeroes; qed") %
872 max.saturating_add(1);
873 random as usize
874 },
875 };
876
877 let config = BalancingConfig { iterations, tolerance: 0 };
878 Some(config)
879 }
880}
881
882pub struct OnChainSeqPhragmen;
883impl onchain::Config for OnChainSeqPhragmen {
884 type Sort = ConstBool<true>;
885 type System = Runtime;
886 type Solver = SequentialPhragmen<AccountId, SolutionAccuracyOf<Runtime>>;
887 type DataProvider = Staking;
888 type WeightInfo = frame_election_provider_support::weights::SubstrateWeight<Runtime>;
889 type Bounds = ElectionBoundsOnChain;
890 type MaxBackersPerWinner = MaxElectingVotersSolution;
891 type MaxWinnersPerPage = MaxActiveValidators;
892}
893
894impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
895 type AccountId = AccountId;
896 type MaxLength = MinerMaxLength;
897 type MaxWeight = MinerMaxWeight;
898 type Solution = NposSolution16;
899 type MaxVotesPerVoter =
900 <<Self as pallet_election_provider_multi_phase::Config>::DataProvider as ElectionDataProvider>::MaxVotesPerVoter;
901 type MaxWinners = MaxActiveValidators;
902 type MaxBackersPerWinner = MaxElectingVotersSolution;
903
904 fn solution_weight(v: u32, t: u32, a: u32, d: u32) -> Weight {
907 <
908 <Self as pallet_election_provider_multi_phase::Config>::WeightInfo
909 as
910 pallet_election_provider_multi_phase::WeightInfo
911 >::submit_unsigned(v, t, a, d)
912 }
913}
914
915impl pallet_election_provider_multi_phase::Config for Runtime {
916 type RuntimeEvent = RuntimeEvent;
917 type Currency = Balances;
918 type EstimateCallFee = TransactionPayment;
919 type SignedPhase = SignedPhase;
920 type UnsignedPhase = UnsignedPhase;
921 type BetterSignedThreshold = ();
922 type OffchainRepeat = OffchainRepeat;
923 type MinerTxPriority = MultiPhaseUnsignedPriority;
924 type MinerConfig = Self;
925 type SignedMaxSubmissions = ConstU32<10>;
926 type SignedRewardBase = SignedRewardBase;
927 type SignedDepositBase =
928 GeometricDepositBase<Balance, SignedFixedDeposit, SignedDepositIncreaseFactor>;
929 type SignedDepositByte = SignedDepositByte;
930 type SignedMaxRefunds = ConstU32<3>;
931 type SignedDepositWeight = ();
932 type SignedMaxWeight = MinerMaxWeight;
933 type SlashHandler = (); type RewardHandler = (); type DataProvider = Staking;
936 type Fallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
937 type GovernanceFallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
938 type Solver = SequentialPhragmen<AccountId, SolutionAccuracyOf<Self>, OffchainRandomBalancing>;
939 type ForceOrigin = EnsureRootOrHalfCouncil;
940 type MaxWinners = MaxActiveValidators;
941 type ElectionBounds = ElectionBoundsMultiPhase;
942 type BenchmarkingConfig = ElectionProviderBenchmarkConfig;
943 type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
944 type MaxBackersPerWinner = MaxElectingVotersSolution;
945}
946
947parameter_types! {
948 pub const BagThresholds: &'static [u64] = &voter_bags::THRESHOLDS;
949 pub const AutoRebagNumber: u32 = 10;
950}
951
952type VoterBagsListInstance = pallet_bags_list::Instance1;
953impl pallet_bags_list::Config<VoterBagsListInstance> for Runtime {
954 type RuntimeEvent = RuntimeEvent;
955 type WeightInfo = pallet_bags_list::weights::SubstrateWeight<Runtime>;
956 type ScoreProvider = Staking;
959 type BagThresholds = BagThresholds;
960 type MaxAutoRebagPerBlock = AutoRebagNumber;
961 type Score = VoteWeight;
962}
963
964parameter_types! {
965 pub const DelegatedStakingPalletId: PalletId = PalletId(*b"py/dlstk");
966 pub const SlashRewardFraction: Perbill = Perbill::from_percent(1);
967}
968
969impl pallet_delegated_staking::Config for Runtime {
970 type RuntimeEvent = RuntimeEvent;
971 type PalletId = DelegatedStakingPalletId;
972 type Currency = Balances;
973 type OnSlash = ();
974 type SlashRewardFraction = SlashRewardFraction;
975 type RuntimeHoldReason = RuntimeHoldReason;
976 type CoreStaking = Staking;
977}
978
979parameter_types! {
980 pub const MaxUnbondingPools: u32 = 24 * 28 + 4;
982 pub const NominationPoolsPalletId: PalletId = PalletId(*b"py/nopls");
983 pub const MaxPointsToBalance: u8 = 10;
984}
985
986use sp_runtime::traits::{Convert, Keccak256};
987pub struct BalanceToU256;
988impl Convert<Balance, sp_core::U256> for BalanceToU256 {
989 fn convert(balance: Balance) -> sp_core::U256 {
990 sp_core::U256::from(balance)
991 }
992}
993pub struct U256ToBalance;
994impl Convert<sp_core::U256, Balance> for U256ToBalance {
995 fn convert(n: sp_core::U256) -> Balance {
996 n.try_into().unwrap_or(Balance::MAX)
997 }
998}
999
1000impl pallet_nomination_pools::Config for Runtime {
1001 type WeightInfo = ();
1002 type RuntimeEvent = RuntimeEvent;
1003 type Currency = Balances;
1004 type RuntimeFreezeReason = RuntimeFreezeReason;
1005 type RewardCounter = FixedU128;
1006 type BalanceToU256 = BalanceToU256;
1007 type U256ToBalance = U256ToBalance;
1008 type StakeAdapter =
1009 pallet_nomination_pools::adapter::DelegateStake<Self, Staking, DelegatedStaking>;
1010 type MaxUnbondingPools = MaxUnbondingPools;
1011 type MaxMetadataLen = ConstU32<256>;
1012 type MaxUnbonding = ConstU32<8>;
1013 type PalletId = NominationPoolsPalletId;
1014 type MaxPointsToBalance = MaxPointsToBalance;
1015 type AdminOrigin = EitherOfDiverse<
1016 EnsureRoot<AccountId>,
1017 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>,
1018 >;
1019 type BlockNumberProvider = System;
1020 type Filter = Nothing;
1021}
1022
1023parameter_types! {
1024 pub const VoteLockingPeriod: BlockNumber = 30 * DAYS;
1025}
1026
1027impl pallet_conviction_voting::Config for Runtime {
1028 type WeightInfo = pallet_conviction_voting::weights::SubstrateWeight<Self>;
1029 type RuntimeEvent = RuntimeEvent;
1030 type Currency = Balances;
1031 type VoteLockingPeriod = VoteLockingPeriod;
1032 type MaxVotes = ConstU32<512>;
1033 type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>;
1034 type Polls = Referenda;
1035 type BlockNumberProvider = System;
1036 type VotingHooks = ();
1037}
1038
1039parameter_types! {
1040 pub const AlarmInterval: BlockNumber = 1;
1041 pub const SubmissionDeposit: Balance = 100 * DOLLARS;
1042 pub const UndecidingTimeout: BlockNumber = 28 * DAYS;
1043}
1044
1045pub struct TracksInfo;
1046impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
1047 type Id = u16;
1048 type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;
1049
1050 fn tracks(
1051 ) -> impl Iterator<Item = Cow<'static, pallet_referenda::Track<Self::Id, Balance, BlockNumber>>>
1052 {
1053 dynamic_params::referenda::Tracks::get().into_iter().map(Cow::Owned)
1054 }
1055 fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> {
1056 dynamic_params::referenda::Origins::get()
1057 .iter()
1058 .find(|(o, _)| id == o)
1059 .map(|(_, track_id)| *track_id)
1060 .ok_or(())
1061 }
1062}
1063
1064impl pallet_referenda::Config for Runtime {
1065 type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
1066 type RuntimeCall = RuntimeCall;
1067 type RuntimeEvent = RuntimeEvent;
1068 type Scheduler = Scheduler;
1069 type Currency = pallet_balances::Pallet<Self>;
1070 type SubmitOrigin = EnsureSigned<AccountId>;
1071 type CancelOrigin = EnsureRoot<AccountId>;
1072 type KillOrigin = EnsureRoot<AccountId>;
1073 type Slash = ();
1074 type Votes = pallet_conviction_voting::VotesOf<Runtime>;
1075 type Tally = pallet_conviction_voting::TallyOf<Runtime>;
1076 type SubmissionDeposit = SubmissionDeposit;
1077 type MaxQueued = ConstU32<100>;
1078 type UndecidingTimeout = UndecidingTimeout;
1079 type AlarmInterval = AlarmInterval;
1080 type Tracks = TracksInfo;
1081 type Preimages = Preimage;
1082 type BlockNumberProvider = System;
1083}
1084
1085impl pallet_referenda::Config<pallet_referenda::Instance2> for Runtime {
1086 type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
1087 type RuntimeCall = RuntimeCall;
1088 type RuntimeEvent = RuntimeEvent;
1089 type Scheduler = Scheduler;
1090 type Currency = pallet_balances::Pallet<Self>;
1091 type SubmitOrigin = EnsureSigned<AccountId>;
1092 type CancelOrigin = EnsureRoot<AccountId>;
1093 type KillOrigin = EnsureRoot<AccountId>;
1094 type Slash = ();
1095 type Votes = pallet_ranked_collective::Votes;
1096 type Tally = pallet_ranked_collective::TallyOf<Runtime>;
1097 type SubmissionDeposit = SubmissionDeposit;
1098 type MaxQueued = ConstU32<100>;
1099 type UndecidingTimeout = UndecidingTimeout;
1100 type AlarmInterval = AlarmInterval;
1101 type Tracks = TracksInfo;
1102 type Preimages = Preimage;
1103 type BlockNumberProvider = System;
1104}
1105
1106impl pallet_ranked_collective::Config for Runtime {
1107 type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight<Self>;
1108 type RuntimeEvent = RuntimeEvent;
1109 type AddOrigin = EnsureRoot<AccountId>;
1110 type RemoveOrigin = Self::DemoteOrigin;
1111 type PromoteOrigin = EnsureRootWithSuccess<AccountId, ConstU16<65535>>;
1112 type DemoteOrigin = EnsureRootWithSuccess<AccountId, ConstU16<65535>>;
1113 type ExchangeOrigin = EnsureRootWithSuccess<AccountId, ConstU16<65535>>;
1114 type Polls = RankedPolls;
1115 type MinRankOfClass = traits::Identity;
1116 type VoteWeight = pallet_ranked_collective::Geometric;
1117 type MemberSwappedHandler = (CoreFellowship, Salary);
1118 type MaxMemberCount = ();
1119 #[cfg(feature = "runtime-benchmarks")]
1120 type BenchmarkSetup = (CoreFellowship, Salary);
1121}
1122
1123impl pallet_remark::Config for Runtime {
1124 type WeightInfo = pallet_remark::weights::SubstrateWeight<Self>;
1125 type RuntimeEvent = RuntimeEvent;
1126}
1127
1128impl pallet_root_testing::Config for Runtime {
1129 type RuntimeEvent = RuntimeEvent;
1130}
1131
1132parameter_types! {
1133 pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
1134 pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
1135 pub const FastTrackVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES;
1136 pub const MinimumDeposit: Balance = 100 * DOLLARS;
1137 pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
1138 pub const CooloffPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
1139 pub const MaxProposals: u32 = 100;
1140}
1141
1142impl pallet_democracy::Config for Runtime {
1143 type RuntimeEvent = RuntimeEvent;
1144 type Currency = Balances;
1145 type EnactmentPeriod = EnactmentPeriod;
1146 type LaunchPeriod = LaunchPeriod;
1147 type VotingPeriod = VotingPeriod;
1148 type VoteLockingPeriod = EnactmentPeriod; type MinimumDeposit = MinimumDeposit;
1150 type ExternalOrigin =
1152 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;
1153 type ExternalMajorityOrigin =
1155 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>;
1156 type ExternalDefaultOrigin =
1159 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;
1160 type SubmitOrigin = EnsureSigned<AccountId>;
1161 type FastTrackOrigin =
1164 pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 2, 3>;
1165 type InstantOrigin =
1166 pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>;
1167 type InstantAllowed = ConstBool<true>;
1168 type FastTrackVotingPeriod = FastTrackVotingPeriod;
1169 type CancellationOrigin =
1171 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>;
1172 type CancelProposalOrigin = EitherOfDiverse<
1175 EnsureRoot<AccountId>,
1176 pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>,
1177 >;
1178 type BlacklistOrigin = EnsureRoot<AccountId>;
1179 type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
1182 type CooloffPeriod = CooloffPeriod;
1183 type Slash = Treasury;
1184 type Scheduler = Scheduler;
1185 type PalletsOrigin = OriginCaller;
1186 type MaxVotes = ConstU32<100>;
1187 type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
1188 type MaxProposals = MaxProposals;
1189 type Preimages = Preimage;
1190 type MaxDeposits = ConstU32<100>;
1191 type MaxBlacklisted = ConstU32<100>;
1192}
1193
1194parameter_types! {
1195 pub const CouncilMotionDuration: BlockNumber = 5 * DAYS;
1196 pub const CouncilMaxProposals: u32 = 100;
1197 pub const CouncilMaxMembers: u32 = 100;
1198 pub const ProposalDepositOffset: Balance = ExistentialDeposit::get() + ExistentialDeposit::get();
1199 pub const ProposalHoldReason: RuntimeHoldReason =
1200 RuntimeHoldReason::Council(pallet_collective::HoldReason::ProposalSubmission);
1201}
1202
1203type CouncilCollective = pallet_collective::Instance1;
1204impl pallet_collective::Config<CouncilCollective> for Runtime {
1205 type RuntimeOrigin = RuntimeOrigin;
1206 type Proposal = RuntimeCall;
1207 type RuntimeEvent = RuntimeEvent;
1208 type MotionDuration = CouncilMotionDuration;
1209 type MaxProposals = CouncilMaxProposals;
1210 type MaxMembers = CouncilMaxMembers;
1211 type DefaultVote = pallet_collective::PrimeDefaultVote;
1212 type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
1213 type SetMembersOrigin = EnsureRoot<Self::AccountId>;
1214 type MaxProposalWeight = MaxCollectivesProposalWeight;
1215 type DisapproveOrigin = EnsureRoot<Self::AccountId>;
1216 type KillOrigin = EnsureRoot<Self::AccountId>;
1217 type Consideration = HoldConsideration<
1218 AccountId,
1219 Balances,
1220 ProposalHoldReason,
1221 pallet_collective::deposit::Delayed<
1222 ConstU32<2>,
1223 pallet_collective::deposit::Linear<ConstU32<2>, ProposalDepositOffset>,
1224 >,
1225 u32,
1226 >;
1227}
1228
1229parameter_types! {
1230 pub const CandidacyBond: Balance = 10 * DOLLARS;
1231 pub const VotingBondBase: Balance = deposit(1, 64);
1233 pub const VotingBondFactor: Balance = deposit(0, 32);
1235 pub const TermDuration: BlockNumber = 7 * DAYS;
1236 pub const DesiredMembers: u32 = 13;
1237 pub const DesiredRunnersUp: u32 = 7;
1238 pub const MaxVotesPerVoter: u32 = 16;
1239 pub const MaxVoters: u32 = 256;
1240 pub const MaxCandidates: u32 = 128;
1241 pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
1242}
1243
1244const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());
1246
1247impl pallet_elections_phragmen::Config for Runtime {
1248 type RuntimeEvent = RuntimeEvent;
1249 type PalletId = ElectionsPhragmenPalletId;
1250 type Currency = Balances;
1251 type ChangeMembers = Council;
1252 type InitializeMembers = Council;
1255 type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
1256 type CandidacyBond = CandidacyBond;
1257 type VotingBondBase = VotingBondBase;
1258 type VotingBondFactor = VotingBondFactor;
1259 type LoserCandidate = ();
1260 type KickedMember = ();
1261 type DesiredMembers = DesiredMembers;
1262 type DesiredRunnersUp = DesiredRunnersUp;
1263 type TermDuration = TermDuration;
1264 type MaxVoters = MaxVoters;
1265 type MaxVotesPerVoter = MaxVotesPerVoter;
1266 type MaxCandidates = MaxCandidates;
1267 type WeightInfo = pallet_elections_phragmen::weights::SubstrateWeight<Runtime>;
1268}
1269
1270parameter_types! {
1271 pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS;
1272 pub const TechnicalMaxProposals: u32 = 100;
1273 pub const TechnicalMaxMembers: u32 = 100;
1274}
1275
1276type TechnicalCollective = pallet_collective::Instance2;
1277impl pallet_collective::Config<TechnicalCollective> for Runtime {
1278 type RuntimeOrigin = RuntimeOrigin;
1279 type Proposal = RuntimeCall;
1280 type RuntimeEvent = RuntimeEvent;
1281 type MotionDuration = TechnicalMotionDuration;
1282 type MaxProposals = TechnicalMaxProposals;
1283 type MaxMembers = TechnicalMaxMembers;
1284 type DefaultVote = pallet_collective::PrimeDefaultVote;
1285 type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
1286 type SetMembersOrigin = EnsureRoot<Self::AccountId>;
1287 type MaxProposalWeight = MaxCollectivesProposalWeight;
1288 type DisapproveOrigin = EnsureRoot<Self::AccountId>;
1289 type KillOrigin = EnsureRoot<Self::AccountId>;
1290 type Consideration = ();
1291}
1292
1293type EnsureRootOrHalfCouncil = EitherOfDiverse<
1294 EnsureRoot<AccountId>,
1295 pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
1296>;
1297impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
1298 type RuntimeEvent = RuntimeEvent;
1299 type AddOrigin = EnsureRootOrHalfCouncil;
1300 type RemoveOrigin = EnsureRootOrHalfCouncil;
1301 type SwapOrigin = EnsureRootOrHalfCouncil;
1302 type ResetOrigin = EnsureRootOrHalfCouncil;
1303 type PrimeOrigin = EnsureRootOrHalfCouncil;
1304 type MembershipInitialized = TechnicalCommittee;
1305 type MembershipChanged = TechnicalCommittee;
1306 type MaxMembers = TechnicalMaxMembers;
1307 type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;
1308}
1309
1310parameter_types! {
1311 pub const SpendPeriod: BlockNumber = 1 * DAYS;
1312 pub const Burn: Permill = Permill::from_percent(50);
1313 pub const TipCountdown: BlockNumber = 1 * DAYS;
1314 pub const TipFindersFee: Percent = Percent::from_percent(20);
1315 pub const TipReportDepositBase: Balance = 1 * DOLLARS;
1316 pub const DataDepositPerByte: Balance = 1 * CENTS;
1317 pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
1318 pub const MaximumReasonLength: u32 = 300;
1319 pub const MaxApprovals: u32 = 100;
1320 pub const MaxBalance: Balance = Balance::MAX;
1321 pub const SpendPayoutPeriod: BlockNumber = 30 * DAYS;
1322}
1323
1324impl pallet_treasury::Config for Runtime {
1325 type PalletId = TreasuryPalletId;
1326 type Currency = Balances;
1327 type RejectOrigin = EitherOfDiverse<
1328 EnsureRoot<AccountId>,
1329 pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
1330 >;
1331 type RuntimeEvent = RuntimeEvent;
1332 type SpendPeriod = SpendPeriod;
1333 type Burn = Burn;
1334 type BurnDestination = ();
1335 type SpendFunds = Bounties;
1336 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
1337 type MaxApprovals = MaxApprovals;
1338 type SpendOrigin = EnsureWithSuccess<EnsureRoot<AccountId>, AccountId, MaxBalance>;
1339 type AssetKind = NativeOrWithId<u32>;
1340 type Beneficiary = AccountId;
1341 type BeneficiaryLookup = Indices;
1342 type Paymaster = PayAssetFromAccount<NativeAndAssets, TreasuryAccount>;
1343 type BalanceConverter = AssetRate;
1344 type PayoutPeriod = SpendPayoutPeriod;
1345 type BlockNumberProvider = System;
1346 #[cfg(feature = "runtime-benchmarks")]
1347 type BenchmarkHelper = PalletTreasuryArguments;
1348}
1349
1350impl pallet_asset_rate::Config for Runtime {
1351 type CreateOrigin = EnsureRoot<AccountId>;
1352 type RemoveOrigin = EnsureRoot<AccountId>;
1353 type UpdateOrigin = EnsureRoot<AccountId>;
1354 type Currency = Balances;
1355 type AssetKind = NativeOrWithId<u32>;
1356 type RuntimeEvent = RuntimeEvent;
1357 type WeightInfo = pallet_asset_rate::weights::SubstrateWeight<Runtime>;
1358 #[cfg(feature = "runtime-benchmarks")]
1359 type BenchmarkHelper = AssetRateArguments;
1360}
1361
1362parameter_types! {
1363 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
1364 pub const BountyValueMinimum: Balance = 5 * DOLLARS;
1365 pub const BountyDepositBase: Balance = 1 * DOLLARS;
1366 pub const CuratorDepositFromFeeMultiplier: Permill = Permill::from_percent(50);
1367 pub const CuratorDepositMin: Balance = 1 * DOLLARS;
1368 pub const CuratorDepositMax: Balance = 100 * DOLLARS;
1369 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
1370 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
1371}
1372
1373impl pallet_bounties::Config for Runtime {
1374 type RuntimeEvent = RuntimeEvent;
1375 type BountyDepositBase = BountyDepositBase;
1376 type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
1377 type BountyUpdatePeriod = BountyUpdatePeriod;
1378 type CuratorDepositMultiplier = CuratorDepositFromFeeMultiplier;
1379 type CuratorDepositMin = CuratorDepositMin;
1380 type CuratorDepositMax = CuratorDepositMax;
1381 type BountyValueMinimum = BountyValueMinimum;
1382 type DataDepositPerByte = DataDepositPerByte;
1383 type MaximumReasonLength = MaximumReasonLength;
1384 type WeightInfo = pallet_bounties::weights::SubstrateWeight<Runtime>;
1385 type ChildBountyManager = ChildBounties;
1386 type OnSlash = Treasury;
1387 type TransferAllAssets = pallet_bounties::TransferFungible<AccountId, Balances>;
1388}
1389
1390parameter_types! {
1391 pub MessageQueueServiceWeight: Option<Weight> = Some(Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block);
1395}
1396
1397impl pallet_message_queue::Config for Runtime {
1398 type RuntimeEvent = RuntimeEvent;
1399 type WeightInfo = ();
1400 type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<u32>;
1402 type Size = u32;
1403 type QueueChangeHandler = ();
1404 type QueuePausedQuery = ();
1405 type HeapSize = ConstU32<{ 64 * 1024 }>;
1406 type MaxStale = ConstU32<128>;
1407 type ServiceWeight = MessageQueueServiceWeight;
1408 type IdleMaxServiceWeight = ();
1409}
1410
1411parameter_types! {
1412 pub const ChildBountyValueMinimum: Balance = 1 * DOLLARS;
1413 pub const MaxActiveChildBountyCount: u32 = 5;
1414}
1415
1416impl pallet_child_bounties::Config for Runtime {
1417 type RuntimeEvent = RuntimeEvent;
1418 type MaxActiveChildBountyCount = MaxActiveChildBountyCount;
1419 type ChildBountyValueMinimum = ChildBountyValueMinimum;
1420 type WeightInfo = pallet_child_bounties::weights::SubstrateWeight<Runtime>;
1421}
1422
1423parameter_types! {
1424 pub const CuratorDepositFromValueMultiplier: Permill = Permill::from_percent(10);
1425 pub const CuratorHoldReason: RuntimeHoldReason =
1426 RuntimeHoldReason::MultiAssetBounties(pallet_multi_asset_bounties::HoldReason::CuratorDeposit);
1427}
1428
1429impl pallet_multi_asset_bounties::Config for Runtime {
1430 type Balance = Balance;
1431 type RejectOrigin = EitherOfDiverse<
1432 EnsureRoot<AccountId>,
1433 pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
1434 >;
1435 type SpendOrigin = EnsureWithSuccess<EnsureRoot<AccountId>, AccountId, MaxBalance>;
1436 type AssetKind = NativeOrWithId<u32>;
1437 type Beneficiary = AccountId;
1438 type BeneficiaryLookup = Indices;
1439 type BountyValueMinimum = BountyValueMinimum;
1440 type ChildBountyValueMinimum = ChildBountyValueMinimum;
1441 type MaxActiveChildBountyCount = MaxActiveChildBountyCount;
1442 type WeightInfo = pallet_multi_asset_bounties::weights::SubstrateWeight<Runtime>;
1443 type FundingSource = pallet_multi_asset_bounties::PalletIdAsFundingSource<
1444 TreasuryPalletId,
1445 Runtime,
1446 sp_runtime::traits::Identity,
1447 >;
1448 type BountySource = pallet_multi_asset_bounties::BountySourceFromPalletId<
1449 TreasuryPalletId,
1450 pallet_multi_asset_bounties::BountyAccountPrefix,
1451 Runtime,
1452 sp_runtime::traits::Identity,
1453 >;
1454 type ChildBountySource = pallet_multi_asset_bounties::ChildBountySourceFromPalletId<
1455 TreasuryPalletId,
1456 pallet_multi_asset_bounties::ChildBountyAccountPrefix,
1457 Runtime,
1458 sp_runtime::traits::Identity,
1459 >;
1460 type Paymaster = PayWithFungibles<NativeAndAssets, AccountId>;
1461 type BalanceConverter = AssetRate;
1462 type Preimages = Preimage;
1463 type Consideration = HoldConsideration<
1464 AccountId,
1465 Balances,
1466 CuratorHoldReason,
1467 pallet_multi_asset_bounties::CuratorDepositAmount<
1468 CuratorDepositFromValueMultiplier,
1469 CuratorDepositMin,
1470 CuratorDepositMax,
1471 Balance,
1472 >,
1473 Balance,
1474 >;
1475 #[cfg(feature = "runtime-benchmarks")]
1476 type BenchmarkHelper = PalletMultiAssetBountiesArguments;
1477}
1478
1479impl pallet_assets_precompiles::ForeignAssetsConfig for Runtime {
1480 type ForeignAssetId = u32;
1481 #[cfg(feature = "runtime-benchmarks")]
1482 type AssetsInstance = Instance1;
1483}
1484
1485impl pallet_assets_precompiles::PermitConfig for Runtime {
1486 type ChainId = ConstU64<420_420_420>;
1487 type WeightInfo = pallet_assets_precompiles::weights::SubstrateWeight<Runtime>;
1488}
1489
1490impl pallet_tips::Config for Runtime {
1491 type RuntimeEvent = RuntimeEvent;
1492 type DataDepositPerByte = DataDepositPerByte;
1493 type MaximumReasonLength = MaximumReasonLength;
1494 type Tippers = Elections;
1495 type TipCountdown = TipCountdown;
1496 type TipFindersFee = TipFindersFee;
1497 type TipReportDepositBase = TipReportDepositBase;
1498 type MaxTipAmount = ConstU128<{ 500 * DOLLARS }>;
1499 type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
1500 type OnSlash = Treasury;
1501}
1502
1503parameter_types! {
1504 pub const DepositPerItem: Balance = deposit(1, 0);
1505 pub const DepositPerChildTrieItem: Balance = deposit(1, 0) / 100;
1506 pub const DepositPerByte: Balance = deposit(0, 1);
1507 pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
1508 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
1509 pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
1510 pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
1511}
1512
1513impl pallet_contracts::Config for Runtime {
1514 type Time = Timestamp;
1515 type Randomness = RandomnessCollectiveFlip;
1516 type Currency = Balances;
1517 type RuntimeEvent = RuntimeEvent;
1518 type RuntimeCall = RuntimeCall;
1519 type CallFilter = Nothing;
1526 type DepositPerItem = DepositPerItem;
1527 type DepositPerByte = DepositPerByte;
1528 type DefaultDepositLimit = DefaultDepositLimit;
1529 type CallStack = [pallet_contracts::Frame<Self>; 5];
1530 type WeightPrice = pallet_transaction_payment::Pallet<Self>;
1531 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
1532 type ChainExtension = ();
1533 type Schedule = Schedule;
1534 type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
1535 type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
1536 type MaxStorageKeyLen = ConstU32<128>;
1537 type UnsafeUnstableInterface = ConstBool<false>;
1538 type UploadOrigin = EnsureSigned<Self::AccountId>;
1539 type InstantiateOrigin = EnsureSigned<Self::AccountId>;
1540 type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
1541 type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
1542 type RuntimeHoldReason = RuntimeHoldReason;
1543 #[cfg(not(feature = "runtime-benchmarks"))]
1544 type Migrations = ();
1545 #[cfg(feature = "runtime-benchmarks")]
1546 type Migrations = pallet_contracts::migration::codegen::BenchMigrations;
1547 type MaxDelegateDependencies = ConstU32<32>;
1548 type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
1549 type Debug = ();
1550 type Environment = ();
1551 type ApiVersion = ();
1552 type Xcm = ();
1553}
1554
1555impl pallet_revive::Config for Runtime {
1556 type Time = Timestamp;
1557 type Balance = Balance;
1558 type Currency = Balances;
1559 type RuntimeEvent = RuntimeEvent;
1560 type RuntimeCall = RuntimeCall;
1561 type RuntimeOrigin = RuntimeOrigin;
1562 type DepositPerItem = DepositPerItem;
1563 type DepositPerChildTrieItem = DepositPerChildTrieItem;
1564 type DepositPerByte = DepositPerByte;
1565 type WeightInfo = pallet_revive::weights::SubstrateWeight<Self>;
1566 type Precompiles = (
1567 ERC20<Self, InlineIdConfig<0x1>, Instance1>,
1568 ERC20<Self, InlineIdConfig<0x2>, Instance2>,
1569 VestingPrecompile<Self>,
1570 );
1571 type AddressMapper = pallet_revive::AccountId32Mapper<Self>;
1572 type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;
1573 type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>;
1574 type UploadOrigin = EnsureSigned<Self::AccountId>;
1575 type InstantiateOrigin = EnsureSigned<Self::AccountId>;
1576 type RuntimeHoldReason = RuntimeHoldReason;
1577 type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
1578 type ChainId = ConstU64<420_420_420>;
1579 type NativeToEthRatio = ConstU32<1_000_000>; type FindAuthor = <Runtime as pallet_authorship::Config>::FindAuthor;
1581 type AllowEVMBytecode = ConstBool<true>;
1582 type FeeInfo = pallet_revive::evm::fees::Info<Address, Signature, EthExtraImpl>;
1583 type MaxEthExtrinsicWeight = MaxEthExtrinsicWeight;
1584 type DebugEnabled = ConstBool<false>;
1585 type AutoMap = ConstBool<false>;
1586 type GasScale = ConstU32<1000>;
1587 type OnBurn = ();
1588 type MaxOutsideFrameLogs = ConstU32<2048>;
1592 type Deposit = ();
1593}
1594
1595impl pallet_vesting_precompiles::pallet::Config for Runtime {
1596 type WeightInfo = pallet_vesting_precompiles::weights::SubstrateWeight<Runtime>;
1597}
1598
1599impl pallet_sudo::Config for Runtime {
1600 type RuntimeEvent = RuntimeEvent;
1601 type RuntimeCall = RuntimeCall;
1602 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
1603}
1604
1605parameter_types! {
1606 pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::MAX;
1607 pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::MAX / 2;
1609 pub const MaxAuthorities: u32 = 1000;
1610 pub const MaxKeys: u32 = 10_000;
1611 pub const MaxPeerInHeartbeats: u32 = 10_000;
1612}
1613
1614impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
1615where
1616 RuntimeCall: From<LocalCall>,
1617{
1618 type Extension = TxExtension;
1619
1620 fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
1621 generic::UncheckedExtrinsic::new_transaction(call, extension).into()
1622 }
1623}
1624
1625impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
1626where
1627 RuntimeCall: From<LocalCall>,
1628{
1629 fn create_signed_transaction<
1630 C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>,
1631 >(
1632 call: RuntimeCall,
1633 public: <Signature as traits::Verify>::Signer,
1634 account: AccountId,
1635 nonce: Nonce,
1636 ) -> Option<UncheckedExtrinsic> {
1637 let tip = 0;
1638 let period =
1640 BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
1641 let current_block = System::block_number()
1642 .saturated_into::<u64>()
1643 .saturating_sub(1);
1646 let era = Era::mortal(period, current_block);
1647 let tx_ext: TxExtension = (
1648 frame_system::AuthorizeCall::<Runtime>::new(),
1649 frame_system::CheckNonZeroSender::<Runtime>::new(),
1650 frame_system::CheckSpecVersion::<Runtime>::new(),
1651 frame_system::CheckTxVersion::<Runtime>::new(),
1652 frame_system::CheckGenesis::<Runtime>::new(),
1653 frame_system::CheckEra::<Runtime>::from(era),
1654 frame_system::CheckNonce::<Runtime>::from(nonce),
1655 frame_system::CheckWeight::<Runtime>::new(),
1656 pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
1657 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(
1658 tip, None,
1659 ),
1660 ),
1661 frame_metadata_hash_extension::CheckMetadataHash::new(false),
1662 pallet_revive::evm::tx_extension::SetOrigin::<Runtime>::default(),
1663 frame_system::WeightReclaim::<Runtime>::new(),
1664 );
1665
1666 let raw_payload = SignedPayload::new(call, tx_ext)
1667 .map_err(|e| {
1668 log::warn!("Unable to create signed payload: {:?}", e);
1669 })
1670 .ok()?;
1671 let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
1672 let address = Indices::unlookup(account);
1673 let (call, tx_ext, _) = raw_payload.deconstruct();
1674 let transaction =
1675 generic::UncheckedExtrinsic::new_signed(call, address, signature, tx_ext).into();
1676 Some(transaction)
1677 }
1678}
1679
1680impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
1681where
1682 RuntimeCall: From<LocalCall>,
1683{
1684 fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
1685 generic::UncheckedExtrinsic::new_bare(call).into()
1686 }
1687}
1688
1689impl frame_system::offchain::SigningTypes for Runtime {
1690 type Public = <Signature as traits::Verify>::Signer;
1691 type Signature = Signature;
1692}
1693
1694impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
1695where
1696 RuntimeCall: From<C>,
1697{
1698 type Extrinsic = UncheckedExtrinsic;
1699 type RuntimeCall = RuntimeCall;
1700}
1701
1702impl<C> frame_system::offchain::CreateAuthorizedTransaction<C> for Runtime
1703where
1704 RuntimeCall: From<C>,
1705{
1706 fn create_extension() -> Self::Extension {
1707 (
1708 frame_system::AuthorizeCall::<Runtime>::new(),
1709 frame_system::CheckNonZeroSender::<Runtime>::new(),
1710 frame_system::CheckSpecVersion::<Runtime>::new(),
1711 frame_system::CheckTxVersion::<Runtime>::new(),
1712 frame_system::CheckGenesis::<Runtime>::new(),
1713 frame_system::CheckEra::<Runtime>::from(Era::Immortal),
1714 frame_system::CheckNonce::<Runtime>::from(0),
1715 frame_system::CheckWeight::<Runtime>::new(),
1716 pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
1717 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(0, None),
1718 ),
1719 frame_metadata_hash_extension::CheckMetadataHash::new(false),
1720 pallet_revive::evm::tx_extension::SetOrigin::<Runtime>::default(),
1721 frame_system::WeightReclaim::<Runtime>::new(),
1722 )
1723 }
1724}
1725
1726impl pallet_im_online::Config for Runtime {
1727 type AuthorityId = ImOnlineId;
1728 type RuntimeEvent = RuntimeEvent;
1729 type NextSessionRotation = Babe;
1730 type ValidatorSet = Historical;
1731 type ReportUnresponsiveness = Offences;
1732 type UnsignedPriority = ImOnlineUnsignedPriority;
1733 type WeightInfo = pallet_im_online::weights::SubstrateWeight<Runtime>;
1734 type MaxKeys = MaxKeys;
1735 type MaxPeerInHeartbeats = MaxPeerInHeartbeats;
1736}
1737
1738impl pallet_offences::Config for Runtime {
1739 type RuntimeEvent = RuntimeEvent;
1740 type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
1741 type OnOffenceHandler = Staking;
1742}
1743
1744impl pallet_authority_discovery::Config for Runtime {
1745 type MaxAuthorities = MaxAuthorities;
1746}
1747
1748parameter_types! {
1749 pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
1750}
1751
1752impl pallet_grandpa::Config for Runtime {
1753 type RuntimeEvent = RuntimeEvent;
1754 type WeightInfo = ();
1755 type MaxAuthorities = MaxAuthorities;
1756 type MaxNominators = MaxNominators;
1757 type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
1758 type KeyOwnerProof = sp_session::MembershipProof;
1759 type EquivocationReportSystem =
1760 pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
1761}
1762
1763parameter_types! {
1764 pub const BasicDeposit: Balance = deposit(1, 17);
1767 pub const ByteDeposit: Balance = deposit(0, 1);
1768 pub const UsernameDeposit: Balance = deposit(0, 32);
1769 pub const SubAccountDeposit: Balance = 2 * DOLLARS; pub const MaxSubAccounts: u32 = 100;
1771 pub const MaxAdditionalFields: u32 = 100;
1772 pub const MaxRegistrars: u32 = 20;
1773}
1774
1775impl pallet_identity::Config for Runtime {
1776 type RuntimeEvent = RuntimeEvent;
1777 type Currency = Balances;
1778 type BasicDeposit = BasicDeposit;
1779 type ByteDeposit = ByteDeposit;
1780 type UsernameDeposit = UsernameDeposit;
1781 type SubAccountDeposit = SubAccountDeposit;
1782 type MaxSubAccounts = MaxSubAccounts;
1783 type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
1784 type MaxRegistrars = MaxRegistrars;
1785 type Slashed = Treasury;
1786 type ForceOrigin = EnsureRootOrHalfCouncil;
1787 type RegistrarOrigin = EnsureRootOrHalfCouncil;
1788 type OffchainSignature = Signature;
1789 type SigningPublicKey = <Signature as traits::Verify>::Signer;
1790 type UsernameAuthorityOrigin = EnsureRoot<Self::AccountId>;
1791 type PendingUsernameExpiration = ConstU32<{ 7 * DAYS }>;
1792 type UsernameGracePeriod = ConstU32<{ 30 * DAYS }>;
1793 type MaxSuffixLength = ConstU32<7>;
1794 type MaxUsernameLength = ConstU32<32>;
1795 #[cfg(feature = "runtime-benchmarks")]
1796 type BenchmarkHelper = ();
1797 type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;
1798}
1799
1800impl pallet_recovery::Config for Runtime {
1801 type RuntimeCall = RuntimeCall;
1802 type RuntimeHoldReason = RuntimeHoldReason;
1803 type BlockNumberProvider = frame_system::Pallet<Runtime>;
1804 type Currency = Balances;
1805 type FriendGroupsConsideration = ();
1806 type AttemptConsideration = ();
1807 type InheritorConsideration = ();
1808 type SecurityDeposit = ();
1809 type MaxFriendsPerConfig = ConstU32<100>;
1810 type WeightInfo = ();
1811 type Slash = (); }
1813
1814parameter_types! {
1815 pub const GraceStrikes: u32 = 10;
1816 pub const SocietyVotingPeriod: BlockNumber = 80 * HOURS;
1817 pub const ClaimPeriod: BlockNumber = 80 * HOURS;
1818 pub const PeriodSpend: Balance = 500 * DOLLARS;
1819 pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS;
1820 pub const ChallengePeriod: BlockNumber = 7 * DAYS;
1821 pub const MaxPayouts: u32 = 10;
1822 pub const MaxBids: u32 = 10;
1823 pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
1824}
1825
1826impl pallet_society::Config for Runtime {
1827 type RuntimeEvent = RuntimeEvent;
1828 type PalletId = SocietyPalletId;
1829 type Currency = Balances;
1830 type Randomness = RandomnessCollectiveFlip;
1831 type GraceStrikes = GraceStrikes;
1832 type PeriodSpend = PeriodSpend;
1833 type VotingPeriod = SocietyVotingPeriod;
1834 type ClaimPeriod = ClaimPeriod;
1835 type MaxLockDuration = MaxLockDuration;
1836 type FounderSetOrigin =
1837 pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>;
1838 type ChallengePeriod = ChallengePeriod;
1839 type MaxPayouts = MaxPayouts;
1840 type MaxBids = MaxBids;
1841 type BlockNumberProvider = System;
1842 type WeightInfo = pallet_society::weights::SubstrateWeight<Runtime>;
1843}
1844
1845parameter_types! {
1846 pub const MinVestedTransfer: Balance = 100 * DOLLARS;
1847 pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
1848 WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
1849}
1850
1851impl pallet_vesting::Config for Runtime {
1852 type RuntimeEvent = RuntimeEvent;
1853 type Currency = Balances;
1854 type BlockNumberToBalance = ConvertInto;
1855 type MinVestedTransfer = MinVestedTransfer;
1856 type WeightInfo = pallet_vesting::weights::SubstrateWeight<Runtime>;
1857 type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
1858 type BlockNumberProvider = System;
1859 const MAX_VESTING_SCHEDULES: u32 = 28;
1862}
1863
1864impl pallet_mmr::Config for Runtime {
1865 const INDEXING_PREFIX: &'static [u8] = b"mmr";
1866 type Hashing = Keccak256;
1867 type LeafData = pallet_mmr::ParentNumberAndHash<Self>;
1868 type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
1869 type BlockHashProvider = pallet_mmr::DefaultBlockHashProvider<Runtime>;
1870 type WeightInfo = ();
1871 #[cfg(feature = "runtime-benchmarks")]
1872 type BenchmarkHelper = ();
1873}
1874
1875parameter_types! {
1876 pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0);
1877}
1878
1879impl pallet_beefy_mmr::Config for Runtime {
1880 type LeafVersion = LeafVersion;
1881 type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum;
1882 type LeafExtra = Vec<u8>;
1883 type BeefyDataProvider = ();
1884 type WeightInfo = ();
1885}
1886
1887parameter_types! {
1888 pub const LotteryPalletId: PalletId = PalletId(*b"py/lotto");
1889 pub const MaxCalls: u32 = 10;
1890 pub const MaxGenerateRandom: u32 = 10;
1891}
1892
1893impl pallet_lottery::Config for Runtime {
1894 type PalletId = LotteryPalletId;
1895 type RuntimeCall = RuntimeCall;
1896 type Currency = Balances;
1897 type Randomness = RandomnessCollectiveFlip;
1898 type RuntimeEvent = RuntimeEvent;
1899 type ManagerOrigin = EnsureRoot<AccountId>;
1900 type MaxCalls = MaxCalls;
1901 type ValidateCall = Lottery;
1902 type MaxGenerateRandom = MaxGenerateRandom;
1903 type WeightInfo = pallet_lottery::weights::SubstrateWeight<Runtime>;
1904}
1905
1906parameter_types! {
1907 pub const AssetDeposit: Balance = 100 * DOLLARS;
1908 pub const ApprovalDeposit: Balance = 1 * DOLLARS;
1909 pub const StringLimit: u32 = 50;
1910 pub const MetadataDepositBase: Balance = 10 * DOLLARS;
1911 pub const MetadataDepositPerByte: Balance = 1 * DOLLARS;
1912}
1913
1914impl pallet_assets::Config<Instance1> for Runtime {
1915 type RuntimeEvent = RuntimeEvent;
1916 type Balance = u128;
1917 type AssetId = u32;
1918 type AssetIdParameter = codec::Compact<u32>;
1919 type ReserveData = ();
1920 type Currency = Balances;
1921 type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
1922 type ForceOrigin = EnsureRoot<AccountId>;
1923 type AssetDeposit = AssetDeposit;
1924 type AssetAccountDeposit = ConstU128<DOLLARS>;
1925 type MetadataDepositBase = MetadataDepositBase;
1926 type MetadataDepositPerByte = MetadataDepositPerByte;
1927 type ApprovalDeposit = ApprovalDeposit;
1928 type StringLimit = StringLimit;
1929 type Holder = ();
1930 type Freezer = ();
1931 type Extra = ();
1932 type CallbackHandle = (pallet_assets_precompiles::ForeignAssetId<Runtime, Instance1>,);
1933 type AssetIdAllocator = ();
1934 type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
1935 type RemoveItemsLimit = ConstU32<1000>;
1936 #[cfg(feature = "runtime-benchmarks")]
1937 type BenchmarkHelper = ();
1938}
1939
1940ord_parameter_types! {
1941 pub const AssetConversionOrigin: AccountId = AccountIdConversion::<AccountId>::into_account_truncating(&AssetConversionPalletId::get());
1942}
1943
1944impl pallet_assets::Config<Instance2> for Runtime {
1945 type RuntimeEvent = RuntimeEvent;
1946 type Balance = u128;
1947 type AssetId = u32;
1948 type AssetIdParameter = codec::Compact<u32>;
1949 type ReserveData = ();
1950 type Currency = Balances;
1951 type CreateOrigin = AsEnsureOriginWithArg<EnsureSignedBy<AssetConversionOrigin, AccountId>>;
1952 type ForceOrigin = EnsureRoot<AccountId>;
1953 type AssetDeposit = AssetDeposit;
1954 type AssetAccountDeposit = ConstU128<DOLLARS>;
1955 type MetadataDepositBase = MetadataDepositBase;
1956 type MetadataDepositPerByte = MetadataDepositPerByte;
1957 type ApprovalDeposit = ApprovalDeposit;
1958 type StringLimit = StringLimit;
1959 type Holder = ();
1960 type Freezer = ();
1961 type Extra = ();
1962 type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
1963 type RemoveItemsLimit = ConstU32<1000>;
1964 type CallbackHandle = ();
1965 type AssetIdAllocator = ();
1966 #[cfg(feature = "runtime-benchmarks")]
1967 type BenchmarkHelper = ();
1968}
1969
1970parameter_types! {
1971 pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
1972 pub const PoolSetupFee: Balance = 1 * DOLLARS; pub const MintMinLiquidity: Balance = 100; pub LpFee: Permill = Permill::from_rational(3u32, 1_000u32); pub MaxSwapFee: Permill = Permill::from_percent(2);
1976 pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
1977 pub const Native: NativeOrWithId<u32> = NativeOrWithId::Native;
1978}
1979
1980pub type NativeAndAssets =
1981 UnionOf<Balances, Assets, NativeFromLeft, NativeOrWithId<u32>, AccountId>;
1982
1983impl pallet_asset_conversion::Config for Runtime {
1984 type RuntimeEvent = RuntimeEvent;
1985 type Balance = u128;
1986 type HigherPrecisionBalance = sp_core::U256;
1987 type AssetKind = NativeOrWithId<u32>;
1988 type Assets = NativeAndAssets;
1989 type PoolId = (Self::AssetKind, Self::AssetKind);
1990 type PoolLocator = Chain<
1991 WithFirstAsset<
1992 Native,
1993 AccountId,
1994 NativeOrWithId<u32>,
1995 AccountIdConverter<AssetConversionPalletId, Self::PoolId>,
1996 >,
1997 Ascending<
1998 AccountId,
1999 NativeOrWithId<u32>,
2000 AccountIdConverter<AssetConversionPalletId, Self::PoolId>,
2001 >,
2002 >;
2003 type PoolAssetId = <Self as pallet_assets::Config<Instance2>>::AssetId;
2004 type PoolAssets = PoolAssets;
2005 type PoolSetupFee = PoolSetupFee;
2006 type PoolSetupFeeAsset = Native;
2007 type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
2008 type PalletId = AssetConversionPalletId;
2009 type LPFee = LpFee;
2010 type AdminOrigin = EnsureRoot<AccountId>;
2011 type MaxSwapFee = MaxSwapFee;
2012 type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
2013 type WeightInfo = pallet_asset_conversion::weights::SubstrateWeight<Runtime>;
2014 type MaxSwapPathLength = ConstU32<4>;
2015 type MintMinLiquidity = MintMinLiquidity;
2016 #[cfg(feature = "runtime-benchmarks")]
2017 type BenchmarkHelper = ();
2018}
2019
2020pub type NativeAndAssetsFreezer =
2021 UnionOf<Balances, AssetsFreezer, NativeFromLeft, NativeOrWithId<u32>, AccountId>;
2022
2023#[cfg(feature = "runtime-benchmarks")]
2025pub struct AssetRewardsBenchmarkHelper;
2026
2027#[cfg(feature = "runtime-benchmarks")]
2028impl pallet_asset_rewards::benchmarking::BenchmarkHelper<NativeOrWithId<u32>>
2029 for AssetRewardsBenchmarkHelper
2030{
2031 fn staked_asset() -> NativeOrWithId<u32> {
2032 NativeOrWithId::<u32>::WithId(100)
2033 }
2034 fn reward_asset() -> NativeOrWithId<u32> {
2035 NativeOrWithId::<u32>::WithId(101)
2036 }
2037}
2038
2039parameter_types! {
2040 pub const StakingRewardsPalletId: PalletId = PalletId(*b"py/stkrd");
2041 pub const CreationHoldReason: RuntimeHoldReason =
2042 RuntimeHoldReason::AssetRewards(pallet_asset_rewards::HoldReason::PoolCreation);
2043 pub const StakePoolCreationDeposit: Balance = deposit(1, 135);
2045}
2046
2047impl pallet_asset_rewards::Config for Runtime {
2048 type RuntimeEvent = RuntimeEvent;
2049 type RuntimeFreezeReason = RuntimeFreezeReason;
2050 type AssetId = NativeOrWithId<u32>;
2051 type Balance = Balance;
2052 type Assets = NativeAndAssets;
2053 type PalletId = StakingRewardsPalletId;
2054 type CreatePoolOrigin = EnsureSigned<AccountId>;
2055 type WeightInfo = ();
2056 type AssetsFreezer = NativeAndAssetsFreezer;
2057 type Consideration = HoldConsideration<
2058 AccountId,
2059 Balances,
2060 CreationHoldReason,
2061 ConstantStoragePrice<StakePoolCreationDeposit, Balance>,
2062 >;
2063 type BlockNumberProvider = frame_system::Pallet<Runtime>;
2064 #[cfg(feature = "runtime-benchmarks")]
2065 type BenchmarkHelper = AssetRewardsBenchmarkHelper;
2066}
2067
2068impl pallet_asset_conversion_ops::Config for Runtime {
2069 type RuntimeEvent = RuntimeEvent;
2070 type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<(
2071 NativeOrWithId<u32>,
2072 NativeOrWithId<u32>,
2073 )>;
2074 type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
2075 type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
2076 type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
2077 type DepositAsset = Balances;
2078 type WeightInfo = pallet_asset_conversion_ops::weights::SubstrateWeight<Runtime>;
2079}
2080
2081parameter_types! {
2082 pub const QueueCount: u32 = 300;
2083 pub const MaxQueueLen: u32 = 1000;
2084 pub const FifoQueueLen: u32 = 500;
2085 pub const NisBasePeriod: BlockNumber = 30 * DAYS;
2086 pub const MinBid: Balance = 100 * DOLLARS;
2087 pub const MinReceipt: Perquintill = Perquintill::from_percent(1);
2088 pub const IntakePeriod: BlockNumber = 10;
2089 pub MaxIntakeWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
2090 pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
2091 pub Target: Perquintill = Perquintill::zero();
2092 pub const NisPalletId: PalletId = PalletId(*b"py/nis ");
2093}
2094
2095impl pallet_nis::Config for Runtime {
2096 type WeightInfo = pallet_nis::weights::SubstrateWeight<Runtime>;
2097 type RuntimeEvent = RuntimeEvent;
2098 type Currency = Balances;
2099 type CurrencyBalance = Balance;
2100 type FundOrigin = frame_system::EnsureSigned<AccountId>;
2101 type Counterpart = ItemOf<Assets, ConstU32<9u32>, AccountId>;
2102 type CounterpartAmount = WithMaximumOf<ConstU128<21_000_000_000_000_000_000u128>>;
2103 type Deficit = ();
2104 type IgnoredIssuance = ();
2105 type Target = Target;
2106 type PalletId = NisPalletId;
2107 type QueueCount = QueueCount;
2108 type MaxQueueLen = MaxQueueLen;
2109 type FifoQueueLen = FifoQueueLen;
2110 type BasePeriod = NisBasePeriod;
2111 type MinBid = MinBid;
2112 type MinReceipt = MinReceipt;
2113 type IntakePeriod = IntakePeriod;
2114 type MaxIntakeWeight = MaxIntakeWeight;
2115 type ThawThrottle = ThawThrottle;
2116 type RuntimeHoldReason = RuntimeHoldReason;
2117 #[cfg(feature = "runtime-benchmarks")]
2118 type BenchmarkSetup = SetupAsset;
2119}
2120
2121#[cfg(feature = "runtime-benchmarks")]
2122pub struct SetupAsset;
2123#[cfg(feature = "runtime-benchmarks")]
2124impl pallet_nis::BenchmarkSetup for SetupAsset {
2125 fn create_counterpart_asset() {
2126 let owner = AccountId::from([0u8; 32]);
2127 let _ = Assets::force_create(
2129 RuntimeOrigin::root(),
2130 9u32.into(),
2131 sp_runtime::MultiAddress::Id(owner),
2132 true,
2133 1,
2134 );
2135 }
2136}
2137
2138parameter_types! {
2139 pub const CollectionDeposit: Balance = 100 * DOLLARS;
2140 pub const ItemDeposit: Balance = 1 * DOLLARS;
2141 pub const ApprovalsLimit: u32 = 20;
2142 pub const ItemAttributesApprovalsLimit: u32 = 20;
2143 pub const MaxTips: u32 = 10;
2144 pub const MaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
2145}
2146
2147impl pallet_uniques::Config for Runtime {
2148 type RuntimeEvent = RuntimeEvent;
2149 type CollectionId = u32;
2150 type ItemId = u32;
2151 type Currency = Balances;
2152 type ForceOrigin = frame_system::EnsureRoot<AccountId>;
2153 type CollectionDeposit = CollectionDeposit;
2154 type ItemDeposit = ItemDeposit;
2155 type MetadataDepositBase = MetadataDepositBase;
2156 type AttributeDepositBase = MetadataDepositBase;
2157 type DepositPerByte = MetadataDepositPerByte;
2158 type StringLimit = ConstU32<128>;
2159 type KeyLimit = ConstU32<32>;
2160 type ValueLimit = ConstU32<64>;
2161 type WeightInfo = pallet_uniques::weights::SubstrateWeight<Runtime>;
2162 #[cfg(feature = "runtime-benchmarks")]
2163 type Helper = ();
2164 type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
2165 type Locker = ();
2166}
2167
2168parameter_types! {
2169 pub const Budget: Balance = 10_000 * DOLLARS;
2170 pub TreasuryAccount: AccountId = Treasury::account_id();
2171}
2172
2173pub struct SalaryForRank;
2174impl GetSalary<u16, AccountId, Balance> for SalaryForRank {
2175 fn get_salary(a: u16, _: &AccountId) -> Balance {
2176 Balance::from(a) * 1000 * DOLLARS
2177 }
2178}
2179
2180impl pallet_salary::Config for Runtime {
2181 type WeightInfo = ();
2182 type RuntimeEvent = RuntimeEvent;
2183 type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
2184 type Members = RankedCollective;
2185 type Salary = SalaryForRank;
2186 type RegistrationPeriod = ConstU32<200>;
2187 type PayoutPeriod = ConstU32<200>;
2188 type Budget = Budget;
2189}
2190
2191impl pallet_core_fellowship::Config for Runtime {
2192 type WeightInfo = ();
2193 type RuntimeEvent = RuntimeEvent;
2194 type Members = RankedCollective;
2195 type Balance = Balance;
2196 type ParamsOrigin = frame_system::EnsureRoot<AccountId>;
2197 type InductOrigin = pallet_core_fellowship::EnsureInducted<Runtime, (), 1>;
2198 type ApproveOrigin = EnsureRootWithSuccess<AccountId, ConstU16<9>>;
2199 type PromoteOrigin = EnsureRootWithSuccess<AccountId, ConstU16<9>>;
2200 type FastPromoteOrigin = Self::PromoteOrigin;
2201 type EvidenceSize = ConstU32<16_384>;
2202 type MaxRank = ConstU16<9>;
2203 type BlockNumberProvider = System;
2204}
2205
2206parameter_types! {
2207 pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction");
2208 pub NewAssetSymbol: BoundedVec<u8, StringLimit> = (*b"FRAC").to_vec().try_into().unwrap();
2209 pub NewAssetName: BoundedVec<u8, StringLimit> = (*b"Frac").to_vec().try_into().unwrap();
2210}
2211
2212impl pallet_nft_fractionalization::Config for Runtime {
2213 type RuntimeEvent = RuntimeEvent;
2214 type Deposit = AssetDeposit;
2215 type Currency = Balances;
2216 type NewAssetSymbol = NewAssetSymbol;
2217 type NewAssetName = NewAssetName;
2218 type StringLimit = StringLimit;
2219 type NftCollectionId = <Self as pallet_nfts::Config>::CollectionId;
2220 type NftId = <Self as pallet_nfts::Config>::ItemId;
2221 type AssetBalance = <Self as pallet_balances::Config>::Balance;
2222 type AssetId = <Self as pallet_assets::Config<Instance1>>::AssetId;
2223 type Assets = Assets;
2224 type Nfts = Nfts;
2225 type PalletId = NftFractionalizationPalletId;
2226 type WeightInfo = pallet_nft_fractionalization::weights::SubstrateWeight<Runtime>;
2227 type RuntimeHoldReason = RuntimeHoldReason;
2228 #[cfg(feature = "runtime-benchmarks")]
2229 type BenchmarkHelper = ();
2230}
2231
2232parameter_types! {
2233 pub Features: PalletFeatures = PalletFeatures::all_enabled();
2234 pub const MaxAttributesPerCall: u32 = 10;
2235}
2236
2237impl pallet_nfts::Config for Runtime {
2238 type RuntimeEvent = RuntimeEvent;
2239 type CollectionId = u32;
2240 type ItemId = u32;
2241 type Currency = Balances;
2242 type ForceOrigin = frame_system::EnsureRoot<AccountId>;
2243 type CollectionDeposit = CollectionDeposit;
2244 type ItemDeposit = ItemDeposit;
2245 type MetadataDepositBase = MetadataDepositBase;
2246 type AttributeDepositBase = MetadataDepositBase;
2247 type DepositPerByte = MetadataDepositPerByte;
2248 type StringLimit = ConstU32<256>;
2249 type KeyLimit = ConstU32<64>;
2250 type ValueLimit = ConstU32<256>;
2251 type ApprovalsLimit = ApprovalsLimit;
2252 type ItemAttributesApprovalsLimit = ItemAttributesApprovalsLimit;
2253 type MaxTips = MaxTips;
2254 type MaxDeadlineDuration = MaxDeadlineDuration;
2255 type MaxAttributesPerCall = MaxAttributesPerCall;
2256 type Features = Features;
2257 type OffchainSignature = Signature;
2258 type OffchainPublic = <Signature as traits::Verify>::Signer;
2259 type WeightInfo = pallet_nfts::weights::SubstrateWeight<Runtime>;
2260 #[cfg(feature = "runtime-benchmarks")]
2261 type Helper = ();
2262 type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
2263 type Locker = ();
2264 type BlockNumberProvider = frame_system::Pallet<Runtime>;
2265}
2266
2267impl pallet_transaction_storage::Config for Runtime {
2268 type RuntimeEvent = RuntimeEvent;
2269 type Currency = Balances;
2270 type RuntimeHoldReason = RuntimeHoldReason;
2271 type RuntimeCall = RuntimeCall;
2272 type FeeDestination = ();
2273 type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight<Runtime>;
2274 type MaxBlockTransactions =
2275 ConstU32<{ pallet_transaction_storage::DEFAULT_MAX_BLOCK_TRANSACTIONS }>;
2276 type MaxTransactionSize =
2277 ConstU32<{ pallet_transaction_storage::DEFAULT_MAX_TRANSACTION_SIZE }>;
2278}
2279
2280impl pallet_verify_signature::Config for Runtime {
2281 type Signature = MultiSignature;
2282 type AccountIdentifier = MultiSigner;
2283 type WeightInfo = pallet_verify_signature::weights::SubstrateWeight<Runtime>;
2284 #[cfg(feature = "runtime-benchmarks")]
2285 type BenchmarkHelper = ();
2286}
2287
2288impl pallet_whitelist::Config for Runtime {
2289 type RuntimeEvent = RuntimeEvent;
2290 type RuntimeCall = RuntimeCall;
2291 type WhitelistOrigin = EnsureRoot<AccountId>;
2292 type DispatchWhitelistedOrigin =
2294 EitherOfDiverse<EnsureRoot<AccountId>, EnsureAuthorized<AccountId>>;
2295 type Preimages = Preimage;
2296 type DeferredDispatchExpiration = ConstU32<{ 28 * DAYS }>;
2297 type BlockNumberProvider = frame_system::Pallet<Runtime>;
2298 type WeightInfo = pallet_whitelist::weights::SubstrateWeight<Runtime>;
2299}
2300
2301parameter_types! {
2302 pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
2303 pub const MigrationSignedDepositBase: Balance = 20 * DOLLARS;
2304 pub const MigrationMaxKeyLen: u32 = 512;
2305}
2306
2307impl pallet_state_trie_migration::Config for Runtime {
2308 type RuntimeEvent = RuntimeEvent;
2309 type ControlOrigin = EnsureRoot<AccountId>;
2310 type Currency = Balances;
2311 type RuntimeHoldReason = RuntimeHoldReason;
2312 type MaxKeyLen = MigrationMaxKeyLen;
2313 type SignedDepositPerItem = MigrationSignedDepositPerItem;
2314 type SignedDepositBase = MigrationSignedDepositBase;
2315 type SignedFilter = EnsureSigned<Self::AccountId>;
2320 type WeightInfo = ();
2321}
2322
2323const ALLIANCE_MOTION_DURATION_IN_BLOCKS: BlockNumber = 5 * DAYS;
2324
2325parameter_types! {
2326 pub const AllianceMotionDuration: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS;
2327 pub const AllianceMaxProposals: u32 = 100;
2328 pub const AllianceMaxMembers: u32 = 100;
2329}
2330
2331type AllianceCollective = pallet_collective::Instance3;
2332impl pallet_collective::Config<AllianceCollective> for Runtime {
2333 type RuntimeOrigin = RuntimeOrigin;
2334 type Proposal = RuntimeCall;
2335 type RuntimeEvent = RuntimeEvent;
2336 type MotionDuration = AllianceMotionDuration;
2337 type MaxProposals = AllianceMaxProposals;
2338 type MaxMembers = AllianceMaxMembers;
2339 type DefaultVote = pallet_collective::PrimeDefaultVote;
2340 type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
2341 type SetMembersOrigin = EnsureRoot<Self::AccountId>;
2342 type MaxProposalWeight = MaxCollectivesProposalWeight;
2343 type DisapproveOrigin = EnsureRoot<Self::AccountId>;
2344 type KillOrigin = EnsureRoot<Self::AccountId>;
2345 type Consideration = ();
2346}
2347
2348parameter_types! {
2349 pub const MaxFellows: u32 = AllianceMaxMembers::get();
2350 pub const MaxAllies: u32 = 100;
2351 pub const AllyDeposit: Balance = 10 * DOLLARS;
2352 pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS + (1 * DAYS);
2353}
2354
2355impl pallet_alliance::Config for Runtime {
2356 type RuntimeEvent = RuntimeEvent;
2357 type Proposal = RuntimeCall;
2358 type AdminOrigin = EitherOfDiverse<
2359 EnsureRoot<AccountId>,
2360 pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
2361 >;
2362 type MembershipManager = EitherOfDiverse<
2363 EnsureRoot<AccountId>,
2364 pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
2365 >;
2366 type AnnouncementOrigin = EitherOfDiverse<
2367 EnsureRoot<AccountId>,
2368 pallet_collective::EnsureProportionMoreThan<AccountId, AllianceCollective, 2, 3>,
2369 >;
2370 type Currency = Balances;
2371 type Slashed = Treasury;
2372 type InitializeMembers = AllianceMotion;
2373 type MembershipChanged = AllianceMotion;
2374 #[cfg(not(feature = "runtime-benchmarks"))]
2375 type IdentityVerifier = AllianceIdentityVerifier;
2376 #[cfg(feature = "runtime-benchmarks")]
2377 type IdentityVerifier = ();
2378 type ProposalProvider = AllianceProposalProvider;
2379 type MaxProposals = AllianceMaxProposals;
2380 type MaxFellows = MaxFellows;
2381 type MaxAllies = MaxAllies;
2382 type MaxUnscrupulousItems = ConstU32<100>;
2383 type MaxWebsiteUrlLength = ConstU32<255>;
2384 type MaxAnnouncementsCount = ConstU32<100>;
2385 type MaxMembersCount = AllianceMaxMembers;
2386 type AllyDeposit = AllyDeposit;
2387 type WeightInfo = pallet_alliance::weights::SubstrateWeight<Runtime>;
2388 type RetirementPeriod = RetirementPeriod;
2389}
2390
2391impl frame_benchmarking_pallet_pov::Config for Runtime {
2392 type RuntimeEvent = RuntimeEvent;
2393}
2394
2395parameter_types! {
2396 pub StatementCost: Balance = 1 * DOLLARS;
2397 pub StatementByteCost: Balance = 100 * MILLICENTS;
2398 pub const MinAllowedStatements: u32 = 4;
2399 pub const MaxAllowedStatements: u32 = 10;
2400 pub const MinAllowedBytes: u32 = 1024;
2401 pub const MaxAllowedBytes: u32 = 4096;
2402}
2403
2404impl pallet_statement::Config for Runtime {
2405 type RuntimeEvent = RuntimeEvent;
2406 type Currency = Balances;
2407 type StatementCost = StatementCost;
2408 type ByteCost = StatementByteCost;
2409 type MinAllowedStatements = MinAllowedStatements;
2410 type MaxAllowedStatements = MaxAllowedStatements;
2411 type MinAllowedBytes = MinAllowedBytes;
2412 type MaxAllowedBytes = MaxAllowedBytes;
2413}
2414
2415parameter_types! {
2416 pub MbmServiceWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
2417}
2418
2419impl pallet_migrations::Config for Runtime {
2420 type RuntimeEvent = RuntimeEvent;
2421 #[cfg(not(feature = "runtime-benchmarks"))]
2422 type Migrations = ();
2423 #[cfg(feature = "runtime-benchmarks")]
2425 type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
2426 type CursorMaxLen = ConstU32<65_536>;
2427 type IdentifierMaxLen = ConstU32<256>;
2428 type MigrationStatusHandler = ();
2429 type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
2430 type MaxServiceWeight = MbmServiceWeight;
2431 type WeightInfo = pallet_migrations::weights::SubstrateWeight<Runtime>;
2432}
2433
2434parameter_types! {
2435 pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
2436 pub const MinimumCreditPurchase: Balance = 100 * MILLICENTS;
2437}
2438
2439pub struct IntoAuthor;
2440impl OnUnbalanced<Credit<AccountId, Balances>> for IntoAuthor {
2441 fn on_nonzero_unbalanced(credit: Credit<AccountId, Balances>) {
2442 if let Some(author) = Authorship::author() {
2443 let _ = <Balances as Balanced<_>>::resolve(&author, credit);
2444 }
2445 }
2446}
2447
2448pub struct CoretimeProvider;
2449impl CoretimeInterface for CoretimeProvider {
2450 type AccountId = AccountId;
2451 type Balance = Balance;
2452 type RelayChainBlockNumberProvider = System;
2453 fn request_core_count(_count: CoreIndex) {}
2454 fn request_revenue_info_at(_when: u32) {}
2455 fn credit_account(_who: Self::AccountId, _amount: Self::Balance) {}
2456 fn assign_core(
2457 _core: CoreIndex,
2458 _begin: u32,
2459 _assignment: Vec<(CoreAssignment, PartsOf57600)>,
2460 _end_hint: Option<u32>,
2461 ) {
2462 }
2463}
2464
2465pub struct SovereignAccountOf;
2466impl MaybeConvert<TaskId, AccountId> for SovereignAccountOf {
2468 fn maybe_convert(task: TaskId) -> Option<AccountId> {
2469 let mut account: [u8; 32] = [0; 32];
2470 account[..4].copy_from_slice(&task.to_le_bytes());
2471 Some(account.into())
2472 }
2473}
2474impl pallet_broker::Config for Runtime {
2475 type RuntimeEvent = RuntimeEvent;
2476 type Currency = Balances;
2477 type OnRevenue = IntoAuthor;
2478 type TimeslicePeriod = ConstU32<2>;
2479 type MaxLeasedCores = ConstU32<5>;
2480 type MaxReservedCores = ConstU32<5>;
2481 type Coretime = CoretimeProvider;
2482 type ConvertBalance = traits::Identity;
2483 type WeightInfo = ();
2484 type PalletId = BrokerPalletId;
2485 type AdminOrigin = EnsureRoot<AccountId>;
2486 type SovereignAccountOf = SovereignAccountOf;
2487 type MaxAutoRenewals = ConstU32<10>;
2488 type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
2489 type MinimumCreditPurchase = MinimumCreditPurchase;
2490}
2491
2492parameter_types! {
2493 pub const OnDemandPalletId: PalletId = PalletId(*b"py/ondmd");
2494}
2495
2496pub struct OnDemandPoolCapacity;
2501impl pallet_on_demand_para::PoolCapacityProvider for OnDemandPoolCapacity {
2502 fn pool_cores() -> u32 {
2503 1
2504 }
2505}
2506
2507impl pallet_on_demand_para::Config for Runtime {
2508 type WeightInfo = pallet_on_demand_para::weights::SubstrateWeight<Runtime>;
2509 type Currency = Balances;
2510 type AdminOrigin = EnsureRoot<AccountId>;
2511 type RelayBlockNumberProvider = System;
2512 type PoolCapacityProvider = OnDemandPoolCapacity;
2513 type PricingProvider = pallet_on_demand_para::DefaultPricingProvider;
2514 type OrderQueue = ();
2516 type MaxBatchSize = ConstU32<1000>;
2517 type PalletId = OnDemandPalletId;
2518}
2519
2520parameter_types! {
2521 pub const MixnetNumCoverToCurrentBlocks: BlockNumber = 3;
2522 pub const MixnetNumRequestsToCurrentBlocks: BlockNumber = 3;
2523 pub const MixnetNumCoverToPrevBlocks: BlockNumber = 3;
2524 pub const MixnetNumRegisterStartSlackBlocks: BlockNumber = 3;
2525 pub const MixnetNumRegisterEndSlackBlocks: BlockNumber = 3;
2526 pub const MixnetRegistrationPriority: TransactionPriority = ImOnlineUnsignedPriority::get() - 1;
2527}
2528
2529impl pallet_mixnet::Config for Runtime {
2530 type MaxAuthorities = MaxAuthorities;
2531 type MaxExternalAddressSize = ConstU32<128>;
2532 type MaxExternalAddressesPerMixnode = ConstU32<16>;
2533 type NextSessionRotation = Babe;
2534 type NumCoverToCurrentBlocks = MixnetNumCoverToCurrentBlocks;
2535 type NumRequestsToCurrentBlocks = MixnetNumRequestsToCurrentBlocks;
2536 type NumCoverToPrevBlocks = MixnetNumCoverToPrevBlocks;
2537 type NumRegisterStartSlackBlocks = MixnetNumRegisterStartSlackBlocks;
2538 type NumRegisterEndSlackBlocks = MixnetNumRegisterEndSlackBlocks;
2539 type RegistrationPriority = MixnetRegistrationPriority;
2540 type MinMixnodes = ConstU32<7>; }
2542
2543#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
2546pub mod dynamic_params {
2547 use super::*;
2548
2549 #[dynamic_pallet_params]
2550 #[codec(index = 0)]
2551 pub mod storage {
2552 #[codec(index = 0)]
2554 pub static BaseDeposit: Balance = 1 * DOLLARS;
2555
2556 #[codec(index = 1)]
2558 pub static ByteDeposit: Balance = 1 * CENTS;
2559 }
2560
2561 #[dynamic_pallet_params]
2562 #[codec(index = 1)]
2563 pub mod referenda {
2564 #[codec(index = 0)]
2566 pub static Tracks: BoundedVec<
2567 pallet_referenda::Track<u16, Balance, BlockNumber>,
2568 ConstU32<100>,
2569 > = BoundedVec::truncate_from(vec![pallet_referenda::Track {
2570 id: 0u16,
2571 info: pallet_referenda::TrackInfo {
2572 name: s("root"),
2573 max_deciding: 1,
2574 decision_deposit: 10,
2575 prepare_period: 4,
2576 decision_period: 4,
2577 confirm_period: 2,
2578 min_enactment_period: 4,
2579 min_approval: pallet_referenda::Curve::LinearDecreasing {
2580 length: Perbill::from_percent(100),
2581 floor: Perbill::from_percent(50),
2582 ceil: Perbill::from_percent(100),
2583 },
2584 min_support: pallet_referenda::Curve::LinearDecreasing {
2585 length: Perbill::from_percent(100),
2586 floor: Perbill::from_percent(0),
2587 ceil: Perbill::from_percent(100),
2588 },
2589 },
2590 }]);
2591
2592 #[codec(index = 1)]
2594 pub static Origins: BoundedVec<(OriginCaller, u16), ConstU32<100>> =
2595 BoundedVec::truncate_from(vec![(
2596 OriginCaller::system(frame_system::RawOrigin::Root),
2597 0,
2598 )]);
2599 }
2600}
2601
2602#[cfg(feature = "runtime-benchmarks")]
2603impl Default for RuntimeParameters {
2604 fn default() -> Self {
2605 RuntimeParameters::Storage(dynamic_params::storage::Parameters::BaseDeposit(
2606 dynamic_params::storage::BaseDeposit,
2607 Some(1 * DOLLARS),
2608 ))
2609 }
2610}
2611
2612pub struct DynamicParametersManagerOrigin;
2613impl EnsureOriginWithArg<RuntimeOrigin, RuntimeParametersKey> for DynamicParametersManagerOrigin {
2614 type Success = ();
2615
2616 fn try_origin(
2617 origin: RuntimeOrigin,
2618 key: &RuntimeParametersKey,
2619 ) -> Result<Self::Success, RuntimeOrigin> {
2620 match key {
2621 RuntimeParametersKey::Storage(_) => {
2622 frame_system::ensure_root(origin.clone()).map_err(|_| origin)?;
2623 return Ok(());
2624 },
2625 RuntimeParametersKey::Referenda(_) => {
2626 frame_system::ensure_root(origin.clone()).map_err(|_| origin)?;
2627 return Ok(());
2628 },
2629 }
2630 }
2631
2632 #[cfg(feature = "runtime-benchmarks")]
2633 fn try_successful_origin(_key: &RuntimeParametersKey) -> Result<RuntimeOrigin, ()> {
2634 Ok(RuntimeOrigin::root())
2635 }
2636}
2637
2638impl pallet_parameters::Config for Runtime {
2639 type RuntimeParameters = RuntimeParameters;
2640 type RuntimeEvent = RuntimeEvent;
2641 type AdminOrigin = DynamicParametersManagerOrigin;
2642 type WeightInfo = ();
2643}
2644
2645pub type MetaTxExtension = (
2646 pallet_verify_signature::VerifySignature<Runtime>,
2647 pallet_meta_tx::MetaTxMarker<Runtime>,
2648 frame_system::CheckNonZeroSender<Runtime>,
2649 frame_system::CheckSpecVersion<Runtime>,
2650 frame_system::CheckTxVersion<Runtime>,
2651 frame_system::CheckGenesis<Runtime>,
2652 frame_system::CheckEra<Runtime>,
2653 frame_system::CheckNonce<Runtime>,
2654 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
2655);
2656
2657impl pallet_meta_tx::Config for Runtime {
2658 type WeightInfo = ();
2659 type RuntimeEvent = RuntimeEvent;
2660 #[cfg(not(feature = "runtime-benchmarks"))]
2661 type Extension = MetaTxExtension;
2662 #[cfg(feature = "runtime-benchmarks")]
2663 type Extension = pallet_meta_tx::WeightlessExtension<Runtime>;
2664}
2665
2666pub struct DiscardRegistrarMessages;
2668
2669impl pallet_registrar_para::SendToRelay for DiscardRegistrarMessages {
2670 type AccountId = AccountId;
2671
2672 fn send(_message: registrar_primitives::MessageToRelay<AccountId>) -> Result<(), ()> {
2673 Ok(())
2674 }
2675}
2676
2677impl pallet_registrar_relay::SendToPara for DiscardRegistrarMessages {
2678 fn send(_message: registrar_primitives::MessageToPara) -> Result<(), ()> {
2679 Ok(())
2680 }
2681}
2682
2683parameter_types! {
2684 pub const ParaIdReservationDeposit: Balance = 100 * DOLLARS;
2685 pub const RegistrationDepositPerByte: Balance = 10 * MILLICENTS;
2686 pub const ParaIdReservationHoldReason: RuntimeHoldReason =
2687 RuntimeHoldReason::RegistrarPara(pallet_registrar_para::HoldReason::ParaIdReservation);
2688 pub const RegistrationHoldReason: RuntimeHoldReason =
2689 RuntimeHoldReason::RegistrarPara(pallet_registrar_para::HoldReason::Registration);
2690}
2691
2692impl pallet_registrar_para::Config for Runtime {
2693 type ReservationConsideration = HoldConsideration<
2694 AccountId,
2695 Balances,
2696 ParaIdReservationHoldReason,
2697 ConstantStoragePrice<ParaIdReservationDeposit, Balance>,
2698 >;
2699 type RegistrationConsideration = HoldConsideration<
2700 AccountId,
2701 Balances,
2702 RegistrationHoldReason,
2703 LinearStoragePrice<ConstU128<0>, RegistrationDepositPerByte, Balance>,
2704 >;
2705 type SendToRelay = DiscardRegistrarMessages;
2706 type RelayOrigin = EnsureRoot<AccountId>;
2707 type ParachainOrigin = frame_system::EnsureNever<registrar_primitives::ParaId>;
2708 type FirstPublicParaId = ConstU32<2000>;
2709 type MinCodeSize = ConstU32<9>;
2710 type MaxCodeSize = ConstU32<{ 3 * 1024 * 1024 }>;
2711 type MaxHeadDataSize = ConstU32<{ 1024 * 1024 }>;
2712 type PendingDeadline = ConstU32<600>;
2713 type BlockNumberProvider = System;
2714 type WeightInfo = pallet_registrar_para::weights::SubstrateWeight<Runtime>;
2715}
2716
2717pub struct AcceptingRegistrar;
2719
2720impl registrar_primitives::ParachainRegistrar for AcceptingRegistrar {
2721 type AccountId = AccountId;
2722
2723 fn check_onboarding(_head_len: u32, _code_len: u32) -> Result<(), ()> {
2724 Ok(())
2725 }
2726
2727 fn is_registered(_para_id: registrar_primitives::ParaId) -> bool {
2728 false
2729 }
2730
2731 fn register(
2732 _manager: AccountId,
2733 _para_id: registrar_primitives::ParaId,
2734 _genesis_head: Vec<u8>,
2735 _validation_code: Vec<u8>,
2736 ) -> sp_runtime::DispatchResult {
2737 Ok(())
2738 }
2739
2740 fn deregister(_para_id: registrar_primitives::ParaId) -> sp_runtime::DispatchResult {
2741 Ok(())
2742 }
2743
2744 #[cfg(feature = "runtime-benchmarks")]
2745 fn setup_worst_case_deregister(
2746 _para_id: registrar_primitives::ParaId,
2747 ) -> sp_runtime::DispatchResult {
2748 Ok(())
2749 }
2750
2751 fn check_head_data(_head_len: u32) -> Result<(), ()> {
2752 Ok(())
2753 }
2754
2755 fn set_current_head(_para_id: registrar_primitives::ParaId, _head: Vec<u8>) {}
2756
2757 fn check_code_upgrade(
2758 _para_id: registrar_primitives::ParaId,
2759 _code_len: u32,
2760 ) -> Result<(), ()> {
2761 Ok(())
2762 }
2763
2764 fn schedule_code_upgrade(
2765 _para_id: registrar_primitives::ParaId,
2766 _validation_code: Vec<u8>,
2767 ) -> sp_runtime::DispatchResult {
2768 Ok(())
2769 }
2770}
2771
2772impl pallet_registrar_relay::Config for Runtime {
2773 type RuntimeEvent = RuntimeEvent;
2774 type ParaOrigin = EnsureRoot<AccountId>;
2775 type SendToPara = DiscardRegistrarMessages;
2776 type Registrar = AcceptingRegistrar;
2777 type MaxHeadDataSize = ConstU32<{ 1024 * 1024 }>;
2778 type MaxCodeSize = ConstU32<{ 3 * 1024 * 1024 }>;
2779 type MaxPendingRegistrations = ConstU32<128>;
2780 type UnsignedPriority = ConstU64<100>;
2781 type WeightInfo = pallet_registrar_relay::weights::SubstrateWeight<Runtime>;
2782}
2783
2784#[frame_support::runtime]
2785mod runtime {
2786 use super::*;
2787
2788 #[runtime::runtime]
2789 #[runtime::derive(
2790 RuntimeCall,
2791 RuntimeEvent,
2792 RuntimeError,
2793 RuntimeOrigin,
2794 RuntimeFreezeReason,
2795 RuntimeHoldReason,
2796 RuntimeSlashReason,
2797 RuntimeLockId,
2798 RuntimeTask,
2799 RuntimeViewFunction
2800 )]
2801 pub struct Runtime;
2802
2803 #[runtime::pallet_index(0)]
2804 pub type System = frame_system::Pallet<Runtime>;
2805
2806 #[runtime::pallet_index(1)]
2807 pub type Utility = pallet_utility::Pallet<Runtime>;
2808
2809 #[runtime::pallet_index(2)]
2810 pub type Babe = pallet_babe::Pallet<Runtime>;
2811
2812 #[runtime::pallet_index(3)]
2813 pub type Timestamp = pallet_timestamp::Pallet<Runtime>;
2814
2815 #[runtime::pallet_index(4)]
2818 pub type Authorship = pallet_authorship::Pallet<Runtime>;
2819
2820 #[runtime::pallet_index(5)]
2821 pub type Indices = pallet_indices::Pallet<Runtime>;
2822
2823 #[runtime::pallet_index(6)]
2824 pub type Balances = pallet_balances::Pallet<Runtime>;
2825
2826 #[runtime::pallet_index(7)]
2827 pub type TransactionPayment = pallet_transaction_payment::Pallet<Runtime>;
2828
2829 #[runtime::pallet_index(9)]
2830 pub type AssetConversionTxPayment = pallet_asset_conversion_tx_payment::Pallet<Runtime>;
2831
2832 #[runtime::pallet_index(10)]
2833 pub type ElectionProviderMultiPhase = pallet_election_provider_multi_phase::Pallet<Runtime>;
2834
2835 #[runtime::pallet_index(11)]
2836 pub type Staking = pallet_staking::Pallet<Runtime>;
2837
2838 #[runtime::pallet_index(12)]
2839 pub type Session = pallet_session::Pallet<Runtime>;
2840
2841 #[runtime::pallet_index(13)]
2842 pub type Democracy = pallet_democracy::Pallet<Runtime>;
2843
2844 #[runtime::pallet_index(14)]
2845 pub type Council = pallet_collective::Pallet<Runtime, Instance1>;
2846
2847 #[runtime::pallet_index(15)]
2848 pub type TechnicalCommittee = pallet_collective::Pallet<Runtime, Instance2>;
2849
2850 #[runtime::pallet_index(16)]
2851 pub type Elections = pallet_elections_phragmen::Pallet<Runtime>;
2852
2853 #[runtime::pallet_index(17)]
2854 pub type TechnicalMembership = pallet_membership::Pallet<Runtime, Instance1>;
2855
2856 #[runtime::pallet_index(18)]
2857 pub type Grandpa = pallet_grandpa::Pallet<Runtime>;
2858
2859 #[runtime::pallet_index(19)]
2860 pub type Treasury = pallet_treasury::Pallet<Runtime>;
2861
2862 #[runtime::pallet_index(20)]
2863 pub type AssetRate = pallet_asset_rate::Pallet<Runtime>;
2864
2865 #[runtime::pallet_index(21)]
2866 pub type Contracts = pallet_contracts::Pallet<Runtime>;
2867
2868 #[runtime::pallet_index(22)]
2869 pub type Sudo = pallet_sudo::Pallet<Runtime>;
2870
2871 #[runtime::pallet_index(23)]
2872 pub type ImOnline = pallet_im_online::Pallet<Runtime>;
2873
2874 #[runtime::pallet_index(24)]
2875 pub type AuthorityDiscovery = pallet_authority_discovery::Pallet<Runtime>;
2876
2877 #[runtime::pallet_index(25)]
2878 pub type Offences = pallet_offences::Pallet<Runtime>;
2879
2880 #[runtime::pallet_index(26)]
2881 pub type Historical = pallet_session_historical::Pallet<Runtime>;
2882
2883 #[runtime::pallet_index(27)]
2884 pub type RandomnessCollectiveFlip = pallet_insecure_randomness_collective_flip::Pallet<Runtime>;
2885
2886 #[runtime::pallet_index(28)]
2887 pub type Identity = pallet_identity::Pallet<Runtime>;
2888
2889 #[runtime::pallet_index(29)]
2890 pub type Society = pallet_society::Pallet<Runtime>;
2891
2892 #[runtime::pallet_index(30)]
2893 pub type Recovery = pallet_recovery::Pallet<Runtime>;
2894
2895 #[runtime::pallet_index(31)]
2896 pub type Vesting = pallet_vesting::Pallet<Runtime>;
2897
2898 #[runtime::pallet_index(32)]
2899 pub type Scheduler = pallet_scheduler::Pallet<Runtime>;
2900
2901 #[runtime::pallet_index(33)]
2902 pub type Glutton = pallet_glutton::Pallet<Runtime>;
2903
2904 #[runtime::pallet_index(34)]
2905 pub type Preimage = pallet_preimage::Pallet<Runtime>;
2906
2907 #[runtime::pallet_index(35)]
2908 pub type Proxy = pallet_proxy::Pallet<Runtime>;
2909
2910 #[runtime::pallet_index(36)]
2911 pub type Multisig = pallet_multisig::Pallet<Runtime>;
2912
2913 #[runtime::pallet_index(37)]
2914 pub type Bounties = pallet_bounties::Pallet<Runtime>;
2915
2916 #[runtime::pallet_index(38)]
2917 pub type Tips = pallet_tips::Pallet<Runtime>;
2918
2919 #[runtime::pallet_index(39)]
2920 pub type Assets = pallet_assets::Pallet<Runtime, Instance1>;
2921
2922 #[runtime::pallet_index(40)]
2923 pub type PoolAssets = pallet_assets::Pallet<Runtime, Instance2>;
2924
2925 #[runtime::pallet_index(41)]
2926 pub type Beefy = pallet_beefy::Pallet<Runtime>;
2927
2928 #[runtime::pallet_index(42)]
2931 pub type Mmr = pallet_mmr::Pallet<Runtime>;
2932
2933 #[runtime::pallet_index(43)]
2934 pub type MmrLeaf = pallet_beefy_mmr::Pallet<Runtime>;
2935
2936 #[runtime::pallet_index(44)]
2937 pub type Lottery = pallet_lottery::Pallet<Runtime>;
2938
2939 #[runtime::pallet_index(45)]
2940 pub type Nis = pallet_nis::Pallet<Runtime>;
2941
2942 #[runtime::pallet_index(46)]
2943 pub type Uniques = pallet_uniques::Pallet<Runtime>;
2944
2945 #[runtime::pallet_index(47)]
2946 pub type Nfts = pallet_nfts::Pallet<Runtime>;
2947
2948 #[runtime::pallet_index(48)]
2949 pub type NftFractionalization = pallet_nft_fractionalization::Pallet<Runtime>;
2950
2951 #[runtime::pallet_index(49)]
2952 pub type Salary = pallet_salary::Pallet<Runtime>;
2953
2954 #[runtime::pallet_index(50)]
2955 pub type CoreFellowship = pallet_core_fellowship::Pallet<Runtime>;
2956
2957 #[runtime::pallet_index(51)]
2958 pub type TransactionStorage = pallet_transaction_storage::Pallet<Runtime>;
2959
2960 #[runtime::pallet_index(52)]
2961 pub type VoterList = pallet_bags_list::Pallet<Runtime, Instance1>;
2962
2963 #[runtime::pallet_index(53)]
2964 pub type StateTrieMigration = pallet_state_trie_migration::Pallet<Runtime>;
2965
2966 #[runtime::pallet_index(54)]
2967 pub type ChildBounties = pallet_child_bounties::Pallet<Runtime>;
2968
2969 #[runtime::pallet_index(55)]
2970 pub type Referenda = pallet_referenda::Pallet<Runtime>;
2971
2972 #[runtime::pallet_index(56)]
2973 pub type Remark = pallet_remark::Pallet<Runtime>;
2974
2975 #[runtime::pallet_index(57)]
2976 pub type RootTesting = pallet_root_testing::Pallet<Runtime>;
2977
2978 #[runtime::pallet_index(58)]
2979 pub type ConvictionVoting = pallet_conviction_voting::Pallet<Runtime>;
2980
2981 #[runtime::pallet_index(59)]
2982 pub type Whitelist = pallet_whitelist::Pallet<Runtime>;
2983
2984 #[runtime::pallet_index(60)]
2985 pub type AllianceMotion = pallet_collective::Pallet<Runtime, Instance3>;
2986
2987 #[runtime::pallet_index(61)]
2988 pub type Alliance = pallet_alliance::Pallet<Runtime>;
2989
2990 #[runtime::pallet_index(62)]
2991 pub type NominationPools = pallet_nomination_pools::Pallet<Runtime>;
2992
2993 #[runtime::pallet_index(63)]
2994 pub type RankedPolls = pallet_referenda::Pallet<Runtime, Instance2>;
2995
2996 #[runtime::pallet_index(64)]
2997 pub type RankedCollective = pallet_ranked_collective::Pallet<Runtime>;
2998
2999 #[runtime::pallet_index(65)]
3000 pub type AssetConversion = pallet_asset_conversion::Pallet<Runtime>;
3001
3002 #[runtime::pallet_index(66)]
3003 pub type FastUnstake = pallet_fast_unstake::Pallet<Runtime>;
3004
3005 #[runtime::pallet_index(67)]
3006 pub type MessageQueue = pallet_message_queue::Pallet<Runtime>;
3007
3008 #[runtime::pallet_index(68)]
3009 pub type Pov = frame_benchmarking_pallet_pov::Pallet<Runtime>;
3010
3011 #[runtime::pallet_index(69)]
3012 pub type TxPause = pallet_tx_pause::Pallet<Runtime>;
3013
3014 #[runtime::pallet_index(70)]
3015 pub type SafeMode = pallet_safe_mode::Pallet<Runtime>;
3016
3017 #[runtime::pallet_index(71)]
3018 pub type Statement = pallet_statement::Pallet<Runtime>;
3019
3020 #[runtime::pallet_index(72)]
3021 pub type MultiBlockMigrations = pallet_migrations::Pallet<Runtime>;
3022
3023 #[runtime::pallet_index(73)]
3024 pub type Broker = pallet_broker::Pallet<Runtime>;
3025
3026 #[runtime::pallet_index(74)]
3027 pub type TasksExample = pallet_example_tasks::Pallet<Runtime>;
3028
3029 #[runtime::pallet_index(75)]
3030 pub type Mixnet = pallet_mixnet::Pallet<Runtime>;
3031
3032 #[runtime::pallet_index(76)]
3033 pub type Parameters = pallet_parameters::Pallet<Runtime>;
3034
3035 #[runtime::pallet_index(77)]
3036 pub type SkipFeelessPayment = pallet_skip_feeless_payment::Pallet<Runtime>;
3037
3038 #[runtime::pallet_index(78)]
3039 pub type PalletExampleMbms = pallet_example_mbm::Pallet<Runtime>;
3040
3041 #[runtime::pallet_index(79)]
3042 pub type AssetConversionMigration = pallet_asset_conversion_ops::Pallet<Runtime>;
3043
3044 #[runtime::pallet_index(80)]
3045 pub type Revive = pallet_revive::Pallet<Runtime>;
3046
3047 #[runtime::pallet_index(81)]
3048 pub type VerifySignature = pallet_verify_signature::Pallet<Runtime>;
3049
3050 #[runtime::pallet_index(82)]
3051 pub type DelegatedStaking = pallet_delegated_staking::Pallet<Runtime>;
3052
3053 #[runtime::pallet_index(83)]
3054 pub type AssetRewards = pallet_asset_rewards::Pallet<Runtime>;
3055
3056 #[runtime::pallet_index(84)]
3057 pub type AssetsFreezer = pallet_assets_freezer::Pallet<Runtime, Instance1>;
3058
3059 #[runtime::pallet_index(85)]
3060 pub type Oracle = pallet_oracle::Pallet<Runtime>;
3061
3062 #[runtime::pallet_index(86)]
3063 pub type Psm = pallet_psm::Pallet<Runtime>;
3064
3065 #[runtime::pallet_index(89)]
3066 pub type MetaTx = pallet_meta_tx::Pallet<Runtime>;
3067
3068 #[runtime::pallet_index(90)]
3069 pub type MultiAssetBounties = pallet_multi_asset_bounties::Pallet<Runtime>;
3070
3071 #[runtime::pallet_index(91)]
3072 pub type AssetsPrecompiles = pallet_assets_precompiles::pallet::Pallet<Runtime>;
3073
3074 #[runtime::pallet_index(92)]
3075 pub type AssetsPrecompilesPermit = pallet_assets_precompiles::permit::pallet::Pallet<Runtime>;
3076
3077 #[runtime::pallet_index(93)]
3078 pub type VestingPrecompiles = pallet_vesting_precompiles::pallet::Pallet<Runtime>;
3079
3080 #[runtime::pallet_index(94)]
3081 pub type Dap = pallet_dap::Pallet<Runtime>;
3082
3083 #[runtime::pallet_index(95)]
3084 pub type RegistrarPara = pallet_registrar_para::Pallet<Runtime>;
3085
3086 #[runtime::pallet_index(96)]
3087 pub type RegistrarRelay = pallet_registrar_relay::Pallet<Runtime>;
3088
3089 #[runtime::pallet_index(97)]
3090 pub type OnDemand = pallet_on_demand_para::Pallet<Runtime>;
3091}
3092
3093pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
3095pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
3097pub type Block = generic::Block<Header, UncheckedExtrinsic>;
3099pub type SignedBlock = generic::SignedBlock<Block>;
3101pub type BlockId = generic::BlockId<Block>;
3103pub type TxExtension = (
3109 frame_system::AuthorizeCall<Runtime>,
3110 frame_system::CheckNonZeroSender<Runtime>,
3111 frame_system::CheckSpecVersion<Runtime>,
3112 frame_system::CheckTxVersion<Runtime>,
3113 frame_system::CheckGenesis<Runtime>,
3114 frame_system::CheckEra<Runtime>,
3115 frame_system::CheckNonce<Runtime>,
3116 frame_system::CheckWeight<Runtime>,
3117 pallet_skip_feeless_payment::SkipCheckIfFeeless<
3118 Runtime,
3119 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
3120 >,
3121 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
3122 pallet_revive::evm::tx_extension::SetOrigin<Runtime>,
3123 frame_system::WeightReclaim<Runtime>,
3124);
3125
3126#[derive(Clone, PartialEq, Eq, Debug)]
3127pub struct EthExtraImpl;
3128
3129impl EthExtra for EthExtraImpl {
3130 type Config = Runtime;
3131 type ExtensionV0 = TxExtension;
3132 type ExtensionOtherVersions = sp_runtime::traits::InvalidVersion;
3133
3134 fn get_eth_extension(nonce: u32, tip: Balance) -> Self::ExtensionV0 {
3135 (
3136 frame_system::AuthorizeCall::<Runtime>::new(),
3137 frame_system::CheckNonZeroSender::<Runtime>::new(),
3138 frame_system::CheckSpecVersion::<Runtime>::new(),
3139 frame_system::CheckTxVersion::<Runtime>::new(),
3140 frame_system::CheckGenesis::<Runtime>::new(),
3141 frame_system::CheckEra::from(crate::generic::Era::Immortal),
3142 frame_system::CheckNonce::<Runtime>::from(nonce),
3143 frame_system::CheckWeight::<Runtime>::new(),
3144 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(tip, None)
3145 .into(),
3146 frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
3147 pallet_revive::evm::tx_extension::SetOrigin::<Runtime>::new_from_eth_transaction(),
3148 frame_system::WeightReclaim::<Runtime>::new(),
3149 )
3150 }
3151}
3152
3153pub type UncheckedExtrinsic =
3155 pallet_revive::evm::runtime::UncheckedExtrinsic<Address, Signature, EthExtraImpl>;
3156pub type UncheckedSignaturePayload =
3158 generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
3159pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
3161pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, TxExtension>;
3163pub type Executive = frame_executive::Executive<
3165 Runtime,
3166 Block,
3167 frame_system::ChainContext<Runtime>,
3168 Runtime,
3169 AllPalletsWithSystem,
3170>;
3171
3172const IDENTITY_MIGRATION_KEY_LIMIT: u64 = u64::MAX;
3174
3175type Migrations = (
3179 pallet_nomination_pools::migration::versioned::V6ToV7<Runtime>,
3180 pallet_alliance::migration::Migration<Runtime>,
3181 pallet_contracts::Migration<Runtime>,
3182 pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
3183);
3184
3185type EventRecord = frame_system::EventRecord<
3186 <Runtime as frame_system::Config>::RuntimeEvent,
3187 <Runtime as frame_system::Config>::Hash,
3188>;
3189
3190parameter_types! {
3191 pub const BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
3192}
3193
3194impl pallet_beefy::Config for Runtime {
3195 type BeefyId = BeefyId;
3196 type MaxAuthorities = MaxAuthorities;
3197 type MaxNominators = ConstU32<0>;
3198 type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
3199 type OnNewValidatorSet = MmrLeaf;
3200 type AncestryHelper = MmrLeaf;
3201 type WeightInfo = ();
3202 type KeyOwnerProof = sp_session::MembershipProof;
3203 type EquivocationReportSystem =
3204 pallet_beefy::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
3205}
3206
3207parameter_types! {
3208 pub const OracleMaxHasDispatchedSize: u32 = 20;
3209 pub const RootOperatorAccountId: AccountId = AccountId::new([0xffu8; 32]);
3210
3211 pub const OracleMaxFeedValues: u32 = 10;
3212}
3213
3214#[cfg(feature = "runtime-benchmarks")]
3215pub struct OracleBenchmarkingHelper;
3216
3217#[cfg(feature = "runtime-benchmarks")]
3218impl pallet_oracle::BenchmarkHelper<u32, u128, OracleMaxFeedValues> for OracleBenchmarkingHelper {
3219 fn get_currency_id_value_pairs() -> BoundedVec<(u32, u128), OracleMaxFeedValues> {
3220 use rand::{distributions::Uniform, prelude::*};
3221
3222 let mut rng = rand_pcg::Pcg32::seed_from_u64(0x1234567890ABCDEF);
3224 let max_values = OracleMaxFeedValues::get() as usize;
3225
3226 let currency_range = Uniform::new_inclusive(1, 1000);
3228 let value_range = Uniform::new_inclusive(1000, 1_000_000);
3229
3230 let pairs: Vec<(u32, u128)> = (0..max_values)
3231 .map(|_| {
3232 let currency_id = rng.sample(currency_range);
3233 let value = rng.sample(value_range);
3234 (currency_id, value)
3235 })
3236 .collect();
3237
3238 BoundedVec::try_from(pairs).unwrap_or_default()
3240 }
3241}
3242
3243parameter_types! {
3244 pub const OraclePalletId: PalletId = PalletId(*b"py/oracl");
3245}
3246
3247impl pallet_oracle::Config for Runtime {
3248 type OnNewData = ();
3249 type CombineData = pallet_oracle::DefaultCombineData<Self, ConstU32<5>, ConstU64<3600>>;
3250 type Time = Timestamp;
3251 type OracleKey = u32;
3252 type OracleValue = u128;
3253 type PalletId = OraclePalletId;
3254 type Members = TechnicalMembership;
3255 type WeightInfo = ();
3256 type MaxHasDispatchedSize = OracleMaxHasDispatchedSize;
3257 type MaxFeedValues = OracleMaxFeedValues;
3258 #[cfg(feature = "runtime-benchmarks")]
3259 type BenchmarkHelper = OracleBenchmarkingHelper;
3260}
3261
3262parameter_types! {
3263 pub const PsmPalletId: PalletId = PalletId(*b"py/pegsm");
3265 pub const PsmCreationDeposit: Balance = 10 * DOLLARS;
3267 pub const PsmDepositSlope: Balance = 0;
3269 pub PsmHoldReason: RuntimeHoldReason = RuntimeHoldReason::Psm(pallet_psm::HoldReason::CreationDeposit);
3270}
3271
3272#[cfg(feature = "runtime-benchmarks")]
3273pub struct PsmBenchmarkHelper;
3274#[cfg(feature = "runtime-benchmarks")]
3275impl pallet_psm::BenchmarkHelper<u32, AccountId> for PsmBenchmarkHelper {
3276 fn get_asset_id(asset_index: u32) -> u32 {
3277 asset_index
3278 }
3279 fn create_asset(asset_id: u32, owner: &AccountId, decimals: u8) {
3280 use frame_support::traits::fungibles::{metadata::Mutate as MetadataMutate, Create};
3281 if !<Assets as frame_support::traits::fungibles::Inspect<AccountId>>::asset_exists(asset_id)
3282 {
3283 let _ = <Assets as Create<AccountId>>::create(asset_id, owner.clone(), true, 1);
3284 }
3285 let _ = Balances::force_set_balance(
3286 RuntimeOrigin::root(),
3287 owner.clone().into(),
3288 10u128.pow(18),
3289 );
3290 let _ = <Assets as MetadataMutate<AccountId>>::set(
3291 asset_id,
3292 owner,
3293 b"Benchmark".to_vec(),
3294 b"BNC".to_vec(),
3295 decimals,
3296 );
3297 }
3298}
3299
3300impl pallet_psm::Config for Runtime {
3302 type Fungibles = Assets;
3303 type Consideration = HoldConsideration<
3304 AccountId,
3305 Balances,
3306 PsmHoldReason,
3307 LinearStoragePrice<PsmCreationDeposit, PsmDepositSlope, Balance>,
3308 >;
3309 type CreateOrigin = pallet_psm::EnsureAssetOwner<Runtime>;
3310 type RuntimeOrigin = RuntimeOrigin;
3311 type PalletsOrigin = OriginCaller;
3312 type AssetId = u32;
3313 type WeightInfo = pallet_psm::weights::SubstrateWeight<Runtime>;
3314 type PalletId = PsmPalletId;
3315 type MaxExternals = ConstU32<10>;
3316 #[cfg(feature = "runtime-benchmarks")]
3317 type BenchmarkHelper = PsmBenchmarkHelper;
3318}
3319
3320mod mmr {
3322 use super::*;
3323 pub use pallet_mmr::primitives::*;
3324
3325 pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
3326 pub type Hash = <Hashing as sp_runtime::traits::Hash>::Output;
3327 pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
3328}
3329
3330#[cfg(feature = "runtime-benchmarks")]
3331pub struct AssetConversionTxHelper;
3332
3333#[cfg(feature = "runtime-benchmarks")]
3334impl
3335 pallet_asset_conversion_tx_payment::BenchmarkHelperTrait<
3336 AccountId,
3337 NativeOrWithId<u32>,
3338 NativeOrWithId<u32>,
3339 > for AssetConversionTxHelper
3340{
3341 fn create_asset_id_parameter(seed: u32) -> (NativeOrWithId<u32>, NativeOrWithId<u32>) {
3342 (NativeOrWithId::WithId(seed), NativeOrWithId::WithId(seed))
3343 }
3344
3345 fn setup_balances_and_pool(asset_id: NativeOrWithId<u32>, account: AccountId) {
3346 use frame_support::{assert_ok, traits::fungibles::Mutate};
3347 let NativeOrWithId::WithId(asset_idx) = asset_id.clone() else { unimplemented!() };
3348 assert_ok!(Assets::force_create(
3349 RuntimeOrigin::root(),
3350 asset_idx.into(),
3351 account.clone().into(), true, 1,
3354 ));
3355
3356 let lp_provider = account.clone();
3357 let _ = Balances::deposit_creating(&lp_provider, ((u64::MAX as u128) * 100).into());
3358 assert_ok!(Assets::mint_into(
3359 asset_idx.into(),
3360 &lp_provider,
3361 ((u64::MAX as u128) * 100).into()
3362 ));
3363
3364 let token_native = alloc::boxed::Box::new(NativeOrWithId::Native);
3365 let token_second = alloc::boxed::Box::new(asset_id);
3366
3367 assert_ok!(AssetConversion::create_pool(
3368 RuntimeOrigin::signed(lp_provider.clone()),
3369 token_native.clone(),
3370 token_second.clone()
3371 ));
3372
3373 assert_ok!(AssetConversion::add_liquidity(
3374 RuntimeOrigin::signed(lp_provider.clone()),
3375 token_native,
3376 token_second,
3377 u64::MAX.into(), u64::MAX.into(), 1, 1, lp_provider,
3382 ));
3383 }
3384}
3385
3386#[cfg(feature = "runtime-benchmarks")]
3387mod benches {
3388 polkadot_sdk::frame_benchmarking::define_benchmarks!(
3389 [frame_benchmarking, BaselineBench::<Runtime>]
3390 [frame_benchmarking_pallet_pov, Pov]
3391 [pallet_alliance, Alliance]
3392 [pallet_assets, Assets]
3393 [pallet_babe, Babe]
3394 [pallet_bags_list, VoterList]
3395 [pallet_balances, Balances]
3396 [pallet_beefy_mmr, MmrLeaf]
3397 [pallet_bounties, Bounties]
3398 [pallet_broker, Broker]
3399 [pallet_child_bounties, ChildBounties]
3400 [pallet_collective, Council]
3401 [pallet_conviction_voting, ConvictionVoting]
3402 [pallet_contracts, Contracts]
3403 [pallet_revive, Revive]
3404 [pallet_core_fellowship, CoreFellowship]
3405 [pallet_example_tasks, TasksExample]
3406 [pallet_democracy, Democracy]
3407 [pallet_asset_conversion, AssetConversion]
3408 [pallet_asset_rewards, AssetRewards]
3409 [pallet_asset_conversion_tx_payment, AssetConversionTxPayment]
3410 [pallet_transaction_payment, TransactionPayment]
3411 [pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
3412 [pallet_election_provider_support_benchmarking, EPSBench::<Runtime>]
3413 [pallet_elections_phragmen, Elections]
3414 [pallet_fast_unstake, FastUnstake]
3415 [pallet_nis, Nis]
3416 [pallet_parameters, Parameters]
3417 [pallet_grandpa, Grandpa]
3418 [pallet_identity, Identity]
3419 [pallet_im_online, ImOnline]
3420 [pallet_indices, Indices]
3421 [pallet_lottery, Lottery]
3422 [pallet_membership, TechnicalMembership]
3423 [pallet_message_queue, MessageQueue]
3424 [pallet_migrations, MultiBlockMigrations]
3425 [pallet_mmr, Mmr]
3426 [pallet_multi_asset_bounties, MultiAssetBounties]
3427 [pallet_assets_precompiles, AssetsPrecompiles]
3428 [pallet_vesting_precompiles, VestingPrecompiles]
3429 [pallet_multisig, Multisig]
3430 [pallet_offences, OffencesBench::<Runtime>]
3431 [pallet_on_demand_para, OnDemand]
3432 [pallet_oracle, Oracle]
3433 [pallet_preimage, Preimage]
3434 [pallet_proxy, Proxy]
3435 [pallet_ranked_collective, RankedCollective]
3436 [pallet_referenda, Referenda]
3437 [pallet_recovery, Recovery]
3438 [pallet_registrar_para, RegistrarPara]
3439 [pallet_registrar_relay, RegistrarRelay]
3440 [pallet_remark, Remark]
3441 [pallet_salary, Salary]
3442 [pallet_scheduler, Scheduler]
3443 [pallet_glutton, Glutton]
3444 [pallet_session, SessionBench::<Runtime>]
3445 [pallet_society, Society]
3446 [pallet_dap, Dap]
3447 [pallet_staking, Staking]
3448 [pallet_state_trie_migration, StateTrieMigration]
3449 [pallet_sudo, Sudo]
3450 [frame_system, SystemBench::<Runtime>]
3451 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
3452 [pallet_timestamp, Timestamp]
3453 [pallet_tips, Tips]
3454 [pallet_transaction_storage, TransactionStorage]
3455 [pallet_treasury, Treasury]
3456 [pallet_asset_rate, AssetRate]
3457 [pallet_uniques, Uniques]
3458 [pallet_nfts, Nfts]
3459 [pallet_nft_fractionalization, NftFractionalization]
3460 [pallet_utility, Utility]
3461 [pallet_vesting, Vesting]
3462 [pallet_whitelist, Whitelist]
3463 [pallet_tx_pause, TxPause]
3464 [pallet_safe_mode, SafeMode]
3465 [pallet_example_mbm, PalletExampleMbms]
3466 [pallet_asset_conversion_ops, AssetConversionMigration]
3467 [pallet_verify_signature, VerifySignature]
3468 [pallet_meta_tx, MetaTx]
3469 [pallet_psm, Psm]
3470 );
3471}
3472
3473pallet_revive::impl_runtime_apis_plus_revive_traits!(
3474 Runtime,
3475 Revive,
3476 Executive,
3477 EthExtraImpl,
3478
3479 impl sp_api::Core<Block> for Runtime {
3480 fn version() -> RuntimeVersion {
3481 VERSION
3482 }
3483
3484 fn execute_block(block: <Block as BlockT>::LazyBlock) {
3485 Executive::execute_block(block);
3486 }
3487
3488 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
3489 Executive::initialize_block(header)
3490 }
3491 }
3492
3493 impl sp_api::Metadata<Block> for Runtime {
3494 fn metadata() -> OpaqueMetadata {
3495 OpaqueMetadata::new(Runtime::metadata().into())
3496 }
3497
3498 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
3499 Runtime::metadata_at_version(version)
3500 }
3501
3502 fn metadata_versions() -> alloc::vec::Vec<u32> {
3503 Runtime::metadata_versions()
3504 }
3505 }
3506
3507 impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
3508 fn execute_view_function(id: frame_support::view_functions::ViewFunctionId, input: Vec<u8>) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
3509 Runtime::execute_view_function(id, input)
3510 }
3511 }
3512
3513 impl sp_block_builder::BlockBuilder<Block> for Runtime {
3514 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
3515 Executive::apply_extrinsic(extrinsic)
3516 }
3517
3518 fn finalize_block() -> <Block as BlockT>::Header {
3519 Executive::finalize_block()
3520 }
3521
3522 fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
3523 data.create_extrinsics()
3524 }
3525
3526 fn check_inherents(block: <Block as BlockT>::LazyBlock, data: InherentData) -> CheckInherentsResult {
3527 data.check_extrinsics(&block)
3528 }
3529 }
3530
3531 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
3532 fn validate_transaction(
3533 source: TransactionSource,
3534 tx: <Block as BlockT>::Extrinsic,
3535 block_hash: <Block as BlockT>::Hash,
3536 ) -> TransactionValidity {
3537 Executive::validate_transaction(source, tx, block_hash)
3538 }
3539 }
3540
3541 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
3542 fn offchain_worker(header: &<Block as BlockT>::Header) {
3543 Executive::offchain_worker(header)
3544 }
3545 }
3546
3547 impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
3548 fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
3549 Grandpa::grandpa_authorities()
3550 }
3551
3552 fn current_set_id() -> sp_consensus_grandpa::SetId {
3553 pallet_grandpa::CurrentSetId::<Runtime>::get()
3554 }
3555
3556 fn submit_report_equivocation_unsigned_extrinsic(
3557 equivocation_proof: sp_consensus_grandpa::EquivocationProof<
3558 <Block as BlockT>::Hash,
3559 NumberFor<Block>,
3560 >,
3561 key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
3562 ) -> Option<()> {
3563 let key_owner_proof = key_owner_proof.decode()?;
3564
3565 Grandpa::submit_unsigned_equivocation_report(
3566 equivocation_proof,
3567 key_owner_proof,
3568 )
3569 }
3570
3571 fn generate_key_ownership_proof(
3572 _set_id: sp_consensus_grandpa::SetId,
3573 authority_id: GrandpaId,
3574 ) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
3575 use codec::Encode;
3576
3577 Historical::prove((sp_consensus_grandpa::KEY_TYPE, authority_id))
3578 .map(|p| p.encode())
3579 .map(sp_consensus_grandpa::OpaqueKeyOwnershipProof::new)
3580 }
3581 }
3582
3583 impl pallet_nomination_pools_runtime_api::NominationPoolsApi<Block, AccountId, Balance> for Runtime {
3584 fn pending_rewards(who: AccountId) -> Balance {
3585 NominationPools::api_pending_rewards(who).unwrap_or_default()
3586 }
3587
3588 fn points_to_balance(pool_id: PoolId, points: Balance) -> Balance {
3589 NominationPools::api_points_to_balance(pool_id, points)
3590 }
3591
3592 fn balance_to_points(pool_id: PoolId, new_funds: Balance) -> Balance {
3593 NominationPools::api_balance_to_points(pool_id, new_funds)
3594 }
3595
3596 fn pool_pending_slash(pool_id: PoolId) -> Balance {
3597 NominationPools::api_pool_pending_slash(pool_id)
3598 }
3599
3600 fn member_pending_slash(member: AccountId) -> Balance {
3601 NominationPools::api_member_pending_slash(member)
3602 }
3603
3604 fn pool_needs_delegate_migration(pool_id: PoolId) -> bool {
3605 NominationPools::api_pool_needs_delegate_migration(pool_id)
3606 }
3607
3608 fn member_needs_delegate_migration(member: AccountId) -> bool {
3609 NominationPools::api_member_needs_delegate_migration(member)
3610 }
3611
3612 fn member_total_balance(member: AccountId) -> Balance {
3613 NominationPools::api_member_total_balance(member)
3614 }
3615
3616 fn pool_balance(pool_id: PoolId) -> Balance {
3617 NominationPools::api_pool_balance(pool_id)
3618 }
3619
3620 fn pool_accounts(pool_id: PoolId) -> (AccountId, AccountId) {
3621 NominationPools::api_pool_accounts(pool_id)
3622 }
3623 }
3624
3625 impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
3626 fn nominations_quota(balance: Balance) -> u32 {
3627 Staking::api_nominations_quota(balance)
3628 }
3629
3630 fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
3631 Staking::api_eras_stakers_page_count(era, account)
3632 }
3633
3634 fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool {
3635 Staking::api_pending_rewards(era, account)
3636 }
3637 }
3638
3639 impl sp_consensus_babe::BabeApi<Block> for Runtime {
3640 fn configuration() -> sp_consensus_babe::BabeConfiguration {
3641 let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
3642 sp_consensus_babe::BabeConfiguration {
3643 slot_duration: Babe::slot_duration(),
3644 epoch_length: EpochDuration::get(),
3645 c: epoch_config.c,
3646 authorities: Babe::authorities().to_vec(),
3647 randomness: Babe::randomness(),
3648 allowed_slots: epoch_config.allowed_slots,
3649 }
3650 }
3651
3652 fn current_epoch_start() -> sp_consensus_babe::Slot {
3653 Babe::current_epoch_start()
3654 }
3655
3656 fn current_epoch() -> sp_consensus_babe::Epoch {
3657 Babe::current_epoch()
3658 }
3659
3660 fn next_epoch() -> sp_consensus_babe::Epoch {
3661 Babe::next_epoch()
3662 }
3663
3664 fn generate_key_ownership_proof(
3665 _slot: sp_consensus_babe::Slot,
3666 authority_id: sp_consensus_babe::AuthorityId,
3667 ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
3668 use codec::Encode;
3669
3670 Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
3671 .map(|p| p.encode())
3672 .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
3673 }
3674
3675 fn submit_report_equivocation_unsigned_extrinsic(
3676 equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
3677 key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
3678 ) -> Option<()> {
3679 let key_owner_proof = key_owner_proof.decode()?;
3680
3681 Babe::submit_unsigned_equivocation_report(
3682 equivocation_proof,
3683 key_owner_proof,
3684 )
3685 }
3686 }
3687
3688 impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
3689 fn authorities() -> Vec<AuthorityDiscoveryId> {
3690 AuthorityDiscovery::authorities()
3691 }
3692 }
3693
3694 impl polkadot_sdk::pallet_oracle_runtime_api::OracleApi<Block, u32, u32, u128> for Runtime {
3695 fn get_value(_provider_id: u32, key: u32) -> Option<u128> {
3696 pallet_oracle::Pallet::<Runtime>::get(&key).map(|v| v.value)
3698 }
3699
3700 fn get_all_values(_provider_id: u32) -> Vec<(u32, Option<u128>)> {
3701 use pallet_oracle::DataProviderExtended;
3702 pallet_oracle::Pallet::<Runtime>::get_all_values()
3703 .map(|(k, v)| (k, v.map(|tv| tv.value)))
3704 .collect()
3705 }
3706 }
3707
3708 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
3709 fn account_nonce(account: AccountId) -> Nonce {
3710 System::account_nonce(account)
3711 }
3712 }
3713
3714 impl assets_api::AssetsApi<
3715 Block,
3716 AccountId,
3717 Balance,
3718 u32,
3719 > for Runtime
3720 {
3721 fn account_balances(account: AccountId) -> Vec<(u32, Balance)> {
3722 Assets::account_balances(account)
3723 }
3724 }
3725
3726 impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash, EventRecord> for Runtime
3727 {
3728 fn call(
3729 origin: AccountId,
3730 dest: AccountId,
3731 value: Balance,
3732 gas_limit: Option<Weight>,
3733 storage_deposit_limit: Option<Balance>,
3734 input_data: Vec<u8>,
3735 ) -> pallet_contracts::ContractExecResult<Balance, EventRecord> {
3736 let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
3737 Contracts::bare_call(
3738 origin,
3739 dest,
3740 value,
3741 gas_limit,
3742 storage_deposit_limit,
3743 input_data,
3744 pallet_contracts::DebugInfo::UnsafeDebug,
3745 pallet_contracts::CollectEvents::UnsafeCollect,
3746 pallet_contracts::Determinism::Enforced,
3747 )
3748 }
3749
3750 fn instantiate(
3751 origin: AccountId,
3752 value: Balance,
3753 gas_limit: Option<Weight>,
3754 storage_deposit_limit: Option<Balance>,
3755 code: pallet_contracts::Code<Hash>,
3756 data: Vec<u8>,
3757 salt: Vec<u8>,
3758 ) -> pallet_contracts::ContractInstantiateResult<AccountId, Balance, EventRecord>
3759 {
3760 let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
3761 Contracts::bare_instantiate(
3762 origin,
3763 value,
3764 gas_limit,
3765 storage_deposit_limit,
3766 code,
3767 data,
3768 salt,
3769 pallet_contracts::DebugInfo::UnsafeDebug,
3770 pallet_contracts::CollectEvents::UnsafeCollect,
3771 )
3772 }
3773
3774 fn upload_code(
3775 origin: AccountId,
3776 code: Vec<u8>,
3777 storage_deposit_limit: Option<Balance>,
3778 determinism: pallet_contracts::Determinism,
3779 ) -> pallet_contracts::CodeUploadResult<Hash, Balance>
3780 {
3781 Contracts::bare_upload_code(
3782 origin,
3783 code,
3784 storage_deposit_limit,
3785 determinism,
3786 )
3787 }
3788
3789 fn get_storage(
3790 address: AccountId,
3791 key: Vec<u8>,
3792 ) -> pallet_contracts::GetStorageResult {
3793 Contracts::get_storage(
3794 address,
3795 key
3796 )
3797 }
3798 }
3799
3800 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
3801 Block,
3802 Balance,
3803 > for Runtime {
3804 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
3805 TransactionPayment::query_info(uxt, len)
3806 }
3807 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
3808 TransactionPayment::query_fee_details(uxt, len)
3809 }
3810 fn query_weight_to_fee(weight: Weight) -> Balance {
3811 TransactionPayment::weight_to_fee(weight)
3812 }
3813 fn query_length_to_fee(length: u32) -> Balance {
3814 TransactionPayment::length_to_fee(length)
3815 }
3816 }
3817
3818 impl pallet_asset_conversion::AssetConversionApi<
3819 Block,
3820 Balance,
3821 NativeOrWithId<u32>
3822 > for Runtime
3823 {
3824 fn quote_price_exact_tokens_for_tokens(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>, amount: Balance, include_fee: bool) -> Option<Balance> {
3825 AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
3826 }
3827
3828 fn quote_price_tokens_for_exact_tokens(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>, amount: Balance, include_fee: bool) -> Option<Balance> {
3829 AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
3830 }
3831
3832 fn get_reserves(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>) -> Option<(Balance, Balance)> {
3833 AssetConversion::get_reserves(asset1, asset2).ok()
3834 }
3835 }
3836
3837 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
3838 for Runtime
3839 {
3840 fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo<Balance> {
3841 TransactionPayment::query_call_info(call, len)
3842 }
3843 fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails<Balance> {
3844 TransactionPayment::query_call_fee_details(call, len)
3845 }
3846 fn query_weight_to_fee(weight: Weight) -> Balance {
3847 TransactionPayment::weight_to_fee(weight)
3848 }
3849 fn query_length_to_fee(length: u32) -> Balance {
3850 TransactionPayment::length_to_fee(length)
3851 }
3852 }
3853
3854 impl pallet_nfts_runtime_api::NftsApi<Block, AccountId, u32, u32> for Runtime {
3855 fn owner(collection: u32, item: u32) -> Option<AccountId> {
3856 <Nfts as Inspect<AccountId>>::owner(&collection, &item)
3857 }
3858
3859 fn collection_owner(collection: u32) -> Option<AccountId> {
3860 <Nfts as Inspect<AccountId>>::collection_owner(&collection)
3861 }
3862
3863 fn attribute(
3864 collection: u32,
3865 item: u32,
3866 key: Vec<u8>,
3867 ) -> Option<Vec<u8>> {
3868 <Nfts as Inspect<AccountId>>::attribute(&collection, &item, &key)
3869 }
3870
3871 fn custom_attribute(
3872 account: AccountId,
3873 collection: u32,
3874 item: u32,
3875 key: Vec<u8>,
3876 ) -> Option<Vec<u8>> {
3877 <Nfts as Inspect<AccountId>>::custom_attribute(
3878 &account,
3879 &collection,
3880 &item,
3881 &key,
3882 )
3883 }
3884
3885 fn system_attribute(
3886 collection: u32,
3887 item: Option<u32>,
3888 key: Vec<u8>,
3889 ) -> Option<Vec<u8>> {
3890 <Nfts as Inspect<AccountId>>::system_attribute(&collection, item.as_ref(), &key)
3891 }
3892
3893 fn collection_attribute(collection: u32, key: Vec<u8>) -> Option<Vec<u8>> {
3894 <Nfts as Inspect<AccountId>>::collection_attribute(&collection, &key)
3895 }
3896 }
3897
3898 #[api_version(6)]
3899 impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
3900 fn beefy_genesis() -> Option<BlockNumber> {
3901 pallet_beefy::GenesisBlock::<Runtime>::get()
3902 }
3903
3904 fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
3905 Beefy::validator_set()
3906 }
3907
3908 fn submit_report_double_voting_unsigned_extrinsic(
3909 equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
3910 BlockNumber,
3911 BeefyId,
3912 BeefySignature,
3913 >,
3914 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3915 ) -> Option<()> {
3916 let key_owner_proof = key_owner_proof.decode()?;
3917
3918 Beefy::submit_unsigned_double_voting_report(
3919 equivocation_proof,
3920 key_owner_proof,
3921 )
3922 }
3923
3924 fn submit_report_fork_voting_unsigned_extrinsic(
3925 equivocation_proof:
3926 sp_consensus_beefy::ForkVotingProof<
3927 <Block as BlockT>::Header,
3928 BeefyId,
3929 sp_runtime::OpaqueValue
3930 >,
3931 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3932 ) -> Option<()> {
3933 Beefy::submit_unsigned_fork_voting_report(
3934 equivocation_proof.try_into()?,
3935 key_owner_proof.decode()?,
3936 )
3937 }
3938
3939 fn submit_report_future_block_voting_unsigned_extrinsic(
3940 equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
3941 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3942 ) -> Option<()> {
3943 Beefy::submit_unsigned_future_block_voting_report(
3944 equivocation_proof,
3945 key_owner_proof.decode()?,
3946 )
3947 }
3948
3949 fn generate_key_ownership_proof(
3950 _set_id: sp_consensus_beefy::ValidatorSetId,
3951 authority_id: BeefyId,
3952 ) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
3953 Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
3954 .map(|p| p.encode())
3955 .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
3956 }
3957 }
3958
3959 #[api_version(3)]
3960 impl pallet_mmr::primitives::MmrApi<
3961 Block,
3962 mmr::Hash,
3963 BlockNumber,
3964 > for Runtime {
3965 fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
3966 Ok(pallet_mmr::RootHash::<Runtime>::get())
3967 }
3968
3969 fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
3970 Ok(pallet_mmr::NumberOfLeaves::<Runtime>::get())
3971 }
3972
3973 fn generate_proof(
3974 block_numbers: Vec<BlockNumber>,
3975 best_known_block_number: Option<BlockNumber>,
3976 ) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<mmr::Hash>), mmr::Error> {
3977 Mmr::generate_proof(block_numbers, best_known_block_number).map(
3978 |(leaves, proof)| {
3979 (
3980 leaves
3981 .into_iter()
3982 .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
3983 .collect(),
3984 proof,
3985 )
3986 },
3987 )
3988 }
3989
3990 fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::LeafProof<mmr::Hash>)
3991 -> Result<(), mmr::Error>
3992 {
3993 let leaves = leaves.into_iter().map(|leaf|
3994 leaf.into_opaque_leaf()
3995 .try_decode()
3996 .ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;
3997 Mmr::verify_leaves(leaves, proof)
3998 }
3999
4000 fn generate_ancestry_proof(
4001 prev_block_number: BlockNumber,
4002 best_known_block_number: Option<BlockNumber>,
4003 ) -> Result<mmr::AncestryProof<mmr::Hash>, mmr::Error> {
4004 Mmr::generate_ancestry_proof(prev_block_number, best_known_block_number)
4005 }
4006
4007 fn verify_proof_stateless(
4008 root: mmr::Hash,
4009 leaves: Vec<mmr::EncodableOpaqueLeaf>,
4010 proof: mmr::LeafProof<mmr::Hash>
4011 ) -> Result<(), mmr::Error> {
4012 let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
4013 pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)
4014 }
4015 }
4016
4017 impl sp_mixnet::runtime_api::MixnetApi<Block> for Runtime {
4018 fn session_status() -> sp_mixnet::types::SessionStatus {
4019 Mixnet::session_status()
4020 }
4021
4022 fn prev_mixnodes() -> Result<Vec<sp_mixnet::types::Mixnode>, sp_mixnet::types::MixnodesErr> {
4023 Mixnet::prev_mixnodes()
4024 }
4025
4026 fn current_mixnodes() -> Result<Vec<sp_mixnet::types::Mixnode>, sp_mixnet::types::MixnodesErr> {
4027 Mixnet::current_mixnodes()
4028 }
4029
4030 fn maybe_register(session_index: sp_mixnet::types::SessionIndex, mixnode: sp_mixnet::types::Mixnode) -> bool {
4031 Mixnet::maybe_register(session_index, mixnode)
4032 }
4033 }
4034
4035 impl sp_session::SessionKeys<Block> for Runtime {
4036 fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
4037 SessionKeys::generate(&owner, seed).into()
4038 }
4039
4040 fn decode_session_keys(
4041 encoded: Vec<u8>,
4042 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
4043 SessionKeys::decode_into_raw_public_keys(&encoded)
4044 }
4045 }
4046
4047 impl pallet_asset_rewards::AssetRewards<Block, Balance> for Runtime {
4048 fn pool_creation_cost() -> Balance {
4049 StakePoolCreationDeposit::get()
4050 }
4051 }
4052
4053 impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
4054 fn retention_period() -> NumberFor<Block> {
4055 TransactionStorage::retention_period()
4056 }
4057
4058 fn indexed_transactions(
4059 block: NumberFor<Block>,
4060 ) -> Vec<sp_transaction_storage_proof::IndexedTransactionInfo> {
4061 TransactionStorage::indexed_transactions(block)
4062 }
4063 }
4064
4065 #[cfg(feature = "try-runtime")]
4066 impl frame_try_runtime::TryRuntime<Block> for Runtime {
4067 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
4068 let weight = Executive::try_runtime_upgrade(checks).unwrap();
4072 (weight, RuntimeBlockWeights::get().max_block)
4073 }
4074
4075 fn execute_block(
4076 block: <Block as BlockT>::LazyBlock,
4077 state_root_check: bool,
4078 signature_check: bool,
4079 select: frame_try_runtime::TryStateSelect
4080 ) -> Weight {
4081 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
4084 }
4085 }
4086
4087 #[cfg(feature = "runtime-benchmarks")]
4088 impl frame_benchmarking::Benchmark<Block> for Runtime {
4089 fn benchmark_metadata(extra: bool) -> (
4090 Vec<frame_benchmarking::BenchmarkList>,
4091 Vec<frame_support::traits::StorageInfo>,
4092 ) {
4093 use frame_benchmarking::{baseline, BenchmarkList};
4094 use frame_support::traits::StorageInfoTrait;
4095
4096 use pallet_session_benchmarking::Pallet as SessionBench;
4100 use pallet_offences_benchmarking::Pallet as OffencesBench;
4101 use pallet_election_provider_support_benchmarking::Pallet as EPSBench;
4102 use frame_system_benchmarking::Pallet as SystemBench;
4103 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
4104 use baseline::Pallet as BaselineBench;
4105
4106 let mut list = Vec::<BenchmarkList>::new();
4107 list_benchmarks!(list, extra);
4108
4109 let storage_info = AllPalletsWithSystem::storage_info();
4110
4111 (list, storage_info)
4112 }
4113
4114 #[allow(non_local_definitions)]
4115 fn dispatch_benchmark(
4116 config: frame_benchmarking::BenchmarkConfig
4117 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
4118 use frame_benchmarking::{baseline, BenchmarkBatch};
4119 use sp_storage::TrackedStorageKey;
4120
4121 use pallet_session_benchmarking::Pallet as SessionBench;
4125 use pallet_offences_benchmarking::Pallet as OffencesBench;
4126 use pallet_election_provider_support_benchmarking::Pallet as EPSBench;
4127 use frame_system_benchmarking::Pallet as SystemBench;
4128 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
4129 use baseline::Pallet as BaselineBench;
4130
4131 impl pallet_session_benchmarking::Config for Runtime {
4132 fn generate_session_keys_and_proof(owner: Self::AccountId) -> (Self::Keys, Vec<u8>) {
4133 let keys = SessionKeys::generate(&owner.encode(), None);
4134 (keys.keys, keys.proof.encode())
4135 }
4136 }
4137 impl pallet_offences_benchmarking::Config for Runtime {}
4138 impl pallet_election_provider_support_benchmarking::Config for Runtime {}
4139 impl frame_system_benchmarking::Config for Runtime {}
4140 impl pallet_transaction_payment::BenchmarkConfig for Runtime {}
4141 impl baseline::Config for Runtime {}
4142
4143 use frame_support::traits::WhitelistedStorageKeys;
4144 let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
4145
4146 let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
4150 whitelist.push(treasury_key.to_vec().into());
4151
4152 let mut batches = Vec::<BenchmarkBatch>::new();
4153 let params = (&config, &whitelist);
4154 add_benchmarks!(params, batches);
4155 Ok(batches)
4156 }
4157 }
4158
4159 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
4160 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
4161 build_state::<RuntimeGenesisConfig>(config)
4162 }
4163
4164 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
4165 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
4166 }
4167
4168 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
4169 genesis_config_presets::preset_names()
4170 }
4171 }
4172
4173);
4174
4175#[cfg(test)]
4176mod tests {
4177 use super::*;
4178 use frame_system::offchain::CreateSignedTransaction;
4179
4180 #[test]
4181 fn validate_transaction_submitter_bounds() {
4182 fn is_submit_signed_transaction<T>()
4183 where
4184 T: CreateSignedTransaction<RuntimeCall>,
4185 {
4186 }
4187
4188 is_submit_signed_transaction::<Runtime>();
4189 }
4190
4191 #[test]
4192 fn call_size() {
4193 let size = core::mem::size_of::<RuntimeCall>();
4194 assert!(
4195 size <= CALL_PARAMS_MAX_SIZE,
4196 "size of RuntimeCall {} is more than {CALL_PARAMS_MAX_SIZE} bytes.
4197 Some calls have too big arguments, use Box to reduce the size of RuntimeCall.
4198 If the limit is too strong, maybe consider increase the limit.",
4199 size,
4200 );
4201 }
4202}