mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 11:51:01 +00:00
* Rename Fixed128 to FixedI128. * Bump cargo, merge #6236 fixes Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Generated
+135
-134
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
|||||||
//! Auxillary struct/enums for polkadot runtime.
|
//! Auxillary struct/enums for polkadot runtime.
|
||||||
|
|
||||||
use sp_runtime::traits::{Convert, Saturating};
|
use sp_runtime::traits::{Convert, Saturating};
|
||||||
use sp_runtime::{FixedPointNumber, Fixed128, Perquintill};
|
use sp_runtime::{FixedPointNumber, FixedI128, Perquintill};
|
||||||
use frame_support::traits::{OnUnbalanced, Imbalance, Currency, Get};
|
use frame_support::traits::{OnUnbalanced, Imbalance, Currency, Get};
|
||||||
use crate::{MaximumBlockWeight, NegativeImbalance};
|
use crate::{MaximumBlockWeight, NegativeImbalance};
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@ where
|
|||||||
/// https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#relay-chain-transaction-fees
|
/// https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#relay-chain-transaction-fees
|
||||||
pub struct TargetedFeeAdjustment<T, R>(sp_std::marker::PhantomData<(T, R)>);
|
pub struct TargetedFeeAdjustment<T, R>(sp_std::marker::PhantomData<(T, R)>);
|
||||||
|
|
||||||
impl<T: Get<Perquintill>, R: system::Trait> Convert<Fixed128, Fixed128> for TargetedFeeAdjustment<T, R> {
|
impl<T: Get<Perquintill>, R: system::Trait> Convert<FixedI128, FixedI128> for TargetedFeeAdjustment<T, R> {
|
||||||
fn convert(multiplier: Fixed128) -> Fixed128 {
|
fn convert(multiplier: FixedI128) -> FixedI128 {
|
||||||
let max_weight = MaximumBlockWeight::get();
|
let max_weight = MaximumBlockWeight::get();
|
||||||
let block_weight = <system::Module<R>>::block_weight().total().min(max_weight);
|
let block_weight = <system::Module<R>>::block_weight().total().min(max_weight);
|
||||||
let target_weight = (T::get() * max_weight) as u128;
|
let target_weight = (T::get() * max_weight) as u128;
|
||||||
@@ -94,14 +94,14 @@ impl<T: Get<Perquintill>, R: system::Trait> Convert<Fixed128, Fixed128> for Targ
|
|||||||
let positive = block_weight >= target_weight;
|
let positive = block_weight >= target_weight;
|
||||||
let diff_abs = block_weight.max(target_weight) - block_weight.min(target_weight);
|
let diff_abs = block_weight.max(target_weight) - block_weight.min(target_weight);
|
||||||
// safe, diff_abs cannot exceed u64 and it can always be computed safely even with the lossy
|
// safe, diff_abs cannot exceed u64 and it can always be computed safely even with the lossy
|
||||||
// `Fixed128::saturating_from_rational`.
|
// `FixedI128::saturating_from_rational`.
|
||||||
let diff = Fixed128::saturating_from_rational(diff_abs, max_weight.max(1));
|
let diff = FixedI128::saturating_from_rational(diff_abs, max_weight.max(1));
|
||||||
let diff_squared = diff.saturating_mul(diff);
|
let diff_squared = diff.saturating_mul(diff);
|
||||||
|
|
||||||
// 0.00004 = 4/100_000 = 40_000/10^9
|
// 0.00004 = 4/100_000 = 40_000/10^9
|
||||||
let v = Fixed128::saturating_from_rational(4, 100_000);
|
let v = FixedI128::saturating_from_rational(4, 100_000);
|
||||||
// 0.00004^2 = 16/10^10 Taking the future /2 into account... 8/10^10
|
// 0.00004^2 = 16/10^10 Taking the future /2 into account... 8/10^10
|
||||||
let v_squared_2 = Fixed128::saturating_from_rational(8, 10_000_000_000u64);
|
let v_squared_2 = FixedI128::saturating_from_rational(8, 10_000_000_000u64);
|
||||||
|
|
||||||
let first_term = v.saturating_mul(diff);
|
let first_term = v.saturating_mul(diff);
|
||||||
let second_term = v_squared_2.saturating_mul(diff_squared);
|
let second_term = v_squared_2.saturating_mul(diff_squared);
|
||||||
@@ -120,7 +120,7 @@ impl<T: Get<Perquintill>, R: system::Trait> Convert<Fixed128, Fixed128> for Targ
|
|||||||
// multiplier. While at -1, it means that the network is so un-congested that all
|
// multiplier. While at -1, it means that the network is so un-congested that all
|
||||||
// transactions have no weight fee. We stop here and only increase if the network
|
// transactions have no weight fee. We stop here and only increase if the network
|
||||||
// became more busy.
|
// became more busy.
|
||||||
.max(Fixed128::saturating_from_integer(-1))
|
.max(FixedI128::saturating_from_integer(-1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -874,7 +874,7 @@ construct_runtime! {
|
|||||||
Scheduler: scheduler::{Module, Call, Storage, Event<T>},
|
Scheduler: scheduler::{Module, Call, Storage, Event<T>},
|
||||||
|
|
||||||
// Proxy module. Late addition.
|
// Proxy module. Late addition.
|
||||||
Proxy: proxy::{Module, Call, Storage, Event}
|
Proxy: proxy::{Module, Call, Storage, Event<T>}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -850,7 +850,7 @@ construct_runtime! {
|
|||||||
Identity: identity::{Module, Call, Storage, Event<T>},
|
Identity: identity::{Module, Call, Storage, Event<T>},
|
||||||
|
|
||||||
// Proxy module. Late addition.
|
// Proxy module. Late addition.
|
||||||
Proxy: proxy::{Module, Call, Storage, Event}
|
Proxy: proxy::{Module, Call, Storage, Event<T>}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -664,7 +664,7 @@ construct_runtime! {
|
|||||||
Sudo: sudo::{Module, Call, Storage, Event<T>, Config<T>},
|
Sudo: sudo::{Module, Call, Storage, Event<T>, Config<T>},
|
||||||
|
|
||||||
// Proxy module. Late addition.
|
// Proxy module. Late addition.
|
||||||
Proxy: proxy::{Module, Call, Storage, Event}
|
Proxy: proxy::{Module, Call, Storage, Event<T>}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user