From 6f5adcdfe8fef0acc42da4ae9ca29b2c50ed634b Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Sat, 26 Nov 2022 09:58:57 +0100 Subject: [PATCH] Fix minor storage leak; clean-up `BurnedBootstrapperNewbieTickets` and `BurnedReputableNewbieTickets` (#285) * [ceremonies] clean-up `BurnedReputableNewbieTickets` in `purge_community_ceremony` * [ceremonies] clean-up `BurnedBootstrapperNewbieTickets` in `purge_community` * [ceremonies] add minor documentation about endorsees --- ceremonies/src/lib.rs | 8 ++++++++ ceremonies/src/tests.rs | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/ceremonies/src/lib.rs b/ceremonies/src/lib.rs index 5e0a981a..e6d793b6 100644 --- a/ceremonies/src/lib.rs +++ b/ceremonies/src/lib.rs @@ -917,6 +917,10 @@ pub mod pallet { ValueQuery, >; + /// Accounts that have been endorsed by a reputable or a bootstrapper. + /// + /// This is not the same as `EndorseeRegistry`, which contains the `Endorsees` who + /// have registered for a meetup. #[pallet::storage] #[pallet::getter(fn endorsees)] pub(super) type Endorsees = StorageDoubleMap< @@ -1313,6 +1317,7 @@ impl Pallet { >::remove_prefix(cc, None); >::remove_prefix(cc, None); + >::remove_prefix(cc, None); Self::deposit_event(Event::CommunityCeremonyHistoryPurged(cindex, cid)); } @@ -1491,6 +1496,9 @@ impl Pallet { >::remove(cid); + #[allow(deprecated)] + >::remove_prefix(cid, None); + >::remove_community(cid); } diff --git a/ceremonies/src/tests.rs b/ceremonies/src/tests.rs index 98d3ccb6..feca1a3f 100644 --- a/ceremonies/src/tests.rs +++ b/ceremonies/src/tests.rs @@ -1781,6 +1781,8 @@ fn grow_population_and_removing_community_works() { // only sanity check. Community removal is better tested in the communities pallet. assert_eq!(EncointerCommunities::community_identifiers().contains(&cid), false); + assert_eq!(BurnedBootstrapperNewbieTickets::::iter_prefix(cid).next(), None); + for cindex in current_cindex.saturating_sub(reputation_lifetime)..=current_cindex { assert_eq!( BootstrapperRegistry::::iter_prefix((cid, cindex)).next(), @@ -1824,6 +1826,11 @@ fn grow_population_and_removing_community_works() { assert_eq!(IssuedRewards::::iter_prefix((cid, cindex)).next(), None); + assert_eq!( + BurnedReputableNewbieTickets::::iter_prefix((cid, cindex)).next(), + None + ); + assert_eq!(InactivityCounters::::contains_key(cid), false); } });