Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 Jun 11, 2021
bdfabd2
storage getters and setters for Bag, Node
coriolinus Jun 11, 2021
450c344
node getters and iterators for VoterList, Bag
coriolinus Jun 11, 2021
21e79ee
simplify get_npos_voters
coriolinus Jun 11, 2021
f4998e2
simplify fn voters
coriolinus Jun 11, 2021
8960daa
VoterList::insert
coriolinus Jun 11, 2021
f9d061d
VoterList::remove
coriolinus Jun 11, 2021
1e7dfd9
nodes are doubly-linked
coriolinus Jun 14, 2021
7f6460f
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jun 14, 2021
c6bcc76
impl fn update_position_for, update voter counts appropriately
coriolinus Jun 14, 2021
82154dd
keep VoterBagFor updated
coriolinus Jun 14, 2021
294cd99
manipulate VoterList everywhere which seems relevant
coriolinus Jun 15, 2021
9787daf
start sketching out `notional_bag_for`
coriolinus Jun 15, 2021
a857f59
`notional_bag_for` doesn't need a type parameter
coriolinus Jun 15, 2021
1a50bba
implement voter bag thresholds in terms of a precomputed list
coriolinus Jun 17, 2021
5858569
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jun 18, 2021
721c2cb
fix a failing test
coriolinus Jun 18, 2021
92220ec
fix the rest of the non-benchmark tests
coriolinus Jun 18, 2021
033d87f
revert an accidental change
coriolinus Jun 21, 2021
18c8eef
adapt tests from benchmarking.rs for easier debugging
coriolinus Jun 21, 2021
9bd6682
investigate a theory as to why the payout_stakers tests are failing
coriolinus Jun 21, 2021
7a74fcf
Revert "investigate a theory as to why the payout_stakers tests are f…
coriolinus Jun 21, 2021
e0ae1c0
find threshold more directly
coriolinus Jun 24, 2021
6699654
fix failing benchmark tests
coriolinus Jun 24, 2021
871b525
debug_assert that voter count is accurate
coriolinus Jun 24, 2021
f221404
add extrinsic to rebag a stash
coriolinus Jun 24, 2021
976c41b
WIP: rebag benchmark
coriolinus Jun 24, 2021
37e666a
WIP: rebag benchmark
coriolinus Jun 25, 2021
b75b55b
make rebag test into a test case for easier debugging
coriolinus Jun 25, 2021
1cb9e26
WIP: rebag benchmark
coriolinus Jun 25, 2021
c03d6ea
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jun 28, 2021
27cbb79
fix rebag benchmark
coriolinus Jun 28, 2021
247f2a1
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jun 28, 2021
b650861
reduce diff
coriolinus Jun 28, 2021
9b53d4c
re-benchmark to add rebag
coriolinus Jun 29, 2021
ab048c6
add VoterList::regenerate()
coriolinus Jun 29, 2021
5583ae4
add VoterList migration
coriolinus Jun 29, 2021
ae67ae7
add benchmark for regenerate
coriolinus Jun 30, 2021
efe15e2
remove redundant check
coriolinus Jun 30, 2021
fb5431e
debug assertions that `VoterList` and `CounterFor{Nominators,Validato…
coriolinus Jun 30, 2021
ee7959d
remove extra whitespace
coriolinus Jun 30, 2021
f58bb3a
only emit rebag event on success
coriolinus Jun 30, 2021
1cd8730
Merge branch 'prgn-nominator-unsorted-bags' of github.com:paritytech/…
coriolinus Jun 30, 2021
3c92eda
add doc explaining the term voter
coriolinus Jun 30, 2021
22bc615
revamp/simplify rebag test
coriolinus Jun 30, 2021
4092fa8
ensure genesis accounts are placed into the correct nodes/bags
coriolinus Jun 30, 2021
2182abe
bond_extra implicitly rebags
coriolinus Jun 30, 2021
472baa9
types at top; doc public type
coriolinus Jun 30, 2021
f1e7fe7
start sketching out adjustable thresholds
coriolinus Jun 29, 2021
16e4774
add integrity test for voter bag threshold requirements
coriolinus Jun 29, 2021
2a4ebf7
get rid of BagIdx
coriolinus Jun 30, 2021
cc6d0df
implement migration logic for when the threshold list changes
coriolinus Jul 1, 2021
88195fe
start sketching out threshold proc macros
coriolinus Jul 1, 2021
70848ea
further refine macro signatures
coriolinus Jul 1, 2021
b630321
WIP: implement make_ratio macro
coriolinus Jul 2, 2021
8ce3bc0
start rethinking the process of producing threshold lists
coriolinus Jul 2, 2021
202def0
write helper functions to emit voter bags module
coriolinus Jul 2, 2021
4da8204
WIP: demo generating voter bags for a realistic runtime
coriolinus Jul 2, 2021
498ab65
rm unnecessary arg_enum
coriolinus Jul 2, 2021
734ea86
fix voter bags math
coriolinus Jul 5, 2021
3cfa8cf
add computed voter bags thresholds to node
coriolinus Jul 5, 2021
a05df69
fixup some docs
coriolinus Jul 5, 2021
2838b83
iter from large bags to small, fulfuilling the contract
coriolinus Jul 5, 2021
3f17724
make tests compile
coriolinus Jul 5, 2021
b73fd7f
add VoterBagThresholds to some configs
coriolinus Jul 5, 2021
c719c5c
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jul 5, 2021
4861789
ensure that iteration covers all voters even with implied final bag
coriolinus Jul 6, 2021
59041b7
use sp_std::boxed::Box;
coriolinus Jul 6, 2021
646f708
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jul 6, 2021
f5c8a4d
fix unused import
coriolinus Jul 6, 2021
5e05e3f
add some more voter bags tests
coriolinus Jul 7, 2021
dbf3a84
file_header.txt
coriolinus Jul 7, 2021
873005e
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jul 7, 2021
d5e0c8d
integrity test to ensure min bag exceeds existential weight
coriolinus Jul 9, 2021
dbfb951
add more debug assertions about node list length
coriolinus Jul 9, 2021
06e69a8
rm unused imports
coriolinus Jul 9, 2021
df75e66
Merge branch 'master' of github.com:paritytech/substrate into prgn-no…
kianenigma Jul 9, 2021
6f15cc3
Kian enters
kianenigma Jul 10, 2021
1b545e4
Update frame/election-provider-support/src/onchain.rs
kianenigma Jul 12, 2021
e0a00fd
Suggestions for #9081 (Store voters in unsorted bags) (#9328)
emostov Jul 21, 2021
008cacf
Merge master pre-fmt
emostov Jul 21, 2021
48ccfc9
merge fallout
emostov Jul 22, 2021
225eb47
Merge origin master with new formatting
emostov Jul 22, 2021
acc9183
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov Jul 22, 2021
1c56016
Run cargo +nightly fmt
emostov Jul 22, 2021
1f02cb4
Fix a bunch of stuff, remove not needed runtime arg of make-bags
kianenigma Jul 22, 2021
2f83f16
add logs
kianenigma Jul 22, 2021
abb61c1
Merge branch 'master' of github.com:paritytech/substrate into prgn-no…
kianenigma Jul 22, 2021
0df47b0
Glue the new staking bags to the election snapshot (#9415)
kianenigma Jul 23, 2021
c1c4fcd
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov Jul 23, 2021
2c5a20c
Merge branch 'master' of https://github.com/paritytech/substrate into…
emostov Jul 27, 2021
8706404
Update node runtime with VoterSnapshotPerBlock
emostov Jul 27, 2021
98a4b1f
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov Jul 27, 2021
ced6077
Unit test for pallet-staking unsorted bags feature (targets #9081) (#…
emostov Jul 28, 2021
da4814c
Try prepare for master merge
emostov Jul 28, 2021
d20278a
Try merge origin master
emostov Jul 28, 2021
530e4d2
Reduce diff
emostov Jul 28, 2021
99bd08b
Try merge origin master
emostov Jul 30, 2021
df990d3
Add comment for test to add
emostov Aug 1, 2021
1632747
Add in code TODO for update_position efficiency updates
emostov Aug 1, 2021
dc3328e
Try merge origin master
emostov Aug 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
get rid of BagIdx
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.
  • Loading branch information
coriolinus committed Jul 5, 2021
commit 2a4ebf7f9fef531df96028716237e16ea6f248cd
36 changes: 16 additions & 20 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ use sp_runtime::{
curve::PiecewiseLinear,
traits::{
AtLeast32BitUnsigned, Bounded, CheckedSub, Convert, SaturatedConversion, Saturating,
StaticLookup, UniqueSaturatedInto, Zero,
StaticLookup, Zero,
},
};
use sp_staking::{
Expand All @@ -321,7 +321,7 @@ use sp_staking::{
};
use frame_system::{ensure_signed, ensure_root, pallet_prelude::*, offchain::SendTransactionTypes};
use frame_election_provider_support::{ElectionProvider, VoteWeight, Supports, data_provider};
use voter_bags::{BagIdx, VoterList, VoterType};
use voter_bags::{VoterList, VoterType};
pub use weights::WeightInfo;
pub use pallet::*;

Expand Down Expand Up @@ -1008,11 +1008,6 @@ pub mod pallet {
/// regenerated.
#[pallet::constant]
type VoterBagThresholds: Get<&'static [VoteWeight]>;

/// A type sufficient to distinguish between all voter bags.
///
/// For 256 bags or fewer, `u8` suffices.
type BagIdx: Copy + Eq + Ord + codec::Codec + MaxEncodedLen + Bounded + UniqueSaturatedInto<usize>;
}

#[pallet::extra_constants]
Expand Down Expand Up @@ -1311,6 +1306,8 @@ pub mod pallet {
// The next storage items collectively comprise the voter bags: a composite data structure
// designed to allow efficient iteration of the top N voters by stake, mostly. See
// `mod voter_bags` for details.
//
// In each of these items, voter bags are indexed by their upper weight threshold.

/// How many voters are registered.
#[pallet::storage]
Expand All @@ -1321,21 +1318,25 @@ pub mod pallet {
/// This may not be the appropriate bag for the voter's weight if they have been rewarded or
/// slashed.
#[pallet::storage]
pub(crate) type VoterBagFor<T: Config> = StorageMap<_, Twox64Concat, AccountIdOf<T>, voter_bags::BagIdx>;
pub(crate) type VoterBagFor<T: Config> = StorageMap<_, Twox64Concat, AccountIdOf<T>, VoteWeight>;

/// The head and tail of each bag of voters.
/// This storage item maps a bag (identified by its upper threshold) to the `Bag` struct, which
/// mainly exists to store head and tail pointers to the appropriate nodes.
#[pallet::storage]
pub(crate) type VoterBags<T: Config> = StorageMap<
_,
Twox64Concat, voter_bags::BagIdx,
Twox64Concat, VoteWeight,
voter_bags::Bag<T>,
>;

/// The nodes comprising each bag.
/// Voter nodes store links forward and back within their respective bags, the stash id, and
/// whether the voter is a validator or nominator.
///
/// There is nothing in this map directly identifying to which bag a particular node belongs.
/// However, the `Node` data structure has helpers which can provide that information.
#[pallet::storage]
pub(crate) type VoterNodes<T: Config> = StorageDoubleMap<
pub(crate) type VoterNodes<T: Config> = StorageMap<
_,
Twox64Concat, voter_bags::BagIdx,
Twox64Concat, AccountIdOf<T>,
voter_bags::Node<T>,
>;
Expand Down Expand Up @@ -1456,7 +1457,7 @@ pub mod pallet {
/// The election failed. No new era is planned.
StakingElectionFailed,
/// Moved an account from one bag to another. \[who, from, to\].
Rebagged(T::AccountId, BagIdx, BagIdx),
Rebagged(T::AccountId, VoteWeight, VoteWeight),
}

#[pallet::error]
Expand Down Expand Up @@ -1562,11 +1563,6 @@ pub mod pallet {
T::VoterBagThresholds::get().windows(2).all(|window| window[1] > window[0]),
"Voter bag thresholds must strictly increase",
);

assert!(
T::BagIdx::max_value().saturated_into() >= T::VoterBagThresholds::get().len(),
"BagIdx must be sufficient to uniquely identify every bag",
);
});
}
}
Expand Down Expand Up @@ -3204,7 +3200,7 @@ impl<T: Config> Pallet<T> {
/// Move a stash account from one bag to another, depositing an event on success.
///
/// If the stash changed bags, returns `Some((from, to))`.
pub fn do_rebag(stash: &T::AccountId) -> Option<(BagIdx, BagIdx)> {
pub fn do_rebag(stash: &T::AccountId) -> Option<(VoteWeight, VoteWeight)> {
// if no voter at that node, don't do anything.
// the caller just wasted the fee to call this.
let maybe_movement = voter_bags::Node::<T>::from_id(&stash).and_then(|node| {
Expand Down
109 changes: 56 additions & 53 deletions frame/staking/src/voter_bags/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,37 @@

pub mod thresholds;

use thresholds::THRESHOLDS;
use crate::{
AccountIdOf, Config, Nominations, Nominators, Pallet, Validators, VoteWeight, VoterBagFor,
VotingDataOf, slashing::SlashingSpans,
};
use codec::{Encode, Decode};
use frame_support::DefaultNoBound;
use frame_support::{DefaultNoBound, traits::Get};
use sp_runtime::SaturatedConversion;
use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData};

/// [`Voter`] parametrized by [`Config`] instead of by `AccountId`.
pub type VoterOf<T> = Voter<AccountIdOf<T>>;

/// Index type for a bag.
pub type BagIdx = u8;

/// How many bags there are
pub const N_BAGS: BagIdx = 200;

/// Given a certain vote weight, which bag should this voter contain?
/// Given a certain vote weight, which bag should contain this voter?
///
/// Bags are identified by their upper threshold; the value returned by this function is guaranteed
/// to be a member of `T::VoterBagThresholds`.
///
/// Bags are separated by fixed thresholds. To the extent possible, each threshold is a constant
/// small multiple of the one before it. That ratio is [`thresholds::CONSTANT_RATIO`]. The exception
/// are the smallest bags, which are each at least 1 greater than the previous, and the largest bag,
/// which is defined as `u64::MAX`.
/// This is used instead of a simpler scheme, such as the index within `T::VoterBagThresholds`,
/// because in the event that bags are inserted or deleted, the number of affected voters which need
/// to be migrated is smaller.
///
/// Bags are arranged such that `bags[0]` is the largest bag, and `bags[N_BAGS-1]` is the smallest.
fn notional_bag_for(weight: VoteWeight) -> BagIdx {
let raw_bag =
THRESHOLDS.partition_point(|&threshold| weight > threshold) as BagIdx;
N_BAGS - 1 - raw_bag
/// Note that even if the thresholds list does not have `VoteWeight::MAX` as its final member, this
/// function behaves as if it does.
fn notional_bag_for<T: Config>(weight: VoteWeight) -> VoteWeight {
let thresholds = T::VoterBagThresholds::get();
let idx = thresholds.partition_point(|&threshold| weight > threshold);
thresholds.get(idx).copied().unwrap_or(VoteWeight::MAX)
}

/// Find the actual bag containing the current voter.
fn current_bag_for<T: Config>(id: &AccountIdOf<T>) -> Option<BagIdx> {
/// Find the upper threshold of the actual bag containing the current voter.
fn current_bag_for<T: Config>(id: &AccountIdOf<T>) -> Option<VoteWeight> {
VoterBagFor::<T>::try_get(id).ok()
}

Expand Down Expand Up @@ -110,10 +106,13 @@ impl<T: Config> VoterList<T> {

/// Iterate over all nodes in all bags in the voter list.
///
/// Note that this exhaustively attempts to try all possible bag indices. Full iteration can be
/// expensive; it's recommended to limit the number of items with `.take(n)`.
/// Full iteration can be expensive; it's recommended to limit the number of items with `.take(n)`.
pub fn iter() -> impl Iterator<Item = Node<T>> {
(0..=BagIdx::MAX).filter_map(|bag_idx| Bag::get(bag_idx)).flat_map(|bag| bag.iter())
T::VoterBagThresholds::get()
.iter()
.copied()
.filter_map(Bag::get)
.flat_map(|bag| bag.iter())
}

/// Insert a new voter into the appropriate bag in the voter list.
Expand Down Expand Up @@ -147,7 +146,7 @@ impl<T: Config> VoterList<T> {

for voter in voters.into_iter() {
let weight = weight_of(&voter.id);
let bag = notional_bag_for(weight);
let bag = notional_bag_for::<T>(weight);
bags.entry(bag).or_insert_with(|| Bag::<T>::get_or_make(bag)).insert(voter);
count += 1;
}
Expand Down Expand Up @@ -180,11 +179,11 @@ impl<T: Config> VoterList<T> {
count += 1;

// clear the bag head/tail pointers as necessary
let bag = bags.entry(node.bag_idx).or_insert_with(|| Bag::<T>::get_or_make(node.bag_idx));
let bag = bags.entry(node.bag_upper).or_insert_with(|| Bag::<T>::get_or_make(node.bag_upper));
bag.remove_node(&node);

// now get rid of the node itself
crate::VoterNodes::<T>::remove(node.bag_idx, voter_id);
crate::VoterNodes::<T>::remove(voter_id);
crate::VoterBagFor::<T>::remove(voter_id);
}

Expand All @@ -208,12 +207,12 @@ impl<T: Config> VoterList<T> {
pub fn update_position_for(
mut node: Node<T>,
weight_of: impl Fn(&AccountIdOf<T>) -> VoteWeight,
) -> Option<(BagIdx, BagIdx)> {
) -> Option<(VoteWeight, VoteWeight)> {
node.is_misplaced(&weight_of).then(move || {
let old_idx = node.bag_idx;
let old_idx = node.bag_upper;

// clear the old bag head/tail pointers as necessary
if let Some(mut bag) = Bag::<T>::get(node.bag_idx) {
if let Some(mut bag) = Bag::<T>::get(node.bag_upper) {
bag.remove_node(&node);
bag.put();
} else {
Expand All @@ -226,9 +225,9 @@ impl<T: Config> VoterList<T> {
}

// put the voter into the appropriate new bag
let new_idx = notional_bag_for(weight_of(&node.voter.id));
node.bag_idx = new_idx;
let mut bag = Bag::<T>::get_or_make(node.bag_idx);
let new_idx = notional_bag_for::<T>(weight_of(&node.voter.id));
node.bag_upper = new_idx;
let mut bag = Bag::<T>::get_or_make(node.bag_upper);
bag.insert_node(node);
bag.put();

Expand All @@ -250,36 +249,40 @@ pub struct Bag<T: Config> {
tail: Option<AccountIdOf<T>>,

#[codec(skip)]
bag_idx: BagIdx,
bag_upper: VoteWeight,
}

impl<T: Config> Bag<T> {
/// Get a bag by idx.
pub fn get(bag_idx: BagIdx) -> Option<Bag<T>> {
crate::VoterBags::<T>::try_get(bag_idx).ok().map(|mut bag| {
bag.bag_idx = bag_idx;
/// Get a bag by its upper vote weight.
pub fn get(bag_upper: VoteWeight) -> Option<Bag<T>> {
debug_assert!(
T::VoterBagThresholds::get().contains(&bag_upper) || bag_upper == VoteWeight::MAX,
"it is a logic error to attempt to get a bag which is not in the thresholds list"
);
crate::VoterBags::<T>::try_get(bag_upper).ok().map(|mut bag| {
bag.bag_upper = bag_upper;
bag
})
}

/// Get a bag by idx or make it, appropriately initialized.
pub fn get_or_make(bag_idx: BagIdx) -> Bag<T> {
Self::get(bag_idx).unwrap_or(Bag { bag_idx, ..Default::default() })
/// Get a bag by its upper vote weight or make it, appropriately initialized.
pub fn get_or_make(bag_upper: VoteWeight) -> Bag<T> {
Self::get(bag_upper).unwrap_or(Bag { bag_upper, ..Default::default() })
}

/// Put the bag back into storage.
pub fn put(self) {
crate::VoterBags::<T>::insert(self.bag_idx, self);
crate::VoterBags::<T>::insert(self.bag_upper, self);
}

/// Get the head node in this bag.
pub fn head(&self) -> Option<Node<T>> {
self.head.as_ref().and_then(|id| Node::get(self.bag_idx, id))
self.head.as_ref().and_then(|id| Node::get(self.bag_upper, id))
}

/// Get the tail node in this bag.
pub fn tail(&self) -> Option<Node<T>> {
self.tail.as_ref().and_then(|id| Node::get(self.bag_idx, id))
self.tail.as_ref().and_then(|id| Node::get(self.bag_upper, id))
}

/// Iterate over the nodes in this bag.
Expand All @@ -299,7 +302,7 @@ impl<T: Config> Bag<T> {
voter,
prev: None,
next: None,
bag_idx: self.bag_idx,
bag_upper: self.bag_upper,
});
}

Expand Down Expand Up @@ -329,7 +332,7 @@ impl<T: Config> Bag<T> {
}
self.tail = Some(id.clone());

crate::VoterBagFor::<T>::insert(id, self.bag_idx);
crate::VoterBagFor::<T>::insert(id, self.bag_upper);
}

/// Remove a voter node from this bag.
Expand Down Expand Up @@ -362,14 +365,14 @@ pub struct Node<T: Config> {

/// The bag index is not stored in storage, but injected during all fetch operations.
#[codec(skip)]
pub(crate) bag_idx: BagIdx,
pub(crate) bag_upper: VoteWeight,
}

impl<T: Config> Node<T> {
/// Get a node by bag idx and account id.
pub fn get(bag_idx: BagIdx, account_id: &AccountIdOf<T>) -> Option<Node<T>> {
crate::VoterNodes::<T>::try_get(&bag_idx, account_id).ok().map(|mut node| {
node.bag_idx = bag_idx;
pub fn get(bag_upper: VoteWeight, account_id: &AccountIdOf<T>) -> Option<Node<T>> {
crate::VoterNodes::<T>::try_get(account_id).ok().map(|mut node| {
node.bag_upper = bag_upper;
node
})
}
Expand All @@ -385,12 +388,12 @@ impl<T: Config> Node<T> {

/// Get a node by account id, assuming it's in the same bag as this node.
pub fn in_bag(&self, account_id: &AccountIdOf<T>) -> Option<Node<T>> {
Self::get(self.bag_idx, account_id)
Self::get(self.bag_upper, account_id)
}

/// Put the node back into storage.
pub fn put(self) {
crate::VoterNodes::<T>::insert(self.bag_idx, self.voter.id.clone(), self);
crate::VoterNodes::<T>::insert(self.voter.id.clone(), self);
}

/// Get the previous node in the bag.
Expand Down Expand Up @@ -448,7 +451,7 @@ impl<T: Config> Node<T> {

/// `true` when this voter is in the wrong bag.
pub fn is_misplaced(&self, weight_of: impl Fn(&T::AccountId) -> VoteWeight) -> bool {
notional_bag_for(weight_of(&self.voter.id)) != self.bag_idx
notional_bag_for::<T>(weight_of(&self.voter.id)) != self.bag_upper
}

/// Update the voter type associated with a particular node by id.
Expand All @@ -470,7 +473,7 @@ impl<T: Config> Node<T> {
///
/// This is a helper intended only for benchmarking and should not be used in production.
#[cfg(any(test, feature = "runtime-benchmarks"))]
pub fn proper_bag_for(&self) -> BagIdx {
pub fn proper_bag_for(&self) -> VoteWeight {
let weight_of = crate::Pallet::<T>::weight_of_fn();
let current_weight = weight_of(&self.voter.id);
notional_bag_for(current_weight)
Expand Down
4 changes: 1 addition & 3 deletions frame/staking/src/voter_bags/thresholds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@

//! Generated voter bag thresholds.

use super::N_BAGS;

/// Ratio between adjacent bags;
#[cfg(any(test, feature = "std"))]
#[allow(unused)]
pub const CONSTANT_RATIO: f64 = 1.2483305489016119;

/// Upper thresholds for each bag.
pub const THRESHOLDS: [u64; N_BAGS as usize] = [
pub const THRESHOLDS: [u64; 200] = [
1,
2,
3,
Expand Down