1234567891011121314151617use frame_support::{18 traits::{Everything, ConstU32},19 weights::{20 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},21 DispatchClass, WeightToFeePolynomial, WeightToFeeCoefficients, ConstantMultiplier,22 WeightToFeeCoefficient,23 },24 parameter_types, PalletId,25};26use sp_runtime::{27 generic,28 traits::{BlakeTwo256, AccountIdLookup},29 Perbill, Permill, Percent,30};31use frame_system::{32 limits::{BlockLength, BlockWeights},33 EnsureRoot,34};35use sp_arithmetic::traits::{BaseArithmetic, Unsigned};36use smallvec::smallvec;37use crate::{38 runtime_common::DealWithFees, Runtime, Event, Call, Origin, PalletInfo, System, Balances,39 Treasury, SS58Prefix, Version,40};41use up_common::{types::*, constants::*};4243parameter_types! {44 pub const BlockHashCount: BlockNumber = 2400;45 pub RuntimeBlockLength: BlockLength =46 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);47 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);48 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;49 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()50 .base_block(BlockExecutionWeight::get())51 .for_class(DispatchClass::all(), |weights| {52 weights.base_extrinsic = ExtrinsicBaseWeight::get();53 })54 .for_class(DispatchClass::Normal, |weights| {55 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);56 })57 .for_class(DispatchClass::Operational, |weights| {58 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);59 60 61 weights.reserved = Some(62 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT63 );64 })65 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)66 .build_or_panic();67}6869impl frame_system::Config for Runtime {70 71 type AccountData = pallet_balances::AccountData<Balance>;72 73 type AccountId = AccountId;74 75 type BaseCallFilter = Everything;76 77 type BlockHashCount = BlockHashCount;78 79 type BlockLength = RuntimeBlockLength;80 81 type BlockNumber = BlockNumber;82 83 type BlockWeights = RuntimeBlockWeights;84 85 type Call = Call;86 87 type DbWeight = RocksDbWeight;88 89 type Event = Event;90 91 type Hash = Hash;92 93 type Hashing = BlakeTwo256;94 95 type Header = generic::Header<BlockNumber, BlakeTwo256>;96 97 type Index = Index;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 Origin = Origin;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}117118impl pallet_randomness_collective_flip::Config for Runtime {}119120parameter_types! {121 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;122}123124impl pallet_timestamp::Config for Runtime {125 126 type Moment = u64;127 type OnTimestampSet = ();128 type MinimumPeriod = MinimumPeriod;129 type WeightInfo = ();130}131132parameter_types! {133 134 pub const ExistentialDeposit: u128 = 0;135 pub const MaxLocks: u32 = 50;136 pub const MaxReserves: u32 = 50;137}138139impl pallet_balances::Config for Runtime {140 type MaxLocks = MaxLocks;141 type MaxReserves = MaxReserves;142 type ReserveIdentifier = [u8; 16];143 144 type Balance = Balance;145 146 type Event = Event;147 type DustRemoval = Treasury;148 type ExistentialDeposit = ExistentialDeposit;149 type AccountStore = System;150 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;151}152153parameter_types! {154 155 156 pub const OperationalFeeMultiplier: u8 = 5;157}158159160pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);161162impl<T> WeightToFeePolynomial for LinearFee<T>163where164 T: BaseArithmetic + From<u32> + Copy + Unsigned,165{166 type Balance = T;167168 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {169 smallvec!(WeightToFeeCoefficient {170 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),171 coeff_frac: Perbill::zero(),172 negative: false,173 degree: 1,174 })175 }176}177178impl pallet_transaction_payment::Config for Runtime {179 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;180 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;181 type OperationalFeeMultiplier = OperationalFeeMultiplier;182 type WeightToFee = LinearFee<Balance>;183 type FeeMultiplierUpdate = ();184}185186parameter_types! {187 pub const ProposalBond: Permill = Permill::from_percent(5);188 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;189 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;190 pub const SpendPeriod: BlockNumber = 5 * MINUTES;191 pub const Burn: Permill = Permill::from_percent(0);192 pub const TipCountdown: BlockNumber = 1 * DAYS;193 pub const TipFindersFee: Percent = Percent::from_percent(20);194 pub const TipReportDepositBase: Balance = 1 * UNIQUE;195 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;196 pub const BountyDepositBase: Balance = 1 * UNIQUE;197 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;198 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");199 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;200 pub const MaximumReasonLength: u32 = 16384;201 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);202 pub const BountyValueMinimum: Balance = 5 * UNIQUE;203 pub const MaxApprovals: u32 = 100;204}205206impl pallet_treasury::Config for Runtime {207 type PalletId = TreasuryModuleId;208 type Currency = Balances;209 type ApproveOrigin = EnsureRoot<AccountId>;210 type RejectOrigin = EnsureRoot<AccountId>;211 type Event = Event;212 type OnSlash = ();213 type ProposalBond = ProposalBond;214 type ProposalBondMinimum = ProposalBondMinimum;215 type ProposalBondMaximum = ProposalBondMaximum;216 type SpendPeriod = SpendPeriod;217 type Burn = Burn;218 type BurnDestination = ();219 type SpendFunds = ();220 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;221 type MaxApprovals = MaxApprovals;222}223224impl pallet_sudo::Config for Runtime {225 type Event = Event;226 type Call = Call;227}228229parameter_types! {230 pub const MaxAuthorities: u32 = 100_000;231}232233impl pallet_aura::Config for Runtime {234 type AuthorityId = AuraId;235 type DisabledValidators = ();236 type MaxAuthorities = MaxAuthorities;237}