difftreelog
fix weight coeffs
in: master
3 files changed
pallets/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,
})
primitives/common/src/constants.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use sp_runtime::Perbill;18use frame_support::{19 parameter_types,20 weights::{Weight, constants::WEIGHT_PER_SECOND},21};22use cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE;23use crate::types::{BlockNumber, Balance};2425pub const MILLISECS_PER_BLOCK: u64 = 12000;26pub const MILLISECS_PER_RELAY_BLOCK: u64 = 6000;2728pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;2930// These time units are defined in number of blocks.31pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);32pub const HOURS: BlockNumber = MINUTES * 60;33pub const DAYS: BlockNumber = HOURS * 24;3435// These time units are defined in number of relay blocks.36pub const RELAY_MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_RELAY_BLOCK as BlockNumber);37pub const RELAY_HOURS: BlockNumber = RELAY_MINUTES * 60;38pub const RELAY_DAYS: BlockNumber = RELAY_HOURS * 24;3940pub const MICROUNIQUE: Balance = 1_000_000_000_000;41pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;42pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;43pub const UNIQUE: Balance = 100 * CENTIUNIQUE;4445// Targeting 0.1 UNQ per transfer46pub const WEIGHT_TO_FEE_COEFF: u32 = /*<weight2fee>*/175_199_920/*</weight2fee>*/;4748// Targeting 0.15 UNQ per transfer via ETH49pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_014_919_410_810/*</mingasprice>*/;5051/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.52/// This is used to limit the maximal weight of a single extrinsic.53pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);54/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used55/// by Operational extrinsics.56pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);57/// We allow for 2 seconds of compute with a 6 second average block time.58pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND59 .saturating_div(2)60 .set_proof_size(MAX_POV_SIZE as u64);6162parameter_types! {63 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE;64}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use sp_runtime::Perbill;18use frame_support::{19 parameter_types,20 weights::{Weight, constants::WEIGHT_PER_SECOND},21};22use cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE;23use crate::types::{BlockNumber, Balance};2425pub const MILLISECS_PER_BLOCK: u64 = 12000;26pub const MILLISECS_PER_RELAY_BLOCK: u64 = 6000;2728pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;2930// These time units are defined in number of blocks.31pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);32pub const HOURS: BlockNumber = MINUTES * 60;33pub const DAYS: BlockNumber = HOURS * 24;3435// These time units are defined in number of relay blocks.36pub const RELAY_MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_RELAY_BLOCK as BlockNumber);37pub const RELAY_HOURS: BlockNumber = RELAY_MINUTES * 60;38pub const RELAY_DAYS: BlockNumber = RELAY_HOURS * 24;3940pub const MICROUNIQUE: Balance = 1_000_000_000_000;41pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;42pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;43pub const UNIQUE: Balance = 100 * CENTIUNIQUE;4445// Targeting 0.1 UNQ per transfer46pub const WEIGHT_TO_FEE_COEFF: u64 = /*<weight2fee>*/78_389_100_150_858_528/*</weight2fee>*/;4748// Targeting 0.15 UNQ per transfer via ETH49pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_014_919_410_810/*</mingasprice>*/;5051/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.52/// This is used to limit the maximal weight of a single extrinsic.53pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);54/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used55/// by Operational extrinsics.56pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);57/// We allow for 2 seconds of compute with a 6 second average block time.58pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND59 .saturating_div(2)60 .set_proof_size(MAX_POV_SIZE as u64);6162parameter_types! {63 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE / 2;64}runtime/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;