Better Parameterisation for Fee system (#3823)

* Better fee parameters

* Fix build

* Better runtime tests

* Price to Weight ratio as type parameter (#3856)

* Price to Weight ration as type parameter

* Kian feedback

* Some renames.

* Fix executor tests

* Getting Closer.

* Phantom Data

* Actually fix executor tests.

* Fix tests.

* Remove todo

* Fix build
This commit is contained in:
Kian Paimani
2019-10-24 15:03:52 +02:00
committed by Gavin Wood
parent 022126f906
commit ecd1ed7b65
10 changed files with 214 additions and 186 deletions
+19 -8
View File
@@ -157,15 +157,17 @@ pub fn extrinsics_data_root<H: Hash>(xts: Vec<Vec<u8>>) -> H::Output {
pub trait Trait: 'static + Eq + Clone {
/// The aggregated `Origin` type used by dispatchable calls.
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>> + From<RawOrigin<Self::AccountId>>;
type Origin:
Into<Result<RawOrigin<Self::AccountId>, Self::Origin>> + From<RawOrigin<Self::AccountId>>;
/// The aggregated `Call` type.
type Call: Debug;
/// Account index (aka nonce) type. This stores the number of previous transactions associated with a sender
/// account.
/// Account index (aka nonce) type. This stores the number of previous transactions associated
/// with a sender account.
type Index:
Parameter + Member + MaybeSerialize + Debug + Default + MaybeDisplay + SimpleArithmetic + Copy;
Parameter + Member + MaybeSerialize + Debug + Default + MaybeDisplay + SimpleArithmetic
+ Copy;
/// The block number type used by the runtime.
type BlockNumber:
@@ -181,13 +183,15 @@ pub trait Trait: 'static + Eq + Clone {
type Hashing: Hash<Output = Self::Hash>;
/// The user account identifier type for the runtime.
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord
+ Default;
/// Converting trait to take a source type and convert to `AccountId`.
///
/// Used to define the type and conversion mechanism for referencing accounts in transactions. It's perfectly
/// reasonable for this to be an identity conversion (with the source type being `AccountId`), but other modules
/// (e.g. Indices module) may provide more functional/efficient alternatives.
/// Used to define the type and conversion mechanism for referencing accounts in transactions.
/// It's perfectly reasonable for this to be an identity conversion (with the source type being
/// `AccountId`), but other modules (e.g. Indices module) may provide more functional/efficient
/// alternatives.
type Lookup: StaticLookup<Target = Self::AccountId>;
/// The block header.
@@ -701,6 +705,13 @@ impl<T: Trait> Module<T> {
<ParentHash<T>>::put(n);
}
/// Set the current block weight. This should only be used in some integration tests.
#[cfg(any(feature = "std", test))]
pub fn set_block_limits(weight: Weight, len: usize) {
AllExtrinsicsWeight::put(weight);
AllExtrinsicsLen::put(len as u32);
}
/// Return the chain's current runtime version.
pub fn runtime_version() -> RuntimeVersion { T::Version::get() }
@@ -70,8 +70,7 @@ pub trait Trait: system::Trait {
type WeightToFee: Convert<Weight, BalanceOf<Self>>;
/// Update the multiplier of the next block, based on the previous block's weight.
// TODO: maybe this does not need previous weight and can just read it
type FeeMultiplierUpdate: Convert<(Weight, Multiplier), Multiplier>;
type FeeMultiplierUpdate: Convert<Multiplier, Multiplier>;
}
decl_storage! {
@@ -89,9 +88,8 @@ decl_module! {
const TransactionByteFee: BalanceOf<T> = T::TransactionByteFee::get();
fn on_finalize() {
let current_weight = <system::Module<T>>::all_extrinsics_weight();
NextFeeMultiplier::mutate(|fm| {
*fm = T::FeeMultiplierUpdate::convert((current_weight, *fm))
*fm = T::FeeMultiplierUpdate::convert(*fm)
});
}
}