From 8672f1bda20a2a65bf9a9c0fd4489271282c6abc Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 5 Aug 2020 15:15:00 +0200 Subject: [PATCH 01/13] initial updates to system --- bin/node/runtime/src/weights/frame_system.rs | 64 ++++++++++++++++++++ frame/system/benchmarking/src/lib.rs | 18 ++---- frame/system/src/default_weights.rs | 64 ++++++++++++++++++++ frame/system/src/lib.rs | 22 ++----- utils/frame/benchmarking-cli/src/writer.rs | 7 +++ 5 files changed, 147 insertions(+), 28 deletions(-) create mode 100644 bin/node/runtime/src/weights/frame_system.rs create mode 100644 frame/system/src/default_weights.rs diff --git a/bin/node/runtime/src/weights/frame_system.rs b/bin/node/runtime/src/weights/frame_system.rs new file mode 100644 index 0000000000000..039009feefccd --- /dev/null +++ b/bin/node/runtime/src/weights/frame_system.rs @@ -0,0 +1,64 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5 + +#![allow(unused_parens)] + +use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; + +impl crate::WeightInfo for () { + // WARNING! Some components were not used: ["b"] + fn remark() -> Weight { + (1385000 as Weight) + } + // WARNING! Some components were not used: ["i"] + fn set_heap_pages() -> Weight { + (2098000 as Weight) + .saturating_add(DbWeight::get().writes(1 as Weight)) + } + // WARNING! Some components were not used: ["b"] + fn set_code_without_checks() -> Weight { + (21572000 as Weight) + .saturating_add(DbWeight::get().writes(1 as Weight)) + } + // WARNING! Some components were not used: ["d"] + fn set_changes_trie_config() -> Weight { + (10546000 as Weight) + .saturating_add(DbWeight::get().reads(1 as Weight)) + .saturating_add(DbWeight::get().writes(2 as Weight)) + } + fn set_storage(i: u32, ) -> Weight { + (0 as Weight) + .saturating_add((654000 as Weight).saturating_mul(i as Weight)) + .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + } + fn kill_storage(i: u32, ) -> Weight { + (4210000 as Weight) + .saturating_add((490000 as Weight).saturating_mul(i as Weight)) + .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + } + fn kill_prefix(p: u32, ) -> Weight { + (11452000 as Weight) + .saturating_add((831000 as Weight).saturating_mul(p as Weight)) + .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + } + // WARNING! Some components were not used: ["n"] + fn suicide() -> Weight { + (30017000 as Weight) + } +} diff --git a/frame/system/benchmarking/src/lib.rs b/frame/system/benchmarking/src/lib.rs index 049fa5298c677..afdc0c1409d02 100644 --- a/frame/system/benchmarking/src/lib.rs +++ b/frame/system/benchmarking/src/lib.rs @@ -39,29 +39,24 @@ benchmarks! { _ { } remark { - // # of Bytes - let b in 0 .. 16_384; - let remark_message = vec![1; b as usize]; + let remark_message = vec![1; 16_384 as usize]; let caller = account("caller", 0, SEED); }: _(RawOrigin::Signed(caller), remark_message) set_heap_pages { - // Heap page size - let i in 0 .. u32::max_value(); - }: _(RawOrigin::Root, i.into()) + }: _(RawOrigin::Root, Default::default()) // `set_code` was not benchmarked because it is pretty hard to come up with a real // Wasm runtime to test the upgrade with. But this is okay because we will make // `set_code` take a full block anyway. set_code_without_checks { - // Version number - let b in 0 .. 16_384; - let code = vec![1; b as usize]; + // Assume Wasm ~4MB + let code = vec![1; 4_000_000 as usize]; }: _(RawOrigin::Root, code) verify { let current_code = storage::unhashed::get_raw(well_known_keys::CODE).ok_or("Code not stored.")?; - assert_eq!(current_code.len(), b as usize); + assert_eq!(current_code.len(), 4_000_000 as usize); } set_changes_trie_config { @@ -141,10 +136,9 @@ benchmarks! { } suicide { - let n in 1 .. 1000; let caller: T::AccountId = account("caller", 0, SEED); let account_info = AccountInfo:: { - nonce: n.into(), + nonce: 1337, refcount: 0, data: T::AccountData::default() }; diff --git a/frame/system/src/default_weights.rs b/frame/system/src/default_weights.rs new file mode 100644 index 0000000000000..039009feefccd --- /dev/null +++ b/frame/system/src/default_weights.rs @@ -0,0 +1,64 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5 + +#![allow(unused_parens)] + +use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; + +impl crate::WeightInfo for () { + // WARNING! Some components were not used: ["b"] + fn remark() -> Weight { + (1385000 as Weight) + } + // WARNING! Some components were not used: ["i"] + fn set_heap_pages() -> Weight { + (2098000 as Weight) + .saturating_add(DbWeight::get().writes(1 as Weight)) + } + // WARNING! Some components were not used: ["b"] + fn set_code_without_checks() -> Weight { + (21572000 as Weight) + .saturating_add(DbWeight::get().writes(1 as Weight)) + } + // WARNING! Some components were not used: ["d"] + fn set_changes_trie_config() -> Weight { + (10546000 as Weight) + .saturating_add(DbWeight::get().reads(1 as Weight)) + .saturating_add(DbWeight::get().writes(2 as Weight)) + } + fn set_storage(i: u32, ) -> Weight { + (0 as Weight) + .saturating_add((654000 as Weight).saturating_mul(i as Weight)) + .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + } + fn kill_storage(i: u32, ) -> Weight { + (4210000 as Weight) + .saturating_add((490000 as Weight).saturating_mul(i as Weight)) + .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + } + fn kill_prefix(p: u32, ) -> Weight { + (11452000 as Weight) + .saturating_add((831000 as Weight).saturating_mul(p as Weight)) + .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + } + // WARNING! Some components were not used: ["n"] + fn suicide() -> Weight { + (30017000 as Weight) + } +} diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 0852bdd253fe5..9837a429d2296 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -139,6 +139,7 @@ mod extensions; mod weights; #[cfg(test)] mod tests; +mod default_weights; pub use extensions::{ check_mortality::CheckMortality, check_genesis::CheckGenesis, check_nonce::CheckNonce, @@ -159,25 +160,14 @@ pub fn extrinsics_data_root(xts: Vec>) -> H::Output { } pub trait WeightInfo { - fn remark(b: u32, ) -> Weight; - fn set_heap_pages(i: u32, ) -> Weight; - fn set_code_without_checks(b: u32, ) -> Weight; - fn set_changes_trie_config(d: u32, ) -> Weight; + fn remark() -> Weight; + fn set_heap_pages() -> Weight; + fn set_code_without_checks() -> Weight; + fn set_changes_trie_config() -> Weight; fn set_storage(i: u32, ) -> Weight; fn kill_storage(i: u32, ) -> Weight; fn kill_prefix(p: u32, ) -> Weight; - fn suicide(n: u32, ) -> Weight; -} - -impl WeightInfo for () { - fn remark(_b: u32, ) -> Weight { 1_000_000_000 } - fn set_heap_pages(_i: u32, ) -> Weight { 1_000_000_000 } - fn set_code_without_checks(_b: u32, ) -> Weight { 1_000_000_000 } - fn set_changes_trie_config(_d: u32, ) -> Weight { 1_000_000_000 } - fn set_storage(_i: u32, ) -> Weight { 1_000_000_000 } - fn kill_storage(_i: u32, ) -> Weight { 1_000_000_000 } - fn kill_prefix(_p: u32, ) -> Weight { 1_000_000_000 } - fn suicide(_n: u32, ) -> Weight { 1_000_000_000 } + fn suicide() -> Weight; } pub trait Trait: 'static + Eq + Clone { diff --git a/utils/frame/benchmarking-cli/src/writer.rs b/utils/frame/benchmarking-cli/src/writer.rs index 2bc17aa85bddb..0dedd39954868 100644 --- a/utils/frame/benchmarking-cli/src/writer.rs +++ b/utils/frame/benchmarking-cli/src/writer.rs @@ -107,6 +107,13 @@ pub fn write_results(batches: &[BenchmarkBatch]) -> Result<(), std::io::Error> { VERSION, )?; + // allow statements + write!( + file, + "#![allow(unused_parens)]\n\n", + VERSION, + )?; + // general imports write!( file, From 78daffb660ea48c1b756662ee977a2c566038fdf Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 5 Aug 2020 15:17:43 +0200 Subject: [PATCH 02/13] fix compile --- frame/system/benchmarking/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/system/benchmarking/src/lib.rs b/frame/system/benchmarking/src/lib.rs index afdc0c1409d02..27f37bbc578a0 100644 --- a/frame/system/benchmarking/src/lib.rs +++ b/frame/system/benchmarking/src/lib.rs @@ -138,13 +138,13 @@ benchmarks! { suicide { let caller: T::AccountId = account("caller", 0, SEED); let account_info = AccountInfo:: { - nonce: 1337, + nonce: 1337.into(), refcount: 0, data: T::AccountData::default() }; frame_system::Account::::insert(&caller, account_info); let new_account_info = System::::account(caller.clone()); - assert_eq!(new_account_info.nonce, n.into()); + assert_eq!(new_account_info.nonce, 1337.into()); }: _(RawOrigin::Signed(caller.clone())) verify { let account_info = System::::account(&caller); From 996f0836f902433a98b42654dd2aa82a2d7aeb1b Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 5 Aug 2020 15:21:30 +0200 Subject: [PATCH 03/13] Update writer.rs --- utils/frame/benchmarking-cli/src/writer.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/frame/benchmarking-cli/src/writer.rs b/utils/frame/benchmarking-cli/src/writer.rs index 0dedd39954868..8f9764677d99a 100644 --- a/utils/frame/benchmarking-cli/src/writer.rs +++ b/utils/frame/benchmarking-cli/src/writer.rs @@ -111,7 +111,6 @@ pub fn write_results(batches: &[BenchmarkBatch]) -> Result<(), std::io::Error> { write!( file, "#![allow(unused_parens)]\n\n", - VERSION, )?; // general imports From 66fa8893cb307ed679ea1e4be774016fda2b7c79 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 5 Aug 2020 15:56:30 +0200 Subject: [PATCH 04/13] update weights --- frame/system/benchmarking/src/lib.rs | 5 ++++- frame/system/src/default_weights.rs | 26 +++++++++----------------- frame/system/src/lib.rs | 18 +++++++----------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/frame/system/benchmarking/src/lib.rs b/frame/system/benchmarking/src/lib.rs index 27f37bbc578a0..a3e7797996ac9 100644 --- a/frame/system/benchmarking/src/lib.rs +++ b/frame/system/benchmarking/src/lib.rs @@ -25,6 +25,7 @@ use sp_std::prelude::*; use sp_core::{ChangesTrieConfiguration, storage::well_known_keys}; use sp_runtime::traits::Hash; use frame_benchmarking::{benchmarks, account}; +use frame_support::traits::Get; use frame_support::storage::{self, StorageMap}; use frame_system::{Module as System, Call, RawOrigin, DigestItemOf, AccountInfo}; @@ -39,7 +40,8 @@ benchmarks! { _ { } remark { - let remark_message = vec![1; 16_384 as usize]; + let b in 0 .. T::MaximumBlockLength::get(); + let remark_message = vec![1; b as usize]; let caller = account("caller", 0, SEED); }: _(RawOrigin::Signed(caller), remark_message) @@ -50,6 +52,7 @@ benchmarks! { // Wasm runtime to test the upgrade with. But this is okay because we will make // `set_code` take a full block anyway. + #[extra] set_code_without_checks { // Assume Wasm ~4MB let code = vec![1; 4_000_000 as usize]; diff --git a/frame/system/src/default_weights.rs b/frame/system/src/default_weights.rs index 039009feefccd..b585672d4f79f 100644 --- a/frame/system/src/default_weights.rs +++ b/frame/system/src/default_weights.rs @@ -22,43 +22,35 @@ use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; impl crate::WeightInfo for () { - // WARNING! Some components were not used: ["b"] fn remark() -> Weight { - (1385000 as Weight) + (1411000 as Weight) } - // WARNING! Some components were not used: ["i"] fn set_heap_pages() -> Weight { - (2098000 as Weight) - .saturating_add(DbWeight::get().writes(1 as Weight)) - } - // WARNING! Some components were not used: ["b"] - fn set_code_without_checks() -> Weight { - (21572000 as Weight) + (1947000 as Weight) .saturating_add(DbWeight::get().writes(1 as Weight)) } // WARNING! Some components were not used: ["d"] fn set_changes_trie_config() -> Weight { - (10546000 as Weight) + (9804000 as Weight) .saturating_add(DbWeight::get().reads(1 as Weight)) .saturating_add(DbWeight::get().writes(2 as Weight)) } fn set_storage(i: u32, ) -> Weight { (0 as Weight) - .saturating_add((654000 as Weight).saturating_mul(i as Weight)) + .saturating_add((655000 as Weight).saturating_mul(i as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) } fn kill_storage(i: u32, ) -> Weight { - (4210000 as Weight) - .saturating_add((490000 as Weight).saturating_mul(i as Weight)) + (1630000 as Weight) + .saturating_add((476000 as Weight).saturating_mul(i as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) } fn kill_prefix(p: u32, ) -> Weight { - (11452000 as Weight) - .saturating_add((831000 as Weight).saturating_mul(p as Weight)) + (9295000 as Weight) + .saturating_add((845000 as Weight).saturating_mul(p as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) } - // WARNING! Some components were not used: ["n"] fn suicide() -> Weight { - (30017000 as Weight) + (29068000 as Weight) } } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 9837a429d2296..565c29b63042d 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -162,7 +162,6 @@ pub fn extrinsics_data_root(xts: Vec>) -> H::Output { pub trait WeightInfo { fn remark() -> Weight; fn set_heap_pages() -> Weight; - fn set_code_without_checks() -> Weight; fn set_changes_trie_config() -> Weight; fn set_storage(i: u32, ) -> Weight; fn kill_storage(i: u32, ) -> Weight; @@ -554,7 +553,7 @@ decl_module! { /// - Base Weight: 0.665 µs, independent of remark length. /// - No DB operations. /// # - #[weight = 700_000] + #[weight = T::SystemWeightInfo::remark()] fn remark(origin, _remark: Vec) { ensure_signed(origin)?; } @@ -567,7 +566,7 @@ decl_module! { /// - Base Weight: 1.405 µs /// - 1 write to HEAP_PAGES /// # - #[weight = (T::DbWeight::get().writes(1) + 1_500_000, DispatchClass::Operational)] + #[weight = (T::SystemWeightInfo::set_heap_pages(), DispatchClass::Operational)] fn set_heap_pages(origin, pages: u64) { ensure_root(origin)?; storage::unhashed::put_raw(well_known_keys::HEAP_PAGES, &pages.encode()); @@ -616,7 +615,7 @@ decl_module! { /// - DB Weight: /// - Writes: Changes Trie, System Digest /// # - #[weight = (T::DbWeight::get().writes(2) + 10_000_000, DispatchClass::Operational)] + #[weight = (T::SystemWeightInfo::set_changes_trie_config(), DispatchClass::Operational)] pub fn set_changes_trie_config(origin, changes_trie_config: Option) { ensure_root(origin)?; match changes_trie_config.clone() { @@ -642,8 +641,7 @@ decl_module! { /// - Writes: Number of items /// # #[weight = ( - T::DbWeight::get().writes(items.len() as Weight) - .saturating_add((items.len() as Weight).saturating_mul(600_000)), + T::SystemWeightInfo::set_storage(items.len() as u32), DispatchClass::Operational, )] fn set_storage(origin, items: Vec) { @@ -662,8 +660,7 @@ decl_module! { /// - Writes: Number of items /// # #[weight = ( - T::DbWeight::get().writes(keys.len() as Weight) - .saturating_add((keys.len() as Weight).saturating_mul(400_000)), + T::SystemWeightInfo::kill_storage(keys.len() as u32), DispatchClass::Operational, )] fn kill_storage(origin, keys: Vec) { @@ -685,8 +682,7 @@ decl_module! { /// - Writes: Number of subkeys + 1 /// # #[weight = ( - T::DbWeight::get().writes(Weight::from(*_subkeys) + 1) - .saturating_add((Weight::from(*_subkeys) + 1).saturating_mul(850_000)), + T::SystemWeightInfo::kill_prefix(*_subkeys + 1), DispatchClass::Operational, )] fn kill_prefix(origin, prefix: Key, _subkeys: u32) { @@ -704,7 +700,7 @@ decl_module! { /// Base Weight: 8.626 µs /// No DB Read or Write operations because caller is already in overlay /// # - #[weight = (10_000_000, DispatchClass::Operational)] + #[weight = (T::SystemWeightInfo::suicide(), DispatchClass::Operational)] pub fn suicide(origin) { let who = ensure_signed(origin)?; let account = Account::::get(&who); From 0277875142b95cd685304f2f9678e78310c3ba9b Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 5 Aug 2020 16:24:02 +0200 Subject: [PATCH 05/13] finish system weights --- bin/node/runtime/src/lib.rs | 2 +- bin/node/runtime/src/weights/frame_system.rs | 28 ++++++++------------ bin/node/runtime/src/weights/mod.rs | 1 + frame/system/src/default_weights.rs | 19 ++++++------- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index acc1b07281834..db80dae6ae005 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -182,7 +182,7 @@ impl frame_system::Trait for Runtime { type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); - type SystemWeightInfo = (); + type SystemWeightInfo = weights::frame_system::WeightInfo; } impl pallet_utility::Trait for Runtime { diff --git a/bin/node/runtime/src/weights/frame_system.rs b/bin/node/runtime/src/weights/frame_system.rs index 039009feefccd..9522fa7520390 100644 --- a/bin/node/runtime/src/weights/frame_system.rs +++ b/bin/node/runtime/src/weights/frame_system.rs @@ -21,44 +21,38 @@ use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; -impl crate::WeightInfo for () { +pub struct WeightInfo; +impl frame_system::WeightInfo for WeightInfo { // WARNING! Some components were not used: ["b"] fn remark() -> Weight { - (1385000 as Weight) + (1305000 as Weight) } - // WARNING! Some components were not used: ["i"] fn set_heap_pages() -> Weight { - (2098000 as Weight) - .saturating_add(DbWeight::get().writes(1 as Weight)) - } - // WARNING! Some components were not used: ["b"] - fn set_code_without_checks() -> Weight { - (21572000 as Weight) + (2023000 as Weight) .saturating_add(DbWeight::get().writes(1 as Weight)) } // WARNING! Some components were not used: ["d"] fn set_changes_trie_config() -> Weight { - (10546000 as Weight) + (10026000 as Weight) .saturating_add(DbWeight::get().reads(1 as Weight)) .saturating_add(DbWeight::get().writes(2 as Weight)) } fn set_storage(i: u32, ) -> Weight { (0 as Weight) - .saturating_add((654000 as Weight).saturating_mul(i as Weight)) + .saturating_add((656000 as Weight).saturating_mul(i as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) } fn kill_storage(i: u32, ) -> Weight { - (4210000 as Weight) - .saturating_add((490000 as Weight).saturating_mul(i as Weight)) + (4327000 as Weight) + .saturating_add((478000 as Weight).saturating_mul(i as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) } fn kill_prefix(p: u32, ) -> Weight { - (11452000 as Weight) - .saturating_add((831000 as Weight).saturating_mul(p as Weight)) + (8349000 as Weight) + .saturating_add((838000 as Weight).saturating_mul(p as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) } - // WARNING! Some components were not used: ["n"] fn suicide() -> Weight { - (30017000 as Weight) + (29247000 as Weight) } } diff --git a/bin/node/runtime/src/weights/mod.rs b/bin/node/runtime/src/weights/mod.rs index 70bae879ce05c..e98e3b059ef6b 100644 --- a/bin/node/runtime/src/weights/mod.rs +++ b/bin/node/runtime/src/weights/mod.rs @@ -15,5 +15,6 @@ //! A list of the different weight modules for our runtime. +pub mod frame_system; pub mod pallet_balances; pub mod pallet_democracy; diff --git a/frame/system/src/default_weights.rs b/frame/system/src/default_weights.rs index b585672d4f79f..8a84cb0b7903a 100644 --- a/frame/system/src/default_weights.rs +++ b/frame/system/src/default_weights.rs @@ -22,35 +22,36 @@ use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; impl crate::WeightInfo for () { + // WARNING! Some components were not used: ["b"] fn remark() -> Weight { - (1411000 as Weight) + (1305000 as Weight) } fn set_heap_pages() -> Weight { - (1947000 as Weight) + (2023000 as Weight) .saturating_add(DbWeight::get().writes(1 as Weight)) } // WARNING! Some components were not used: ["d"] fn set_changes_trie_config() -> Weight { - (9804000 as Weight) + (10026000 as Weight) .saturating_add(DbWeight::get().reads(1 as Weight)) .saturating_add(DbWeight::get().writes(2 as Weight)) } fn set_storage(i: u32, ) -> Weight { (0 as Weight) - .saturating_add((655000 as Weight).saturating_mul(i as Weight)) + .saturating_add((656000 as Weight).saturating_mul(i as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) } fn kill_storage(i: u32, ) -> Weight { - (1630000 as Weight) - .saturating_add((476000 as Weight).saturating_mul(i as Weight)) + (4327000 as Weight) + .saturating_add((478000 as Weight).saturating_mul(i as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) } fn kill_prefix(p: u32, ) -> Weight { - (9295000 as Weight) - .saturating_add((845000 as Weight).saturating_mul(p as Weight)) + (8349000 as Weight) + .saturating_add((838000 as Weight).saturating_mul(p as Weight)) .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) } fn suicide() -> Weight { - (29068000 as Weight) + (29247000 as Weight) } } From 676236db6996e04d30b4174712319c7b2fa55f58 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 10 Aug 2020 23:57:28 +0200 Subject: [PATCH 06/13] timestamp weights --- bin/node/runtime/src/lib.rs | 2 +- bin/node/runtime/src/weights/mod.rs | 1 + .../runtime/src/weights/pallet_timestamp.rs | 36 ++++++++++++++++++ frame/timestamp/src/default_weights.rs | 37 +++++++++++++++++++ frame/timestamp/src/lib.rs | 28 +++----------- 5 files changed, 80 insertions(+), 24 deletions(-) create mode 100644 bin/node/runtime/src/weights/pallet_timestamp.rs create mode 100644 frame/timestamp/src/default_weights.rs diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index db80dae6ae005..27478b4cd84f4 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -352,7 +352,7 @@ impl pallet_timestamp::Trait for Runtime { type Moment = Moment; type OnTimestampSet = Babe; type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); + type WeightInfo = weights::pallet_timestamp::WeightInfo; } parameter_types! { diff --git a/bin/node/runtime/src/weights/mod.rs b/bin/node/runtime/src/weights/mod.rs index e98e3b059ef6b..c5533793671b3 100644 --- a/bin/node/runtime/src/weights/mod.rs +++ b/bin/node/runtime/src/weights/mod.rs @@ -18,3 +18,4 @@ pub mod frame_system; pub mod pallet_balances; pub mod pallet_democracy; +pub mod pallet_timestamp; diff --git a/bin/node/runtime/src/weights/pallet_timestamp.rs b/bin/node/runtime/src/weights/pallet_timestamp.rs new file mode 100644 index 0000000000000..fb9fa89a06f72 --- /dev/null +++ b/bin/node/runtime/src/weights/pallet_timestamp.rs @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5 + +#![allow(unused_parens)] + +use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; + +pub struct WeightInfo; +impl pallet_timestamp::WeightInfo for WeightInfo { + // WARNING! Some components were not used: ["t"] + fn set() -> Weight { + (9133000 as Weight) + .saturating_add(DbWeight::get().reads(2 as Weight)) + .saturating_add(DbWeight::get().writes(2 as Weight)) + } + // WARNING! Some components were not used: ["t"] + fn on_finalize() -> Weight { + (5915000 as Weight) + .saturating_add(DbWeight::get().reads(1 as Weight)) + .saturating_add(DbWeight::get().writes(1 as Weight)) + } +} diff --git a/frame/timestamp/src/default_weights.rs b/frame/timestamp/src/default_weights.rs new file mode 100644 index 0000000000000..2223289173251 --- /dev/null +++ b/frame/timestamp/src/default_weights.rs @@ -0,0 +1,37 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5 + +#![allow(unused_parens)] + +use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; + +impl crate::WeightInfo for () { + // WARNING! Some components were not used: ["t"] + fn set() -> Weight { + (9133000 as Weight) + .saturating_add(DbWeight::get().reads(2 as Weight)) + .saturating_add(DbWeight::get().writes(2 as Weight)) + } + // WARNING! Some components were not used: ["t"] + fn on_finalize() -> Weight { + (5915000 as Weight) + .saturating_add(DbWeight::get().reads(1 as Weight)) + .saturating_add(DbWeight::get().writes(1 as Weight)) + } +} diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 1177165abed8c..deab7bb0e4fef 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -93,6 +93,7 @@ #![cfg_attr(not(feature = "std"), no_std)] mod benchmarking; +mod default_weights; use sp_std::{result, cmp}; use sp_inherents::{ProvideInherent, InherentData, InherentIdentifier}; @@ -116,13 +117,8 @@ use sp_timestamp::{ }; pub trait WeightInfo { - fn set(t: u32, ) -> Weight; - fn on_finalize(t: u32, ) -> Weight; -} - -impl WeightInfo for () { - fn set(_t: u32, ) -> Weight { 1_000_000_000 } - fn on_finalize(_t: u32, ) -> Weight { 1_000_000_000 } + fn set() -> Weight; + fn on_finalize() -> Weight; } /// The module configuration trait @@ -161,17 +157,8 @@ decl_module! { /// `MinimumPeriod`. /// /// The dispatch origin for this call must be `Inherent`. - /// - /// # - /// - `O(T)` where `T` complexity of `on_timestamp_set` - /// - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`) - /// - 1 event handler `on_timestamp_set` `O(T)`. - /// - Benchmark: 7.678 (min squares analysis) - /// - NOTE: This benchmark was done for a runtime with insignificant `on_timestamp_set` handlers. - /// New benchmarking is needed when adding new handlers. - /// # #[weight = ( - T::DbWeight::get().reads_writes(2, 1) + 8_000_000, + T::WeightInfo::set(), DispatchClass::Mandatory )] fn set(origin, #[compact] now: T::Moment) { @@ -191,14 +178,9 @@ decl_module! { /// dummy `on_initialize` to return the weight used in `on_finalize`. fn on_initialize() -> Weight { // weight of `on_finalize` - 5_000_000 + T::WeightInfo::on_finalize() } - /// # - /// - `O(1)` - /// - 1 storage deletion (codec `O(1)`). - /// - Benchmark: 4.928 µs (min squares analysis) - /// # fn on_finalize() { assert!(::DidUpdate::take(), "Timestamp must be updated once in the block"); } From 792a216d06329454e59adfd8f56e2c01d3e7cc16 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 11 Aug 2020 00:28:28 +0200 Subject: [PATCH 07/13] utility weight --- bin/node/runtime/src/lib.rs | 2 +- bin/node/runtime/src/weights/mod.rs | 1 + .../runtime/src/weights/pallet_utility.rs | 35 +++++++++++++++++++ frame/utility/src/default_weights.rs | 34 ++++++++++++++++++ frame/utility/src/lib.rs | 19 ++++------ 5 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 bin/node/runtime/src/weights/pallet_utility.rs create mode 100644 frame/utility/src/default_weights.rs diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 27478b4cd84f4..aa0ddfc61a7bb 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -188,7 +188,7 @@ impl frame_system::Trait for Runtime { impl pallet_utility::Trait for Runtime { type Event = Event; type Call = Call; - type WeightInfo = (); + type WeightInfo = weights::pallet_utility::WeightInfo; } parameter_types! { diff --git a/bin/node/runtime/src/weights/mod.rs b/bin/node/runtime/src/weights/mod.rs index c5533793671b3..0e078e7ac0859 100644 --- a/bin/node/runtime/src/weights/mod.rs +++ b/bin/node/runtime/src/weights/mod.rs @@ -19,3 +19,4 @@ pub mod frame_system; pub mod pallet_balances; pub mod pallet_democracy; pub mod pallet_timestamp; +pub mod pallet_utility; diff --git a/bin/node/runtime/src/weights/pallet_utility.rs b/bin/node/runtime/src/weights/pallet_utility.rs new file mode 100644 index 0000000000000..c9ae0d7d2333b --- /dev/null +++ b/bin/node/runtime/src/weights/pallet_utility.rs @@ -0,0 +1,35 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5 + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; + +pub struct WeightInfo; +impl pallet_utility::WeightInfo for WeightInfo { + fn batch(c: u32, ) -> Weight { + (16461000 as Weight) + .saturating_add((1982000 as Weight).saturating_mul(c as Weight)) + } + // WARNING! Some components were not used: ["u"] + fn as_derivative() -> Weight { + (4086000 as Weight) + } +} diff --git a/frame/utility/src/default_weights.rs b/frame/utility/src/default_weights.rs new file mode 100644 index 0000000000000..d023dbddd4f80 --- /dev/null +++ b/frame/utility/src/default_weights.rs @@ -0,0 +1,34 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5 + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight}; + +impl crate::WeightInfo for () { + fn batch(c: u32, ) -> Weight { + (16461000 as Weight) + .saturating_add((1982000 as Weight).saturating_mul(c as Weight)) + } + // WARNING! Some components were not used: ["u"] + fn as_derivative() -> Weight { + (4086000 as Weight) + } +} diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index cf2ea9119b973..fe9d76a747f1e 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -69,15 +69,11 @@ use sp_runtime::{DispatchError, DispatchResult, traits::Dispatchable}; mod tests; mod benchmarking; +mod default_weights; pub trait WeightInfo { fn batch(c: u32, ) -> Weight; - fn as_derivative(u: u32, ) -> Weight; -} - -impl WeightInfo for () { - fn batch(_c: u32, ) -> Weight { 1_000_000_000 } - fn as_derivative(_u: u32, ) -> Weight { 1_000_000_000 } + fn as_derivative() -> Weight; } /// Configuration trait. @@ -145,7 +141,8 @@ decl_module! { #[weight = ( calls.iter() .map(|call| call.get_dispatch_info().weight) - .fold(15_000_000, |a: Weight, n| a.saturating_add(n).saturating_add(1_000_000)), + .sum::() + .saturating_add(T::WeightInfo::batch(calls.len() as u32)), { let all_operational = calls.iter() .map(|call| call.get_dispatch_info().class) @@ -186,13 +183,9 @@ decl_module! { /// NOTE: Prior to version *12, this was called `as_limited_sub`. /// /// The dispatch origin for this call must be _Signed_. - /// - /// # - /// - Base weight: 2.861 µs - /// - Plus the weight of the `call` - /// # #[weight = ( - call.get_dispatch_info().weight.saturating_add(3_000_000), + T::WeightInfo::as_derivative() + .saturating_add(call.get_dispatch_info().weight), call.get_dispatch_info().class, )] fn as_derivative(origin, index: u16, call: Box<::Call>) -> DispatchResult { From 50a724f4b4d4d680c9dc30f972975062c35cccb7 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 13 Aug 2020 11:54:33 +0200 Subject: [PATCH 08/13] Fix overflow in weight calculations --- frame/system/src/lib.rs | 2 +- frame/utility/src/lib.rs | 2 +- frame/utility/src/tests.rs | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 565c29b63042d..b1f0d5de1e744 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -682,7 +682,7 @@ decl_module! { /// - Writes: Number of subkeys + 1 /// # #[weight = ( - T::SystemWeightInfo::kill_prefix(*_subkeys + 1), + T::SystemWeightInfo::kill_prefix(_subkeys.saturating_add(1)), DispatchClass::Operational, )] fn kill_prefix(origin, prefix: Key, _subkeys: u32) { diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index fe9d76a747f1e..d67fdc85db5a5 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -141,7 +141,7 @@ decl_module! { #[weight = ( calls.iter() .map(|call| call.get_dispatch_info().weight) - .sum::() + .fold(0, |total: Weight, weight: Weight| total.saturating_add(weight)) .saturating_add(T::WeightInfo::batch(calls.len() as u32)), { let all_operational = calls.iter() diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 6de70506e452c..611c42907ca04 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -54,7 +54,7 @@ impl_outer_dispatch! { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockWeight: Weight = Weight::max_value(); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } @@ -121,6 +121,7 @@ type System = frame_system::Module; type Balances = pallet_balances::Module; type Utility = Module; +use frame_system::Call as SystemCall; use pallet_balances::Call as BalancesCall; use pallet_balances::Error as BalancesError; @@ -236,3 +237,20 @@ fn batch_early_exit_works() { assert_eq!(Balances::free_balance(2), 15); }); } + +#[test] +fn batch_weight_calculation_doesnt_overflow() { + new_test_ext().execute_with(|| { + let big_call = Call::System(SystemCall::fill_block(Perbill::from_percent(50))); + assert_eq!(big_call.get_dispatch_info().weight, Weight::max_value() / 2); + + // 3 * 50% saturates to 100% + let batch_call = Call::Utility(crate::Call::batch(vec![ + big_call.clone(), + big_call.clone(), + big_call.clone(), + ])); + + assert_eq!(batch_call.get_dispatch_info().weight, Weight::max_value()); + }); +} From 2e58cdd95203c6349b96cf889a5c02414c5f6c91 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 13 Aug 2020 11:58:17 +0200 Subject: [PATCH 09/13] add back weight notes --- frame/timestamp/src/lib.rs | 10 ++++++++++ utils/frame/benchmarking-cli/src/writer.rs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index deab7bb0e4fef..d74a94cb9201b 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -157,6 +157,12 @@ decl_module! { /// `MinimumPeriod`. /// /// The dispatch origin for this call must be `Inherent`. + /// + /// # + /// - `O(T)` where `T` complexity of `on_timestamp_set` + /// - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`) + /// - 1 event handler `on_timestamp_set` `O(T)`. + /// # #[weight = ( T::WeightInfo::set(), DispatchClass::Mandatory @@ -181,6 +187,10 @@ decl_module! { T::WeightInfo::on_finalize() } + /// # + /// - `O(1)` + /// - 1 storage deletion (codec `O(1)`). + /// # fn on_finalize() { assert!(::DidUpdate::take(), "Timestamp must be updated once in the block"); } diff --git a/utils/frame/benchmarking-cli/src/writer.rs b/utils/frame/benchmarking-cli/src/writer.rs index 8f9764677d99a..964c1bf5fc112 100644 --- a/utils/frame/benchmarking-cli/src/writer.rs +++ b/utils/frame/benchmarking-cli/src/writer.rs @@ -110,7 +110,7 @@ pub fn write_results(batches: &[BenchmarkBatch]) -> Result<(), std::io::Error> { // allow statements write!( file, - "#![allow(unused_parens)]\n\n", + "#![allow(unused_parens)]\n#![allow(unused_imports)]\n\n", )?; // general imports From da6b4f9fbf7604ff1bcd22afece110d68adc4ec2 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 17 Aug 2020 01:38:17 +0200 Subject: [PATCH 10/13] Update for whitelisted benchmarks --- bin/node/runtime/src/weights/pallet_timestamp.rs | 6 ++---- frame/timestamp/src/default_weights.rs | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/bin/node/runtime/src/weights/pallet_timestamp.rs b/bin/node/runtime/src/weights/pallet_timestamp.rs index fb9fa89a06f72..65a238af466b8 100644 --- a/bin/node/runtime/src/weights/pallet_timestamp.rs +++ b/bin/node/runtime/src/weights/pallet_timestamp.rs @@ -24,13 +24,11 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // WARNING! Some components were not used: ["t"] fn set() -> Weight { (9133000 as Weight) - .saturating_add(DbWeight::get().reads(2 as Weight)) - .saturating_add(DbWeight::get().writes(2 as Weight)) + .saturating_add(DbWeight::get().reads(1 as Weight)) + .saturating_add(DbWeight::get().writes(1 as Weight)) } // WARNING! Some components were not used: ["t"] fn on_finalize() -> Weight { (5915000 as Weight) - .saturating_add(DbWeight::get().reads(1 as Weight)) - .saturating_add(DbWeight::get().writes(1 as Weight)) } } diff --git a/frame/timestamp/src/default_weights.rs b/frame/timestamp/src/default_weights.rs index 2223289173251..341fc9dfea92e 100644 --- a/frame/timestamp/src/default_weights.rs +++ b/frame/timestamp/src/default_weights.rs @@ -25,13 +25,11 @@ impl crate::WeightInfo for () { // WARNING! Some components were not used: ["t"] fn set() -> Weight { (9133000 as Weight) - .saturating_add(DbWeight::get().reads(2 as Weight)) - .saturating_add(DbWeight::get().writes(2 as Weight)) + .saturating_add(DbWeight::get().reads(1 as Weight)) + .saturating_add(DbWeight::get().writes(1 as Weight)) } // WARNING! Some components were not used: ["t"] fn on_finalize() -> Weight { (5915000 as Weight) - .saturating_add(DbWeight::get().reads(1 as Weight)) - .saturating_add(DbWeight::get().writes(1 as Weight)) } } From 12b08b7189aa3969f96fa19b211a370860fdb240 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 17 Aug 2020 04:30:21 +0200 Subject: [PATCH 11/13] add trait bounds --- frame/benchmarking/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 7ef274f25b157..b2aa167c47894 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -573,7 +573,7 @@ macro_rules! benchmark_backend { #[allow(unused_variables)] impl, I: Instance)? > $crate::BenchmarkingSetup for $name - where $( $where_clause )* + where T: frame_system::Trait, $( $where_clause )* { fn components(&self) -> Vec<($crate::BenchmarkParameter, u32, u32)> { vec! [ @@ -659,7 +659,7 @@ macro_rules! selected_benchmark { // Allow us to select a benchmark from the list of available benchmarks. impl, I: Instance )? > $crate::BenchmarkingSetup for SelectedBenchmark - where $( $where_clause )* + where T: frame_system::Trait, $( $where_clause )* { fn components(&self) -> Vec<($crate::BenchmarkParameter, u32, u32)> { match self { From a79855abf17d769d9699e36f158579beff618e61 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 17 Aug 2020 04:31:37 +0200 Subject: [PATCH 12/13] Revert "add trait bounds" This reverts commit 12b08b7189aa3969f96fa19b211a370860fdb240. --- frame/benchmarking/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index b2aa167c47894..7ef274f25b157 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -573,7 +573,7 @@ macro_rules! benchmark_backend { #[allow(unused_variables)] impl, I: Instance)? > $crate::BenchmarkingSetup for $name - where T: frame_system::Trait, $( $where_clause )* + where $( $where_clause )* { fn components(&self) -> Vec<($crate::BenchmarkParameter, u32, u32)> { vec! [ @@ -659,7 +659,7 @@ macro_rules! selected_benchmark { // Allow us to select a benchmark from the list of available benchmarks. impl, I: Instance )? > $crate::BenchmarkingSetup for SelectedBenchmark - where T: frame_system::Trait, $( $where_clause )* + where $( $where_clause )* { fn components(&self) -> Vec<($crate::BenchmarkParameter, u32, u32)> { match self { From 124a2a3dd78dc5c835cd6b72fe08107761bec3db Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 17 Aug 2020 21:19:20 +0200 Subject: [PATCH 13/13] Update weights for unaccounted for read --- bin/node/runtime/src/weights/pallet_timestamp.rs | 2 +- frame/timestamp/src/default_weights.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/node/runtime/src/weights/pallet_timestamp.rs b/bin/node/runtime/src/weights/pallet_timestamp.rs index 65a238af466b8..cfd5f192d3529 100644 --- a/bin/node/runtime/src/weights/pallet_timestamp.rs +++ b/bin/node/runtime/src/weights/pallet_timestamp.rs @@ -24,7 +24,7 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // WARNING! Some components were not used: ["t"] fn set() -> Weight { (9133000 as Weight) - .saturating_add(DbWeight::get().reads(1 as Weight)) + .saturating_add(DbWeight::get().reads(2 as Weight)) .saturating_add(DbWeight::get().writes(1 as Weight)) } // WARNING! Some components were not used: ["t"] diff --git a/frame/timestamp/src/default_weights.rs b/frame/timestamp/src/default_weights.rs index 341fc9dfea92e..726b3444e2532 100644 --- a/frame/timestamp/src/default_weights.rs +++ b/frame/timestamp/src/default_weights.rs @@ -25,7 +25,7 @@ impl crate::WeightInfo for () { // WARNING! Some components were not used: ["t"] fn set() -> Weight { (9133000 as Weight) - .saturating_add(DbWeight::get().reads(1 as Weight)) + .saturating_add(DbWeight::get().reads(2 as Weight)) .saturating_add(DbWeight::get().writes(1 as Weight)) } // WARNING! Some components were not used: ["t"]