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