From 2aae3023cd6accb4ec6cdeb4339884b6deafb863 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Sat, 25 Nov 2023 18:12:28 +0100 Subject: [PATCH] remove handlers weights for pallet_identity --- pallets/duniter-account/src/lib.rs | 5 +---- pallets/duniter-wot/src/lib.rs | 3 +-- pallets/identity/src/traits.rs | 8 ++------ pallets/quota/src/lib.rs | 4 +--- runtime/common/src/handlers.rs | 3 +-- 5 files changed, 6 insertions(+), 17 deletions(-) diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index cf38dba4e..d7c5127bc 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -484,7 +484,7 @@ where // implement identity event handler impl<T: Config> pallet_identity::traits::OnIdtyChange<T> for Pallet<T> { - fn on_idty_change(idty_id: IdtyIdOf<T>, idty_event: &IdtyEvent<T>) -> Weight { + fn on_idty_change(idty_id: IdtyIdOf<T>, idty_event: &IdtyEvent<T>) { match idty_event { // link account to newly created identity IdtyEvent::Created { owner_key, .. } => { @@ -495,8 +495,5 @@ impl<T: Config> pallet_identity::traits::OnIdtyChange<T> for Pallet<T> { | IdtyEvent::ChangedOwnerKey { .. } | IdtyEvent::Removed { .. } => {} } - // The weight accounting is performed where the handler is called. - // See in pallet-identity. - Weight::zero() } } diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index 38951486b..ed1c4fcff 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -363,7 +363,7 @@ where // implement identity event handler impl<T: Config<I>, I: 'static> pallet_identity::traits::OnIdtyChange<T> for Pallet<T, I> { - fn on_idty_change(idty_index: IdtyIndex, idty_event: &IdtyEvent<T>) -> Weight { + fn on_idty_change(idty_index: IdtyIndex, idty_event: &IdtyEvent<T>) { match idty_event { IdtyEvent::Created { creator, .. } => { if let Err(e) = <pallet_certification::Pallet<T, I>>::do_add_cert_checked( @@ -394,7 +394,6 @@ impl<T: Config<I>, I: 'static> pallet_identity::traits::OnIdtyChange<T> for Pall } IdtyEvent::Confirmed | IdtyEvent::ChangedOwnerKey { .. } => {} } - Weight::zero() } } diff --git a/pallets/identity/src/traits.rs b/pallets/identity/src/traits.rs index 86acc604b..ae7bedf48 100644 --- a/pallets/identity/src/traits.rs +++ b/pallets/identity/src/traits.rs @@ -55,17 +55,13 @@ pub trait IdtyNameValidator { } pub trait OnIdtyChange<T: Config> { - fn on_idty_change(idty_index: T::IdtyIndex, idty_event: &IdtyEvent<T>) -> Weight; + fn on_idty_change(idty_index: T::IdtyIndex, idty_event: &IdtyEvent<T>); } #[impl_for_tuples(5)] #[allow(clippy::let_and_return)] impl<T: Config> OnIdtyChange<T> for Tuple { - fn on_idty_change(idty_index: T::IdtyIndex, idty_event: &IdtyEvent<T>) -> Weight { - let mut weight = Weight::zero(); - for_tuples!( #( weight = weight.saturating_add(Tuple::on_idty_change(idty_index, idty_event)); )* ); - weight - } + fn on_idty_change(idty_index: T::IdtyIndex, idty_event: &IdtyEvent<T>) {} } pub trait RemoveIdentityConsumers<IndtyIndex> { diff --git a/pallets/quota/src/lib.rs b/pallets/quota/src/lib.rs index eff611f21..85b4492d4 100644 --- a/pallets/quota/src/lib.rs +++ b/pallets/quota/src/lib.rs @@ -338,7 +338,7 @@ fn is_eligible_for_refund<T: pallet_identity::Config>(_identity: IdtyId<T>) -> b // implement identity event handler impl<T: Config> pallet_identity::traits::OnIdtyChange<T> for Pallet<T> { - fn on_idty_change(idty_id: IdtyId<T>, idty_event: &IdtyEvent<T>) -> Weight { + fn on_idty_change(idty_id: IdtyId<T>, idty_event: &IdtyEvent<T>) { match idty_event { // initialize quota on identity creation IdtyEvent::Created { .. } => { @@ -355,7 +355,5 @@ impl<T: Config> pallet_identity::traits::OnIdtyChange<T> for Pallet<T> { } IdtyEvent::Confirmed | IdtyEvent::Validated | IdtyEvent::ChangedOwnerKey { .. } => {} } - // TODO proper weight - Weight::zero() } } diff --git a/runtime/common/src/handlers.rs b/runtime/common/src/handlers.rs index 540054ab3..d59ff5da5 100644 --- a/runtime/common/src/handlers.rs +++ b/runtime/common/src/handlers.rs @@ -45,7 +45,7 @@ where T: pallet_identity::Config<IdtyIndex = IdtyIndex, IdtyData = IdtyData>, T: pallet_universal_dividend::Config, { - fn on_idty_change(idty_index: IdtyIndex, idty_event: &IdtyEvent<T>) -> Weight { + fn on_idty_change(idty_index: IdtyIndex, idty_event: &IdtyEvent<T>) { match idty_event { IdtyEvent::Validated => { // when identity is validated, it starts getting right to UD @@ -64,7 +64,6 @@ where } IdtyEvent::Created { .. } | IdtyEvent::Confirmed | IdtyEvent::Removed { .. } => {} } - Weight::zero() } } -- GitLab