mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Use proper bounded vector type for nominations (#10601)
* Use proper bounded vector type for nominations * add docs and tweak chill_other for cleanup purposes * Fix the build * remove TODO * add a bit more doc * even more docs gushc * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <z.mostov@gmail.com> * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <z.mostov@gmail.com> * Fix the nasty bug * also bound the Snapshot type * fix doc test * document bounded_vec * self-review * remove unused * Fix build * frame-support: repetition overload for bounded_vec Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fix * remove the need to allocate into unbounded voters etc etc * Don't expect * unbreal the build again * handle macro a bit better Co-authored-by: Zeke Mostov <z.mostov@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -355,17 +355,17 @@ benchmarks! {
|
||||
kick {
|
||||
// scenario: we want to kick `k` nominators from nominating us (we are a validator).
|
||||
// we'll assume that `k` is under 128 for the purposes of determining the slope.
|
||||
// each nominator should have `T::MAX_NOMINATIONS` validators nominated, and our validator
|
||||
// each nominator should have `T::MaxNominations::get()` validators nominated, and our validator
|
||||
// should be somewhere in there.
|
||||
let k in 1 .. 128;
|
||||
|
||||
// these are the other validators; there are `T::MAX_NOMINATIONS - 1` of them, so
|
||||
// there are a total of `T::MAX_NOMINATIONS` validators in the system.
|
||||
let rest_of_validators = create_validators_with_seed::<T>(T::MAX_NOMINATIONS - 1, 100, 415)?;
|
||||
// these are the other validators; there are `T::MaxNominations::get() - 1` of them, so
|
||||
// there are a total of `T::MaxNominations::get()` validators in the system.
|
||||
let rest_of_validators = create_validators_with_seed::<T>(T::MaxNominations::get() - 1, 100, 415)?;
|
||||
|
||||
// this is the validator that will be kicking.
|
||||
let (stash, controller) = create_stash_controller::<T>(
|
||||
T::MAX_NOMINATIONS - 1,
|
||||
T::MaxNominations::get() - 1,
|
||||
100,
|
||||
Default::default(),
|
||||
)?;
|
||||
@@ -380,7 +380,7 @@ benchmarks! {
|
||||
for i in 0 .. k {
|
||||
// create a nominator stash.
|
||||
let (n_stash, n_controller) = create_stash_controller::<T>(
|
||||
T::MAX_NOMINATIONS + i,
|
||||
T::MaxNominations::get() + i,
|
||||
100,
|
||||
Default::default(),
|
||||
)?;
|
||||
@@ -415,9 +415,9 @@ benchmarks! {
|
||||
}
|
||||
}
|
||||
|
||||
// Worst case scenario, T::MAX_NOMINATIONS
|
||||
// Worst case scenario, T::MaxNominations::get()
|
||||
nominate {
|
||||
let n in 1 .. T::MAX_NOMINATIONS;
|
||||
let n in 1 .. T::MaxNominations::get();
|
||||
|
||||
// clean up any existing state.
|
||||
clear_validators_and_nominators::<T>();
|
||||
@@ -428,7 +428,7 @@ benchmarks! {
|
||||
// we are just doing an insert into the origin position.
|
||||
let scenario = ListScenario::<T>::new(origin_weight, true)?;
|
||||
let (stash, controller) = create_stash_controller_with_balance::<T>(
|
||||
SEED + T::MAX_NOMINATIONS + 1, // make sure the account does not conflict with others
|
||||
SEED + T::MaxNominations::get() + 1, // make sure the account does not conflict with others
|
||||
origin_weight,
|
||||
Default::default(),
|
||||
).unwrap();
|
||||
@@ -724,7 +724,7 @@ benchmarks! {
|
||||
create_validators_with_nominators_for_era::<T>(
|
||||
v,
|
||||
n,
|
||||
<T as Config>::MAX_NOMINATIONS as usize,
|
||||
<T as Config>::MaxNominations::get() as usize,
|
||||
false,
|
||||
None,
|
||||
)?;
|
||||
@@ -742,7 +742,7 @@ benchmarks! {
|
||||
create_validators_with_nominators_for_era::<T>(
|
||||
v,
|
||||
n,
|
||||
<T as Config>::MAX_NOMINATIONS as usize,
|
||||
<T as Config>::MaxNominations::get() as usize,
|
||||
false,
|
||||
None,
|
||||
)?;
|
||||
@@ -822,7 +822,7 @@ benchmarks! {
|
||||
let s in 1 .. 20;
|
||||
|
||||
let validators = create_validators_with_nominators_for_era::<T>(
|
||||
v, n, T::MAX_NOMINATIONS as usize, false, None
|
||||
v, n, T::MaxNominations::get() as usize, false, None
|
||||
)?
|
||||
.into_iter()
|
||||
.map(|v| T::Lookup::lookup(v).unwrap())
|
||||
@@ -845,7 +845,7 @@ benchmarks! {
|
||||
let n = MaxNominators::<T>::get();
|
||||
|
||||
let _ = create_validators_with_nominators_for_era::<T>(
|
||||
v, n, T::MAX_NOMINATIONS as usize, false, None
|
||||
v, n, T::MaxNominations::get() as usize, false, None
|
||||
)?;
|
||||
}: {
|
||||
let targets = <Staking<T>>::get_npos_targets();
|
||||
@@ -923,7 +923,7 @@ mod tests {
|
||||
create_validators_with_nominators_for_era::<Test>(
|
||||
v,
|
||||
n,
|
||||
<Test as Config>::MAX_NOMINATIONS as usize,
|
||||
<Test as Config>::MaxNominations::get() as usize,
|
||||
false,
|
||||
None,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user