1234567891011121314151617use frame_support::{18 traits::{Everything, ConstU32},19 weights::{20 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},21 DispatchClass, WeightToFeePolynomial, WeightToFeeCoefficients,22 ConstantMultiplier, WeightToFeeCoefficient,23 },24 parameter_types,25 PalletId,26};27use sp_runtime::{28 generic,29 traits::{BlakeTwo256, AccountIdLookup},30 Perbill, Permill, Percent,31};32use frame_system::{33 limits::{BlockLength, BlockWeights},34 EnsureRoot,35};36use sp_arithmetic::traits::{BaseArithmetic, Unsigned};37use smallvec::smallvec;38use crate::{39 runtime_common::{40 DealWithFees,41 constants::*,42 },43 Runtime,44 Event,45 Call,46 Origin,47 PalletInfo,48 System,49 Balances,50 Treasury,51 SS58Prefix,52 Version,53};54use common_types::*;5556parameter_types! {57 pub const BlockHashCount: BlockNumber = 2400;58 pub RuntimeBlockLength: BlockLength =59 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);60 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);61 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;62 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()63 .base_block(BlockExecutionWeight::get())64 .for_class(DispatchClass::all(), |weights| {65 weights.base_extrinsic = ExtrinsicBaseWeight::get();66 })67 .for_class(DispatchClass::Normal, |weights| {68 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);69 })70 .for_class(DispatchClass::Operational, |weights| {71 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);72 73 74 weights.reserved = Some(75 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT76 );77 })78 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)79 .build_or_panic();80}8182impl frame_system::Config for Runtime {83 84 type AccountData = pallet_balances::AccountData<Balance>;85 86 type AccountId = AccountId;87 88 type BaseCallFilter = Everything;89 90 type BlockHashCount = BlockHashCount;91 92 type BlockLength = RuntimeBlockLength;93 94 type BlockNumber = BlockNumber;95 96 type BlockWeights = RuntimeBlockWeights;97 98 type Call = Call;99 100 type DbWeight = RocksDbWeight;101 102 type Event = Event;103 104 type Hash = Hash;105 106 type Hashing = BlakeTwo256;107 108 type Header = generic::Header<BlockNumber, BlakeTwo256>;109 110 type Index = Index;111 112 type Lookup = AccountIdLookup<AccountId, ()>;113 114 type OnKilledAccount = ();115 116 type OnNewAccount = ();117 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;118 119 type Origin = Origin;120 121 type PalletInfo = PalletInfo;122 123 type SS58Prefix = SS58Prefix;124 125 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;126 127 type Version = Version;128 type MaxConsumers = ConstU32<16>;129}130131impl pallet_randomness_collective_flip::Config for Runtime {}132133parameter_types! {134 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;135}136137impl pallet_timestamp::Config for Runtime {138 139 type Moment = u64;140 type OnTimestampSet = ();141 type MinimumPeriod = MinimumPeriod;142 type WeightInfo = ();143}144145parameter_types! {146 147 pub const ExistentialDeposit: u128 = 0;148 pub const MaxLocks: u32 = 50;149 pub const MaxReserves: u32 = 50;150}151152impl pallet_balances::Config for Runtime {153 type MaxLocks = MaxLocks;154 type MaxReserves = MaxReserves;155 type ReserveIdentifier = [u8; 16];156 157 type Balance = Balance;158 159 type Event = Event;160 type DustRemoval = Treasury;161 type ExistentialDeposit = ExistentialDeposit;162 type AccountStore = System;163 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;164}165166parameter_types! {167 168 169 pub const OperationalFeeMultiplier: u8 = 5;170}171172173pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);174175impl<T> WeightToFeePolynomial for LinearFee<T>176where177 T: BaseArithmetic + From<u32> + Copy + Unsigned,178{179 type Balance = T;180181 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {182 smallvec!(WeightToFeeCoefficient {183 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),184 coeff_frac: Perbill::zero(),185 negative: false,186 degree: 1,187 })188 }189}190191impl pallet_transaction_payment::Config for Runtime {192 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;193 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;194 type OperationalFeeMultiplier = OperationalFeeMultiplier;195 type WeightToFee = LinearFee<Balance>;196 type FeeMultiplierUpdate = ();197}198199parameter_types! {200 pub const ProposalBond: Permill = Permill::from_percent(5);201 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;202 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;203 pub const SpendPeriod: BlockNumber = 5 * MINUTES;204 pub const Burn: Permill = Permill::from_percent(0);205 pub const TipCountdown: BlockNumber = 1 * DAYS;206 pub const TipFindersFee: Percent = Percent::from_percent(20);207 pub const TipReportDepositBase: Balance = 1 * UNIQUE;208 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;209 pub const BountyDepositBase: Balance = 1 * UNIQUE;210 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;211 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");212 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;213 pub const MaximumReasonLength: u32 = 16384;214 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);215 pub const BountyValueMinimum: Balance = 5 * UNIQUE;216 pub const MaxApprovals: u32 = 100;217}218219impl pallet_treasury::Config for Runtime {220 type PalletId = TreasuryModuleId;221 type Currency = Balances;222 type ApproveOrigin = EnsureRoot<AccountId>;223 type RejectOrigin = EnsureRoot<AccountId>;224 type Event = Event;225 type OnSlash = ();226 type ProposalBond = ProposalBond;227 type ProposalBondMinimum = ProposalBondMinimum;228 type ProposalBondMaximum = ProposalBondMaximum;229 type SpendPeriod = SpendPeriod;230 type Burn = Burn;231 type BurnDestination = ();232 type SpendFunds = ();233 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;234 type MaxApprovals = MaxApprovals;235}236237impl pallet_sudo::Config for Runtime {238 type Event = Event;239 type Call = Call;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}