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

difftreelog

source

runtime/common/config/substrate.rs10.0 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, Aura, Session, SessionKeys, CollatorSelection, Version,37};38use xcm::v1::BodyId;39use up_common::{types::*, constants::*};4041parameter_types! {42	pub const BlockHashCount: BlockNumber = 2400;43	pub RuntimeBlockLength: BlockLength =44		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);45	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);46	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;47	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()48		.base_block(BlockExecutionWeight::get())49		.for_class(DispatchClass::all(), |weights| {50			weights.base_extrinsic = ExtrinsicBaseWeight::get();51		})52		.for_class(DispatchClass::Normal, |weights| {53			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);54		})55		.for_class(DispatchClass::Operational, |weights| {56			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);57			// Operational transactions have some extra reserved space, so that they58			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.59			weights.reserved = Some(60				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT61			);62		})63		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)64		.build_or_panic();65}6667impl frame_system::Config for Runtime {68	/// The data to be stored in an account.69	type AccountData = pallet_balances::AccountData<Balance>;70	/// The identifier used to distinguish between accounts.71	type AccountId = AccountId;72	/// The basic call filter to use in dispatchable.73	type BaseCallFilter = Everything;74	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).75	type BlockHashCount = BlockHashCount;76	/// The maximum length of a block (in bytes).77	type BlockLength = RuntimeBlockLength;78	/// The index type for blocks.79	type BlockNumber = BlockNumber;80	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.81	type BlockWeights = RuntimeBlockWeights;82	/// The aggregated dispatch type that is available for extrinsics.83	type Call = Call;84	/// The weight of database operations that the runtime can invoke.85	type DbWeight = RocksDbWeight;86	/// The ubiquitous event type.87	type Event = Event;88	/// The type for hashing blocks and tries.89	type Hash = Hash;90	/// The hashing algorithm used.91	type Hashing = BlakeTwo256;92	/// The header type.93	type Header = generic::Header<BlockNumber, BlakeTwo256>;94	/// The index type for storing how many extrinsics an account has signed.95	type Index = Index;96	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.97	type Lookup = AccountIdLookup<AccountId, ()>;98	/// What to do if an account is fully reaped from the system.99	type OnKilledAccount = ();100	/// What to do if a new account is created.101	type OnNewAccount = ();102	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;103	/// The ubiquitous origin type.104	type Origin = Origin;105	/// This type is being generated by `construct_runtime!`.106	type PalletInfo = PalletInfo;107	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.108	type SS58Prefix = SS58Prefix;109	/// Weight information for the extrinsics of this pallet.110	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;111	/// Version of the runtime.112	type Version = Version;113	type MaxConsumers = ConstU32<16>;114}115116impl pallet_randomness_collective_flip::Config for Runtime {}117118parameter_types! {119	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;120}121122impl pallet_timestamp::Config for Runtime {123	/// A timestamp: milliseconds since the unix epoch.124	type Moment = u64;125	type OnTimestampSet = ();126	type MinimumPeriod = MinimumPeriod;127	type WeightInfo = ();128}129130parameter_types! {131	// pub const ExistentialDeposit: u128 = 500;132	pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;133	pub const MaxLocks: u32 = 50;134	pub const MaxReserves: u32 = 50;135}136137impl pallet_balances::Config for Runtime {138	type MaxLocks = MaxLocks;139	type MaxReserves = MaxReserves;140	type ReserveIdentifier = [u8; 16];141	/// The type for recording an account's balance.142	type Balance = Balance;143	/// The ubiquitous event type.144	type Event = Event;145	type DustRemoval = Treasury;146	type ExistentialDeposit = ExistentialDeposit;147	type AccountStore = System;148	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;149}150151parameter_types! {152	/// This value increases the priority of `Operational` transactions by adding153	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.154	pub const OperationalFeeMultiplier: u8 = 5;155}156157impl pallet_transaction_payment::Config for Runtime {158	type Event = Event;159	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;160	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;161	type OperationalFeeMultiplier = OperationalFeeMultiplier;162	type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;163	type FeeMultiplierUpdate = ();164}165166parameter_types! {167	pub const ProposalBond: Permill = Permill::from_percent(5);168	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;169	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;170	pub const SpendPeriod: BlockNumber = 5 * MINUTES;171	pub const Burn: Permill = Permill::from_percent(0);172	pub const TipCountdown: BlockNumber = 1 * DAYS;173	pub const TipFindersFee: Percent = Percent::from_percent(20);174	pub const TipReportDepositBase: Balance = 1 * UNIQUE;175	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;176	pub const BountyDepositBase: Balance = 1 * UNIQUE;177	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;178	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");179	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;180	pub const MaximumReasonLength: u32 = 16384;181	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);182	pub const BountyValueMinimum: Balance = 5 * UNIQUE;183	pub const MaxApprovals: u32 = 100;184}185186impl pallet_treasury::Config for Runtime {187	type PalletId = TreasuryModuleId;188	type Currency = Balances;189	type ApproveOrigin = EnsureRoot<AccountId>;190	type RejectOrigin = EnsureRoot<AccountId>;191	type SpendOrigin = NeverEnsureOrigin<u128>;192	type Event = Event;193	type OnSlash = ();194	type ProposalBond = ProposalBond;195	type ProposalBondMinimum = ProposalBondMinimum;196	type ProposalBondMaximum = ProposalBondMaximum;197	type SpendPeriod = SpendPeriod;198	type Burn = Burn;199	type BurnDestination = ();200	type SpendFunds = ();201	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;202	type MaxApprovals = MaxApprovals;203}204205impl pallet_sudo::Config for Runtime {206	type Event = Event;207	type Call = Call;208}209210parameter_types! {211	pub const MaxAuthorities: u32 = 100_000;212}213214impl pallet_aura::Config for Runtime {215	type AuthorityId = AuraId;216	type DisabledValidators = ();217	type MaxAuthorities = MaxAuthorities;218}219220parameter_types! {221	pub const Period: u32 = 6 * HOURS;222	pub const Offset: u32 = 0;223	//pub const MaxAuthorities: u32 = 100_000;224}225226impl pallet_session::Config for Runtime {227	type Event = Event;228	type ValidatorId = <Self as frame_system::Config>::AccountId;229	// we don't have stash and controller, thus we don't need the convert as well.230	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;231	type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;232	type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;233	type SessionManager = CollatorSelection;234	// Essentially just Aura, but lets be pedantic.235	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;236	type Keys = SessionKeys;237	type WeightInfo = ();238}239240parameter_types! {241	pub const UncleGenerations: u32 = 0;242}243244impl pallet_authorship::Config for Runtime {245	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;246	type UncleGenerations = UncleGenerations;247	type FilterUncle = ();248	type EventHandler = (CollatorSelection,);249}250251parameter_types! {252	pub const PotId: PalletId = PalletId(*b"PotStake");253	pub const MaxCandidates: u32 = 1000;254	pub const MinCandidates: u32 = 5;255	pub const SessionLength: BlockNumber = 6 * HOURS;256	pub const MaxInvulnerables: u32 = 100;257	pub const ExecutiveBody: BodyId = BodyId::Executive;258}259260// We allow root only to execute privileged collator selection operations.261pub type CollatorSelectionUpdateOrigin = EnsureRoot<AccountId>;262263impl pallet_collator_selection::Config for Runtime {264	type Event = Event;265	type Currency = Balances;266	type UpdateOrigin = CollatorSelectionUpdateOrigin;267	type PotId = PotId;268	type MaxCandidates = MaxCandidates;269	type MinCandidates = MinCandidates;270	type MaxInvulnerables = MaxInvulnerables;271	// should be a multiple of session or things will get inconsistent272	type KickThreshold = Period;273	type ValidatorId = <Self as frame_system::Config>::AccountId;274	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;275	type ValidatorRegistration = Session;276	type WeightInfo = ();277}