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
--- a/primitives/common/src/constants.rs
+++ b/primitives/common/src/constants.rs
@@ -43,7 +43,7 @@
 pub const UNIQUE: Balance = 100 * CENTIUNIQUE;
 
 // Targeting 0.1 UNQ per transfer
-pub const WEIGHT_TO_FEE_COEFF: u32 = /*<weight2fee>*/175_199_920/*</weight2fee>*/;
+pub const WEIGHT_TO_FEE_COEFF: u64 = /*<weight2fee>*/78_389_100_150_858_528/*</weight2fee>*/;
 
 // Targeting 0.15 UNQ per transfer via ETH
 pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_014_919_410_810/*</mingasprice>*/;
@@ -60,5 +60,5 @@
 	.set_proof_size(MAX_POV_SIZE as u64);
 
 parameter_types! {
-	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE;
+	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE / 2;
 }
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -25,7 +25,7 @@
 	},
 	Runtime, RuntimeEvent, RuntimeCall, Balances,
 };
-use frame_support::traits::{ConstU32, ConstU64};
+use frame_support::traits::ConstU64;
 use up_common::{
 	types::{AccountId, Balance, BlockNumber},
 	constants::*,
@@ -104,7 +104,7 @@
 	pub const DayRelayBlocks: BlockNumber = RELAY_DAYS;
 }
 impl pallet_configuration::Config for Runtime {
-	type DefaultWeightToFeeCoefficient = ConstU32<{ up_common::constants::WEIGHT_TO_FEE_COEFF }>;
+	type DefaultWeightToFeeCoefficient = ConstU64<{ up_common::constants::WEIGHT_TO_FEE_COEFF }>;
 	type DefaultMinGasPrice = ConstU64<{ up_common::constants::MIN_GAS_PRICE }>;
 	type MaxXcmAllowedLocations = ConstU32<16>;
 	type AppPromotionDailyRate = AppPromotionDailyRate;