WeightInfo for System, Timestamp, and Utility (#6868)

* initial updates to system

* fix compile

* Update writer.rs

* update weights

* finish system weights

* timestamp weights

* utility weight

* Fix overflow in weight calculations

* add back weight notes

* Update for whitelisted benchmarks

* add trait bounds

* Revert "add trait bounds"

This reverts commit 12b08b7189aa3969f96fa19b211a370860fdb240.

* Update weights for unaccounted for read
This commit is contained in:
Shawn Tabrizi
2020-08-17 22:59:23 +02:00
committed by GitHub
parent 93c73b6509
commit 74a583d147
14 changed files with 316 additions and 68 deletions
+9 -12
View File
@@ -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,29 +40,26 @@ benchmarks! {
_ { }
remark {
// # of Bytes
let b in 0 .. 16_384;
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)
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.
#[extra]
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,16 +139,15 @@ benchmarks! {
}
suicide {
let n in 1 .. 1000;
let caller: T::AccountId = account("caller", 0, SEED);
let account_info = AccountInfo::<T::Index, T::AccountData> {
nonce: n.into(),
nonce: 1337.into(),
refcount: 0,
data: T::AccountData::default()
};
frame_system::Account::<T>::insert(&caller, account_info);
let new_account_info = System::<T>::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::<T>::account(&caller);