git.delta.rocks / unique-network / refs/commits / a64769ff6bff

difftreelog

source

runtime/common/config/substrate.rs9.4 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	traits::{Everything, ConstU32, NeverEnsureOrigin},19	weights::{20		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},21		ConstantMultiplier,22	},23	dispatch::DispatchClass,24	parameter_types, ord_parameter_types, PalletId,25};26use sp_runtime::{27	generic,28	traits::{BlakeTwo256, AccountIdLookup},29	Perbill, Permill, Percent,30};31use sp_arithmetic::traits::One;32use frame_system::{33	limits::{BlockLength, BlockWeights},34	EnsureRoot, EnsureSignedBy,35};36use pallet_transaction_payment::{Multiplier, ConstFeeMultiplier};37use crate::{38	runtime_common::DealWithFees, Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, OriginCaller,39	PalletInfo, System, Balances, SS58Prefix, Version,40};41use up_common::{types::*, constants::*};42use sp_std::vec;4344parameter_types! {45	pub const BlockHashCount: BlockNumber = 2400;46	pub RuntimeBlockLength: BlockLength =47		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);48	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);49	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;50	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()51		.base_block(BlockExecutionWeight::get())52		.for_class(DispatchClass::all(), |weights| {53			weights.base_extrinsic = ExtrinsicBaseWeight::get();54		})55		.for_class(DispatchClass::Normal, |weights| {56			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);57		})58		.for_class(DispatchClass::Operational, |weights| {59			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);60			// Operational transactions have some extra reserved space, so that they61			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.62			weights.reserved = Some(63				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT64			);65		})66		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)67		.build_or_panic();68}6970impl frame_system::Config for Runtime {71	/// The data to be stored in an account.72	type AccountData = pallet_balances::AccountData<Balance>;73	/// The identifier used to distinguish between accounts.74	type AccountId = AccountId;75	/// The basic call filter to use in dispatchable.76	type BaseCallFilter = Everything;77	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).78	type BlockHashCount = BlockHashCount;79	/// The block type.80	type Block = Block;81	/// The maximum length of a block (in bytes).82	type BlockLength = RuntimeBlockLength;83	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.84	type BlockWeights = RuntimeBlockWeights;85	/// The aggregated dispatch type that is available for extrinsics.86	type RuntimeCall = RuntimeCall;87	/// The weight of database operations that the runtime can invoke.88	type DbWeight = RocksDbWeight;89	/// The ubiquitous event type.90	type RuntimeEvent = RuntimeEvent;91	/// The type for hashing blocks and tries.92	type Hash = Hash;93	/// The hashing algorithm used.94	type Hashing = BlakeTwo256;95	/// The index type for storing how many extrinsics an account has signed.96	type Nonce = Nonce;97	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.98	type Lookup = AccountIdLookup<AccountId, ()>;99	/// What to do if an account is fully reaped from the system.100	type OnKilledAccount = ();101	/// What to do if a new account is created.102	type OnNewAccount = ();103	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;104	/// The ubiquitous origin type.105	type RuntimeOrigin = RuntimeOrigin;106	/// This type is being generated by `construct_runtime!`.107	type PalletInfo = PalletInfo;108	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.109	type SS58Prefix = SS58Prefix;110	/// Weight information for the extrinsics of this pallet.111	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;112	/// Version of the runtime.113	type Version = Version;114	type MaxConsumers = ConstU32<16>;115}116117parameter_types! {118	pub const MigrationMaxKeyLen: u32 = 512;119}120ord_parameter_types! {121	pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));122}123124impl pallet_state_trie_migration::Config for Runtime {125	type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;126	type RuntimeEvent = RuntimeEvent;127	type Currency = Balances;128	type SignedDepositPerItem = ();129	type SignedDepositBase = ();130	type ControlOrigin = EnsureRoot<AccountId>;131	// Only root can perform this migration132	type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;133	type MaxKeyLen = MigrationMaxKeyLen;134}135136parameter_types! {137	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;138}139140impl pallet_timestamp::Config for Runtime {141	/// A timestamp: milliseconds since the unix epoch.142	type Moment = u64;143	type OnTimestampSet = ();144	type MinimumPeriod = MinimumPeriod;145	type WeightInfo = ();146}147148parameter_types! {149	// pub const ExistentialDeposit: u128 = 500;150	pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;151	pub const MaxLocks: u32 = 50;152	pub const MaxReserves: u32 = 50;153	pub const MaxHolds: u32 = 10;154	pub const MaxFreezes: u32 = 10;155}156157impl pallet_balances::Config for Runtime {158	type MaxLocks = MaxLocks;159	type MaxReserves = MaxReserves;160	type ReserveIdentifier = [u8; 16];161	/// The type for recording an account's balance.162	type Balance = Balance;163	/// The ubiquitous event type.164	type RuntimeEvent = RuntimeEvent;165	// FIXME: Is () the new treasury?166	// Switch to real treasury once we start having dust removals167	// Related issue: https://github.com/paritytech/polkadot/issues/7323168	type DustRemoval = ();169	type ExistentialDeposit = ExistentialDeposit;170	type AccountStore = System;171	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;172	type RuntimeHoldReason = RuntimeHoldReason;173	type FreezeIdentifier = [u8; 16];174	type MaxHolds = MaxHolds;175	type MaxFreezes = MaxFreezes;176}177178parameter_types! {179	/// This value increases the priority of `Operational` transactions by adding180	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.181	pub const OperationalFeeMultiplier: u8 = 5;182183	pub FeeMultiplier: Multiplier = Multiplier::one();184}185186impl pallet_transaction_payment::Config for Runtime {187	type RuntimeEvent = RuntimeEvent;188	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;189	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;190	type OperationalFeeMultiplier = OperationalFeeMultiplier;191	type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;192	type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;193}194195parameter_types! {196	pub const ProposalBond: Permill = Permill::from_percent(5);197	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;198	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;199	pub const SpendPeriod: BlockNumber = 5 * MINUTES;200	pub const Burn: Permill = Permill::from_percent(0);201	pub const TipCountdown: BlockNumber = 1 * DAYS;202	pub const TipFindersFee: Percent = Percent::from_percent(20);203	pub const TipReportDepositBase: Balance = 1 * UNIQUE;204	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;205	pub const BountyDepositBase: Balance = 1 * UNIQUE;206	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;207	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");208	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;209	pub const MaximumReasonLength: u32 = 16384;210	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);211	pub const BountyValueMinimum: Balance = 5 * UNIQUE;212	pub const MaxApprovals: u32 = 100;213}214215impl pallet_treasury::Config for Runtime {216	type PalletId = TreasuryModuleId;217	type Currency = Balances;218	type ApproveOrigin = EnsureRoot<AccountId>;219	type RejectOrigin = EnsureRoot<AccountId>;220	type SpendOrigin = NeverEnsureOrigin<u128>;221	type RuntimeEvent = RuntimeEvent;222	type OnSlash = ();223	type ProposalBond = ProposalBond;224	type ProposalBondMinimum = ProposalBondMinimum;225	type ProposalBondMaximum = ProposalBondMaximum;226	type SpendPeriod = SpendPeriod;227	type Burn = Burn;228	type BurnDestination = ();229	type SpendFunds = ();230	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;231	type MaxApprovals = MaxApprovals;232}233234impl pallet_sudo::Config for Runtime {235	type RuntimeEvent = RuntimeEvent;236	type RuntimeCall = RuntimeCall;237	type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;238}239240parameter_types! {241	pub const MaxAuthorities: u32 = 100_000;242}243244impl pallet_aura::Config for Runtime {245	type AuthorityId = AuraId;246	type DisabledValidators = ();247	type MaxAuthorities = MaxAuthorities;248	type AllowMultipleBlocksPerSlot = ConstBool<true>;249}250251impl pallet_utility::Config for Runtime {252	type RuntimeEvent = RuntimeEvent;253	type RuntimeCall = RuntimeCall;254	type PalletsOrigin = OriginCaller;255	type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;256}