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
--- 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
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;