You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
#9081 introduces a VoterList abstraction to the staking pallet, which uses a number of storage items to implement a data structure that stores voters in based on vote weight in bags made of linked lists.
However, we don't require a mandatory data structure dictating how voters are iterated, as long as we have an iterator that gives the voters in desired order. We can make create a trait, VoterListProvider, that would provide a voter list. The voter_bags module can then be turned into a pallet that implements the trait.
An example use case: we can roll out the voter bags to just Kusama to see how it goes before adding the change to Polkadot. (Previously @shawntabrizi mentioned some other ideas to achieve the same goal, like feature gating voter bags.)
Rough initial trait:
traitVoterListProvider{// Returns iterator over voter list, which can have `take` called on it.fnget_voters() -> implIterator<Item = VoterData>{}// Hook for updating the list when a voter is added, or their vote weight changes.fnon_voter_update(voter:AccountId){}// Hook for removing a voter from the listfnon_voter_removed(){}// Returns function for getting voters weight (may not be necessary)fnweight_of_fn() -> -> Box<dynFn(&T::AccountId) -> VoteWeight>{}}
and a stub implementation not using voter bags
structStakingVoterListStub;implVoterListProviderforStakingVoterListStub{fnget_voters() -> implIterator<Item = VoterData>{
<pallet_staking::Pallet<T>>::nominators().map(|(v, _)| voter_data(v))}// Hook not usedfnon_new_voter(_voter:AccountId){}// Hook not used fnon_voter_removed(){}// Probably not neccesaryfnweight_of_fn() -> -> Box<dynFn(&T::AccountId) -> VoteWeight>{let issuance = T::Currency::total_issuance();Box::new(move |who:&T::AccountId| -> VoteWeight{Self::slashable_balance_of_vote_weight(who, issuance)})}}
#9081 introduces a
VoterList
abstraction to the staking pallet, which uses a number of storage items to implement a data structure that stores voters in based on vote weight in bags made of linked lists.However, we don't require a mandatory data structure dictating how voters are iterated, as long as we have an iterator that gives the voters in desired order. We can make create a trait,
VoterListProvider
, that would provide a voter list. Thevoter_bags
module can then be turned into a pallet that implements the trait.An example use case: we can roll out the voter bags to just Kusama to see how it goes before adding the change to Polkadot. (Previously @shawntabrizi mentioned some other ideas to achieve the same goal, like feature gating voter bags.)
Rough initial trait:
and a stub implementation not using voter bags
cc @kianenigma
The text was updated successfully, but these errors were encountered: