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
--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -25,12 +25,14 @@
 };
 use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
 use scale_info::TypeInfo;
-use sp_arithmetic::traits::{BaseArithmetic, Unsigned};
+use sp_arithmetic::{
+	per_things::{Perbill, PerThing},
+	traits::{BaseArithmetic, Unsigned},
+};
 use smallvec::smallvec;
 
 pub use pallet::*;
 use sp_core::U256;
-use sp_runtime::Perbill;
 
 #[pallet]
 mod pallet {
@@ -46,8 +48,7 @@
 	#[pallet::config]
 	pub trait Config: frame_system::Config {
 		#[pallet::constant]
-		type DefaultWeightToFeeCoefficient: Get<u32>;
-
+		type DefaultWeightToFeeCoefficient: Get<u64>;
 		#[pallet::constant]
 		type DefaultMinGasPrice: Get<u64>;
 
@@ -66,7 +67,7 @@
 
 	#[pallet::storage]
 	pub type WeightToFeeCoefficientOverride<T: Config> = StorageValue<
-		Value = u32,
+		Value = u64,
 		QueryKind = ValueQuery,
 		OnEmpty = T::DefaultWeightToFeeCoefficient,
 	>;
@@ -90,7 +91,7 @@
 		#[pallet::weight(T::DbWeight::get().writes(1))]
 		pub fn set_weight_to_fee_coefficient_override(
 			origin: OriginFor<T>,
-			coeff: Option<u32>,
+			coeff: Option<u64>,
 		) -> DispatchResult {
 			ensure_root(origin)?;
 			if let Some(coeff) = coeff {
@@ -156,14 +157,17 @@
 impl<T, B> WeightToFeePolynomial for WeightToFee<T, B>
 where
 	T: Config,
-	B: BaseArithmetic + From<u32> + Copy + Unsigned,
+	B: BaseArithmetic + From<u32> + From<u64> + Copy + Unsigned,
 {
 	type Balance = B;
 
 	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
 		smallvec!(WeightToFeeCoefficient {
-			coeff_integer: <WeightToFeeCoefficientOverride<T>>::get().into(),
-			coeff_frac: Perbill::zero(),
+			coeff_integer: (<WeightToFeeCoefficientOverride<T>>::get() / Perbill::ACCURACY as u64)
+				.into(),
+			coeff_frac: Perbill::from_parts(
+				(<WeightToFeeCoefficientOverride<T>>::get() % Perbill::ACCURACY as u64) as u32
+			),
 			negative: false,
 			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
--- 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;