Document weight for asset, system and timestamp pallets (#5593)

Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Alexander Popiak
2020-04-24 12:00:07 +02:00
committed by GitHub
parent 8ac2bac58d
commit 61f383a116
3 changed files with 86 additions and 0 deletions
+55
View File
@@ -494,12 +494,21 @@ decl_module! {
}
/// Make some on-chain remark.
///
/// # <weight>
/// - `O(1)`
/// # </weight>
#[weight = MINIMUM_WEIGHT]
fn remark(origin, _remark: Vec<u8>) {
ensure_signed(origin)?;
}
/// Set the number of pages in the WebAssembly environment's heap.
///
/// # <weight>
/// - `O(1)`
/// - 1 storage write.
/// # </weight>
#[weight = (MINIMUM_WEIGHT, DispatchClass::Operational)]
fn set_heap_pages(origin, pages: u64) {
ensure_root(origin)?;
@@ -507,6 +516,13 @@ decl_module! {
}
/// Set the new runtime code.
///
/// # <weight>
/// - `O(C + S)` where `C` length of `code` and `S` complexity of `can_set_code`
/// - 1 storage write (codec `O(C)`).
/// - 1 call to `can_set_code`: `O(S)` (calls `sp_io::misc::runtime_version` which is expensive).
/// - 1 event.
/// # </weight>
#[weight = (200_000_000, DispatchClass::Operational)]
pub fn set_code(origin, code: Vec<u8>) {
Self::can_set_code(origin, &code)?;
@@ -516,6 +532,12 @@ decl_module! {
}
/// Set the new runtime code without doing any checks of the given `code`.
///
/// # <weight>
/// - `O(C)` where `C` length of `code`
/// - 1 storage write (codec `O(C)`).
/// - 1 event.
/// # </weight>
#[weight = (200_000_000, DispatchClass::Operational)]
pub fn set_code_without_checks(origin, code: Vec<u8>) {
ensure_root(origin)?;
@@ -524,6 +546,12 @@ decl_module! {
}
/// Set the new changes trie configuration.
///
/// # <weight>
/// - `O(D)` where `D` length of `Digest`
/// - 1 storage write or delete (codec `O(1)`).
/// - 1 call to `deposit_log`: `O(D)` (which depends on the length of `Digest`)
/// # </weight>
#[weight = (20_000_000, DispatchClass::Operational)]
pub fn set_changes_trie_config(origin, changes_trie_config: Option<ChangesTrieConfiguration>) {
ensure_root(origin)?;
@@ -542,6 +570,11 @@ decl_module! {
}
/// Set some items of storage.
///
/// # <weight>
/// - `O(I)` where `I` length of `items`
/// - `I` storage writes (`O(1)`).
/// # </weight>
#[weight = (MINIMUM_WEIGHT, DispatchClass::Operational)]
fn set_storage(origin, items: Vec<KeyValue>) {
ensure_root(origin)?;
@@ -551,6 +584,11 @@ decl_module! {
}
/// Kill some items from storage.
///
/// # <weight>
/// - `O(VK)` where `V` length of `keys` and `K` length of one key
/// - `V` storage deletions.
/// # </weight>
#[weight = (MINIMUM_WEIGHT, DispatchClass::Operational)]
fn kill_storage(origin, keys: Vec<Key>) {
ensure_root(origin)?;
@@ -560,6 +598,11 @@ decl_module! {
}
/// Kill all storage items with a key that starts with the given prefix.
///
/// # <weight>
/// - `O(P)` where `P` amount of keys with prefix `prefix`
/// - `P` storage deletions.
/// # </weight>
#[weight = (MINIMUM_WEIGHT, DispatchClass::Operational)]
fn kill_prefix(origin, prefix: Key) {
ensure_root(origin)?;
@@ -568,6 +611,13 @@ decl_module! {
/// Kill the sending account, assuming there are no references outstanding and the composite
/// data is equal to its default value.
///
/// # <weight>
/// - `O(K)` with `K` being complexity of `on_killed_account`
/// - 1 storage read and deletion.
/// - 1 call to `on_killed_account` callback with unknown complexity `K`
/// - 1 event.
/// # </weight>
#[weight = (25_000_000, DispatchClass::Operational)]
fn suicide(origin) {
let who = ensure_signed(origin)?;
@@ -924,6 +974,11 @@ impl<T: Trait> Module<T> {
}
/// Deposits a log and ensures it matches the block's log data.
///
/// # <weight>
/// - `O(D)` where `D` length of `Digest`
/// - 1 storage mutation (codec `O(D)`).
/// # </weight>
pub fn deposit_log(item: DigestItemOf<T>) {
let mut l = <Digest<T>>::get();
l.push(item);