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.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;
}
runtime/common/config/pallets/mod.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 frame_support::parameter_types;18use sp_runtime::traits::AccountIdConversion;19use crate::{20 runtime_common::{21 dispatch::CollectionDispatchT,22 config::{substrate::TreasuryModuleId, ethereum::EvmCollectionHelpersAddress},23 weights::CommonWeights,24 RelayChainBlockNumberProvider,25 },26 Runtime, RuntimeEvent, RuntimeCall, Balances,27};28use frame_support::traits::{ConstU32, ConstU64};29use up_common::{30 types::{AccountId, Balance, BlockNumber},31 constants::*,32};33use up_data_structs::{34 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},35};36use sp_arithmetic::Perbill;3738#[cfg(feature = "rmrk")]39pub mod rmrk;4041#[cfg(feature = "scheduler")]42pub mod scheduler;4344#[cfg(feature = "foreign-assets")]45pub mod foreign_asset;4647#[cfg(feature = "app-promotion")]48pub mod app_promotion;4950parameter_types! {51 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();52 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;53}5455impl pallet_common::Config for Runtime {56 type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;57 type RuntimeEvent = RuntimeEvent;58 type Currency = Balances;59 type CollectionCreationPrice = CollectionCreationPrice;60 type TreasuryAccountId = TreasuryAccountId;61 type CollectionDispatch = CollectionDispatchT<Self>;6263 type EvmTokenAddressMapping = EvmTokenAddressMapping;64 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;65 type ContractAddress = EvmCollectionHelpersAddress;66}6768impl pallet_structure::Config for Runtime {69 type RuntimeEvent = RuntimeEvent;70 type RuntimeCall = RuntimeCall;71 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;72}7374impl pallet_fungible::Config for Runtime {75 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;76}77impl pallet_refungible::Config for Runtime {78 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;79}80impl pallet_nonfungible::Config for Runtime {81 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;82}8384parameter_types! {85 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied86}8788/// Used for the pallet inflation89impl pallet_inflation::Config for Runtime {90 type Currency = Balances;91 type TreasuryAccountId = TreasuryAccountId;92 type InflationBlockInterval = InflationBlockInterval;93 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;94}9596impl pallet_unique::Config for Runtime {97 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;98 type CommonWeightInfo = CommonWeights<Self>;99 type RefungibleExtensionsWeightInfo = CommonWeights<Self>;100}101102parameter_types! {103 pub AppPromotionDailyRate: Perbill = Perbill::from_rational(5u32, 10_000);104 pub const DayRelayBlocks: BlockNumber = RELAY_DAYS;105}106impl pallet_configuration::Config for Runtime {107 type DefaultWeightToFeeCoefficient = ConstU32<{ up_common::constants::WEIGHT_TO_FEE_COEFF }>;108 type DefaultMinGasPrice = ConstU64<{ up_common::constants::MIN_GAS_PRICE }>;109 type MaxXcmAllowedLocations = ConstU32<16>;110 type AppPromotionDailyRate = AppPromotionDailyRate;111 type DayRelayBlocks = DayRelayBlocks;112}113114impl pallet_maintenance::Config for Runtime {115 type RuntimeEvent = RuntimeEvent;116 type WeightInfo = pallet_maintenance::weights::SubstrateWeight<Self>;117}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 frame_support::parameter_types;18use sp_runtime::traits::AccountIdConversion;19use crate::{20 runtime_common::{21 dispatch::CollectionDispatchT,22 config::{substrate::TreasuryModuleId, ethereum::EvmCollectionHelpersAddress},23 weights::CommonWeights,24 RelayChainBlockNumberProvider,25 },26 Runtime, RuntimeEvent, RuntimeCall, Balances,27};28use frame_support::traits::ConstU64;29use up_common::{30 types::{AccountId, Balance, BlockNumber},31 constants::*,32};33use up_data_structs::{34 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},35};36use sp_arithmetic::Perbill;3738#[cfg(feature = "rmrk")]39pub mod rmrk;4041#[cfg(feature = "scheduler")]42pub mod scheduler;4344#[cfg(feature = "foreign-assets")]45pub mod foreign_asset;4647#[cfg(feature = "app-promotion")]48pub mod app_promotion;4950parameter_types! {51 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();52 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;53}5455impl pallet_common::Config for Runtime {56 type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;57 type RuntimeEvent = RuntimeEvent;58 type Currency = Balances;59 type CollectionCreationPrice = CollectionCreationPrice;60 type TreasuryAccountId = TreasuryAccountId;61 type CollectionDispatch = CollectionDispatchT<Self>;6263 type EvmTokenAddressMapping = EvmTokenAddressMapping;64 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;65 type ContractAddress = EvmCollectionHelpersAddress;66}6768impl pallet_structure::Config for Runtime {69 type RuntimeEvent = RuntimeEvent;70 type RuntimeCall = RuntimeCall;71 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;72}7374impl pallet_fungible::Config for Runtime {75 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;76}77impl pallet_refungible::Config for Runtime {78 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;79}80impl pallet_nonfungible::Config for Runtime {81 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;82}8384parameter_types! {85 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied86}8788/// Used for the pallet inflation89impl pallet_inflation::Config for Runtime {90 type Currency = Balances;91 type TreasuryAccountId = TreasuryAccountId;92 type InflationBlockInterval = InflationBlockInterval;93 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;94}9596impl pallet_unique::Config for Runtime {97 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;98 type CommonWeightInfo = CommonWeights<Self>;99 type RefungibleExtensionsWeightInfo = CommonWeights<Self>;100}101102parameter_types! {103 pub AppPromotionDailyRate: Perbill = Perbill::from_rational(5u32, 10_000);104 pub const DayRelayBlocks: BlockNumber = RELAY_DAYS;105}106impl pallet_configuration::Config for Runtime {107 type DefaultWeightToFeeCoefficient = ConstU64<{ up_common::constants::WEIGHT_TO_FEE_COEFF }>;108 type DefaultMinGasPrice = ConstU64<{ up_common::constants::MIN_GAS_PRICE }>;109 type MaxXcmAllowedLocations = ConstU32<16>;110 type AppPromotionDailyRate = AppPromotionDailyRate;111 type DayRelayBlocks = DayRelayBlocks;112}113114impl pallet_maintenance::Config for Runtime {115 type RuntimeEvent = RuntimeEvent;116 type WeightInfo = pallet_maintenance::weights::SubstrateWeight<Self>;117}