Skip to content
Snippets Groups Projects
Unverified Commit c4c9a67a authored by bgallois's avatar bgallois
Browse files

add weight for on_removed_wot_member

parent 3240a1aa
No related branches found
No related tags found
1 merge request!246Fix weight accounting
......@@ -96,6 +96,28 @@ mod benchmarks {
Ok(())
}
#[benchmark]
fn on_removed_wot_member() {
let idty: T::IdtyIndex = 1.into();
assert!(Smiths::<T>::get(idty).is_some());
#[block]
{
Pallet::<T>::on_removed_wot_member(idty);
}
}
#[benchmark]
fn on_removed_wot_member_empty() {
let idty: T::IdtyIndex = 100.into();
assert!(Smiths::<T>::get(idty).is_none());
#[block]
{
Pallet::<T>::on_removed_wot_member(idty);
}
}
impl_benchmark_test_suite!(
Pallet,
crate::mock::new_test_ext(crate::GenesisConfig {
......
......@@ -35,6 +35,7 @@ use frame_support::dispatch::DispatchResultWithPostInfo;
use frame_support::ensure;
use frame_support::pallet_prelude::Get;
use frame_support::pallet_prelude::RuntimeDebug;
use frame_support::pallet_prelude::Weight;
use frame_system::ensure_signed;
use frame_system::pallet_prelude::OriginFor;
use scale_info::TypeInfo;
......@@ -491,10 +492,13 @@ impl<T: Config> Pallet<T> {
}
}
pub fn on_removed_wot_member(idty_index: T::IdtyIndex) {
pub fn on_removed_wot_member(idty_index: T::IdtyIndex) -> Weight {
let mut weight = T::WeightInfo::on_removed_wot_member_empty();
if Smiths::<T>::get(idty_index).is_some() {
Self::_do_exclude_smith(idty_index, SmithRemovalReason::LostMembership);
weight += T::WeightInfo::on_removed_wot_member();
}
weight
}
fn _do_exclude_smith(receiver: T::IdtyIndex, reason: SmithRemovalReason) {
......
......@@ -23,6 +23,8 @@ pub trait WeightInfo {
fn invite_smith() -> Weight;
fn accept_invitation() -> Weight;
fn certify_smith() -> Weight;
fn on_removed_wot_member() -> Weight;
fn on_removed_wot_member_empty() -> Weight;
}
impl WeightInfo for () {
......@@ -37,4 +39,12 @@ impl WeightInfo for () {
fn certify_smith() -> Weight {
Weight::zero()
}
fn on_removed_wot_member() -> Weight {
Weight::zero()
}
fn on_removed_wot_member_empty() -> Weight {
Weight::zero()
}
}
......@@ -29,7 +29,7 @@
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=*
// --pallet=pallet-smith-members
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
......@@ -63,8 +63,8 @@ impl<T: frame_system::Config> pallet_smith_members::WeightInfo for WeightInfo<T>
// Proof Size summary in bytes:
// Measured: `765`
// Estimated: `6705`
// Minimum execution time: 24_686_000 picoseconds.
Weight::from_parts(25_681_000, 0)
// Minimum execution time: 25_042_000 picoseconds.
Weight::from_parts(25_821_000, 0)
.saturating_add(Weight::from_parts(0, 6705))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -77,8 +77,8 @@ impl<T: frame_system::Config> pallet_smith_members::WeightInfo for WeightInfo<T>
// Proof Size summary in bytes:
// Measured: `496`
// Estimated: `3961`
// Minimum execution time: 12_957_000 picoseconds.
Weight::from_parts(13_677_000, 0)
// Minimum execution time: 12_694_000 picoseconds.
Weight::from_parts(13_495_000, 0)
.saturating_add(Weight::from_parts(0, 3961))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
......@@ -97,10 +97,47 @@ impl<T: frame_system::Config> pallet_smith_members::WeightInfo for WeightInfo<T>
// Proof Size summary in bytes:
// Measured: `626`
// Estimated: `6566`
// Minimum execution time: 23_890_000 picoseconds.
Weight::from_parts(24_849_000, 0)
// Minimum execution time: 23_095_000 picoseconds.
Weight::from_parts(24_363_000, 0)
.saturating_add(Weight::from_parts(0, 6566))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `SmithMembers::Smiths` (r:3 w:3)
/// Proof: `SmithMembers::Smiths` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `AuthorityMembers::Members` (r:1 w:1)
/// Proof: `AuthorityMembers::Members` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `AuthorityMembers::OnlineAuthorities` (r:1 w:1)
/// Proof: `AuthorityMembers::OnlineAuthorities` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `AuthorityMembers::OutgoingAuthorities` (r:1 w:1)
/// Proof: `AuthorityMembers::OutgoingAuthorities` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `AuthorityMembers::IncomingAuthorities` (r:1 w:1)
/// Proof: `AuthorityMembers::IncomingAuthorities` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Session::NextKeys` (r:1 w:1)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`)
/// Storage: `Session::KeyOwner` (r:0 w:4)
/// Proof: `Session::KeyOwner` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn on_removed_wot_member() -> Weight {
// Proof Size summary in bytes:
// Measured: `911`
// Estimated: `9326`
// Minimum execution time: 49_566_000 picoseconds.
Weight::from_parts(52_187_000, 0)
.saturating_add(Weight::from_parts(0, 9326))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(13))
}
/// Storage: `SmithMembers::Smiths` (r:1 w:0)
/// Proof: `SmithMembers::Smiths` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn on_removed_wot_member_empty() -> Weight {
// Proof Size summary in bytes:
// Measured: `187`
// Estimated: `3652`
// Minimum execution time: 2_864_000 picoseconds.
Weight::from_parts(3_005_000, 0)
.saturating_add(Weight::from_parts(0, 3652))
.saturating_add(T::DbWeight::get().reads(1))
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment