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

difftreelog

refactor use derive_impl for frame_system::Config

Yaroslav Bolyukin2024-06-19parent: #e6ed5f4.patch.diff
in: master

1 file changed

modifiedruntime/common/config/substrate.rsdiffbeforeafterboth
after · runtime/common/config/substrate.rs
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	dispatch::DispatchClass,19	ord_parameter_types, parameter_types,20	traits::{21		tokens::{PayFromAccount, UnityAssetBalanceConversion},22		ConstBool, ConstU32, ConstU64, Everything, NeverEnsureOrigin,23	},24	weights::{25		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},26		ConstantMultiplier,27	},28	PalletId, derive_impl,29};30use frame_system::{31	limits::{BlockLength, BlockWeights},32	EnsureRoot, EnsureSignedBy,33};34use pallet_transaction_payment::{ConstFeeMultiplier, Multiplier};35use sp_arithmetic::traits::One;36use sp_runtime::{37	traits::{AccountIdLookup, BlakeTwo256, IdentityLookup},38	Perbill, Percent, Permill,39};40use sp_std::vec;41use up_common::{constants::*, types::*};4243use crate::{44	runtime_common::DealWithFees, Balances, Block, OriginCaller, PalletInfo, Runtime, RuntimeCall,45	RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, SS58Prefix, System,46	Treasury, Version, RuntimeTask,47};4849parameter_types! {50	pub const BlockHashCount: BlockNumber = 2400;51	pub RuntimeBlockLength: BlockLength =52		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);53	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);54	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;55	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()56		.base_block(BlockExecutionWeight::get())57		.for_class(DispatchClass::all(), |weights| {58			weights.base_extrinsic = ExtrinsicBaseWeight::get();59		})60		.for_class(DispatchClass::Normal, |weights| {61			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);62		})63		.for_class(DispatchClass::Operational, |weights| {64			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);65			// Operational transactions have some extra reserved space, so that they66			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.67			weights.reserved = Some(68				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT69			);70		})71		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)72		.build_or_panic();73}7475#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)]76impl frame_system::Config for Runtime {77	/// The data to be stored in an account.78	type AccountData = pallet_balances::AccountData<Balance>;79	/// The identifier used to distinguish between accounts.80	type AccountId = AccountId;81	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).82	type BlockHashCount = BlockHashCount;83	/// The block type.84	type Block = Block;85	/// The maximum length of a block (in bytes).86	type BlockLength = RuntimeBlockLength;87	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.88	type BlockWeights = RuntimeBlockWeights;89	/// The weight of database operations that the runtime can invoke.90	type DbWeight = RocksDbWeight;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	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;100	/// The ubiquitous origin type.101	type RuntimeOrigin = RuntimeOrigin;102	/// This type is being generated by `construct_runtime!`.103	type PalletInfo = PalletInfo;104	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.105	type SS58Prefix = SS58Prefix;106	/// Weight information for the extrinsics of this pallet.107	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;108	/// Version of the runtime.109	type Version = Version;110	type MaxConsumers = ConstU32<16>;111}112113parameter_types! {114	pub const MigrationMaxKeyLen: u32 = 512;115}116ord_parameter_types! {117	pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));118}119120impl pallet_state_trie_migration::Config for Runtime {121	type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;122	type RuntimeEvent = RuntimeEvent;123	type Currency = Balances;124	type SignedDepositPerItem = ();125	type SignedDepositBase = ();126	type ControlOrigin = EnsureRoot<AccountId>;127	// Only root can perform this migration128	type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;129	type MaxKeyLen = MigrationMaxKeyLen;130	type RuntimeHoldReason = RuntimeHoldReason;131}132133impl pallet_timestamp::Config for Runtime {134	/// A timestamp: milliseconds since the unix epoch.135	type Moment = u64;136	type OnTimestampSet = ();137	#[cfg(not(feature = "lookahead"))]138	type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;139	#[cfg(feature = "lookahead")]140	type MinimumPeriod = ConstU64<0>;141	type WeightInfo = ();142}143144parameter_types! {145	// pub const ExistentialDeposit: u128 = 500;146	pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;147	pub const MaxLocks: u32 = 50;148	pub const MaxReserves: u32 = 50;149	pub const MaxHolds: u32 = 10;150	pub const MaxFreezes: u32 = 10;151}152153impl pallet_balances::Config for Runtime {154	type MaxLocks = MaxLocks;155	type MaxReserves = MaxReserves;156	type ReserveIdentifier = [u8; 16];157	/// The type for recording an account's balance.158	type Balance = Balance;159	/// The ubiquitous event type.160	type RuntimeEvent = RuntimeEvent;161	// FIXME: Is () the new treasury?162	// Switch to real treasury once we start having dust removals163	// Related issue: https://github.com/paritytech/polkadot/issues/7323164	type DustRemoval = ();165	type ExistentialDeposit = ExistentialDeposit;166	type AccountStore = System;167	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;168	type RuntimeHoldReason = RuntimeHoldReason;169	type RuntimeFreezeReason = RuntimeFreezeReason;170	type FreezeIdentifier = [u8; 16];171	type MaxFreezes = MaxFreezes;172}173174parameter_types! {175	/// This value increases the priority of `Operational` transactions by adding176	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.177	pub const OperationalFeeMultiplier: u8 = 5;178179	pub FeeMultiplier: Multiplier = Multiplier::one();180}181182impl pallet_transaction_payment::Config for Runtime {183	type RuntimeEvent = RuntimeEvent;184	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;185	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;186	type OperationalFeeMultiplier = OperationalFeeMultiplier;187	type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;188	type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;189}190191parameter_types! {192	pub const ProposalBond: Permill = Permill::from_percent(5);193	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;194	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;195	pub const SpendPeriod: BlockNumber = 5 * MINUTES;196	pub const Burn: Permill = Permill::from_percent(0);197	pub const TipCountdown: BlockNumber = 1 * DAYS;198	pub const TipFindersFee: Percent = Percent::from_percent(20);199	pub const TipReportDepositBase: Balance = 1 * UNIQUE;200	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;201	pub const BountyDepositBase: Balance = 1 * UNIQUE;202	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;203	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");204	pub TreasuryAccount: AccountId = Treasury::account_id();205	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;206	pub const MaximumReasonLength: u32 = 16384;207	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);208	pub const BountyValueMinimum: Balance = 5 * UNIQUE;209	pub const MaxApprovals: u32 = 100;210}211212impl pallet_treasury::Config for Runtime {213	type PalletId = TreasuryModuleId;214	type Currency = Balances;215	type ApproveOrigin = EnsureRoot<AccountId>;216	type RejectOrigin = EnsureRoot<AccountId>;217	type SpendOrigin = NeverEnsureOrigin<u128>;218	type RuntimeEvent = RuntimeEvent;219	type OnSlash = ();220	type ProposalBond = ProposalBond;221	type ProposalBondMinimum = ProposalBondMinimum;222	type ProposalBondMaximum = ProposalBondMaximum;223	type SpendPeriod = SpendPeriod;224	type Burn = Burn;225	type BurnDestination = ();226	type SpendFunds = ();227	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;228	type MaxApprovals = MaxApprovals;229	type AssetKind = ();230	type Beneficiary = AccountId;231	type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;232	type Paymaster = PayFromAccount<Balances, TreasuryAccount>;233	type BalanceConverter = UnityAssetBalanceConversion;234	type PayoutPeriod = ConstU32<10>;235	#[cfg(feature = "runtime-benchmarks")]236	type BenchmarkHelper = ();237}238239impl pallet_sudo::Config for Runtime {240	type RuntimeEvent = RuntimeEvent;241	type RuntimeCall = RuntimeCall;242	type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;243}244245parameter_types! {246	pub const MaxAuthorities: u32 = 100_000;247}248249impl pallet_aura::Config for Runtime {250	type AuthorityId = AuraId;251	type DisabledValidators = ();252	type MaxAuthorities = MaxAuthorities;253	type AllowMultipleBlocksPerSlot = ConstBool<true>;254	#[cfg(feature = "lookahead")]255	type SlotDuration = ConstU64<SLOT_DURATION>;256}257258impl pallet_utility::Config for Runtime {259	type RuntimeEvent = RuntimeEvent;260	type RuntimeCall = RuntimeCall;261	type PalletsOrigin = OriginCaller;262	type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;263}