1234567891011121314151617use 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,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,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 66 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}7475impl frame_system::Config for Runtime {76 77 type AccountData = pallet_balances::AccountData<Balance>;78 79 type AccountId = AccountId;80 81 type BaseCallFilter = Everything;82 83 type BlockHashCount = BlockHashCount;84 85 type Block = Block;86 87 type BlockLength = RuntimeBlockLength;88 89 type BlockWeights = RuntimeBlockWeights;90 91 type RuntimeCall = RuntimeCall;92 93 type DbWeight = RocksDbWeight;94 95 type RuntimeEvent = RuntimeEvent;96 97 type Hash = Hash;98 99 type Hashing = BlakeTwo256;100 101 type Nonce = Nonce;102 103 type Lookup = AccountIdLookup<AccountId, ()>;104 105 type OnKilledAccount = ();106 107 type OnNewAccount = ();108 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;109 110 type RuntimeOrigin = RuntimeOrigin;111 112 type PalletInfo = PalletInfo;113 114 type SS58Prefix = SS58Prefix;115 116 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;117 118 type Version = Version;119 type MaxConsumers = ConstU32<16>;120121 type RuntimeTask = ();122123 type SingleBlockMigrations = ();124 type MultiBlockMigrator = ();125 type PreInherents = ();126 type PostInherents = ();127 type PostTransactions = ();128}129130parameter_types! {131 pub const MigrationMaxKeyLen: u32 = 512;132}133ord_parameter_types! {134 pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));135}136137impl pallet_state_trie_migration::Config for Runtime {138 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;139 type RuntimeEvent = RuntimeEvent;140 type Currency = Balances;141 type SignedDepositPerItem = ();142 type SignedDepositBase = ();143 type ControlOrigin = EnsureRoot<AccountId>;144 145 type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;146 type MaxKeyLen = MigrationMaxKeyLen;147 type RuntimeHoldReason = RuntimeHoldReason;148}149150impl pallet_timestamp::Config for Runtime {151 152 type Moment = u64;153 type OnTimestampSet = ();154 #[cfg(not(feature = "lookahead"))]155 type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;156 #[cfg(feature = "lookahead")]157 type MinimumPeriod = ConstU64<0>;158 type WeightInfo = ();159}160161parameter_types! {162 163 pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;164 pub const MaxLocks: u32 = 50;165 pub const MaxReserves: u32 = 50;166 pub const MaxHolds: u32 = 10;167 pub const MaxFreezes: u32 = 10;168}169170impl pallet_balances::Config for Runtime {171 type MaxLocks = MaxLocks;172 type MaxReserves = MaxReserves;173 type ReserveIdentifier = [u8; 16];174 175 type Balance = Balance;176 177 type RuntimeEvent = RuntimeEvent;178 179 180 181 type DustRemoval = ();182 type ExistentialDeposit = ExistentialDeposit;183 type AccountStore = System;184 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;185 type RuntimeHoldReason = RuntimeHoldReason;186 type RuntimeFreezeReason = RuntimeFreezeReason;187 type FreezeIdentifier = [u8; 16];188 type MaxFreezes = MaxFreezes;189}190191parameter_types! {192 193 194 pub const OperationalFeeMultiplier: u8 = 5;195196 pub FeeMultiplier: Multiplier = Multiplier::one();197}198199impl pallet_transaction_payment::Config for Runtime {200 type RuntimeEvent = RuntimeEvent;201 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;202 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;203 type OperationalFeeMultiplier = OperationalFeeMultiplier;204 type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;205 type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;206}207208parameter_types! {209 pub const ProposalBond: Permill = Permill::from_percent(5);210 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;211 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;212 pub const SpendPeriod: BlockNumber = 5 * MINUTES;213 pub const Burn: Permill = Permill::from_percent(0);214 pub const TipCountdown: BlockNumber = 1 * DAYS;215 pub const TipFindersFee: Percent = Percent::from_percent(20);216 pub const TipReportDepositBase: Balance = 1 * UNIQUE;217 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;218 pub const BountyDepositBase: Balance = 1 * UNIQUE;219 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;220 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");221 pub TreasuryAccount: AccountId = Treasury::account_id();222 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;223 pub const MaximumReasonLength: u32 = 16384;224 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);225 pub const BountyValueMinimum: Balance = 5 * UNIQUE;226 pub const MaxApprovals: u32 = 100;227}228229impl pallet_treasury::Config for Runtime {230 type PalletId = TreasuryModuleId;231 type Currency = Balances;232 type ApproveOrigin = EnsureRoot<AccountId>;233 type RejectOrigin = EnsureRoot<AccountId>;234 type SpendOrigin = NeverEnsureOrigin<u128>;235 type RuntimeEvent = RuntimeEvent;236 type OnSlash = ();237 type ProposalBond = ProposalBond;238 type ProposalBondMinimum = ProposalBondMinimum;239 type ProposalBondMaximum = ProposalBondMaximum;240 type SpendPeriod = SpendPeriod;241 type Burn = Burn;242 type BurnDestination = ();243 type SpendFunds = ();244 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;245 type MaxApprovals = MaxApprovals;246 type AssetKind = ();247 type Beneficiary = AccountId;248 type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;249 type Paymaster = PayFromAccount<Balances, TreasuryAccount>;250 type BalanceConverter = UnityAssetBalanceConversion;251 type PayoutPeriod = ConstU32<10>;252 #[cfg(feature = "runtime-benchmarks")]253 type BenchmarkHelper = ();254}255256impl pallet_sudo::Config for Runtime {257 type RuntimeEvent = RuntimeEvent;258 type RuntimeCall = RuntimeCall;259 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;260}261262parameter_types! {263 pub const MaxAuthorities: u32 = 100_000;264}265266impl pallet_aura::Config for Runtime {267 type AuthorityId = AuraId;268 type DisabledValidators = ();269 type MaxAuthorities = MaxAuthorities;270 type AllowMultipleBlocksPerSlot = ConstBool<true>;271 #[cfg(feature = "lookahead")]272 type SlotDuration = ConstU64<SLOT_DURATION>;273}274275impl pallet_utility::Config for Runtime {276 type RuntimeEvent = RuntimeEvent;277 type RuntimeCall = RuntimeCall;278 type PalletsOrigin = OriginCaller;279 type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;280}