use counted maps instead of counters in authority members
pallet authority members has storage items like AuthoritiesCounter
for counting elements. It is error prone and could be replaced by CountedStorageMap
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Hugo Trentesaux changed milestone to %Horizon
changed milestone to %Horizon
- Cédric Moreau changed milestone to %runtime-800
changed milestone to %runtime-800
- Cédric Moreau assigned to @c-geek
assigned to @c-geek
- Cédric Moreau added D-easy P7-nicetohave labels
added D-easy P7-nicetohave labels
- Cédric Moreau added RN-runtime label
added RN-runtime label
- Cédric Moreau created branch
148-use-counted-maps-instead-of-counters-in-authority-members
to address this issuecreated branch
148-use-counted-maps-instead-of-counters-in-authority-members
to address this issue - Cédric Moreau mentioned in merge request !224 (merged)
mentioned in merge request !224 (merged)
- Owner
We cannot use
CountedStorageMap
directly.As far as I understand :
AuthoritiesCounter = OnlineAuthorities.len() + IncomingAuthorities.len() - OutgoingAuthorities.len()
. But these are vectors, not maps. 1 Collapse replies - Author Owner
You are right. I think I added the issue too quickly after seeing that we have:
- 4 calls to
AuthoritiesCounter::<T>::mutate
- 1 call to
AuthoritiesCounter::<T>::get()
The only use of authorities counter is to check that
go_online
is allowed and we could instead compute it as you write it:OnlineAuthorities.len() + IncomingAuthorities.len() - OutgoingAuthorities.len()
.Not a big deal though.
- 4 calls to
- Owner
Well, you were right about the "error prone": there was a bug in the pallet (value should have been decremented instead of incremented): !224 (diffs)
1 - Owner
It is even worse: the
saturating_add
had no effect onAuthoritiesCounter
.I've added a revealing test + fix.
1
- Cédric Moreau mentioned in commit 58ba354f
mentioned in commit 58ba354f
- Cédric Moreau mentioned in commit ec23a846
mentioned in commit ec23a846
- Cédric Moreau mentioned in commit 6c35d792
mentioned in commit 6c35d792
- Cédric Moreau mentioned in commit 64bc018b
mentioned in commit 64bc018b
- Cédric Moreau mentioned in commit 8ba0678d
mentioned in commit 8ba0678d
- Cédric Moreau mentioned in commit 0e9cf55d
mentioned in commit 0e9cf55d
- Cédric Moreau mentioned in commit d62c033a
mentioned in commit d62c033a
- Cédric Moreau mentioned in commit 874d1c93
mentioned in commit 874d1c93
- Cédric Moreau closed with merge request !224 (merged)
closed with merge request !224 (merged)