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