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:
Kian Paimani
2022-01-25 15:44:10 +01:00
committed by GitHub
parent d94b5e32c5
commit 38d94d6323
34 changed files with 419 additions and 252 deletions
@@ -28,7 +28,7 @@ use sp_std::{prelude::*, vec};
use frame_benchmarking::benchmarks;
use frame_support::{
codec::Decode,
traits::{KeyOwnerProofSystem, OnInitialize},
traits::{Get, KeyOwnerProofSystem, OnInitialize},
};
use frame_system::RawOrigin;
use pallet_session::{historical::Pallet as Historical, Pallet as Session, *};
@@ -53,10 +53,10 @@ impl<T: Config> OnInitialize<T::BlockNumber> for Pallet<T> {
benchmarks! {
set_keys {
let n = <T as pallet_staking::Config>::MAX_NOMINATIONS;
let n = <T as pallet_staking::Config>::MaxNominations::get();
let (v_stash, _) = create_validator_with_nominators::<T>(
n,
<T as pallet_staking::Config>::MAX_NOMINATIONS,
<T as pallet_staking::Config>::MaxNominations::get(),
false,
RewardDestination::Staked,
)?;
@@ -70,10 +70,10 @@ benchmarks! {
}: _(RawOrigin::Signed(v_controller), keys, proof)
purge_keys {
let n = <T as pallet_staking::Config>::MAX_NOMINATIONS;
let n = <T as pallet_staking::Config>::MaxNominations::get();
let (v_stash, _) = create_validator_with_nominators::<T>(
n,
<T as pallet_staking::Config>::MAX_NOMINATIONS,
<T as pallet_staking::Config>::MaxNominations::get(),
false,
RewardDestination::Staked
)?;
@@ -162,7 +162,7 @@ impl onchain::Config for Test {
}
impl pallet_staking::Config for Test {
const MAX_NOMINATIONS: u32 = 16;
type MaxNominations = ConstU32<16>;
type Currency = Balances;
type UnixTime = pallet_timestamp::Pallet<Self>;
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;