Skip to content
Snippets Groups Projects

fix(wot): Identity should be removed after the consumers of the identity & membership revocation should not trigger identity removal

Merged Éloïs requested to merge elois-fix-57 into release/runtime-100
Files
4
@@ -220,12 +220,25 @@ where
WotDiffs::<T, I>::append(WotDiff::AddNode(*idty_index));
}
}
sp_membership::Event::<IdtyIndex, MetaData>::MembershipExpired(idty_index)
| sp_membership::Event::<IdtyIndex, MetaData>::MembershipRevoked(idty_index) => {
Self::dispath_idty_call(pallet_identity::Call::remove_identity {
idty_index: *idty_index,
idty_name: None,
});
// Membership expiration cases:
// Triggered by the membership pallet: we should remove the identity only for the main
// wot
sp_membership::Event::<IdtyIndex, MetaData>::MembershipExpired(idty_index) => {
if !T::IsSubWot::get() {
Self::dispath_idty_call(pallet_identity::Call::remove_identity {
idty_index: *idty_index,
idty_name: None,
});
WotDiffs::<T, I>::append(WotDiff::DisableNode(*idty_index));
}
}
// Membership revocation cases:
// - Triggered by identity removal: the identity underlying will by removed by the
// caller.
// - Triggered by the membership pallet: it's ondly possible for the sub-wot, so we
// should not remove the underlying identity
// So, in any case, we must do nothing
sp_membership::Event::<IdtyIndex, MetaData>::MembershipRevoked(idty_index) => {
if !T::IsSubWot::get() {
WotDiffs::<T, I>::append(WotDiff::DisableNode(*idty_index));
}
@@ -339,14 +352,10 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::OnRemovedCert<IdtyI
&& pallet_membership::Pallet::<T, I>::is_member(&receiver)
{
// Revoke receiver membership and disable their identity
if let Err(e) = pallet_membership::Pallet::<T, I>::revoke_membership(
RawOrigin::Root.into(),
Some(receiver),
) {
sp_std::if_std! {
println!("fail to revoke membership: {:?}", e)
}
}
Self::dispath_idty_call(pallet_identity::Call::remove_identity {
idty_index: receiver,
idty_name: None,
});
}
if !T::IsSubWot::get() {
WotDiffs::<T, I>::append(WotDiff::DelLink(issuer, receiver));
Loading