1234567891011121314151617use frame_support::{18 traits::{Everything, ConstU32},19 weights::{20 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},21 DispatchClass, ConstantMultiplier,22 },23 parameter_types, PalletId,24};25use sp_runtime::{26 generic,27 traits::{BlakeTwo256, AccountIdLookup},28 Perbill, Permill, Percent,29};30use frame_system::{31 limits::{BlockLength, BlockWeights},32 EnsureRoot,33};34use crate::{35 runtime_common::DealWithFees, Runtime, Event, Call, Origin, PalletInfo, System, Balances,36 Treasury, SS58Prefix, Version,37};38use up_common::{types::*, constants::*};3940parameter_types! {41 pub const BlockHashCount: BlockNumber = 2400;42 pub RuntimeBlockLength: BlockLength =43 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);44 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);45 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;46 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()47 .base_block(BlockExecutionWeight::get())48 .for_class(DispatchClass::all(), |weights| {49 weights.base_extrinsic = ExtrinsicBaseWeight::get();50 })51 .for_class(DispatchClass::Normal, |weights| {52 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);53 })54 .for_class(DispatchClass::Operational, |weights| {55 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);56 57 58 weights.reserved = Some(59 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT60 );61 })62 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)63 .build_or_panic();64}6566impl frame_system::Config for Runtime {67 68 type AccountData = pallet_balances::AccountData<Balance>;69 70 type AccountId = AccountId;71 72 type BaseCallFilter = Everything;73 74 type BlockHashCount = BlockHashCount;75 76 type BlockLength = RuntimeBlockLength;77 78 type BlockNumber = BlockNumber;79 80 type BlockWeights = RuntimeBlockWeights;81 82 type Call = Call;83 84 type DbWeight = RocksDbWeight;85 86 type Event = Event;87 88 type Hash = Hash;89 90 type Hashing = BlakeTwo256;91 92 type Header = generic::Header<BlockNumber, BlakeTwo256>;93 94 type Index = Index;95 96 type Lookup = AccountIdLookup<AccountId, ()>;97 98 type OnKilledAccount = ();99 100 type OnNewAccount = ();101 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;102 103 type Origin = Origin;104 105 type PalletInfo = PalletInfo;106 107 type SS58Prefix = SS58Prefix;108 109 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;110 111 type Version = Version;112 type MaxConsumers = ConstU32<16>;113}114115impl pallet_randomness_collective_flip::Config for Runtime {}116117parameter_types! {118 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;119}120121impl pallet_timestamp::Config for Runtime {122 123 type Moment = u64;124 type OnTimestampSet = ();125 type MinimumPeriod = MinimumPeriod;126 type WeightInfo = ();127}128129parameter_types! {130 131 pub const ExistentialDeposit: u128 = 0;132 pub const MaxLocks: u32 = 50;133 pub const MaxReserves: u32 = 50;134}135136impl pallet_balances::Config for Runtime {137 type MaxLocks = MaxLocks;138 type MaxReserves = MaxReserves;139 type ReserveIdentifier = [u8; 16];140 141 type Balance = Balance;142 143 type Event = Event;144 type DustRemoval = Treasury;145 type ExistentialDeposit = ExistentialDeposit;146 type AccountStore = System;147 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;148}149150parameter_types! {151 152 153 pub const OperationalFeeMultiplier: u8 = 5;154}155156impl pallet_transaction_payment::Config for Runtime {157 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;158 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;159 type OperationalFeeMultiplier = OperationalFeeMultiplier;160 type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;161 type FeeMultiplierUpdate = ();162}163164parameter_types! {165 pub const ProposalBond: Permill = Permill::from_percent(5);166 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;167 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;168 pub const SpendPeriod: BlockNumber = 5 * MINUTES;169 pub const Burn: Permill = Permill::from_percent(0);170 pub const TipCountdown: BlockNumber = 1 * DAYS;171 pub const TipFindersFee: Percent = Percent::from_percent(20);172 pub const TipReportDepositBase: Balance = 1 * UNIQUE;173 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;174 pub const BountyDepositBase: Balance = 1 * UNIQUE;175 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;176 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");177 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;178 pub const MaximumReasonLength: u32 = 16384;179 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);180 pub const BountyValueMinimum: Balance = 5 * UNIQUE;181 pub const MaxApprovals: u32 = 100;182}183184impl pallet_treasury::Config for Runtime {185 type PalletId = TreasuryModuleId;186 type Currency = Balances;187 type ApproveOrigin = EnsureRoot<AccountId>;188 type RejectOrigin = EnsureRoot<AccountId>;189 type Event = Event;190 type OnSlash = ();191 type ProposalBond = ProposalBond;192 type ProposalBondMinimum = ProposalBondMinimum;193 type ProposalBondMaximum = ProposalBondMaximum;194 type SpendPeriod = SpendPeriod;195 type Burn = Burn;196 type BurnDestination = ();197 type SpendFunds = ();198 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;199 type MaxApprovals = MaxApprovals;200}201202impl pallet_sudo::Config for Runtime {203 type Event = Event;204 type Call = Call;205}206207parameter_types! {208 pub const MaxAuthorities: u32 = 100_000;209}210211impl pallet_aura::Config for Runtime {212 type AuthorityId = AuraId;213 type DisabledValidators = ();214 type MaxAuthorities = MaxAuthorities;215}