referrerpolicy=no-referrer-when-downgrade

solochain_template_runtime/configs/
mod.rs

1// This is free and unencumbered software released into the public domain.
2//
3// Anyone is free to copy, modify, publish, use, compile, sell, or
4// distribute this software, either in source code form or as a compiled
5// binary, for any purpose, commercial or non-commercial, and by any
6// means.
7//
8// In jurisdictions that recognize copyright laws, the author or authors
9// of this software dedicate any and all copyright interest in the
10// software to the public domain. We make this dedication for the benefit
11// of the public at large and to the detriment of our heirs and
12// successors. We intend this dedication to be an overt act of
13// relinquishment in perpetuity of all present and future rights to this
14// software under copyright law.
15//
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22// OTHER DEALINGS IN THE SOFTWARE.
23//
24// For more information, please refer to <http://unlicense.org>
25
26// Substrate and Polkadot dependencies
27use frame_support::{
28	derive_impl, parameter_types,
29	traits::{ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, VariantCountOf},
30	weights::{
31		constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND},
32		IdentityFee, Weight,
33	},
34};
35use frame_system::limits::{BlockLength, BlockWeights};
36use pallet_transaction_payment::{ConstFeeMultiplier, FungibleAdapter, Multiplier};
37use sp_consensus_aura::sr25519::AuthorityId as AuraId;
38use sp_runtime::{traits::One, Perbill};
39use sp_version::RuntimeVersion;
40
41// Local module imports
42use super::{
43	AccountId, Aura, Balance, Balances, Block, BlockNumber, Hash, Nonce, PalletInfo, Runtime,
44	RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask,
45	System, EXISTENTIAL_DEPOSIT, SLOT_DURATION, VERSION,
46};
47
48const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
49
50parameter_types! {
51	pub const BlockHashCount: BlockNumber = 2400;
52	pub const Version: RuntimeVersion = VERSION;
53
54	/// We allow for 2 seconds of compute with a 6 second average block time.
55	pub RuntimeBlockWeights: BlockWeights = BlockWeights::with_sensible_defaults(
56		Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
57		NORMAL_DISPATCH_RATIO,
58	);
59	pub RuntimeBlockLength: BlockLength = BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
60	pub const SS58Prefix: u8 = 42;
61}
62
63/// All migrations of the runtime, aside from the ones declared in the pallets.
64///
65/// This can be a tuple of types, each implementing `OnRuntimeUpgrade`.
66#[allow(unused_parens)]
67type SingleBlockMigrations = ();
68
69/// The default types are being injected by [`derive_impl`](`frame_support::derive_impl`) from
70/// [`SoloChainDefaultConfig`](`struct@frame_system::config_preludes::SolochainDefaultConfig`),
71/// but overridden as needed.
72#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
73impl frame_system::Config for Runtime {
74	/// The block type for the runtime.
75	type Block = Block;
76	/// Block & extrinsics weights: base values and limits.
77	type BlockWeights = RuntimeBlockWeights;
78	/// The maximum length of a block (in bytes).
79	type BlockLength = RuntimeBlockLength;
80	/// The identifier used to distinguish between accounts.
81	type AccountId = AccountId;
82	/// The type for storing how many extrinsics an account has signed.
83	type Nonce = Nonce;
84	/// The type for hashing blocks and tries.
85	type Hash = Hash;
86	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
87	type BlockHashCount = BlockHashCount;
88	/// The weight of database operations that the runtime can invoke.
89	type DbWeight = RocksDbWeight;
90	/// Version of the runtime.
91	type Version = Version;
92	/// The data to be stored in an account.
93	type AccountData = pallet_balances::AccountData<Balance>;
94	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
95	type SS58Prefix = SS58Prefix;
96	type MaxConsumers = frame_support::traits::ConstU32<16>;
97	type SingleBlockMigrations = SingleBlockMigrations;
98}
99
100impl pallet_aura::Config for Runtime {
101	type AuthorityId = AuraId;
102	type DisabledValidators = ();
103	type MaxAuthorities = ConstU32<32>;
104	type AllowMultipleBlocksPerSlot = ConstBool<false>;
105	type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Runtime>;
106}
107
108impl pallet_grandpa::Config for Runtime {
109	type RuntimeEvent = RuntimeEvent;
110
111	type WeightInfo = ();
112	type MaxAuthorities = ConstU32<32>;
113	type MaxNominators = ConstU32<0>;
114	type MaxSetIdSessionEntries = ConstU64<0>;
115
116	type KeyOwnerProof = sp_core::Void;
117	type EquivocationReportSystem = ();
118}
119
120impl pallet_timestamp::Config for Runtime {
121	/// A timestamp: milliseconds since the unix epoch.
122	type Moment = u64;
123	type OnTimestampSet = Aura;
124	type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
125	type WeightInfo = ();
126}
127
128impl pallet_balances::Config for Runtime {
129	type MaxLocks = ConstU32<50>;
130	type MaxReserves = ();
131	type ReserveIdentifier = [u8; 8];
132	/// The type for recording an account's balance.
133	type Balance = Balance;
134	/// The ubiquitous event type.
135	type RuntimeEvent = RuntimeEvent;
136	type DustRemoval = ();
137	type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
138	type AccountStore = System;
139	type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
140	type FreezeIdentifier = RuntimeFreezeReason;
141	type MaxFreezes = VariantCountOf<RuntimeFreezeReason>;
142	type RuntimeHoldReason = RuntimeHoldReason;
143	type RuntimeFreezeReason = RuntimeFreezeReason;
144	type DoneSlashHandler = ();
145}
146
147parameter_types! {
148	pub FeeMultiplier: Multiplier = Multiplier::one();
149}
150
151impl pallet_transaction_payment::Config for Runtime {
152	type RuntimeEvent = RuntimeEvent;
153	type OnChargeTransaction = FungibleAdapter<Balances, ()>;
154	type OperationalFeeMultiplier = ConstU8<5>;
155	type WeightToFee = IdentityFee<Balance>;
156	type LengthToFee = IdentityFee<Balance>;
157	type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;
158	type WeightInfo = pallet_transaction_payment::weights::SubstrateWeight<Runtime>;
159}
160
161impl pallet_sudo::Config for Runtime {
162	type RuntimeEvent = RuntimeEvent;
163	type RuntimeCall = RuntimeCall;
164	type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
165}
166
167/// Configure the pallet-template in pallets/template.
168impl pallet_template::Config for Runtime {
169	type RuntimeEvent = RuntimeEvent;
170	type WeightInfo = pallet_template::weights::SubstrateWeight<Runtime>;
171}