Weight v1.5: Opaque Struct (#12138)

* initial idea

* update frame_support

* update a bunch more

* add ord

* adjust RuntimeDbWeight

* frame_system builds

* re-export

* frame_support tests pass

* frame_executive compile

* frame_executive builds

* frame_system tests passing

* pallet-utility tests pass

* fix a bunch of pallets

* more

* phragmen

* state-trie-migration

* scheduler and referenda

* pallet-election-provider-multi-phase

* aura

* staking

* more

* babe

* balances

* bunch more

* sudo

* transaction-payment

* asset-tx-payment

* last pallets

* fix alliance merge

* fix node template runtime

* fix pallet-contracts cc @athei

* fix node runtime

* fix compile on runtime-benchmarks feature

* comment

* fix frame-support-test

* fix more tests

* weight regex

* frame system works

* fix a bunch

* more

* more

* more

* more

* more

* more fixes

* update templates

* fix contracts benchmarks

* Update lib.rs

* Update lib.rs

* fix ui

* make scalar saturating mul const

* more const functions

* scalar div

* refactor using constant functions

* move impl

* fix overhead template

* use compactas

* Update lib.rs
This commit is contained in:
Shawn Tabrizi
2022-08-31 12:26:13 +01:00
committed by GitHub
parent 299f4ba541
commit 30951822ba
187 changed files with 5932 additions and 4930 deletions
+20 -19
View File
@@ -163,13 +163,13 @@ mod multiplier_tests {
let previous_float = previous_float.max(min_multiplier().into_inner() as f64 / accuracy);
// maximum tx weight
let m = max_normal() as f64;
let m = max_normal().ref_time() as f64;
// block weight always truncated to max weight
let block_weight = (block_weight as f64).min(m);
let block_weight = (block_weight.ref_time() as f64).min(m);
let v: f64 = AdjustmentVariable::get().to_float();
// Ideal saturation in terms of weight
let ss = target() as f64;
let ss = target().ref_time() as f64;
// Current saturation in terms of weight
let s = block_weight;
@@ -197,9 +197,9 @@ mod multiplier_tests {
fn truth_value_update_poc_works() {
let fm = Multiplier::saturating_from_rational(1, 2);
let test_set = vec![
(0, fm),
(100, fm),
(1000, fm),
(Weight::zero(), fm),
(Weight::from_ref_time(100), fm),
(Weight::from_ref_time(1000), fm),
(target(), fm),
(max_normal() / 2, fm),
(max_normal(), fm),
@@ -229,7 +229,7 @@ mod multiplier_tests {
#[test]
fn multiplier_cannot_go_below_limit() {
// will not go any further below even if block is empty.
run_with_system_weight(0, || {
run_with_system_weight(Weight::new(), || {
let next = runtime_multiplier_update(min_multiplier());
assert_eq!(next, min_multiplier());
})
@@ -247,7 +247,7 @@ mod multiplier_tests {
// 1 < 0.00001 * k * 0.1875
// 10^9 / 1875 < k
// k > 533_333 ~ 18,5 days.
run_with_system_weight(0, || {
run_with_system_weight(Weight::new(), || {
// start from 1, the default.
let mut fm = Multiplier::one();
let mut iterations: u64 = 0;
@@ -283,7 +283,8 @@ mod multiplier_tests {
// `cargo test congested_chain_simulation -- --nocapture` to get some insight.
// almost full. The entire quota of normal transactions is taken.
let block_weight = BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap() - 100;
let block_weight = BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap() -
Weight::from_ref_time(100);
// Default substrate weight.
let tx_weight = frame_support::weights::constants::ExtrinsicBaseWeight::get();
@@ -407,27 +408,27 @@ mod multiplier_tests {
#[test]
fn weight_to_fee_should_not_overflow_on_large_weights() {
let kb = 1024 as Weight;
let kb = Weight::from_ref_time(1024);
let mb = kb * kb;
let max_fm = Multiplier::saturating_from_integer(i128::MAX);
// check that for all values it can compute, correctly.
vec![
0,
1,
10,
1000,
Weight::zero(),
Weight::one(),
Weight::from_ref_time(10),
Weight::from_ref_time(1000),
kb,
10 * kb,
100 * kb,
mb,
10 * mb,
2147483647,
4294967295,
Weight::from_ref_time(2147483647),
Weight::from_ref_time(4294967295),
BlockWeights::get().max_block / 2,
BlockWeights::get().max_block,
Weight::max_value() / 2,
Weight::max_value(),
Weight::MAX / 2,
Weight::MAX,
]
.into_iter()
.for_each(|i| {
@@ -440,7 +441,7 @@ mod multiplier_tests {
// Some values that are all above the target and will cause an increase.
let t = target();
vec![t + 100, t * 2, t * 4].into_iter().for_each(|i| {
vec![t + Weight::from_ref_time(100), t * 2, t * 4].into_iter().for_each(|i| {
run_with_system_weight(i, || {
let fm = runtime_multiplier_update(max_fm);
// won't grow. The convert saturates everything.