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
@@ -127,7 +127,7 @@ pub struct BenchmarkResult {
impl BenchmarkResult {
pub fn from_weight(w: Weight) -> Self {
Self { extrinsic_time: (w as u128) / 1_000, ..Default::default() }
Self { extrinsic_time: (w.ref_time() / 1_000) as u128, ..Default::default() }
}
}
+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 frame_benchmarking.
@@ -58,75 +58,75 @@ pub trait WeightInfo {
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn addition(_i: u32, ) -> Weight {
(103_000 as Weight)
Weight::from_ref_time(103_000 as RefTimeWeight)
}
fn subtraction(_i: u32, ) -> Weight {
(105_000 as Weight)
Weight::from_ref_time(105_000 as RefTimeWeight)
}
fn multiplication(_i: u32, ) -> Weight {
(113_000 as Weight)
Weight::from_ref_time(113_000 as RefTimeWeight)
}
fn division(_i: u32, ) -> Weight {
(102_000 as Weight)
Weight::from_ref_time(102_000 as RefTimeWeight)
}
fn hashing(_i: u32, ) -> Weight {
(20_865_902_000 as Weight)
Weight::from_ref_time(20_865_902_000 as RefTimeWeight)
}
fn sr25519_verification(i: u32, ) -> Weight {
(319_000 as Weight)
Weight::from_ref_time(319_000 as RefTimeWeight)
// Standard Error: 8_000
.saturating_add((47_171_000 as Weight).saturating_mul(i as Weight))
.saturating_add(Weight::from_ref_time(47_171_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight))
}
// Storage: Skipped Metadata (r:0 w:0)
fn storage_read(i: u32, ) -> Weight {
(0 as Weight)
Weight::from_ref_time(0 as RefTimeWeight)
// Standard Error: 3_000
.saturating_add((2_110_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(Weight::from_ref_time(2_110_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight))
.saturating_add(T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight)))
}
// Storage: Skipped Metadata (r:0 w:0)
fn storage_write(i: u32, ) -> Weight {
(0 as Weight)
Weight::from_ref_time(0 as RefTimeWeight)
// Standard Error: 0
.saturating_add((372_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(Weight::from_ref_time(372_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight)))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
fn addition(_i: u32, ) -> Weight {
(103_000 as Weight)
Weight::from_ref_time(103_000 as RefTimeWeight)
}
fn subtraction(_i: u32, ) -> Weight {
(105_000 as Weight)
Weight::from_ref_time(105_000 as RefTimeWeight)
}
fn multiplication(_i: u32, ) -> Weight {
(113_000 as Weight)
Weight::from_ref_time(113_000 as RefTimeWeight)
}
fn division(_i: u32, ) -> Weight {
(102_000 as Weight)
Weight::from_ref_time(102_000 as RefTimeWeight)
}
fn hashing(_i: u32, ) -> Weight {
(20_865_902_000 as Weight)
Weight::from_ref_time(20_865_902_000 as RefTimeWeight)
}
fn sr25519_verification(i: u32, ) -> Weight {
(319_000 as Weight)
Weight::from_ref_time(319_000 as RefTimeWeight)
// Standard Error: 8_000
.saturating_add((47_171_000 as Weight).saturating_mul(i as Weight))
.saturating_add(Weight::from_ref_time(47_171_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight))
}
// Storage: Skipped Metadata (r:0 w:0)
fn storage_read(i: u32, ) -> Weight {
(0 as Weight)
Weight::from_ref_time(0 as RefTimeWeight)
// Standard Error: 3_000
.saturating_add((2_110_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(Weight::from_ref_time(2_110_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight))
.saturating_add(RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight)))
}
// Storage: Skipped Metadata (r:0 w:0)
fn storage_write(i: u32, ) -> Weight {
(0 as Weight)
Weight::from_ref_time(0 as RefTimeWeight)
// Standard Error: 0
.saturating_add((372_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(Weight::from_ref_time(372_000 as RefTimeWeight).scalar_saturating_mul(i as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes((1 as RefTimeWeight).saturating_mul(i as RefTimeWeight)))
}
}