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
+19 -15
View File
@@ -839,9 +839,10 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
/// The real weight of a migration of the given number of `items` with total `size`.
fn dynamic_weight(items: u32, size: u32) -> frame_support::pallet_prelude::Weight {
let items = items as Weight;
items
.saturating_mul(<T as frame_system::Config>::DbWeight::get().reads_writes(1, 1))
let items = items as u64;
<T as frame_system::Config>::DbWeight::get()
.reads_writes(1, 1)
.scalar_saturating_mul(items)
// we assume that the read/write per-byte weight is the same for child and top tree.
.saturating_add(T::WeightInfo::process_top_key(size))
}
@@ -1129,25 +1130,25 @@ mod mock {
impl WeightInfo for StateMigrationTestWeight {
fn process_top_key(_: u32) -> Weight {
1000000
Weight::from_ref_time(1000000)
}
fn continue_migrate() -> Weight {
1000000
Weight::from_ref_time(1000000)
}
fn continue_migrate_wrong_witness() -> Weight {
1000000
Weight::from_ref_time(1000000)
}
fn migrate_custom_top_fail() -> Weight {
1000000
Weight::from_ref_time(1000000)
}
fn migrate_custom_top_success() -> Weight {
1000000
Weight::from_ref_time(1000000)
}
fn migrate_custom_child_fail() -> Weight {
1000000
Weight::from_ref_time(1000000)
}
fn migrate_custom_child_success() -> Weight {
1000000
Weight::from_ref_time(1000000)
}
}
@@ -1243,9 +1244,9 @@ mod mock {
(custom_storage, version).into()
}
pub(crate) fn run_to_block(n: u32) -> (H256, u64) {
pub(crate) fn run_to_block(n: u32) -> (H256, Weight) {
let mut root = Default::default();
let mut weight_sum = 0;
let mut weight_sum = Weight::new();
log::trace!(target: LOG_TARGET, "running from {:?} to {:?}", System::block_number(), n);
while System::block_number() < n {
System::set_block_number(System::block_number() + 1);
@@ -1606,7 +1607,10 @@ pub(crate) mod remote_tests {
use crate::{AutoLimits, MigrationLimits, Pallet as StateTrieMigration, LOG_TARGET};
use codec::Encode;
use frame_benchmarking::Zero;
use frame_support::traits::{Get, Hooks};
use frame_support::{
traits::{Get, Hooks},
weights::Weight,
};
use frame_system::Pallet as System;
use remote_externalities::Mode;
use sp_core::H256;
@@ -1616,9 +1620,9 @@ pub(crate) mod remote_tests {
#[allow(dead_code)]
fn run_to_block<Runtime: crate::Config<Hash = H256>>(
n: <Runtime as frame_system::Config>::BlockNumber,
) -> (H256, u64) {
) -> (H256, Weight) {
let mut root = Default::default();
let mut weight_sum = 0;
let mut weight_sum = Weight::new();
while System::<Runtime>::block_number() < n {
System::<Runtime>::set_block_number(System::<Runtime>::block_number() + One::one());
System::<Runtime>::on_initialize(System::<Runtime>::block_number());
@@ -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_state_trie_migration.
@@ -59,40 +59,40 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0)
// Storage: StateTrieMigration MigrationProcess (r:1 w:1)
fn continue_migrate() -> Weight {
(19_019_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Weight::from_ref_time(19_019_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
// Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0)
fn continue_migrate_wrong_witness() -> Weight {
(1_874_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
Weight::from_ref_time(1_874_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
}
fn migrate_custom_top_success() -> Weight {
(16_381_000 as Weight)
Weight::from_ref_time(16_381_000 as RefTimeWeight)
}
// Storage: unknown [0x666f6f] (r:1 w:1)
fn migrate_custom_top_fail() -> Weight {
(25_966_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Weight::from_ref_time(25_966_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
fn migrate_custom_child_success() -> Weight {
(16_712_000 as Weight)
Weight::from_ref_time(16_712_000 as RefTimeWeight)
}
// Storage: unknown [0x666f6f] (r:1 w:1)
fn migrate_custom_child_fail() -> Weight {
(29_885_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Weight::from_ref_time(29_885_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
// Storage: unknown [0x6b6579] (r:1 w:1)
fn process_top_key(v: u32, ) -> Weight {
(0 as Weight)
Weight::from_ref_time(0 as RefTimeWeight)
// Standard Error: 0
.saturating_add((2_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight))
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
}
@@ -101,39 +101,39 @@ impl WeightInfo for () {
// Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0)
// Storage: StateTrieMigration MigrationProcess (r:1 w:1)
fn continue_migrate() -> Weight {
(19_019_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
Weight::from_ref_time(19_019_000 as RefTimeWeight)
.saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
}
// Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0)
fn continue_migrate_wrong_witness() -> Weight {
(1_874_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
Weight::from_ref_time(1_874_000 as RefTimeWeight)
.saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight))
}
fn migrate_custom_top_success() -> Weight {
(16_381_000 as Weight)
Weight::from_ref_time(16_381_000 as RefTimeWeight)
}
// Storage: unknown [0x666f6f] (r:1 w:1)
fn migrate_custom_top_fail() -> Weight {
(25_966_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
Weight::from_ref_time(25_966_000 as RefTimeWeight)
.saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
}
fn migrate_custom_child_success() -> Weight {
(16_712_000 as Weight)
Weight::from_ref_time(16_712_000 as RefTimeWeight)
}
// Storage: unknown [0x666f6f] (r:1 w:1)
fn migrate_custom_child_fail() -> Weight {
(29_885_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
Weight::from_ref_time(29_885_000 as RefTimeWeight)
.saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
}
// Storage: unknown [0x6b6579] (r:1 w:1)
fn process_top_key(v: u32, ) -> Weight {
(0 as Weight)
Weight::from_ref_time(0 as RefTimeWeight)
// Standard Error: 0
.saturating_add((2_000 as Weight).saturating_mul(v as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
.saturating_add(Weight::from_ref_time(2_000 as RefTimeWeight).scalar_saturating_mul(v as RefTimeWeight))
.saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
}
}