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

difftreelog

source

runtime/common/config/substrate.rs7.8 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		DispatchClass, ConstantMultiplier,22	},23	parameter_types, PalletId,24};25use sp_runtime::{26	generic,27	traits::{BlakeTwo256, AccountIdLookup},28	Perbill, Permill, Percent,29};30use frame_system::{31	limits::{BlockLength, BlockWeights},32	EnsureRoot,33};34use crate::{35	runtime_common::DealWithFees, Runtime, Event, Call, Origin, PalletInfo, System, Balances,36	Treasury, SS58Prefix, Version,37};38use up_common::{types::*, constants::*};3940parameter_types! {41	pub const BlockHashCount: BlockNumber = 2400;42	pub RuntimeBlockLength: BlockLength =43		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);44	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);45	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;46	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()47		.base_block(BlockExecutionWeight::get())48		.for_class(DispatchClass::all(), |weights| {49			weights.base_extrinsic = ExtrinsicBaseWeight::get();50		})51		.for_class(DispatchClass::Normal, |weights| {52			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);53		})54		.for_class(DispatchClass::Operational, |weights| {55			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);56			// Operational transactions have some extra reserved space, so that they57			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.58			weights.reserved = Some(59				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT60			);61		})62		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)63		.build_or_panic();64}6566impl frame_system::Config for Runtime {67	/// The data to be stored in an account.68	type AccountData = pallet_balances::AccountData<Balance>;69	/// The identifier used to distinguish between accounts.70	type AccountId = AccountId;71	/// The basic call filter to use in dispatchable.72	type BaseCallFilter = Everything;73	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).74	type BlockHashCount = BlockHashCount;75	/// The maximum length of a block (in bytes).76	type BlockLength = RuntimeBlockLength;77	/// The index type for blocks.78	type BlockNumber = BlockNumber;79	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.80	type BlockWeights = RuntimeBlockWeights;81	/// The aggregated dispatch type that is available for extrinsics.82	type Call = Call;83	/// The weight of database operations that the runtime can invoke.84	type DbWeight = RocksDbWeight;85	/// The ubiquitous event type.86	type Event = Event;87	/// The type for hashing blocks and tries.88	type Hash = Hash;89	/// The hashing algorithm used.90	type Hashing = BlakeTwo256;91	/// The header type.92	type Header = generic::Header<BlockNumber, BlakeTwo256>;93	/// The index type for storing how many extrinsics an account has signed.94	type Index = Index;95	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.96	type Lookup = AccountIdLookup<AccountId, ()>;97	/// What to do if an account is fully reaped from the system.98	type OnKilledAccount = ();99	/// What to do if a new account is created.100	type OnNewAccount = ();101	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;102	/// The ubiquitous origin type.103	type Origin = Origin;104	/// This type is being generated by `construct_runtime!`.105	type PalletInfo = PalletInfo;106	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.107	type SS58Prefix = SS58Prefix;108	/// Weight information for the extrinsics of this pallet.109	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;110	/// Version of the runtime.111	type Version = Version;112	type MaxConsumers = ConstU32<16>;113}114115impl pallet_randomness_collective_flip::Config for Runtime {}116117parameter_types! {118	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;119}120121impl pallet_timestamp::Config for Runtime {122	/// A timestamp: milliseconds since the unix epoch.123	type Moment = u64;124	type OnTimestampSet = ();125	type MinimumPeriod = MinimumPeriod;126	type WeightInfo = ();127}128129parameter_types! {130	// pub const ExistentialDeposit: u128 = 500;131	pub const ExistentialDeposit: u128 = 0;132	pub const MaxLocks: u32 = 50;133	pub const MaxReserves: u32 = 50;134}135136impl pallet_balances::Config for Runtime {137	type MaxLocks = MaxLocks;138	type MaxReserves = MaxReserves;139	type ReserveIdentifier = [u8; 16];140	/// The type for recording an account's balance.141	type Balance = Balance;142	/// The ubiquitous event type.143	type Event = Event;144	type DustRemoval = Treasury;145	type ExistentialDeposit = ExistentialDeposit;146	type AccountStore = System;147	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;148}149150parameter_types! {151	/// This value increases the priority of `Operational` transactions by adding152	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.153	pub const OperationalFeeMultiplier: u8 = 5;154}155156impl pallet_transaction_payment::Config for Runtime {157	type Event = Event;158	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;159	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;160	type OperationalFeeMultiplier = OperationalFeeMultiplier;161	type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;162	type FeeMultiplierUpdate = ();163}164165parameter_types! {166	pub const ProposalBond: Permill = Permill::from_percent(5);167	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;168	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;169	pub const SpendPeriod: BlockNumber = 5 * MINUTES;170	pub const Burn: Permill = Permill::from_percent(0);171	pub const TipCountdown: BlockNumber = 1 * DAYS;172	pub const TipFindersFee: Percent = Percent::from_percent(20);173	pub const TipReportDepositBase: Balance = 1 * UNIQUE;174	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;175	pub const BountyDepositBase: Balance = 1 * UNIQUE;176	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;177	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");178	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;179	pub const MaximumReasonLength: u32 = 16384;180	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);181	pub const BountyValueMinimum: Balance = 5 * UNIQUE;182	pub const MaxApprovals: u32 = 100;183}184185impl pallet_treasury::Config for Runtime {186	type PalletId = TreasuryModuleId;187	type Currency = Balances;188	type ApproveOrigin = EnsureRoot<AccountId>;189	type RejectOrigin = EnsureRoot<AccountId>;190	type SpendOrigin = NeverEnsureOrigin<u128>;191	type Event = Event;192	type OnSlash = ();193	type ProposalBond = ProposalBond;194	type ProposalBondMinimum = ProposalBondMinimum;195	type ProposalBondMaximum = ProposalBondMaximum;196	type SpendPeriod = SpendPeriod;197	type Burn = Burn;198	type BurnDestination = ();199	type SpendFunds = ();200	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;201	type MaxApprovals = MaxApprovals;202}203204impl pallet_sudo::Config for Runtime {205	type Event = Event;206	type Call = Call;207}208209parameter_types! {210	pub const MaxAuthorities: u32 = 100_000;211}212213impl pallet_aura::Config for Runtime {214	type AuthorityId = AuraId;215	type DisabledValidators = ();216	type MaxAuthorities = MaxAuthorities;217}