Split Operational and Normal weight (#5954)

* Split operational and normal weight

* Update other parts of the code

* relatively minor changes to add/fix behavior

* Limit reported block weight for fee adjustment

* fix test

* explicit match

* Move common logic out

* Update frame/system/src/lib.rs

Co-authored-by: Gavin Wood <gavin@parity.io>

* API improvement @bkchr

Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
Shawn Tabrizi
2020-05-12 12:18:32 +02:00
committed by GitHub
parent 22db788c08
commit 6013522ab0
3 changed files with 185 additions and 62 deletions
+5 -4
View File
@@ -70,8 +70,8 @@ pub struct TargetedFeeAdjustment<T>(sp_std::marker::PhantomData<T>);
impl<T: Get<Perquintill>> Convert<Fixed128, Fixed128> for TargetedFeeAdjustment<T> {
fn convert(multiplier: Fixed128) -> Fixed128 {
let block_weight = System::all_extrinsics_weight();
let max_weight = MaximumBlockWeight::get();
let block_weight = System::all_extrinsics_weight().total().min(max_weight);
let target_weight = (T::get() * max_weight) as u128;
let block_weight = block_weight as u128;
@@ -132,11 +132,12 @@ mod tests {
// poc reference implementation.
fn fee_multiplier_update(block_weight: Weight, previous: Fixed128) -> Fixed128 {
let block_weight = block_weight as f64;
let v: f64 = 0.00004;
// maximum tx weight
let m = max() as f64;
// block weight always truncated to max weight
let block_weight = (block_weight as f64).min(m);
let v: f64 = 0.00004;
// Ideal saturation in terms of weight
let ss = target() as f64;
// Current saturation in terms of weight