This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Implement pallet-bags-list
and its interfaces with pallet-staking
#9507
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: Kian Paimani <[email protected]>
…substrate into prgn-nominator-unsorted-bags
This reorganizes bag storage such that bags are always referred to by their upper threshold. This in turn means that adding and removing bags is cheaper; you only need to migrate certain voters, not all of them.
The macro approach seems to be a non-starter; that only really works if we're throwing around numeric literals everywhere, and that's just not nice in this case. Instead, let's write helper functions and make it really easy to generate the tables in separate, permanent files, which humans can then edit.
This isn't yet done, becuase it seems to take a Very Long Time to run, and it really shouldn't. Need to look into that. Still, it's a lot closer than it was this morning.
Turns out that when you're working in exponential space, you need to divide, not subtract, in order to keep the math working properly. Also neaten up the output a little bit to make it easier to read.
bot merge force |
Trying merge. |
Merge failed: "3 of 8 required status checks have not succeeded: 1 expected, 1 failing, and 1 pending." |
bot merge |
Trying merge. |
Merge failed: "Required status check "continuous-integration/gitlab-check-polkadot-companion-build" is failing." |
bot merge |
Trying merge. |
ghost
deleted the
zeke-voter-bags-module
branch
September 17, 2021 02:25
11 tasks
kianenigma
added
B7-runtimenoteworthy
and removed
B0-silent
Changes should not be mentioned in any release notes
labels
Oct 7, 2021
25 tasks
This pull request was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
A0-please_review
Pull request needs code review.
C1-low
PR touches the given topic and has a low impact on builders.
D1-audited 👍
PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #9440
polkadot companion paritytech/polkadot#3413
Notes for reviewers
Below is a table describing how an extrinsic would affect an account (relative to
SortedListProvider
andCounterForNominators
) given its role in staking:TODO:
do_rebag
to force a rebag (relates to some work done in Force bag changes in relevant benchmarks (targets #9507) #9529)pallet-bags-list
and its interfaces withpallet-staking
#9507 (comment)voter
inbags-list
, it should beid
andvote-weight
. Ideally we could also use something likepriority
instead ofvote-weight
.SortedListProvider
with random data and calls, and the internal state of the pallet should always remain correct. (Fuzzer for Pallet Bags List #9851)original description for #9081 below:
Problem: there are too many nominators, we can't keep all of them.
Solution: truncate the list by stake.
Problem: an attacker can kick out as many people as they can afford to; those people at the low end would need to re-nominate.
Solution: don't actually take them out of the nominator set, but compute the top N members at runtime.
Problem: computing the top N at runtime is expensive.
Solution: create many bags, each of which holds voters within a particular stake range. Each bag is a linked list, so it can be added to and removed from in
O(1)
. We can then iterate over the bags in order and truncate anywhere we desire. Given a realistic distribution of stake, it doesn't matter where we stop; the final bag is the one with the lowest-staked individuals.polkadot companion: paritytech/polkadot#3413