Add storage size component to weights (#12277)

* Add storage size component to weights

* Rename storage_size to proof_size

* Update primitives/weights/src/weight_v2.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fixes

* cargo fmt

* Implement custom Decode and CompactAs

* Add missing import

* Fixes

* Remove CompactAs implementation

* Properly migrate from 1D weight

* Remove #[pallet::compact] from Weight parameters

* More #[pallet::compact] removals

* Add unit tests

* Set appropriate default block proof size

* cargo fmt

* Remove nonsensical weight constant

* Test only for the reference time weight in frame_system::limits

* Only check for reference time weight on idle

* Use destructuring syntax

* Update test expectations

* Fixes

* Fixes

* Fixes

* Correctly migrate from 1D weights

* cargo fmt

* Migrate using extra extrinsics instead of custom Decode

* Fixes

* Silence dispatch call warnings that were previously allowed

* Fix gas_left test

* Use OldWeight instead of u64

* Fixes

* Only check for reference time weight in election provider

* Fix test expectations

* Fix test expectations

* Use only reference time weight in grandpa test

* Use only reference time weight in examples test

* Use only reference time weight in examples test

* Fix test expectations

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
Keith Yeung
2022-09-28 18:21:53 +08:00
committed by GitHub
parent 9d41de645f
commit 0327258566
20 changed files with 531 additions and 128 deletions
+10 -5
View File
@@ -274,7 +274,11 @@ mod tests {
BalanceOf, CodeHash, Error, Pallet as Contracts,
};
use assert_matches::assert_matches;
use frame_support::{assert_ok, dispatch::DispatchResultWithPostInfo, weights::Weight};
use frame_support::{
assert_ok,
dispatch::DispatchResultWithPostInfo,
weights::{OldWeight, Weight},
};
use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags};
use pretty_assertions::assert_eq;
use sp_core::{Bytes, H256};
@@ -1545,10 +1549,11 @@ mod tests {
let output = execute(CODE_GAS_LEFT, vec![], &mut ext).unwrap();
let gas_left = Weight::decode(&mut &*output.data).unwrap();
let OldWeight(gas_left) = OldWeight::decode(&mut &*output.data).unwrap();
let actual_left = ext.gas_meter.gas_left();
assert!(gas_left.all_lt(gas_limit), "gas_left must be less than initial");
assert!(gas_left.all_gt(actual_left), "gas_left must be greater than final");
// TODO: account for proof size weight
assert!(gas_left < gas_limit.ref_time(), "gas_left must be less than initial");
assert!(gas_left > actual_left.ref_time(), "gas_left must be greater than final");
}
const CODE_VALUE_TRANSFERRED: &str = r#"
@@ -1946,7 +1951,7 @@ mod tests {
)]
);
assert!(mock_ext.gas_meter.gas_left().all_gt(Weight::zero()));
assert!(mock_ext.gas_meter.gas_left().ref_time() > 0);
}
const CODE_DEPOSIT_EVENT_MAX_TOPICS: &str = r#"