1234567891011121314151617use frame_support::{18 dispatch::DispatchClass,19 ord_parameter_types, parameter_types,20 traits::{ConstBool, ConstU32, Everything, NeverEnsureOrigin},21 weights::{22 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},23 ConstantMultiplier,24 },25 PalletId,26};27use frame_system::{28 limits::{BlockLength, BlockWeights},29 EnsureRoot, EnsureSignedBy,30};31use pallet_transaction_payment::{ConstFeeMultiplier, Multiplier};32use sp_arithmetic::traits::One;33use sp_runtime::{34 traits::{AccountIdLookup, BlakeTwo256},35 Perbill, Percent, Permill,36};37use sp_std::vec;38use up_common::{constants::*, types::*};3940use crate::{41 runtime_common::DealWithFees, Balances, Block, OriginCaller, PalletInfo, Runtime, RuntimeCall,42 RuntimeEvent, RuntimeHoldReason, RuntimeOrigin, SS58Prefix, System, Version,43};4445parameter_types! {46 pub const BlockHashCount: BlockNumber = 2400;47 pub RuntimeBlockLength: BlockLength =48 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);49 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);50 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;51 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()52 .base_block(BlockExecutionWeight::get())53 .for_class(DispatchClass::all(), |weights| {54 weights.base_extrinsic = ExtrinsicBaseWeight::get();55 })56 .for_class(DispatchClass::Normal, |weights| {57 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);58 })59 .for_class(DispatchClass::Operational, |weights| {60 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);61 62 63 weights.reserved = Some(64 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT65 );66 })67 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)68 .build_or_panic();69}7071impl frame_system::Config for Runtime {72 73 type AccountData = pallet_balances::AccountData<Balance>;74 75 type AccountId = AccountId;76 77 type BaseCallFilter = Everything;78 79 type BlockHashCount = BlockHashCount;80 81 type Block = Block;82 83 type BlockLength = RuntimeBlockLength;84 85 type BlockWeights = RuntimeBlockWeights;86 87 type RuntimeCall = RuntimeCall;88 89 type DbWeight = RocksDbWeight;90 91 type RuntimeEvent = RuntimeEvent;92 93 type Hash = Hash;94 95 type Hashing = BlakeTwo256;96 97 type Nonce = Nonce;98 99 type Lookup = AccountIdLookup<AccountId, ()>;100 101 type OnKilledAccount = ();102 103 type OnNewAccount = ();104 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;105 106 type RuntimeOrigin = RuntimeOrigin;107 108 type PalletInfo = PalletInfo;109 110 type SS58Prefix = SS58Prefix;111 112 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;113 114 type Version = Version;115 type MaxConsumers = ConstU32<16>;116}117118parameter_types! {119 pub const MigrationMaxKeyLen: u32 = 512;120}121ord_parameter_types! {122 pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));123}124125impl pallet_state_trie_migration::Config for Runtime {126 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;127 type RuntimeEvent = RuntimeEvent;128 type Currency = Balances;129 type SignedDepositPerItem = ();130 type SignedDepositBase = ();131 type ControlOrigin = EnsureRoot<AccountId>;132 133 type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;134 type MaxKeyLen = MigrationMaxKeyLen;135}136137parameter_types! {138 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;139}140141impl pallet_timestamp::Config for Runtime {142 143 type Moment = u64;144 type OnTimestampSet = ();145 type MinimumPeriod = MinimumPeriod;146 type WeightInfo = ();147}148149parameter_types! {150 151 pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;152 pub const MaxLocks: u32 = 50;153 pub const MaxReserves: u32 = 50;154 pub const MaxHolds: u32 = 10;155 pub const MaxFreezes: u32 = 10;156}157158impl pallet_balances::Config for Runtime {159 type MaxLocks = MaxLocks;160 type MaxReserves = MaxReserves;161 type ReserveIdentifier = [u8; 16];162 163 type Balance = Balance;164 165 type RuntimeEvent = RuntimeEvent;166 167 168 169 type DustRemoval = ();170 type ExistentialDeposit = ExistentialDeposit;171 type AccountStore = System;172 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;173 type RuntimeHoldReason = RuntimeHoldReason;174 type FreezeIdentifier = [u8; 16];175 type MaxHolds = MaxHolds;176 type MaxFreezes = MaxFreezes;177}178179parameter_types! {180 181 182 pub const OperationalFeeMultiplier: u8 = 5;183184 pub FeeMultiplier: Multiplier = Multiplier::one();185}186187impl pallet_transaction_payment::Config for Runtime {188 type RuntimeEvent = RuntimeEvent;189 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;190 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;191 type OperationalFeeMultiplier = OperationalFeeMultiplier;192 type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;193 type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;194}195196parameter_types! {197 pub const ProposalBond: Permill = Permill::from_percent(5);198 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;199 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;200 pub const SpendPeriod: BlockNumber = 5 * MINUTES;201 pub const Burn: Permill = Permill::from_percent(0);202 pub const TipCountdown: BlockNumber = 1 * DAYS;203 pub const TipFindersFee: Percent = Percent::from_percent(20);204 pub const TipReportDepositBase: Balance = 1 * UNIQUE;205 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;206 pub const BountyDepositBase: Balance = 1 * UNIQUE;207 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;208 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");209 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;210 pub const MaximumReasonLength: u32 = 16384;211 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);212 pub const BountyValueMinimum: Balance = 5 * UNIQUE;213 pub const MaxApprovals: u32 = 100;214}215216impl pallet_treasury::Config for Runtime {217 type PalletId = TreasuryModuleId;218 type Currency = Balances;219 type ApproveOrigin = EnsureRoot<AccountId>;220 type RejectOrigin = EnsureRoot<AccountId>;221 type SpendOrigin = NeverEnsureOrigin<u128>;222 type RuntimeEvent = RuntimeEvent;223 type OnSlash = ();224 type ProposalBond = ProposalBond;225 type ProposalBondMinimum = ProposalBondMinimum;226 type ProposalBondMaximum = ProposalBondMaximum;227 type SpendPeriod = SpendPeriod;228 type Burn = Burn;229 type BurnDestination = ();230 type SpendFunds = ();231 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;232 type MaxApprovals = MaxApprovals;233}234235impl pallet_sudo::Config for Runtime {236 type RuntimeEvent = RuntimeEvent;237 type RuntimeCall = RuntimeCall;238 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;239}240241parameter_types! {242 pub const MaxAuthorities: u32 = 100_000;243}244245impl pallet_aura::Config for Runtime {246 type AuthorityId = AuraId;247 type DisabledValidators = ();248 type MaxAuthorities = MaxAuthorities;249 type AllowMultipleBlocksPerSlot = ConstBool<true>;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}