diff --git a/bin/runtime/src/lib.rs b/bin/runtime/src/lib.rs index 6fa03a26..097a2553 100644 --- a/bin/runtime/src/lib.rs +++ b/bin/runtime/src/lib.rs @@ -26,7 +26,7 @@ use frame_support::{ ConstBool, ConstU32, Contains, EqualPrivilegeOnly, EstimateNextSessionRotation, InstanceFilter, SortedMembers, WithdrawReasons, }, - weights::constants::WEIGHT_REF_TIME_PER_MILLIS, + weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, WeightToFee}, PalletId, }; use frame_system::{EnsureRoot, EnsureSignedBy}; @@ -59,7 +59,7 @@ use sp_runtime::{ AccountIdLookup, BlakeTwo256, Block as BlockT, Bounded, ConvertInto, One, OpaqueKeys, }, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, FixedU128, RuntimeDebug, + ApplyExtrinsicResult, FixedU128, RuntimeDebug, SaturatedConversion, }; pub use sp_runtime::{FixedPointNumber, Perbill, Permill}; use sp_staking::{currency_to_vote::U128CurrencyToVote, EraIndex}; @@ -261,8 +261,8 @@ parameter_types! { // a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`. // follows polkadot : https://github.com/paritytech/polkadot/blob/9ce5f7ef5abb1a4291454e8c9911b304d80679f9/runtime/polkadot/src/lib.rs#L369 pub const OperationalFeeMultiplier: u8 = 5; - // We expect that on average 25% of the normal capacity will be occupied with normal txs. - pub const TargetSaturationLevel: Perquintill = Perquintill::from_percent(25); + // We expect that on average 50% of the normal capacity will be occupied with normal txs. + pub const TargetSaturationLevel: Perquintill = Perquintill::from_percent(50); // During 20 blocks the fee may not change more than by 100%. This, together with the // `TargetSaturationLevel` value, results in variability ~0.067. For the corresponding // formulas please refer to Substrate code at `frame/transaction-payment/src/lib.rs`. @@ -272,11 +272,21 @@ parameter_types! { pub MaximumMultiplier: Multiplier = Bounded::max_value(); } +pub struct DivideFeeBy; + +impl WeightToFee for DivideFeeBy { + type Balance = Balance; + + fn weight_to_fee(weight: &Weight) -> Self::Balance { + Balance::saturated_from(weight.ref_time()).saturating_div(N) + } +} + impl pallet_transaction_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; - type LengthToFee = IdentityFee; - type WeightToFee = IdentityFee; + type LengthToFee = DivideFeeBy<10>; + type WeightToFee = DivideFeeBy<10>; type FeeMultiplierUpdate = TargetedFeeAdjustment< Self, TargetSaturationLevel,