1234567891011121314151617use 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 61 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 72 type AccountData = pallet_balances::AccountData<Balance>;73 74 type AccountId = AccountId;75 76 type BaseCallFilter = Everything;77 78 type BlockHashCount = BlockHashCount;79 80 type BlockLength = RuntimeBlockLength;81 82 type BlockNumber = BlockNumber;83 84 type BlockWeights = RuntimeBlockWeights;85 86 type RuntimeCall = RuntimeCall;87 88 type DbWeight = RocksDbWeight;89 90 type RuntimeEvent = RuntimeEvent;91 92 type Hash = Hash;93 94 type Hashing = BlakeTwo256;95 96 type Header = generic::Header<BlockNumber, BlakeTwo256>;97 98 type Index = Index;99 100 type Lookup = AccountIdLookup<AccountId, ()>;101 102 type OnKilledAccount = ();103 104 type OnNewAccount = ();105 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;106 107 type RuntimeOrigin = RuntimeOrigin;108 109 type PalletInfo = PalletInfo;110 111 type SS58Prefix = SS58Prefix;112 113 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;114 115 type Version = Version;116 type MaxConsumers = ConstU32<16>;117}118119parameter_types! {120 pub const MigrationMaxKeyLen: u32 = 512;121}122ord_parameter_types! {123 pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));124}125126impl pallet_state_trie_migration::Config for Runtime {127 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;128 type RuntimeEvent = RuntimeEvent;129 type Currency = Balances;130 type SignedDepositPerItem = ();131 type SignedDepositBase = ();132 type ControlOrigin = EnsureRoot<AccountId>;133 134 type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;135 type MaxKeyLen = MigrationMaxKeyLen;136}137138parameter_types! {139 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;140}141142impl pallet_timestamp::Config for Runtime {143 144 type Moment = u64;145 type OnTimestampSet = ();146 type MinimumPeriod = MinimumPeriod;147 type WeightInfo = ();148}149150parameter_types! {151 152 pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;153 pub const MaxLocks: u32 = 50;154 pub const MaxReserves: u32 = 50;155 pub const MaxHolds: u32 = 10;156 pub const MaxFreezes: u32 = 10;157}158159impl pallet_balances::Config for Runtime {160 type MaxLocks = MaxLocks;161 type MaxReserves = MaxReserves;162 type ReserveIdentifier = [u8; 16];163 164 type Balance = Balance;165 166 type RuntimeEvent = RuntimeEvent;167 168 169 170 type DustRemoval = ();171 type ExistentialDeposit = ExistentialDeposit;172 type AccountStore = System;173 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;174 type HoldIdentifier = [u8; 16];175 type FreezeIdentifier = [u8; 16];176 type MaxHolds = MaxHolds;177 type MaxFreezes = MaxFreezes;178}179180parameter_types! {181 182 183 pub const OperationalFeeMultiplier: u8 = 5;184185 pub FeeMultiplier: Multiplier = Multiplier::one();186}187188impl pallet_transaction_payment::Config for Runtime {189 type RuntimeEvent = RuntimeEvent;190 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;191 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;192 type OperationalFeeMultiplier = OperationalFeeMultiplier;193 type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;194 type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;195}196197parameter_types! {198 pub const ProposalBond: Permill = Permill::from_percent(5);199 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;200 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;201 pub const SpendPeriod: BlockNumber = 5 * MINUTES;202 pub const Burn: Permill = Permill::from_percent(0);203 pub const TipCountdown: BlockNumber = 1 * DAYS;204 pub const TipFindersFee: Percent = Percent::from_percent(20);205 pub const TipReportDepositBase: Balance = 1 * UNIQUE;206 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;207 pub const BountyDepositBase: Balance = 1 * UNIQUE;208 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;209 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");210 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;211 pub const MaximumReasonLength: u32 = 16384;212 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);213 pub const BountyValueMinimum: Balance = 5 * UNIQUE;214 pub const MaxApprovals: u32 = 100;215}216217impl pallet_treasury::Config for Runtime {218 type PalletId = TreasuryModuleId;219 type Currency = Balances;220 type ApproveOrigin = EnsureRoot<AccountId>;221 type RejectOrigin = EnsureRoot<AccountId>;222 type SpendOrigin = NeverEnsureOrigin<u128>;223 type RuntimeEvent = RuntimeEvent;224 type OnSlash = ();225 type ProposalBond = ProposalBond;226 type ProposalBondMinimum = ProposalBondMinimum;227 type ProposalBondMaximum = ProposalBondMaximum;228 type SpendPeriod = SpendPeriod;229 type Burn = Burn;230 type BurnDestination = ();231 type SpendFunds = ();232 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;233 type MaxApprovals = MaxApprovals;234}235236impl pallet_sudo::Config for Runtime {237 type RuntimeEvent = RuntimeEvent;238 type RuntimeCall = RuntimeCall;239 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;240}241242parameter_types! {243 pub const MaxAuthorities: u32 = 100_000;244}245246impl pallet_aura::Config for Runtime {247 type AuthorityId = AuraId;248 type DisabledValidators = ();249 type MaxAuthorities = MaxAuthorities;250}251252impl pallet_utility::Config for Runtime {253 type RuntimeEvent = RuntimeEvent;254 type RuntimeCall = RuntimeCall;255 type PalletsOrigin = OriginCaller;256 type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;257}