From 48a8ed36472529d69fa208c1187921830a05c247 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Wed, 16 Mar 2022 12:09:14 -0600 Subject: [PATCH 1/2] No-op changes to reflect LengthToFee feature --- runtime/moonbase/src/lib.rs | 4 ++-- runtime/moonbeam/src/lib.rs | 4 ++-- runtime/moonriver/src/lib.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 6ca2ff7b240..b14a23ed757 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -43,7 +43,7 @@ use frame_support::{ }, weights::{ constants::{RocksDbWeight, WEIGHT_PER_SECOND}, - DispatchClass, GetDispatchInfo, IdentityFee, Weight, WeightToFeeCoefficient, + DispatchClass, GetDispatchInfo, IdentityFee, ConstantModifierFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }, PalletId, @@ -329,9 +329,9 @@ impl WeightToFeePolynomial for WeightToFee { impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter>; - type TransactionByteFee = TransactionByteFee; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = IdentityFee; + type LengthToFee = ConstantModifierFee; type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; } diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index 21f8f5f5850..3bdd53fee22 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -39,7 +39,7 @@ use frame_support::{ }, weights::{ constants::{RocksDbWeight, WEIGHT_PER_SECOND}, - DispatchClass, GetDispatchInfo, IdentityFee, Weight, + DispatchClass, GetDispatchInfo, IdentityFee, ConstantModifierFee, Weight, }, PalletId, }; @@ -304,9 +304,9 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter>; - type TransactionByteFee = TransactionByteFee; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = IdentityFee; + type LengthToFee = ConstantModifierFee; type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; } diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index 8420624313d..383491544a4 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -39,7 +39,7 @@ use frame_support::{ }, weights::{ constants::{RocksDbWeight, WEIGHT_PER_SECOND}, - DispatchClass, GetDispatchInfo, IdentityFee, Weight, WeightToFeeCoefficient, + DispatchClass, GetDispatchInfo, IdentityFee, ConstantModifierFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }, PalletId, @@ -325,9 +325,9 @@ impl WeightToFeePolynomial for WeightToFee { impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter>; - type TransactionByteFee = TransactionByteFee; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = IdentityFee; + type LengthToFee = ConstantModifierFee; type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; } From 3d5a35d6e6d7605485b9381749e82f023c0b6aa3 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Wed, 16 Mar 2022 12:29:01 -0600 Subject: [PATCH 2/2] Use cubic fn for length fee --- runtime/moonbase/src/lib.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index b14a23ed757..7839ed512d0 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -43,7 +43,7 @@ use frame_support::{ }, weights::{ constants::{RocksDbWeight, WEIGHT_PER_SECOND}, - DispatchClass, GetDispatchInfo, IdentityFee, ConstantModifierFee, Weight, WeightToFeeCoefficient, + DispatchClass, GetDispatchInfo, IdentityFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }, PalletId, @@ -118,7 +118,7 @@ pub mod currency { pub const UNIT: Balance = 1_000_000_000_000_000_000; pub const KILOUNIT: Balance = 1_000_000_000_000_000_000_000; - pub const TRANSACTION_BYTE_FEE: Balance = 10 * MICROUNIT * SUPPLY_FACTOR; + pub const TRANSACTION_BYTE_FEE: Balance = 1 * GIGAWEI * SUPPLY_FACTOR; // TODO: review pub const STORAGE_BYTE_FEE: Balance = 100 * MICROUNIT * SUPPLY_FACTOR; pub const WEIGHT_FEE: Balance = 50 * KILOWEI * SUPPLY_FACTOR; @@ -327,11 +327,32 @@ impl WeightToFeePolynomial for WeightToFee { } } +pub struct LengthToFee; +impl WeightToFeePolynomial for LengthToFee { + type Balance = Balance; + + fn polynomial() -> WeightToFeeCoefficients { + smallvec![ + WeightToFeeCoefficients { + degree: 1, + coeff_frac: Perbill::zero(), + coeff_integer: currency::TRANSACTION_BYTE_FEE, + negative: false, + }, + WeightToFeeCoefficients { + degree: 3, + coeff_frac: Perbill::zero(), + coeff_integer: 1, + negative: false, + }, + } +}; + impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter>; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = IdentityFee; - type LengthToFee = ConstantModifierFee; + type LengthToFee = LengthToFee; type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; }