Separate WeightToFee calculation for Kusama and Polkadot (#854)

* Separate `WeightToFee` calculation for Kusama and Polkadot

* Bump spec
This commit is contained in:
Shawn Tabrizi
2020-02-19 22:23:50 +01:00
committed by GitHub
parent b642c4b197
commit c01ef7198f
6 changed files with 48 additions and 27 deletions
+21
View File
@@ -51,7 +51,28 @@ pub mod time {
/// Fee-related.
pub mod fee {
pub use sp_runtime::Perbill;
use primitives::Balance;
use frame_support::weights::Weight;
use sp_runtime::traits::Convert;
/// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
/// node's balance type.
///
/// This should typically create a mapping between the following ranges:
/// - [0, system::MaximumBlockWeight]
/// - [Balance::min, Balance::max]
///
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being:
/// - Setting it to `0` will essentially disable the weight fee.
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged.
pub struct WeightToFee;
impl Convert<Weight, Balance> for WeightToFee {
fn convert(x: Weight) -> Balance {
// in Kusama a weight of 10_000 (smallest non-zero weight) is mapped to 1/10 CENT:
Balance::from(x).saturating_mul(super::currency::CENTS / (10 * 10_000))
}
}
}
+3 -3
View File
@@ -28,7 +28,7 @@ use primitives::{
parachain::{self, ActiveParas, CandidateReceipt}, ValidityError,
};
use runtime_common::{attestations, claims, parachains, registrar, slots,
impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor, WeightToFee},
impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor},
NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
MaximumBlockLength,
};
@@ -65,7 +65,7 @@ pub use parachains::Call as ParachainsCall;
/// Constant values used within the runtime.
pub mod constants;
use constants::{time::*, currency::*};
use constants::{time::*, currency::*, fee::*};
// Make the WASM binary available.
#[cfg(feature = "std")]
@@ -77,7 +77,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2,
spec_version: 1049,
impl_version: 1,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
};