difftreelog
fix weight coeffs
in: master
3 files changed
pallets/configuration/src/lib.rsdiffbeforeafterboth25};25};26use parity_scale_codec::{Decode, Encode, MaxEncodedLen};26use parity_scale_codec::{Decode, Encode, MaxEncodedLen};27use scale_info::TypeInfo;27use scale_info::TypeInfo;28use sp_arithmetic::traits::{BaseArithmetic, Unsigned};28use sp_arithmetic::{29 per_things::{Perbill, PerThing},30 traits::{BaseArithmetic, Unsigned},31};29use smallvec::smallvec;32use smallvec::smallvec;303331pub use pallet::*;34pub use pallet::*;32use sp_core::U256;35use sp_core::U256;33use sp_runtime::Perbill;343635#[pallet]37#[pallet]36mod pallet {38mod pallet {46 #[pallet::config]48 #[pallet::config]47 pub trait Config: frame_system::Config {49 pub trait Config: frame_system::Config {48 #[pallet::constant]50 #[pallet::constant]49 type DefaultWeightToFeeCoefficient: Get<u32>;51 type DefaultWeightToFeeCoefficient: Get<u64>;5051 #[pallet::constant]52 #[pallet::constant]52 type DefaultMinGasPrice: Get<u64>;53 type DefaultMinGasPrice: Get<u64>;666767 #[pallet::storage]68 #[pallet::storage]68 pub type WeightToFeeCoefficientOverride<T: Config> = StorageValue<69 pub type WeightToFeeCoefficientOverride<T: Config> = StorageValue<69 Value = u32,70 Value = u64,70 QueryKind = ValueQuery,71 QueryKind = ValueQuery,71 OnEmpty = T::DefaultWeightToFeeCoefficient,72 OnEmpty = T::DefaultWeightToFeeCoefficient,72 >;73 >;90 #[pallet::weight(T::DbWeight::get().writes(1))]91 #[pallet::weight(T::DbWeight::get().writes(1))]91 pub fn set_weight_to_fee_coefficient_override(92 pub fn set_weight_to_fee_coefficient_override(92 origin: OriginFor<T>,93 origin: OriginFor<T>,93 coeff: Option<u32>,94 coeff: Option<u64>,94 ) -> DispatchResult {95 ) -> DispatchResult {95 ensure_root(origin)?;96 ensure_root(origin)?;96 if let Some(coeff) = coeff {97 if let Some(coeff) = coeff {156impl<T, B> WeightToFeePolynomial for WeightToFee<T, B>157impl<T, B> WeightToFeePolynomial for WeightToFee<T, B>157where158where158 T: Config,159 T: Config,159 B: BaseArithmetic + From<u32> + Copy + Unsigned,160 B: BaseArithmetic + From<u32> + From<u64> + Copy + Unsigned,160{161{161 type Balance = B;162 type Balance = B;162163163 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {164 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {164 smallvec!(WeightToFeeCoefficient {165 smallvec!(WeightToFeeCoefficient {165 coeff_integer: <WeightToFeeCoefficientOverride<T>>::get().into(),166 coeff_integer: (<WeightToFeeCoefficientOverride<T>>::get() / Perbill::ACCURACY as u64)167 .into(),166 coeff_frac: Perbill::zero(),168 coeff_frac: Perbill::from_parts(169 (<WeightToFeeCoefficientOverride<T>>::get() % Perbill::ACCURACY as u64) as u32170 ),167 negative: false,171 negative: false,168 degree: 1,172 degree: 1,primitives/common/src/constants.rsdiffbeforeafterboth43pub const UNIQUE: Balance = 100 * CENTIUNIQUE;43pub const UNIQUE: Balance = 100 * CENTIUNIQUE;444445// Targeting 0.1 UNQ per transfer45// Targeting 0.1 UNQ per transfer46pub const WEIGHT_TO_FEE_COEFF: u32 = /*<weight2fee>*/175_199_920/*</weight2fee>*/;46pub const WEIGHT_TO_FEE_COEFF: u64 = /*<weight2fee>*/78_389_100_150_858_528/*</weight2fee>*/;474748// Targeting 0.15 UNQ per transfer via ETH48// Targeting 0.15 UNQ per transfer via ETH49pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_014_919_410_810/*</mingasprice>*/;49pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_014_919_410_810/*</mingasprice>*/;60 .set_proof_size(MAX_POV_SIZE as u64);60 .set_proof_size(MAX_POV_SIZE as u64);616162parameter_types! {62parameter_types! {63 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE;63 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE / 2;64}64}6565runtime/common/config/pallets/mod.rsdiffbeforeafterboth25 },25 },26 Runtime, RuntimeEvent, RuntimeCall, Balances,26 Runtime, RuntimeEvent, RuntimeCall, Balances,27};27};28use frame_support::traits::{ConstU32, ConstU64};28use frame_support::traits::ConstU64;29use up_common::{29use up_common::{30 types::{AccountId, Balance, BlockNumber},30 types::{AccountId, Balance, BlockNumber},31 constants::*,31 constants::*,104 pub const DayRelayBlocks: BlockNumber = RELAY_DAYS;104 pub const DayRelayBlocks: BlockNumber = RELAY_DAYS;105}105}106impl pallet_configuration::Config for Runtime {106impl pallet_configuration::Config for Runtime {107 type DefaultWeightToFeeCoefficient = ConstU32<{ up_common::constants::WEIGHT_TO_FEE_COEFF }>;107 type DefaultWeightToFeeCoefficient = ConstU64<{ up_common::constants::WEIGHT_TO_FEE_COEFF }>;108 type DefaultMinGasPrice = ConstU64<{ up_common::constants::MIN_GAS_PRICE }>;108 type DefaultMinGasPrice = ConstU64<{ up_common::constants::MIN_GAS_PRICE }>;109 type MaxXcmAllowedLocations = ConstU32<16>;109 type MaxXcmAllowedLocations = ConstU32<16>;110 type AppPromotionDailyRate = AppPromotionDailyRate;110 type AppPromotionDailyRate = AppPromotionDailyRate;