This repository was 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.7k
Store voters in unsorted bags to get good stake iteration properties #9081
Closed
Closed
Changes from 18 commits
Commits
Show all changes
101 commits
Select commit
Hold shift + click to select a range
a549691
start sketching out how voter bags might be implemented
coriolinus bdfabd2
storage getters and setters for Bag, Node
coriolinus 450c344
node getters and iterators for VoterList, Bag
coriolinus 21e79ee
simplify get_npos_voters
coriolinus f4998e2
simplify fn voters
coriolinus 8960daa
VoterList::insert
coriolinus f9d061d
VoterList::remove
coriolinus 1e7dfd9
nodes are doubly-linked
coriolinus 7f6460f
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus c6bcc76
impl fn update_position_for, update voter counts appropriately
coriolinus 82154dd
keep VoterBagFor updated
coriolinus 294cd99
manipulate VoterList everywhere which seems relevant
coriolinus 9787daf
start sketching out `notional_bag_for`
coriolinus a857f59
`notional_bag_for` doesn't need a type parameter
coriolinus 1a50bba
implement voter bag thresholds in terms of a precomputed list
coriolinus 5858569
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus 721c2cb
fix a failing test
coriolinus 92220ec
fix the rest of the non-benchmark tests
coriolinus 033d87f
revert an accidental change
coriolinus 18c8eef
adapt tests from benchmarking.rs for easier debugging
coriolinus 9bd6682
investigate a theory as to why the payout_stakers tests are failing
coriolinus 7a74fcf
Revert "investigate a theory as to why the payout_stakers tests are f…
coriolinus e0ae1c0
find threshold more directly
coriolinus 6699654
fix failing benchmark tests
coriolinus 871b525
debug_assert that voter count is accurate
coriolinus f221404
add extrinsic to rebag a stash
coriolinus 976c41b
WIP: rebag benchmark
coriolinus 37e666a
WIP: rebag benchmark
coriolinus b75b55b
make rebag test into a test case for easier debugging
coriolinus 1cb9e26
WIP: rebag benchmark
coriolinus c03d6ea
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus 27cbb79
fix rebag benchmark
coriolinus 247f2a1
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus b650861
reduce diff
coriolinus 9b53d4c
re-benchmark to add rebag
coriolinus ab048c6
add VoterList::regenerate()
coriolinus 5583ae4
add VoterList migration
coriolinus ae67ae7
add benchmark for regenerate
coriolinus efe15e2
remove redundant check
coriolinus fb5431e
debug assertions that `VoterList` and `CounterFor{Nominators,Validato…
coriolinus ee7959d
remove extra whitespace
coriolinus f58bb3a
only emit rebag event on success
coriolinus 1cd8730
Merge branch 'prgn-nominator-unsorted-bags' of github.com:paritytech/…
coriolinus 3c92eda
add doc explaining the term voter
coriolinus 22bc615
revamp/simplify rebag test
coriolinus 4092fa8
ensure genesis accounts are placed into the correct nodes/bags
coriolinus 2182abe
bond_extra implicitly rebags
coriolinus 472baa9
types at top; doc public type
coriolinus f1e7fe7
start sketching out adjustable thresholds
coriolinus 16e4774
add integrity test for voter bag threshold requirements
coriolinus 2a4ebf7
get rid of BagIdx
coriolinus cc6d0df
implement migration logic for when the threshold list changes
coriolinus 88195fe
start sketching out threshold proc macros
coriolinus 70848ea
further refine macro signatures
coriolinus b630321
WIP: implement make_ratio macro
coriolinus 8ce3bc0
start rethinking the process of producing threshold lists
coriolinus 202def0
write helper functions to emit voter bags module
coriolinus 4da8204
WIP: demo generating voter bags for a realistic runtime
coriolinus 498ab65
rm unnecessary arg_enum
coriolinus 734ea86
fix voter bags math
coriolinus 3cfa8cf
add computed voter bags thresholds to node
coriolinus a05df69
fixup some docs
coriolinus 2838b83
iter from large bags to small, fulfuilling the contract
coriolinus 3f17724
make tests compile
coriolinus b73fd7f
add VoterBagThresholds to some configs
coriolinus c719c5c
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus 4861789
ensure that iteration covers all voters even with implied final bag
coriolinus 59041b7
use sp_std::boxed::Box;
coriolinus 646f708
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus f5c8a4d
fix unused import
coriolinus 5e05e3f
add some more voter bags tests
coriolinus dbf3a84
file_header.txt
coriolinus 873005e
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus d5e0c8d
integrity test to ensure min bag exceeds existential weight
coriolinus dbfb951
add more debug assertions about node list length
coriolinus 06e69a8
rm unused imports
coriolinus df75e66
Merge branch 'master' of github.com:paritytech/substrate into prgn-no…
kianenigma 6f15cc3
Kian enters
kianenigma 1b545e4
Update frame/election-provider-support/src/onchain.rs
kianenigma e0a00fd
Suggestions for #9081 (Store voters in unsorted bags) (#9328)
emostov 008cacf
Merge master pre-fmt
emostov 48ccfc9
merge fallout
emostov 225eb47
Merge origin master with new formatting
emostov acc9183
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov 1c56016
Run cargo +nightly fmt
emostov 1f02cb4
Fix a bunch of stuff, remove not needed runtime arg of make-bags
kianenigma 2f83f16
add logs
kianenigma abb61c1
Merge branch 'master' of github.com:paritytech/substrate into prgn-no…
kianenigma 0df47b0
Glue the new staking bags to the election snapshot (#9415)
kianenigma c1c4fcd
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov 2c5a20c
Merge branch 'master' of https://github.com/paritytech/substrate into…
emostov 8706404
Update node runtime with VoterSnapshotPerBlock
emostov 98a4b1f
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov ced6077
Unit test for pallet-staking unsorted bags feature (targets #9081) (#…
emostov da4814c
Try prepare for master merge
emostov d20278a
Try merge origin master
emostov 530e4d2
Reduce diff
emostov 99bd08b
Try merge origin master
emostov df990d3
Add comment for test to add
emostov 1632747
Add in code TODO for update_position efficiency updates
emostov dc3328e
Try merge origin master
emostov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) 2021 Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Make the set of voting bag thresholds to be used in `voter_bags.rs`. | ||
|
|
||
| use pallet_staking::voter_bags::N_BAGS; | ||
|
|
||
| fn main() { | ||
| let ratio = ((u64::MAX as f64).ln() / (N_BAGS as f64)).exp(); | ||
| println!("pub const CONSTANT_RATIO: f64 = {};", ratio); | ||
|
|
||
| let mut thresholds = Vec::with_capacity(N_BAGS as usize); | ||
|
|
||
| while thresholds.len() < N_BAGS as usize { | ||
| let prev_item: u64 = thresholds.last().copied().unwrap_or_default(); | ||
| let item = (prev_item as f64 * ratio).max(prev_item as f64 + 1.0); | ||
| thresholds.push(item as u64); | ||
| } | ||
|
|
||
| *thresholds.last_mut().unwrap() = u64::MAX; | ||
|
|
||
| println!("pub const THRESHOLDS: [u64; {}] = {:#?};", N_BAGS, thresholds); | ||
|
|
||
| debug_assert_eq!(thresholds.len(), N_BAGS as usize); | ||
| debug_assert_eq!(*thresholds.last().unwrap(), u64::MAX); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.