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
2677pub struct DiscardRegistrarMessages;
2679
2680impl pallet_registrar_para::SendToRelay for DiscardRegistrarMessages {
2681 type AccountId = AccountId;
2682
2683 fn send(_message: registrar_primitives::MessageToRelay<AccountId>) -> Result<(), ()> {
2684 Ok(())
2685 }
2686}
2687
2688impl pallet_registrar_relay::SendToPara for DiscardRegistrarMessages {
2689 fn send(_message: registrar_primitives::MessageToPara) -> Result<(), ()> {
2690 Ok(())
2691 }
2692}
2693
2694parameter_types! {
2695 pub const ParaIdReservationDeposit: Balance = 100 * DOLLARS;
2696 pub const RegistrationDepositPerByte: Balance = 10 * MILLICENTS;
2697 pub const ParaIdReservationHoldReason: RuntimeHoldReason =
2698 RuntimeHoldReason::RegistrarPara(pallet_registrar_para::HoldReason::ParaIdReservation);
2699 pub const RegistrationHoldReason: RuntimeHoldReason =
2700 RuntimeHoldReason::RegistrarPara(pallet_registrar_para::HoldReason::Registration);
2701}
2702
2703impl pallet_registrar_para::Config for Runtime {
2704 type ReservationConsideration = HoldConsideration<
2705 AccountId,
2706 Balances,
2707 ParaIdReservationHoldReason,
2708 ConstantStoragePrice<ParaIdReservationDeposit, Balance>,
2709 >;
2710 type RegistrationConsideration = HoldConsideration<
2711 AccountId,
2712 Balances,
2713 RegistrationHoldReason,
2714 LinearStoragePrice<ConstU128<0>, RegistrationDepositPerByte, Balance>,
2715 >;
2716 type SendToRelay = DiscardRegistrarMessages;
2717 type RelayOrigin = EnsureRoot<AccountId>;
2718 type FirstPublicParaId = ConstU32<2000>;
2719 type MinCodeSize = ConstU32<9>;
2720 type MaxCodeSize = ConstU32<{ 3 * 1024 * 1024 }>;
2721 type MaxHeadDataSize = ConstU32<{ 1024 * 1024 }>;
2722 type PendingDeadline = ConstU32<600>;
2723 type BlockNumberProvider = System;
2724 type WeightInfo = pallet_registrar_para::weights::SubstrateWeight<Runtime>;
2725}
2726
2727pub struct AcceptingRegistrar;
2729
2730impl registrar_primitives::ParachainRegistrar for AcceptingRegistrar {
2731 type AccountId = AccountId;
2732
2733 fn check_onboarding(_head_len: u32, _code_len: u32) -> Result<(), ()> {
2734 Ok(())
2735 }
2736
2737 fn is_registered(_para_id: registrar_primitives::ParaId) -> bool {
2738 false
2739 }
2740
2741 fn register(
2742 _manager: AccountId,
2743 _para_id: registrar_primitives::ParaId,
2744 _genesis_head: Vec<u8>,
2745 _validation_code: Vec<u8>,
2746 ) -> sp_runtime::DispatchResult {
2747 Ok(())
2748 }
2749}
2750
2751impl pallet_registrar_relay::Config for Runtime {
2752 type RuntimeEvent = RuntimeEvent;
2753 type ParaOrigin = EnsureRoot<AccountId>;
2754 type SendToPara = DiscardRegistrarMessages;
2755 type Registrar = AcceptingRegistrar;
2756 type MaxHeadDataSize = ConstU32<{ 1024 * 1024 }>;
2757 type MaxCodeSize = ConstU32<{ 3 * 1024 * 1024 }>;
2758 type MaxPendingRegistrations = ConstU32<128>;
2759 type UnsignedPriority = ConstU64<100>;
2760 type WeightInfo = pallet_registrar_relay::weights::SubstrateWeight<Runtime>;
2761}
2762
2763#[frame_support::runtime]
2764mod runtime {
2765 use super::*;
2766
2767 #[runtime::runtime]
2768 #[runtime::derive(
2769 RuntimeCall,
2770 RuntimeEvent,
2771 RuntimeError,
2772 RuntimeOrigin,
2773 RuntimeFreezeReason,
2774 RuntimeHoldReason,
2775 RuntimeSlashReason,
2776 RuntimeLockId,
2777 RuntimeTask,
2778 RuntimeViewFunction
2779 )]
2780 pub struct Runtime;
2781
2782 #[runtime::pallet_index(0)]
2783 pub type System = frame_system::Pallet<Runtime>;
2784
2785 #[runtime::pallet_index(1)]
2786 pub type Utility = pallet_utility::Pallet<Runtime>;
2787
2788 #[runtime::pallet_index(2)]
2789 pub type Babe = pallet_babe::Pallet<Runtime>;
2790
2791 #[runtime::pallet_index(3)]
2792 pub type Timestamp = pallet_timestamp::Pallet<Runtime>;
2793
2794 #[runtime::pallet_index(4)]
2797 pub type Authorship = pallet_authorship::Pallet<Runtime>;
2798
2799 #[runtime::pallet_index(5)]
2800 pub type Indices = pallet_indices::Pallet<Runtime>;
2801
2802 #[runtime::pallet_index(6)]
2803 pub type Balances = pallet_balances::Pallet<Runtime>;
2804
2805 #[runtime::pallet_index(7)]
2806 pub type TransactionPayment = pallet_transaction_payment::Pallet<Runtime>;
2807
2808 #[runtime::pallet_index(9)]
2809 pub type AssetConversionTxPayment = pallet_asset_conversion_tx_payment::Pallet<Runtime>;
2810
2811 #[runtime::pallet_index(10)]
2812 pub type ElectionProviderMultiPhase = pallet_election_provider_multi_phase::Pallet<Runtime>;
2813
2814 #[runtime::pallet_index(11)]
2815 pub type Staking = pallet_staking::Pallet<Runtime>;
2816
2817 #[runtime::pallet_index(12)]
2818 pub type Session = pallet_session::Pallet<Runtime>;
2819
2820 #[runtime::pallet_index(13)]
2821 pub type Democracy = pallet_democracy::Pallet<Runtime>;
2822
2823 #[runtime::pallet_index(14)]
2824 pub type Council = pallet_collective::Pallet<Runtime, Instance1>;
2825
2826 #[runtime::pallet_index(15)]
2827 pub type TechnicalCommittee = pallet_collective::Pallet<Runtime, Instance2>;
2828
2829 #[runtime::pallet_index(16)]
2830 pub type Elections = pallet_elections_phragmen::Pallet<Runtime>;
2831
2832 #[runtime::pallet_index(17)]
2833 pub type TechnicalMembership = pallet_membership::Pallet<Runtime, Instance1>;
2834
2835 #[runtime::pallet_index(18)]
2836 pub type Grandpa = pallet_grandpa::Pallet<Runtime>;
2837
2838 #[runtime::pallet_index(19)]
2839 pub type Treasury = pallet_treasury::Pallet<Runtime>;
2840
2841 #[runtime::pallet_index(20)]
2842 pub type AssetRate = pallet_asset_rate::Pallet<Runtime>;
2843
2844 #[runtime::pallet_index(21)]
2845 pub type Contracts = pallet_contracts::Pallet<Runtime>;
2846
2847 #[runtime::pallet_index(22)]
2848 pub type Sudo = pallet_sudo::Pallet<Runtime>;
2849
2850 #[runtime::pallet_index(23)]
2851 pub type ImOnline = pallet_im_online::Pallet<Runtime>;
2852
2853 #[runtime::pallet_index(24)]
2854 pub type AuthorityDiscovery = pallet_authority_discovery::Pallet<Runtime>;
2855
2856 #[runtime::pallet_index(25)]
2857 pub type Offences = pallet_offences::Pallet<Runtime>;
2858
2859 #[runtime::pallet_index(26)]
2860 pub type Historical = pallet_session_historical::Pallet<Runtime>;
2861
2862 #[runtime::pallet_index(27)]
2863 pub type RandomnessCollectiveFlip = pallet_insecure_randomness_collective_flip::Pallet<Runtime>;
2864
2865 #[runtime::pallet_index(28)]
2866 pub type Identity = pallet_identity::Pallet<Runtime>;
2867
2868 #[runtime::pallet_index(29)]
2869 pub type Society = pallet_society::Pallet<Runtime>;
2870
2871 #[runtime::pallet_index(30)]
2872 pub type Recovery = pallet_recovery::Pallet<Runtime>;
2873
2874 #[runtime::pallet_index(31)]
2875 pub type Vesting = pallet_vesting::Pallet<Runtime>;
2876
2877 #[runtime::pallet_index(32)]
2878 pub type Scheduler = pallet_scheduler::Pallet<Runtime>;
2879
2880 #[runtime::pallet_index(33)]
2881 pub type Glutton = pallet_glutton::Pallet<Runtime>;
2882
2883 #[runtime::pallet_index(34)]
2884 pub type Preimage = pallet_preimage::Pallet<Runtime>;
2885
2886 #[runtime::pallet_index(35)]
2887 pub type Proxy = pallet_proxy::Pallet<Runtime>;
2888
2889 #[runtime::pallet_index(36)]
2890 pub type Multisig = pallet_multisig::Pallet<Runtime>;
2891
2892 #[runtime::pallet_index(37)]
2893 pub type Bounties = pallet_bounties::Pallet<Runtime>;
2894
2895 #[runtime::pallet_index(38)]
2896 pub type Tips = pallet_tips::Pallet<Runtime>;
2897
2898 #[runtime::pallet_index(39)]
2899 pub type Assets = pallet_assets::Pallet<Runtime, Instance1>;
2900
2901 #[runtime::pallet_index(40)]
2902 pub type PoolAssets = pallet_assets::Pallet<Runtime, Instance2>;
2903
2904 #[runtime::pallet_index(41)]
2905 pub type Beefy = pallet_beefy::Pallet<Runtime>;
2906
2907 #[runtime::pallet_index(42)]
2910 pub type Mmr = pallet_mmr::Pallet<Runtime>;
2911
2912 #[runtime::pallet_index(43)]
2913 pub type MmrLeaf = pallet_beefy_mmr::Pallet<Runtime>;
2914
2915 #[runtime::pallet_index(44)]
2916 pub type Lottery = pallet_lottery::Pallet<Runtime>;
2917
2918 #[runtime::pallet_index(45)]
2919 pub type Nis = pallet_nis::Pallet<Runtime>;
2920
2921 #[runtime::pallet_index(46)]
2922 pub type Uniques = pallet_uniques::Pallet<Runtime>;
2923
2924 #[runtime::pallet_index(47)]
2925 pub type Nfts = pallet_nfts::Pallet<Runtime>;
2926
2927 #[runtime::pallet_index(48)]
2928 pub type NftFractionalization = pallet_nft_fractionalization::Pallet<Runtime>;
2929
2930 #[runtime::pallet_index(49)]
2931 pub type Salary = pallet_salary::Pallet<Runtime>;
2932
2933 #[runtime::pallet_index(50)]
2934 pub type CoreFellowship = pallet_core_fellowship::Pallet<Runtime>;
2935
2936 #[runtime::pallet_index(51)]
2937 pub type TransactionStorage = pallet_transaction_storage::Pallet<Runtime>;
2938
2939 #[runtime::pallet_index(52)]
2940 pub type VoterList = pallet_bags_list::Pallet<Runtime, Instance1>;
2941
2942 #[runtime::pallet_index(53)]
2943 pub type StateTrieMigration = pallet_state_trie_migration::Pallet<Runtime>;
2944
2945 #[runtime::pallet_index(54)]
2946 pub type ChildBounties = pallet_child_bounties::Pallet<Runtime>;
2947
2948 #[runtime::pallet_index(55)]
2949 pub type Referenda = pallet_referenda::Pallet<Runtime>;
2950
2951 #[runtime::pallet_index(56)]
2952 pub type Remark = pallet_remark::Pallet<Runtime>;
2953
2954 #[runtime::pallet_index(57)]
2955 pub type RootTesting = pallet_root_testing::Pallet<Runtime>;
2956
2957 #[runtime::pallet_index(58)]
2958 pub type ConvictionVoting = pallet_conviction_voting::Pallet<Runtime>;
2959
2960 #[runtime::pallet_index(59)]
2961 pub type Whitelist = pallet_whitelist::Pallet<Runtime>;
2962
2963 #[runtime::pallet_index(60)]
2964 pub type AllianceMotion = pallet_collective::Pallet<Runtime, Instance3>;
2965
2966 #[runtime::pallet_index(61)]
2967 pub type Alliance = pallet_alliance::Pallet<Runtime>;
2968
2969 #[runtime::pallet_index(62)]
2970 pub type NominationPools = pallet_nomination_pools::Pallet<Runtime>;
2971
2972 #[runtime::pallet_index(63)]
2973 pub type RankedPolls = pallet_referenda::Pallet<Runtime, Instance2>;
2974
2975 #[runtime::pallet_index(64)]
2976 pub type RankedCollective = pallet_ranked_collective::Pallet<Runtime>;
2977
2978 #[runtime::pallet_index(65)]
2979 pub type AssetConversion = pallet_asset_conversion::Pallet<Runtime>;
2980
2981 #[runtime::pallet_index(66)]
2982 pub type FastUnstake = pallet_fast_unstake::Pallet<Runtime>;
2983
2984 #[runtime::pallet_index(67)]
2985 pub type MessageQueue = pallet_message_queue::Pallet<Runtime>;
2986
2987 #[runtime::pallet_index(68)]
2988 pub type Pov = frame_benchmarking_pallet_pov::Pallet<Runtime>;
2989
2990 #[runtime::pallet_index(69)]
2991 pub type TxPause = pallet_tx_pause::Pallet<Runtime>;
2992
2993 #[runtime::pallet_index(70)]
2994 pub type SafeMode = pallet_safe_mode::Pallet<Runtime>;
2995
2996 #[runtime::pallet_index(71)]
2997 pub type Statement = pallet_statement::Pallet<Runtime>;
2998
2999 #[runtime::pallet_index(72)]
3000 pub type MultiBlockMigrations = pallet_migrations::Pallet<Runtime>;
3001
3002 #[runtime::pallet_index(73)]
3003 pub type Broker = pallet_broker::Pallet<Runtime>;
3004
3005 #[runtime::pallet_index(74)]
3006 pub type TasksExample = pallet_example_tasks::Pallet<Runtime>;
3007
3008 #[runtime::pallet_index(75)]
3009 pub type Mixnet = pallet_mixnet::Pallet<Runtime>;
3010
3011 #[runtime::pallet_index(76)]
3012 pub type Parameters = pallet_parameters::Pallet<Runtime>;
3013
3014 #[runtime::pallet_index(77)]
3015 pub type SkipFeelessPayment = pallet_skip_feeless_payment::Pallet<Runtime>;
3016
3017 #[runtime::pallet_index(78)]
3018 pub type PalletExampleMbms = pallet_example_mbm::Pallet<Runtime>;
3019
3020 #[runtime::pallet_index(79)]
3021 pub type AssetConversionMigration = pallet_asset_conversion_ops::Pallet<Runtime>;
3022
3023 #[runtime::pallet_index(80)]
3024 pub type Revive = pallet_revive::Pallet<Runtime>;
3025
3026 #[runtime::pallet_index(81)]
3027 pub type VerifySignature = pallet_verify_signature::Pallet<Runtime>;
3028
3029 #[runtime::pallet_index(82)]
3030 pub type DelegatedStaking = pallet_delegated_staking::Pallet<Runtime>;
3031
3032 #[runtime::pallet_index(83)]
3033 pub type AssetRewards = pallet_asset_rewards::Pallet<Runtime>;
3034
3035 #[runtime::pallet_index(84)]
3036 pub type AssetsFreezer = pallet_assets_freezer::Pallet<Runtime, Instance1>;
3037
3038 #[runtime::pallet_index(85)]
3039 pub type Oracle = pallet_oracle::Pallet<Runtime>;
3040
3041 #[runtime::pallet_index(86)]
3042 pub type Psm = pallet_psm::Pallet<Runtime>;
3043
3044 #[runtime::pallet_index(87)]
3045 pub type Scarcity = pallet_scarcity::Pallet<Runtime>;
3046
3047 #[runtime::pallet_index(89)]
3048 pub type MetaTx = pallet_meta_tx::Pallet<Runtime>;
3049
3050 #[runtime::pallet_index(90)]
3051 pub type MultiAssetBounties = pallet_multi_asset_bounties::Pallet<Runtime>;
3052
3053 #[runtime::pallet_index(91)]
3054 pub type AssetsPrecompiles = pallet_assets_precompiles::pallet::Pallet<Runtime>;
3055
3056 #[runtime::pallet_index(92)]
3057 pub type AssetsPrecompilesPermit = pallet_assets_precompiles::permit::pallet::Pallet<Runtime>;
3058
3059 #[runtime::pallet_index(93)]
3060 pub type VestingPrecompiles = pallet_vesting_precompiles::pallet::Pallet<Runtime>;
3061
3062 #[runtime::pallet_index(94)]
3063 pub type Dap = pallet_dap::Pallet<Runtime>;
3064
3065 #[runtime::pallet_index(95)]
3066 pub type RegistrarPara = pallet_registrar_para::Pallet<Runtime>;
3067
3068 #[runtime::pallet_index(96)]
3069 pub type RegistrarRelay = pallet_registrar_relay::Pallet<Runtime>;
3070}
3071
3072pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
3074pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
3076pub type Block = generic::Block<Header, UncheckedExtrinsic>;
3078pub type SignedBlock = generic::SignedBlock<Block>;
3080pub type BlockId = generic::BlockId<Block>;
3082pub type TxExtension = (
3095 (pallet_scarcity::extension::AsScarcity<Runtime>, frame_system::AuthorizeCall<Runtime>),
3096 frame_system::CheckNonZeroSender<Runtime>,
3097 frame_system::CheckSpecVersion<Runtime>,
3098 frame_system::CheckTxVersion<Runtime>,
3099 frame_system::CheckGenesis<Runtime>,
3100 frame_system::CheckEra<Runtime>,
3101 frame_system::CheckNonce<Runtime>,
3102 frame_system::CheckWeight<Runtime>,
3103 pallet_skip_feeless_payment::SkipCheckIfFeeless<
3104 Runtime,
3105 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
3106 >,
3107 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
3108 pallet_revive::evm::tx_extension::SetOrigin<Runtime>,
3109 frame_system::WeightReclaim<Runtime>,
3110);
3111
3112pub type ScarcityTxExtension = pallet_scarcity::extension::AsScarcity<Runtime>;
3114
3115#[derive(Clone, PartialEq, Eq, Debug)]
3116pub struct EthExtraImpl;
3117
3118impl EthExtra for EthExtraImpl {
3119 type Config = Runtime;
3120 type ExtensionV0 = TxExtension;
3121 type ExtensionOtherVersions = sp_runtime::traits::InvalidVersion;
3122
3123 fn get_eth_extension(nonce: u32, tip: Balance) -> Self::ExtensionV0 {
3124 (
3125 (ScarcityTxExtension::new(None), frame_system::AuthorizeCall::<Runtime>::new()),
3126 frame_system::CheckNonZeroSender::<Runtime>::new(),
3127 frame_system::CheckSpecVersion::<Runtime>::new(),
3128 frame_system::CheckTxVersion::<Runtime>::new(),
3129 frame_system::CheckGenesis::<Runtime>::new(),
3130 frame_system::CheckEra::from(crate::generic::Era::Immortal),
3131 frame_system::CheckNonce::<Runtime>::from(nonce),
3132 frame_system::CheckWeight::<Runtime>::new(),
3133 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(tip, None)
3134 .into(),
3135 frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
3136 pallet_revive::evm::tx_extension::SetOrigin::<Runtime>::new_from_eth_transaction(),
3137 frame_system::WeightReclaim::<Runtime>::new(),
3138 )
3139 }
3140}
3141
3142pub type UncheckedExtrinsic =
3144 pallet_revive::evm::runtime::UncheckedExtrinsic<Address, Signature, EthExtraImpl>;
3145pub type UncheckedSignaturePayload =
3147 generic::UncheckedSignaturePayload<Address, Signature, TxExtension>;
3148pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
3150pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, TxExtension>;
3152pub type Executive = frame_executive::Executive<
3154 Runtime,
3155 Block,
3156 frame_system::ChainContext<Runtime>,
3157 Runtime,
3158 AllPalletsWithSystem,
3159>;
3160
3161const IDENTITY_MIGRATION_KEY_LIMIT: u64 = u64::MAX;
3163
3164type Migrations = (
3168 pallet_nomination_pools::migration::versioned::V6ToV7<Runtime>,
3169 pallet_alliance::migration::Migration<Runtime>,
3170 pallet_contracts::Migration<Runtime>,
3171 pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
3172);
3173
3174type EventRecord = frame_system::EventRecord<
3175 <Runtime as frame_system::Config>::RuntimeEvent,
3176 <Runtime as frame_system::Config>::Hash,
3177>;
3178
3179parameter_types! {
3180 pub const BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
3181}
3182
3183impl pallet_beefy::Config for Runtime {
3184 type BeefyId = BeefyId;
3185 type MaxAuthorities = MaxAuthorities;
3186 type MaxNominators = ConstU32<0>;
3187 type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
3188 type OnNewValidatorSet = MmrLeaf;
3189 type AncestryHelper = MmrLeaf;
3190 type WeightInfo = ();
3191 type KeyOwnerProof = sp_session::MembershipProof;
3192 type EquivocationReportSystem =
3193 pallet_beefy::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
3194}
3195
3196parameter_types! {
3197 pub const OracleMaxHasDispatchedSize: u32 = 20;
3198 pub const RootOperatorAccountId: AccountId = AccountId::new([0xffu8; 32]);
3199
3200 pub const OracleMaxFeedValues: u32 = 10;
3201}
3202
3203#[cfg(feature = "runtime-benchmarks")]
3204pub struct OracleBenchmarkingHelper;
3205
3206#[cfg(feature = "runtime-benchmarks")]
3207impl pallet_oracle::BenchmarkHelper<u32, u128, OracleMaxFeedValues> for OracleBenchmarkingHelper {
3208 fn get_currency_id_value_pairs() -> BoundedVec<(u32, u128), OracleMaxFeedValues> {
3209 use rand::{distributions::Uniform, prelude::*};
3210
3211 let mut rng = rand_pcg::Pcg32::seed_from_u64(0x1234567890ABCDEF);
3213 let max_values = OracleMaxFeedValues::get() as usize;
3214
3215 let currency_range = Uniform::new_inclusive(1, 1000);
3217 let value_range = Uniform::new_inclusive(1000, 1_000_000);
3218
3219 let pairs: Vec<(u32, u128)> = (0..max_values)
3220 .map(|_| {
3221 let currency_id = rng.sample(currency_range);
3222 let value = rng.sample(value_range);
3223 (currency_id, value)
3224 })
3225 .collect();
3226
3227 BoundedVec::try_from(pairs).unwrap_or_default()
3229 }
3230}
3231
3232parameter_types! {
3233 pub const OraclePalletId: PalletId = PalletId(*b"py/oracl");
3234}
3235
3236impl pallet_oracle::Config for Runtime {
3237 type OnNewData = ();
3238 type CombineData = pallet_oracle::DefaultCombineData<Self, ConstU32<5>, ConstU64<3600>>;
3239 type Time = Timestamp;
3240 type OracleKey = u32;
3241 type OracleValue = u128;
3242 type PalletId = OraclePalletId;
3243 type Members = TechnicalMembership;
3244 type WeightInfo = ();
3245 type MaxHasDispatchedSize = OracleMaxHasDispatchedSize;
3246 type MaxFeedValues = OracleMaxFeedValues;
3247 #[cfg(feature = "runtime-benchmarks")]
3248 type BenchmarkHelper = OracleBenchmarkingHelper;
3249}
3250
3251parameter_types! {
3252 pub const PsmPalletId: PalletId = PalletId(*b"py/pegsm");
3254 pub const PsmCreationDeposit: Balance = 10 * DOLLARS;
3256 pub const PsmDepositSlope: Balance = 0;
3258 pub PsmHoldReason: RuntimeHoldReason = RuntimeHoldReason::Psm(pallet_psm::HoldReason::CreationDeposit);
3259}
3260
3261#[cfg(feature = "runtime-benchmarks")]
3262pub struct PsmBenchmarkHelper;
3263#[cfg(feature = "runtime-benchmarks")]
3264impl pallet_psm::BenchmarkHelper<u32, AccountId> for PsmBenchmarkHelper {
3265 fn get_asset_id(asset_index: u32) -> u32 {
3266 asset_index
3267 }
3268 fn create_asset(asset_id: u32, owner: &AccountId, decimals: u8) {
3269 use frame_support::traits::fungibles::{metadata::Mutate as MetadataMutate, Create};
3270 if !<Assets as frame_support::traits::fungibles::Inspect<AccountId>>::asset_exists(asset_id)
3271 {
3272 let _ = <Assets as Create<AccountId>>::create(asset_id, owner.clone(), true, 1);
3273 }
3274 let _ = Balances::force_set_balance(
3275 RuntimeOrigin::root(),
3276 owner.clone().into(),
3277 10u128.pow(18),
3278 );
3279 let _ = <Assets as MetadataMutate<AccountId>>::set(
3280 asset_id,
3281 owner,
3282 b"Benchmark".to_vec(),
3283 b"BNC".to_vec(),
3284 decimals,
3285 );
3286 }
3287}
3288
3289impl pallet_psm::Config for Runtime {
3291 type Fungibles = Assets;
3292 type Consideration = HoldConsideration<
3293 AccountId,
3294 Balances,
3295 PsmHoldReason,
3296 LinearStoragePrice<PsmCreationDeposit, PsmDepositSlope, Balance>,
3297 >;
3298 type CreateOrigin = pallet_psm::EnsureAssetOwner<Runtime>;
3299 type RuntimeOrigin = RuntimeOrigin;
3300 type PalletsOrigin = OriginCaller;
3301 type AssetId = u32;
3302 type WeightInfo = pallet_psm::weights::SubstrateWeight<Runtime>;
3303 type PalletId = PsmPalletId;
3304 type MaxExternals = ConstU32<10>;
3305 #[cfg(feature = "runtime-benchmarks")]
3306 type BenchmarkHelper = PsmBenchmarkHelper;
3307}
3308
3309mod mmr {
3311 use super::*;
3312 pub use pallet_mmr::primitives::*;
3313
3314 pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
3315 pub type Hash = <Hashing as sp_runtime::traits::Hash>::Output;
3316 pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
3317}
3318
3319#[cfg(feature = "runtime-benchmarks")]
3320pub struct AssetConversionTxHelper;
3321
3322#[cfg(feature = "runtime-benchmarks")]
3323impl
3324 pallet_asset_conversion_tx_payment::BenchmarkHelperTrait<
3325 AccountId,
3326 NativeOrWithId<u32>,
3327 NativeOrWithId<u32>,
3328 > for AssetConversionTxHelper
3329{
3330 fn create_asset_id_parameter(seed: u32) -> (NativeOrWithId<u32>, NativeOrWithId<u32>) {
3331 (NativeOrWithId::WithId(seed), NativeOrWithId::WithId(seed))
3332 }
3333
3334 fn setup_balances_and_pool(asset_id: NativeOrWithId<u32>, account: AccountId) {
3335 use frame_support::{assert_ok, traits::fungibles::Mutate};
3336 let NativeOrWithId::WithId(asset_idx) = asset_id.clone() else { unimplemented!() };
3337 assert_ok!(Assets::force_create(
3338 RuntimeOrigin::root(),
3339 asset_idx.into(),
3340 account.clone().into(), true, 1,
3343 ));
3344
3345 let lp_provider = account.clone();
3346 let _ = Balances::deposit_creating(&lp_provider, ((u64::MAX as u128) * 100).into());
3347 assert_ok!(Assets::mint_into(
3348 asset_idx.into(),
3349 &lp_provider,
3350 ((u64::MAX as u128) * 100).into()
3351 ));
3352
3353 let token_native = alloc::boxed::Box::new(NativeOrWithId::Native);
3354 let token_second = alloc::boxed::Box::new(asset_id);
3355
3356 assert_ok!(AssetConversion::create_pool(
3357 RuntimeOrigin::signed(lp_provider.clone()),
3358 token_native.clone(),
3359 token_second.clone()
3360 ));
3361
3362 assert_ok!(AssetConversion::add_liquidity(
3363 RuntimeOrigin::signed(lp_provider.clone()),
3364 token_native,
3365 token_second,
3366 u64::MAX.into(), u64::MAX.into(), 1, 1, lp_provider,
3371 ));
3372 }
3373}
3374
3375#[cfg(feature = "runtime-benchmarks")]
3376mod benches {
3377 polkadot_sdk::frame_benchmarking::define_benchmarks!(
3378 [frame_benchmarking, BaselineBench::<Runtime>]
3379 [frame_benchmarking_pallet_pov, Pov]
3380 [pallet_alliance, Alliance]
3381 [pallet_assets, Assets]
3382 [pallet_babe, Babe]
3383 [pallet_bags_list, VoterList]
3384 [pallet_balances, Balances]
3385 [pallet_beefy_mmr, MmrLeaf]
3386 [pallet_bounties, Bounties]
3387 [pallet_broker, Broker]
3388 [pallet_child_bounties, ChildBounties]
3389 [pallet_collective, Council]
3390 [pallet_conviction_voting, ConvictionVoting]
3391 [pallet_contracts, Contracts]
3392 [pallet_revive, Revive]
3393 [pallet_core_fellowship, CoreFellowship]
3394 [pallet_example_tasks, TasksExample]
3395 [pallet_democracy, Democracy]
3396 [pallet_asset_conversion, AssetConversion]
3397 [pallet_asset_rewards, AssetRewards]
3398 [pallet_asset_conversion_tx_payment, AssetConversionTxPayment]
3399 [pallet_transaction_payment, TransactionPayment]
3400 [pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
3401 [pallet_election_provider_support_benchmarking, EPSBench::<Runtime>]
3402 [pallet_elections_phragmen, Elections]
3403 [pallet_fast_unstake, FastUnstake]
3404 [pallet_nis, Nis]
3405 [pallet_parameters, Parameters]
3406 [pallet_grandpa, Grandpa]
3407 [pallet_identity, Identity]
3408 [pallet_im_online, ImOnline]
3409 [pallet_indices, Indices]
3410 [pallet_lottery, Lottery]
3411 [pallet_membership, TechnicalMembership]
3412 [pallet_message_queue, MessageQueue]
3413 [pallet_migrations, MultiBlockMigrations]
3414 [pallet_mmr, Mmr]
3415 [pallet_multi_asset_bounties, MultiAssetBounties]
3416 [pallet_assets_precompiles, AssetsPrecompiles]
3417 [pallet_vesting_precompiles, VestingPrecompiles]
3418 [pallet_multisig, Multisig]
3419 [pallet_offences, OffencesBench::<Runtime>]
3420 [pallet_oracle, Oracle]
3421 [pallet_preimage, Preimage]
3422 [pallet_proxy, Proxy]
3423 [pallet_ranked_collective, RankedCollective]
3424 [pallet_referenda, Referenda]
3425 [pallet_recovery, Recovery]
3426 [pallet_registrar_para, RegistrarPara]
3427 [pallet_registrar_relay, RegistrarRelay]
3428 [pallet_remark, Remark]
3429 [pallet_salary, Salary]
3430 [pallet_scarcity, Scarcity]
3431 [pallet_scheduler, Scheduler]
3432 [pallet_glutton, Glutton]
3433 [pallet_session, SessionBench::<Runtime>]
3434 [pallet_society, Society]
3435 [pallet_dap, Dap]
3436 [pallet_staking, Staking]
3437 [pallet_state_trie_migration, StateTrieMigration]
3438 [pallet_sudo, Sudo]
3439 [frame_system, SystemBench::<Runtime>]
3440 [frame_system_extensions, SystemExtensionsBench::<Runtime>]
3441 [pallet_timestamp, Timestamp]
3442 [pallet_tips, Tips]
3443 [pallet_transaction_storage, TransactionStorage]
3444 [pallet_treasury, Treasury]
3445 [pallet_asset_rate, AssetRate]
3446 [pallet_uniques, Uniques]
3447 [pallet_nfts, Nfts]
3448 [pallet_nft_fractionalization, NftFractionalization]
3449 [pallet_utility, Utility]
3450 [pallet_vesting, Vesting]
3451 [pallet_whitelist, Whitelist]
3452 [pallet_tx_pause, TxPause]
3453 [pallet_safe_mode, SafeMode]
3454 [pallet_example_mbm, PalletExampleMbms]
3455 [pallet_asset_conversion_ops, AssetConversionMigration]
3456 [pallet_verify_signature, VerifySignature]
3457 [pallet_meta_tx, MetaTx]
3458 [pallet_psm, Psm]
3459 );
3460}
3461
3462pallet_revive::impl_runtime_apis_plus_revive_traits!(
3463 Runtime,
3464 Revive,
3465 Executive,
3466 EthExtraImpl,
3467
3468 impl sp_api::Core<Block> for Runtime {
3469 fn version() -> RuntimeVersion {
3470 VERSION
3471 }
3472
3473 fn execute_block(block: <Block as BlockT>::LazyBlock) {
3474 Executive::execute_block(block);
3475 }
3476
3477 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
3478 Executive::initialize_block(header)
3479 }
3480 }
3481
3482 impl sp_api::Metadata<Block> for Runtime {
3483 fn metadata() -> OpaqueMetadata {
3484 OpaqueMetadata::new(Runtime::metadata().into())
3485 }
3486
3487 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
3488 Runtime::metadata_at_version(version)
3489 }
3490
3491 fn metadata_versions() -> alloc::vec::Vec<u32> {
3492 Runtime::metadata_versions()
3493 }
3494 }
3495
3496 impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
3497 fn execute_view_function(id: frame_support::view_functions::ViewFunctionId, input: Vec<u8>) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
3498 Runtime::execute_view_function(id, input)
3499 }
3500 }
3501
3502 impl sp_block_builder::BlockBuilder<Block> for Runtime {
3503 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
3504 Executive::apply_extrinsic(extrinsic)
3505 }
3506
3507 fn finalize_block() -> <Block as BlockT>::Header {
3508 Executive::finalize_block()
3509 }
3510
3511 fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
3512 data.create_extrinsics()
3513 }
3514
3515 fn check_inherents(block: <Block as BlockT>::LazyBlock, data: InherentData) -> CheckInherentsResult {
3516 data.check_extrinsics(&block)
3517 }
3518 }
3519
3520 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
3521 fn validate_transaction(
3522 source: TransactionSource,
3523 tx: <Block as BlockT>::Extrinsic,
3524 block_hash: <Block as BlockT>::Hash,
3525 ) -> TransactionValidity {
3526 Executive::validate_transaction(source, tx, block_hash)
3527 }
3528 }
3529
3530 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
3531 fn offchain_worker(header: &<Block as BlockT>::Header) {
3532 Executive::offchain_worker(header)
3533 }
3534 }
3535
3536 impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
3537 fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
3538 Grandpa::grandpa_authorities()
3539 }
3540
3541 fn current_set_id() -> sp_consensus_grandpa::SetId {
3542 pallet_grandpa::CurrentSetId::<Runtime>::get()
3543 }
3544
3545 fn submit_report_equivocation_unsigned_extrinsic(
3546 equivocation_proof: sp_consensus_grandpa::EquivocationProof<
3547 <Block as BlockT>::Hash,
3548 NumberFor<Block>,
3549 >,
3550 key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
3551 ) -> Option<()> {
3552 let key_owner_proof = key_owner_proof.decode()?;
3553
3554 Grandpa::submit_unsigned_equivocation_report(
3555 equivocation_proof,
3556 key_owner_proof,
3557 )
3558 }
3559
3560 fn generate_key_ownership_proof(
3561 _set_id: sp_consensus_grandpa::SetId,
3562 authority_id: GrandpaId,
3563 ) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
3564 use codec::Encode;
3565
3566 Historical::prove((sp_consensus_grandpa::KEY_TYPE, authority_id))
3567 .map(|p| p.encode())
3568 .map(sp_consensus_grandpa::OpaqueKeyOwnershipProof::new)
3569 }
3570 }
3571
3572 impl pallet_nomination_pools_runtime_api::NominationPoolsApi<Block, AccountId, Balance> for Runtime {
3573 fn pending_rewards(who: AccountId) -> Balance {
3574 NominationPools::api_pending_rewards(who).unwrap_or_default()
3575 }
3576
3577 fn points_to_balance(pool_id: PoolId, points: Balance) -> Balance {
3578 NominationPools::api_points_to_balance(pool_id, points)
3579 }
3580
3581 fn balance_to_points(pool_id: PoolId, new_funds: Balance) -> Balance {
3582 NominationPools::api_balance_to_points(pool_id, new_funds)
3583 }
3584
3585 fn pool_pending_slash(pool_id: PoolId) -> Balance {
3586 NominationPools::api_pool_pending_slash(pool_id)
3587 }
3588
3589 fn member_pending_slash(member: AccountId) -> Balance {
3590 NominationPools::api_member_pending_slash(member)
3591 }
3592
3593 fn pool_needs_delegate_migration(pool_id: PoolId) -> bool {
3594 NominationPools::api_pool_needs_delegate_migration(pool_id)
3595 }
3596
3597 fn member_needs_delegate_migration(member: AccountId) -> bool {
3598 NominationPools::api_member_needs_delegate_migration(member)
3599 }
3600
3601 fn member_total_balance(member: AccountId) -> Balance {
3602 NominationPools::api_member_total_balance(member)
3603 }
3604
3605 fn pool_balance(pool_id: PoolId) -> Balance {
3606 NominationPools::api_pool_balance(pool_id)
3607 }
3608
3609 fn pool_accounts(pool_id: PoolId) -> (AccountId, AccountId) {
3610 NominationPools::api_pool_accounts(pool_id)
3611 }
3612 }
3613
3614 impl pallet_staking_runtime_api::StakingApi<Block, Balance, AccountId> for Runtime {
3615 fn nominations_quota(balance: Balance) -> u32 {
3616 Staking::api_nominations_quota(balance)
3617 }
3618
3619 fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
3620 Staking::api_eras_stakers_page_count(era, account)
3621 }
3622
3623 fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool {
3624 Staking::api_pending_rewards(era, account)
3625 }
3626 }
3627
3628 impl sp_consensus_babe::BabeApi<Block> for Runtime {
3629 fn configuration() -> sp_consensus_babe::BabeConfiguration {
3630 let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
3631 sp_consensus_babe::BabeConfiguration {
3632 slot_duration: Babe::slot_duration(),
3633 epoch_length: EpochDuration::get(),
3634 c: epoch_config.c,
3635 authorities: Babe::authorities().to_vec(),
3636 randomness: Babe::randomness(),
3637 allowed_slots: epoch_config.allowed_slots,
3638 }
3639 }
3640
3641 fn current_epoch_start() -> sp_consensus_babe::Slot {
3642 Babe::current_epoch_start()
3643 }
3644
3645 fn current_epoch() -> sp_consensus_babe::Epoch {
3646 Babe::current_epoch()
3647 }
3648
3649 fn next_epoch() -> sp_consensus_babe::Epoch {
3650 Babe::next_epoch()
3651 }
3652
3653 fn generate_key_ownership_proof(
3654 _slot: sp_consensus_babe::Slot,
3655 authority_id: sp_consensus_babe::AuthorityId,
3656 ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
3657 use codec::Encode;
3658
3659 Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
3660 .map(|p| p.encode())
3661 .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
3662 }
3663
3664 fn submit_report_equivocation_unsigned_extrinsic(
3665 equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
3666 key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
3667 ) -> Option<()> {
3668 let key_owner_proof = key_owner_proof.decode()?;
3669
3670 Babe::submit_unsigned_equivocation_report(
3671 equivocation_proof,
3672 key_owner_proof,
3673 )
3674 }
3675 }
3676
3677 impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
3678 fn authorities() -> Vec<AuthorityDiscoveryId> {
3679 AuthorityDiscovery::authorities()
3680 }
3681 }
3682
3683 impl polkadot_sdk::pallet_oracle_runtime_api::OracleApi<Block, u32, u32, u128> for Runtime {
3684 fn get_value(_provider_id: u32, key: u32) -> Option<u128> {
3685 pallet_oracle::Pallet::<Runtime>::get(&key).map(|v| v.value)
3687 }
3688
3689 fn get_all_values(_provider_id: u32) -> Vec<(u32, Option<u128>)> {
3690 use pallet_oracle::DataProviderExtended;
3691 pallet_oracle::Pallet::<Runtime>::get_all_values()
3692 .map(|(k, v)| (k, v.map(|tv| tv.value)))
3693 .collect()
3694 }
3695 }
3696
3697 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
3698 fn account_nonce(account: AccountId) -> Nonce {
3699 System::account_nonce(account)
3700 }
3701 }
3702
3703 impl assets_api::AssetsApi<
3704 Block,
3705 AccountId,
3706 Balance,
3707 u32,
3708 > for Runtime
3709 {
3710 fn account_balances(account: AccountId) -> Vec<(u32, Balance)> {
3711 Assets::account_balances(account)
3712 }
3713 }
3714
3715 impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash, EventRecord> for Runtime
3716 {
3717 fn call(
3718 origin: AccountId,
3719 dest: AccountId,
3720 value: Balance,
3721 gas_limit: Option<Weight>,
3722 storage_deposit_limit: Option<Balance>,
3723 input_data: Vec<u8>,
3724 ) -> pallet_contracts::ContractExecResult<Balance, EventRecord> {
3725 let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
3726 Contracts::bare_call(
3727 origin,
3728 dest,
3729 value,
3730 gas_limit,
3731 storage_deposit_limit,
3732 input_data,
3733 pallet_contracts::DebugInfo::UnsafeDebug,
3734 pallet_contracts::CollectEvents::UnsafeCollect,
3735 pallet_contracts::Determinism::Enforced,
3736 )
3737 }
3738
3739 fn instantiate(
3740 origin: AccountId,
3741 value: Balance,
3742 gas_limit: Option<Weight>,
3743 storage_deposit_limit: Option<Balance>,
3744 code: pallet_contracts::Code<Hash>,
3745 data: Vec<u8>,
3746 salt: Vec<u8>,
3747 ) -> pallet_contracts::ContractInstantiateResult<AccountId, Balance, EventRecord>
3748 {
3749 let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
3750 Contracts::bare_instantiate(
3751 origin,
3752 value,
3753 gas_limit,
3754 storage_deposit_limit,
3755 code,
3756 data,
3757 salt,
3758 pallet_contracts::DebugInfo::UnsafeDebug,
3759 pallet_contracts::CollectEvents::UnsafeCollect,
3760 )
3761 }
3762
3763 fn upload_code(
3764 origin: AccountId,
3765 code: Vec<u8>,
3766 storage_deposit_limit: Option<Balance>,
3767 determinism: pallet_contracts::Determinism,
3768 ) -> pallet_contracts::CodeUploadResult<Hash, Balance>
3769 {
3770 Contracts::bare_upload_code(
3771 origin,
3772 code,
3773 storage_deposit_limit,
3774 determinism,
3775 )
3776 }
3777
3778 fn get_storage(
3779 address: AccountId,
3780 key: Vec<u8>,
3781 ) -> pallet_contracts::GetStorageResult {
3782 Contracts::get_storage(
3783 address,
3784 key
3785 )
3786 }
3787 }
3788
3789 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
3790 Block,
3791 Balance,
3792 > for Runtime {
3793 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
3794 TransactionPayment::query_info(uxt, len)
3795 }
3796 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
3797 TransactionPayment::query_fee_details(uxt, len)
3798 }
3799 fn query_weight_to_fee(weight: Weight) -> Balance {
3800 TransactionPayment::weight_to_fee(weight)
3801 }
3802 fn query_length_to_fee(length: u32) -> Balance {
3803 TransactionPayment::length_to_fee(length)
3804 }
3805 }
3806
3807 impl pallet_asset_conversion::AssetConversionApi<
3808 Block,
3809 Balance,
3810 NativeOrWithId<u32>
3811 > for Runtime
3812 {
3813 fn quote_price_exact_tokens_for_tokens(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>, amount: Balance, include_fee: bool) -> Option<Balance> {
3814 AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
3815 }
3816
3817 fn quote_price_tokens_for_exact_tokens(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>, amount: Balance, include_fee: bool) -> Option<Balance> {
3818 AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
3819 }
3820
3821 fn get_reserves(asset1: NativeOrWithId<u32>, asset2: NativeOrWithId<u32>) -> Option<(Balance, Balance)> {
3822 AssetConversion::get_reserves(asset1, asset2).ok()
3823 }
3824 }
3825
3826 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
3827 for Runtime
3828 {
3829 fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo<Balance> {
3830 TransactionPayment::query_call_info(call, len)
3831 }
3832 fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails<Balance> {
3833 TransactionPayment::query_call_fee_details(call, len)
3834 }
3835 fn query_weight_to_fee(weight: Weight) -> Balance {
3836 TransactionPayment::weight_to_fee(weight)
3837 }
3838 fn query_length_to_fee(length: u32) -> Balance {
3839 TransactionPayment::length_to_fee(length)
3840 }
3841 }
3842
3843 impl pallet_nfts_runtime_api::NftsApi<Block, AccountId, u32, u32> for Runtime {
3844 fn owner(collection: u32, item: u32) -> Option<AccountId> {
3845 <Nfts as Inspect<AccountId>>::owner(&collection, &item)
3846 }
3847
3848 fn collection_owner(collection: u32) -> Option<AccountId> {
3849 <Nfts as Inspect<AccountId>>::collection_owner(&collection)
3850 }
3851
3852 fn attribute(
3853 collection: u32,
3854 item: u32,
3855 key: Vec<u8>,
3856 ) -> Option<Vec<u8>> {
3857 <Nfts as Inspect<AccountId>>::attribute(&collection, &item, &key)
3858 }
3859
3860 fn custom_attribute(
3861 account: AccountId,
3862 collection: u32,
3863 item: u32,
3864 key: Vec<u8>,
3865 ) -> Option<Vec<u8>> {
3866 <Nfts as Inspect<AccountId>>::custom_attribute(
3867 &account,
3868 &collection,
3869 &item,
3870 &key,
3871 )
3872 }
3873
3874 fn system_attribute(
3875 collection: u32,
3876 item: Option<u32>,
3877 key: Vec<u8>,
3878 ) -> Option<Vec<u8>> {
3879 <Nfts as Inspect<AccountId>>::system_attribute(&collection, item.as_ref(), &key)
3880 }
3881
3882 fn collection_attribute(collection: u32, key: Vec<u8>) -> Option<Vec<u8>> {
3883 <Nfts as Inspect<AccountId>>::collection_attribute(&collection, &key)
3884 }
3885 }
3886
3887 #[api_version(6)]
3888 impl sp_consensus_beefy::BeefyApi<Block, BeefyId> for Runtime {
3889 fn beefy_genesis() -> Option<BlockNumber> {
3890 pallet_beefy::GenesisBlock::<Runtime>::get()
3891 }
3892
3893 fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<BeefyId>> {
3894 Beefy::validator_set()
3895 }
3896
3897 fn submit_report_double_voting_unsigned_extrinsic(
3898 equivocation_proof: sp_consensus_beefy::DoubleVotingProof<
3899 BlockNumber,
3900 BeefyId,
3901 BeefySignature,
3902 >,
3903 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3904 ) -> Option<()> {
3905 let key_owner_proof = key_owner_proof.decode()?;
3906
3907 Beefy::submit_unsigned_double_voting_report(
3908 equivocation_proof,
3909 key_owner_proof,
3910 )
3911 }
3912
3913 fn submit_report_fork_voting_unsigned_extrinsic(
3914 equivocation_proof:
3915 sp_consensus_beefy::ForkVotingProof<
3916 <Block as BlockT>::Header,
3917 BeefyId,
3918 sp_runtime::OpaqueValue
3919 >,
3920 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3921 ) -> Option<()> {
3922 Beefy::submit_unsigned_fork_voting_report(
3923 equivocation_proof.try_into()?,
3924 key_owner_proof.decode()?,
3925 )
3926 }
3927
3928 fn submit_report_future_block_voting_unsigned_extrinsic(
3929 equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof<BlockNumber, BeefyId>,
3930 key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
3931 ) -> Option<()> {
3932 Beefy::submit_unsigned_future_block_voting_report(
3933 equivocation_proof,
3934 key_owner_proof.decode()?,
3935 )
3936 }
3937
3938 fn generate_key_ownership_proof(
3939 _set_id: sp_consensus_beefy::ValidatorSetId,
3940 authority_id: BeefyId,
3941 ) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> {
3942 Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id))
3943 .map(|p| p.encode())
3944 .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new)
3945 }
3946 }
3947
3948 #[api_version(3)]
3949 impl pallet_mmr::primitives::MmrApi<
3950 Block,
3951 mmr::Hash,
3952 BlockNumber,
3953 > for Runtime {
3954 fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
3955 Ok(pallet_mmr::RootHash::<Runtime>::get())
3956 }
3957
3958 fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
3959 Ok(pallet_mmr::NumberOfLeaves::<Runtime>::get())
3960 }
3961
3962 fn generate_proof(
3963 block_numbers: Vec<BlockNumber>,
3964 best_known_block_number: Option<BlockNumber>,
3965 ) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::LeafProof<mmr::Hash>), mmr::Error> {
3966 Mmr::generate_proof(block_numbers, best_known_block_number).map(
3967 |(leaves, proof)| {
3968 (
3969 leaves
3970 .into_iter()
3971 .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
3972 .collect(),
3973 proof,
3974 )
3975 },
3976 )
3977 }
3978
3979 fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::LeafProof<mmr::Hash>)
3980 -> Result<(), mmr::Error>
3981 {
3982 let leaves = leaves.into_iter().map(|leaf|
3983 leaf.into_opaque_leaf()
3984 .try_decode()
3985 .ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;
3986 Mmr::verify_leaves(leaves, proof)
3987 }
3988
3989 fn generate_ancestry_proof(
3990 prev_block_number: BlockNumber,
3991 best_known_block_number: Option<BlockNumber>,
3992 ) -> Result<mmr::AncestryProof<mmr::Hash>, mmr::Error> {
3993 Mmr::generate_ancestry_proof(prev_block_number, best_known_block_number)
3994 }
3995
3996 fn verify_proof_stateless(
3997 root: mmr::Hash,
3998 leaves: Vec<mmr::EncodableOpaqueLeaf>,
3999 proof: mmr::LeafProof<mmr::Hash>
4000 ) -> Result<(), mmr::Error> {
4001 let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
4002 pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)
4003 }
4004 }
4005
4006 impl sp_mixnet::runtime_api::MixnetApi<Block> for Runtime {
4007 fn session_status() -> sp_mixnet::types::SessionStatus {
4008 Mixnet::session_status()
4009 }
4010
4011 fn prev_mixnodes() -> Result<Vec<sp_mixnet::types::Mixnode>, sp_mixnet::types::MixnodesErr> {
4012 Mixnet::prev_mixnodes()
4013 }
4014
4015 fn current_mixnodes() -> Result<Vec<sp_mixnet::types::Mixnode>, sp_mixnet::types::MixnodesErr> {
4016 Mixnet::current_mixnodes()
4017 }
4018
4019 fn maybe_register(session_index: sp_mixnet::types::SessionIndex, mixnode: sp_mixnet::types::Mixnode) -> bool {
4020 Mixnet::maybe_register(session_index, mixnode)
4021 }
4022 }
4023
4024 impl sp_session::SessionKeys<Block> for Runtime {
4025 fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
4026 SessionKeys::generate(&owner, seed).into()
4027 }
4028
4029 fn decode_session_keys(
4030 encoded: Vec<u8>,
4031 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
4032 SessionKeys::decode_into_raw_public_keys(&encoded)
4033 }
4034 }
4035
4036 impl pallet_asset_rewards::AssetRewards<Block, Balance> for Runtime {
4037 fn pool_creation_cost() -> Balance {
4038 StakePoolCreationDeposit::get()
4039 }
4040 }
4041
4042 impl sp_transaction_storage_proof::runtime_api::TransactionStorageApi<Block> for Runtime {
4043 fn retention_period() -> NumberFor<Block> {
4044 TransactionStorage::retention_period()
4045 }
4046
4047 fn indexed_transactions(
4048 block: NumberFor<Block>,
4049 ) -> Vec<sp_transaction_storage_proof::IndexedTransactionInfo> {
4050 TransactionStorage::indexed_transactions(block)
4051 }
4052 }
4053
4054 #[cfg(feature = "try-runtime")]
4055 impl frame_try_runtime::TryRuntime<Block> for Runtime {
4056 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
4057 let weight = Executive::try_runtime_upgrade(checks).unwrap();
4061 (weight, RuntimeBlockWeights::get().max_block)
4062 }
4063
4064 fn execute_block(
4065 block: <Block as BlockT>::LazyBlock,
4066 state_root_check: bool,
4067 signature_check: bool,
4068 select: frame_try_runtime::TryStateSelect
4069 ) -> Weight {
4070 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
4073 }
4074 }
4075
4076 #[cfg(feature = "runtime-benchmarks")]
4077 impl frame_benchmarking::Benchmark<Block> for Runtime {
4078 fn benchmark_metadata(extra: bool) -> (
4079 Vec<frame_benchmarking::BenchmarkList>,
4080 Vec<frame_support::traits::StorageInfo>,
4081 ) {
4082 use frame_benchmarking::{baseline, BenchmarkList};
4083 use frame_support::traits::StorageInfoTrait;
4084
4085 use pallet_session_benchmarking::Pallet as SessionBench;
4089 use pallet_offences_benchmarking::Pallet as OffencesBench;
4090 use pallet_election_provider_support_benchmarking::Pallet as EPSBench;
4091 use frame_system_benchmarking::Pallet as SystemBench;
4092 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
4093 use baseline::Pallet as BaselineBench;
4094
4095 let mut list = Vec::<BenchmarkList>::new();
4096 list_benchmarks!(list, extra);
4097
4098 let storage_info = AllPalletsWithSystem::storage_info();
4099
4100 (list, storage_info)
4101 }
4102
4103 #[allow(non_local_definitions)]
4104 fn dispatch_benchmark(
4105 config: frame_benchmarking::BenchmarkConfig
4106 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
4107 use frame_benchmarking::{baseline, BenchmarkBatch};
4108 use sp_storage::TrackedStorageKey;
4109
4110 use pallet_session_benchmarking::Pallet as SessionBench;
4114 use pallet_offences_benchmarking::Pallet as OffencesBench;
4115 use pallet_election_provider_support_benchmarking::Pallet as EPSBench;
4116 use frame_system_benchmarking::Pallet as SystemBench;
4117 use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
4118 use baseline::Pallet as BaselineBench;
4119
4120 impl pallet_session_benchmarking::Config for Runtime {
4121 fn generate_session_keys_and_proof(owner: Self::AccountId) -> (Self::Keys, Vec<u8>) {
4122 let keys = SessionKeys::generate(&owner.encode(), None);
4123 (keys.keys, keys.proof.encode())
4124 }
4125 }
4126 impl pallet_offences_benchmarking::Config for Runtime {}
4127 impl pallet_election_provider_support_benchmarking::Config for Runtime {}
4128 impl frame_system_benchmarking::Config for Runtime {}
4129 impl pallet_transaction_payment::BenchmarkConfig for Runtime {}
4130 impl baseline::Config for Runtime {}
4131
4132 use frame_support::traits::WhitelistedStorageKeys;
4133 let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
4134
4135 let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
4139 whitelist.push(treasury_key.to_vec().into());
4140
4141 let mut batches = Vec::<BenchmarkBatch>::new();
4142 let params = (&config, &whitelist);
4143 add_benchmarks!(params, batches);
4144 Ok(batches)
4145 }
4146 }
4147
4148 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
4149 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
4150 build_state::<RuntimeGenesisConfig>(config)
4151 }
4152
4153 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
4154 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
4155 }
4156
4157 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
4158 genesis_config_presets::preset_names()
4159 }
4160 }
4161
4162);
4163
4164#[cfg(test)]
4165mod tests {
4166 use super::*;
4167 use frame_support::dispatch::GetDispatchInfo;
4168 use frame_system::offchain::CreateSignedTransaction;
4169 use sp_runtime::{traits::DispatchTransaction, BuildStorage};
4170
4171 fn scarcity_tx_extension(nonce: Nonce, state_nonce: u64) -> TxExtension {
4172 (
4173 (
4174 ScarcityTxExtension::new(Some(pallet_scarcity::extension::AsScarcityInfo::AsNft {
4175 instance: 0,
4176 state_nonce,
4177 })),
4178 frame_system::AuthorizeCall::<Runtime>::new(),
4179 ),
4180 frame_system::CheckNonZeroSender::<Runtime>::new(),
4181 frame_system::CheckSpecVersion::<Runtime>::new(),
4182 frame_system::CheckTxVersion::<Runtime>::new(),
4183 frame_system::CheckGenesis::<Runtime>::new(),
4184 frame_system::CheckEra::<Runtime>::from(Era::Immortal),
4185 frame_system::CheckNonce::<Runtime>::from(nonce),
4186 frame_system::CheckWeight::<Runtime>::new(),
4187 pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
4188 pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(0, None),
4189 ),
4190 frame_metadata_hash_extension::CheckMetadataHash::new(false),
4191 pallet_revive::evm::tx_extension::SetOrigin::<Runtime>::default(),
4192 frame_system::WeightReclaim::<Runtime>::new(),
4193 )
4194 }
4195
4196 #[test]
4197 fn validate_transaction_submitter_bounds() {
4198 fn is_submit_signed_transaction<T>()
4199 where
4200 T: CreateSignedTransaction<RuntimeCall>,
4201 {
4202 }
4203
4204 is_submit_signed_transaction::<Runtime>();
4205 }
4206
4207 #[test]
4208 fn call_size() {
4209 let size = core::mem::size_of::<RuntimeCall>();
4210 assert!(
4211 size <= CALL_PARAMS_MAX_SIZE,
4212 "size of RuntimeCall {} is more than {CALL_PARAMS_MAX_SIZE} bytes.
4213 Some calls have too big arguments, use Box to reduce the size of RuntimeCall.
4214 If the limit is too strong, maybe consider increase the limit.",
4215 size,
4216 );
4217 }
4218
4219 #[test]
4220 fn nft_only_purse_without_system_account_can_transfer() {
4221 let storage = frame_system::GenesisConfig::<Runtime>::default().build_storage().unwrap();
4222 let mut ext: sp_io::TestExternalities = storage.into();
4223
4224 ext.execute_with(|| {
4225 System::set_block_number(1);
4226 Timestamp::set_timestamp(1_000);
4227 let from = AccountId::new([1u8; 32]);
4228 let to = AccountId::new([2u8; 32]);
4229 pallet_scarcity::NftsByOwner::<Runtime>::insert(
4230 &from,
4231 pallet_scarcity::Nft {
4232 instance: 0,
4233 collection: 0,
4234 item: 0,
4235 minted_at: 0,
4236 last_moved: 0,
4237 state_nonce: 0,
4238 },
4239 );
4240 pallet_scarcity::Instances::<Runtime>::insert(0, &from);
4241
4242 assert_eq!(Balances::free_balance(&from), 0);
4243 assert_eq!(System::account_nonce(&from), 0);
4244 assert!(!frame_system::Account::<Runtime>::contains_key(&from));
4245
4246 let call = RuntimeCall::Scarcity(pallet_scarcity::Call::<Runtime>::transfer {
4247 to: to.clone(),
4248 });
4249 let info = call.get_dispatch_info();
4250 let result = scarcity_tx_extension(7, 0).dispatch_transaction(
4252 RuntimeOrigin::signed(from.clone()),
4253 call,
4254 &info,
4255 0,
4256 0,
4257 );
4258 assert!(matches!(result, Ok(Ok(_))), "transaction failed: {result:?}");
4259
4260 assert_eq!(Balances::free_balance(&from), 0);
4261 assert!(!frame_system::Account::<Runtime>::contains_key(&from));
4262 assert!(!frame_system::Account::<Runtime>::contains_key(&to));
4263 assert!(!pallet_scarcity::NftsByOwner::<Runtime>::contains_key(&from));
4264 assert_eq!(
4265 pallet_scarcity::NftsByOwner::<Runtime>::get(&to).map(|nft| nft.instance),
4266 Some(0),
4267 );
4268 assert!(System::events().iter().any(|record| matches!(
4269 record.event,
4270 RuntimeEvent::SkipFeelessPayment(
4271 pallet_skip_feeless_payment::Event::FeeSkipped { .. }
4272 )
4273 )));
4274 });
4275 }
4276
4277 #[test]
4278 fn failed_scarcity_transfer_is_feeless_and_retryable_after_lock() {
4279 let storage = frame_system::GenesisConfig::<Runtime>::default().build_storage().unwrap();
4280 let mut ext: sp_io::TestExternalities = storage.into();
4281
4282 ext.execute_with(|| {
4283 System::set_block_number(1);
4284 Timestamp::set_timestamp(1_000);
4285 let from = AccountId::new([1u8; 32]);
4286 let to = AccountId::new([2u8; 32]);
4287 pallet_scarcity::NftsByOwner::<Runtime>::insert(
4288 &from,
4289 pallet_scarcity::Nft {
4290 instance: 0,
4291 collection: 0,
4292 item: 0,
4293 minted_at: 0,
4294 last_moved: 0,
4295 state_nonce: u64::MAX,
4296 },
4297 );
4298 pallet_scarcity::Instances::<Runtime>::insert(0, &from);
4299
4300 let call = RuntimeCall::Scarcity(pallet_scarcity::Call::<Runtime>::transfer {
4301 to: to.clone(),
4302 });
4303 let info = call.get_dispatch_info();
4304 let result = scarcity_tx_extension(9, u64::MAX).dispatch_transaction(
4305 RuntimeOrigin::signed(from.clone()),
4306 call,
4307 &info,
4308 0,
4309 0,
4310 );
4311 assert!(matches!(result, Ok(Err(_))), "transaction did not reach dispatch: {result:?}");
4312
4313 assert_eq!(Balances::free_balance(&from), 0);
4314 assert_eq!(System::account_nonce(&from), 0);
4315 assert!(!frame_system::Account::<Runtime>::contains_key(&from));
4316 assert_eq!(
4317 pallet_scarcity::NftsByOwner::<Runtime>::get(&from).map(|nft| nft.state_nonce),
4318 Some(u64::MAX),
4319 );
4320 assert!(!pallet_scarcity::NftsByOwner::<Runtime>::contains_key(&to));
4321 assert_eq!(pallet_scarcity::Locked::<Runtime>::get(&from).unwrap().retries, 1);
4322
4323 pallet_timestamp::Now::<Runtime>::put(62_000);
4324 let retry_call =
4325 RuntimeCall::Scarcity(pallet_scarcity::Call::<Runtime>::transfer { to });
4326 let retry_info = retry_call.get_dispatch_info();
4327 let retry_result = scarcity_tx_extension(9, u64::MAX).dispatch_transaction(
4328 RuntimeOrigin::signed(from.clone()),
4329 retry_call,
4330 &retry_info,
4331 0,
4332 0,
4333 );
4334 assert!(
4335 matches!(retry_result, Ok(Err(_))),
4336 "retry did not reach dispatch: {retry_result:?}"
4337 );
4338 assert_eq!(System::account_nonce(&from), 0);
4339 assert_eq!(pallet_scarcity::Locked::<Runtime>::get(&from).unwrap().retries, 2);
4340 });
4341 }
4342}