git.delta.rocks / unique-network / refs/commits / cc3ebd788a7b

difftreelog

fix weight coeffs

Daniel Shiposha2022-11-28parent: #f461d40.patch.diff
in: master

3 files changed

modifiedpallets/configuration/src/lib.rsdiffbeforeafterboth
25};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;
3033
31pub use pallet::*;34pub use pallet::*;
32use sp_core::U256;35use sp_core::U256;
33use sp_runtime::Perbill;
3436
35#[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>;
50
51 #[pallet::constant]52 #[pallet::constant]
52 type DefaultMinGasPrice: Get<u64>;53 type DefaultMinGasPrice: Get<u64>;
6667
67 #[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>
157where158where
158 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;
162163
163 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 u32
170 ),
167 negative: false,171 negative: false,
168 degree: 1,172 degree: 1,
modifiedprimitives/common/src/constants.rsdiffbeforeafterboth
43pub const UNIQUE: Balance = 100 * CENTIUNIQUE;43pub const UNIQUE: Balance = 100 * CENTIUNIQUE;
4444
45// Targeting 0.1 UNQ per transfer45// Targeting 0.1 UNQ per transfer
46pub 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>*/;
4747
48// Targeting 0.15 UNQ per transfer via ETH48// Targeting 0.15 UNQ per transfer via ETH
49pub 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);
6161
62parameter_types! {62parameter_types! {
63 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE;63 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE / 2;
64}64}
6565
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
25 },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;