From 3826a96e711b84aee3c12c95146107763e3200dd Mon Sep 17 00:00:00 2001 From: Adel Golghalyani <48685760+Ad96el@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:15:29 +0100 Subject: [PATCH] chore: add weightinfo to runtime (#606) ## Add weightinfo This PR adds the weighinfo for the peregrine runtime for dip provider and storage. --- runtimes/peregrine/src/dip/mod.rs | 8 +- runtimes/peregrine/src/weights/mod.rs | 2 + .../src/weights/pallet_deposit_storage.rs | 86 ++++++++++++ .../src/weights/pallet_dip_provider.rs | 126 ++++++++++++++++++ 4 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 runtimes/peregrine/src/weights/pallet_deposit_storage.rs create mode 100644 runtimes/peregrine/src/weights/pallet_dip_provider.rs diff --git a/runtimes/peregrine/src/dip/mod.rs b/runtimes/peregrine/src/dip/mod.rs index 73cb569f9..22d00a44e 100644 --- a/runtimes/peregrine/src/dip/mod.rs +++ b/runtimes/peregrine/src/dip/mod.rs @@ -27,7 +27,7 @@ use sp_core::ConstU32; use crate::{ dip::deposit::{DepositCollectorHooks, DepositHooks, DepositNamespace}, - Balances, Runtime, RuntimeEvent, RuntimeHoldReason, + weights, Balances, Runtime, RuntimeEvent, RuntimeHoldReason, }; pub(crate) mod deposit; @@ -47,8 +47,7 @@ impl pallet_dip_provider::Config for Runtime { type IdentityProvider = LinkedDidInfoProvider; type ProviderHooks = DepositCollectorHooks; type RuntimeEvent = RuntimeEvent; - // TODO: Change after benchmarks - type WeightInfo = (); + type WeightInfo = weights::pallet_dip_provider::WeightInfo; } impl pallet_deposit_storage::Config for Runtime { @@ -64,6 +63,5 @@ impl pallet_deposit_storage::Config for Runtime { type Namespace = DepositNamespace; type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; - // TODO: Change after benchmarks - type WeightInfo = (); + type WeightInfo = weights::pallet_deposit_storage::WeightInfo; } diff --git a/runtimes/peregrine/src/weights/mod.rs b/runtimes/peregrine/src/weights/mod.rs index b75e910ee..b642d2c5c 100644 --- a/runtimes/peregrine/src/weights/mod.rs +++ b/runtimes/peregrine/src/weights/mod.rs @@ -25,7 +25,9 @@ pub mod pallet_balances; pub mod pallet_collective; pub mod pallet_configuration; pub mod pallet_democracy; +pub mod pallet_deposit_storage; pub mod pallet_did_lookup; +pub mod pallet_dip_provider; pub mod pallet_indices; pub mod pallet_inflation; pub mod pallet_membership; diff --git a/runtimes/peregrine/src/weights/pallet_deposit_storage.rs b/runtimes/peregrine/src/weights/pallet_deposit_storage.rs new file mode 100644 index 000000000..68cbf24d1 --- /dev/null +++ b/runtimes/peregrine/src/weights/pallet_deposit_storage.rs @@ -0,0 +1,86 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_deposit_storage` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-01-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `eyrie-7`, CPU: `Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/kilt-parachain +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --chain=dev +// --pallet=pallet-deposit-storage +// --extrinsic=* +// --output=./runtimes/peregrine/src/weights/pallet_deposit_storage.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_deposit_storage`. +pub struct WeightInfo(PhantomData); +impl pallet_deposit_storage::WeightInfo for WeightInfo { + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(103), added: 2578, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + fn reclaim_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `888` + // Estimated: `4414` + // Minimum execution time: 58_537_000 picoseconds. + Weight::from_parts(59_466_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_reclaim_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/runtimes/peregrine/src/weights/pallet_dip_provider.rs b/runtimes/peregrine/src/weights/pallet_dip_provider.rs new file mode 100644 index 000000000..31f86bfa6 --- /dev/null +++ b/runtimes/peregrine/src/weights/pallet_dip_provider.rs @@ -0,0 +1,126 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_dip_provider` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-01-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `eyrie-7`, CPU: `Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/kilt-parachain +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --chain=dev +// --pallet=pallet-dip-provider +// --extrinsic=* +// --output=./runtimes/peregrine/src/weights/pallet_dip_provider.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_dip_provider`. +pub struct WeightInfo(PhantomData); +impl pallet_dip_provider::WeightInfo for WeightInfo { + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:11 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(103), added: 2578, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn commit_identity() -> Weight { + // Proof Size summary in bytes: + // Measured: `3427` + // Estimated: `29282` + // Minimum execution time: 213_866_000 picoseconds. + Weight::from_parts(219_534_000, 0) + .saturating_add(Weight::from_parts(0, 29282)) + .saturating_add(T::DbWeight::get().reads(19)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(103), added: 2578, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn delete_identity_commitment() -> Weight { + // Proof Size summary in bytes: + // Measured: `1083` + // Estimated: `4414` + // Minimum execution time: 61_294_000 picoseconds. + Weight::from_parts(61_873_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_commit_identity() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 29282 + ); + } + #[test] + fn test_delete_identity_commitment() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +}