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
+1 -1
View File
@@ -51,7 +51,7 @@ construct_runtime!(
parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::from_ref_time(1024));
}
impl frame_system::Config for Test {
type BaseCallFilter = Nothing;
+9 -3
View File
@@ -19,7 +19,9 @@
use crate::mock::*;
use codec::Encode;
use frame_support::{assert_noop, assert_ok, dispatch::GetDispatchInfo, traits::PreimageProvider};
use frame_support::{
assert_noop, assert_ok, dispatch::GetDispatchInfo, traits::PreimageProvider, weights::Weight,
};
use sp_runtime::{traits::Hash, DispatchError};
#[test]
@@ -94,7 +96,11 @@ fn test_whitelist_call_and_execute() {
assert!(Preimage::preimage_requested(&call_hash));
assert_noop!(
Whitelist::dispatch_whitelisted_call(Origin::root(), call_hash, call_weight - 1),
Whitelist::dispatch_whitelisted_call(
Origin::root(),
call_hash,
call_weight - Weight::one()
),
crate::Error::<Test>::InvalidCallWeightWitness,
);
@@ -114,7 +120,7 @@ fn test_whitelist_call_and_execute_failing_call() {
new_test_ext().execute_with(|| {
let call = Call::Whitelist(crate::Call::dispatch_whitelisted_call {
call_hash: Default::default(),
call_weight_witness: 0,
call_weight_witness: Weight::zero(),
});
let call_weight = call.get_dispatch_info().weight;
let encoded_call = call.encode();
+27 -27
View File
@@ -39,7 +39,7 @@
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use frame_support::{traits::Get, weights::{RefTimeWeight, Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_whitelist.
@@ -56,35 +56,35 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Whitelist WhitelistedCall (r:1 w:1)
// Storage: Preimage StatusFor (r:1 w:1)
fn whitelist_call() -> Weight {
(20_938_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
Weight::from_ref_time(20_938_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight))
}
// Storage: Whitelist WhitelistedCall (r:1 w:1)
// Storage: Preimage StatusFor (r:1 w:1)
// Storage: Preimage PreimageFor (r:0 w:1)
fn remove_whitelisted_call() -> Weight {
(22_332_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Weight::from_ref_time(22_332_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
}
// Storage: Whitelist WhitelistedCall (r:1 w:1)
// Storage: Preimage PreimageFor (r:1 w:1)
// Storage: Preimage StatusFor (r:1 w:1)
fn dispatch_whitelisted_call() -> Weight {
(5_989_917_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Weight::from_ref_time(5_989_917_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
}
// Storage: Whitelist WhitelistedCall (r:1 w:1)
// Storage: Preimage StatusFor (r:1 w:1)
// Storage: Preimage PreimageFor (r:0 w:1)
fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight {
(25_325_000 as Weight)
Weight::from_ref_time(25_325_000 as RefTimeWeight)
// Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
.saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
.saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
}
}
@@ -93,34 +93,34 @@ impl WeightInfo for () {
// Storage: Whitelist WhitelistedCall (r:1 w:1)
// Storage: Preimage StatusFor (r:1 w:1)
fn whitelist_call() -> Weight {
(20_938_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
Weight::from_ref_time(20_938_000 as RefTimeWeight)
.saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight))
}
// Storage: Whitelist WhitelistedCall (r:1 w:1)
// Storage: Preimage StatusFor (r:1 w:1)
// Storage: Preimage PreimageFor (r:0 w:1)
fn remove_whitelisted_call() -> Weight {
(22_332_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
Weight::from_ref_time(22_332_000 as RefTimeWeight)
.saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
}
// Storage: Whitelist WhitelistedCall (r:1 w:1)
// Storage: Preimage PreimageFor (r:1 w:1)
// Storage: Preimage StatusFor (r:1 w:1)
fn dispatch_whitelisted_call() -> Weight {
(5_989_917_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
Weight::from_ref_time(5_989_917_000 as RefTimeWeight)
.saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
}
// Storage: Whitelist WhitelistedCall (r:1 w:1)
// Storage: Preimage StatusFor (r:1 w:1)
// Storage: Preimage PreimageFor (r:0 w:1)
fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight {
(25_325_000 as Weight)
Weight::from_ref_time(25_325_000 as RefTimeWeight)
// Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(n as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
.saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
.saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
}
}