Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add Control to Growth of the Staking Pallet #8920

Merged
51 commits merged into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
216eeab
start count
shawntabrizi May 25, 2021
a0118b5
track count
shawntabrizi May 27, 2021
fbd4145
add max limit
shawntabrizi May 27, 2021
4601569
min bonds for participating
shawntabrizi May 27, 2021
b2ef6c8
respect min bond when unbonding
shawntabrizi May 27, 2021
f1353cd
Merge branch 'master' of github.com:paritytech/substrate into shawnta…
kianenigma May 31, 2021
b7fc68e
revert a bit of u32
kianenigma May 31, 2021
5544916
Upstream.into()
kianenigma May 31, 2021
1dc6314
Merge branch 'master' into shawntabrizi-staking-count
shawntabrizi Jun 13, 2021
3591936
fix merge
shawntabrizi Jun 13, 2021
ff082e8
more merge fixes
shawntabrizi Jun 13, 2021
2fe269c
update to `Current*`
shawntabrizi Jun 14, 2021
8acc58c
add helper functions
shawntabrizi Jun 14, 2021
1be4f79
Update frame/staking/src/lib.rs
shawntabrizi Jun 14, 2021
8ccaa10
Merge branch 'master' into shawntabrizi-staking-count
shawntabrizi Jun 14, 2021
b50ae31
Merge branch 'shawntabrizi-staking-count' of https://github.com/parit…
shawntabrizi Jun 14, 2021
71e5121
fix
shawntabrizi Jun 14, 2021
4bc3cb8
minbond as storage
shawntabrizi Jun 14, 2021
51ba2bf
checkpoint
shawntabrizi Jun 14, 2021
b1d46e7
chill_other
shawntabrizi Jun 14, 2021
a81e09c
better bond tracking
shawntabrizi Jun 14, 2021
867fe4e
MinBond to MinNominatorBond
shawntabrizi Jun 14, 2021
93a69bd
better doc
shawntabrizi Jun 14, 2021
2f314a8
use helper function
shawntabrizi Jun 14, 2021
d148821
oops
shawntabrizi Jun 14, 2021
11ac9dd
simple hard limits to validators / nominators.
shawntabrizi Jun 14, 2021
1d9e8e0
Merge branch 'master' into shawntabrizi-staking-count
shawntabrizi Jun 14, 2021
c428fb2
better doc
shawntabrizi Jun 14, 2021
6c54ed4
update storage version
shawntabrizi Jun 14, 2021
e26209f
fix tests
shawntabrizi Jun 14, 2021
8270c9f
enable migrations
kianenigma Jun 14, 2021
5b44612
min bond tests
shawntabrizi Jun 14, 2021
0215bd0
chill other tests
shawntabrizi Jun 14, 2021
f2a0d06
tests for max cap
shawntabrizi Jun 14, 2021
0d6b8e2
check `None` on cap too
shawntabrizi Jun 14, 2021
f50d723
benchmarks
shawntabrizi Jun 14, 2021
18f2ec0
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 14, 2021
17d0365
Update frame/staking/src/lib.rs
kianenigma Jun 15, 2021
9ca7cbb
Update frame/staking/src/lib.rs
kianenigma Jun 15, 2021
4aef0b9
Update frame/staking/src/lib.rs
kianenigma Jun 15, 2021
3c959c2
Update frame/staking/src/tests.rs
kianenigma Jun 15, 2021
2554eb9
Merge branch 'shawntabrizi-staking-count' of github.com:paritytech/su…
kianenigma Jun 15, 2021
8713076
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 15, 2021
2fd7ab2
fix benchmark
shawntabrizi Jun 15, 2021
312e291
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 15, 2021
d6f237d
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Jun 15, 2021
cf54657
nits
shawntabrizi Jun 15, 2021
34c7853
Merge branch 'master' into shawntabrizi-staking-count
shawntabrizi Jun 15, 2021
b46e8b6
fix reap_stash benchmark
shawntabrizi Jun 15, 2021
79eb2b5
Merge branch 'shawntabrizi-staking-count' of github.com:paritytech/su…
kianenigma Jun 15, 2021
eb367da
remove lower bound to min bond
shawntabrizi Jun 15, 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
42 changes: 33 additions & 9 deletions frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub use frame_benchmarking::{
const SEED: u32 = 0;
const MAX_SPANS: u32 = 100;
const MAX_VALIDATORS: u32 = 1000;
const MAX_NOMINATORS: u32 = 1000;
const MAX_SLASHES: u32 = 1000;

// Add slashing spans to a user account. Not relevant for actual use, only to benchmark
Expand Down Expand Up @@ -563,9 +564,9 @@ benchmarks! {

get_npos_voters {
// number of validator intention.
let v in 200 .. 400;
let v in (MAX_VALIDATORS / 2) .. MAX_VALIDATORS;
// number of nominator intention.
let n in 200 .. 400;
let n in (MAX_NOMINATORS / 2) .. MAX_NOMINATORS;
// total number of slashing spans. Assigned to validators randomly.
let s in 1 .. 20;

Expand All @@ -584,15 +585,37 @@ benchmarks! {

get_npos_targets {
// number of validator intention.
let v in 200 .. 400;
let v in (MAX_VALIDATORS / 2) .. MAX_VALIDATORS;
// number of nominator intention.
let n = 500;
let n = MAX_NOMINATORS;

let _ = create_validators_with_nominators_for_era::<T>(v, n, T::MAX_NOMINATIONS as usize, false, None)?;
}: {
let targets = <Staking<T>>::get_npos_targets();
assert_eq!(targets.len() as u32, v);
}

update_staking_limits {
// This function always does the same thing... just write to 4 storage items.
}: _(RawOrigin::Root, 1234u32.into(), 5678u32.into(), Some(100), Some(200))
verify {
assert_eq!(MinNominatorBond::<T>::get(), 1234u32.into());
assert_eq!(MinValidatorBond::<T>::get(), 5678u32.into());
assert_eq!(MaxNominatorsCount::<T>::get(), Some(100u32));
assert_eq!(MaxValidatorsCount::<T>::get(), Some(200u32));
}

chill_other {
let (_, controller) = create_stash_controller::<T>(USER_SEED, 100, Default::default())?;
Staking::<T>::validate(RawOrigin::Signed(controller.clone()).into(), ValidatorPrefs::default())?;
Staking::<T>::update_staking_limits(
RawOrigin::Root.into(), BalanceOf::<T>::max_value(), BalanceOf::<T>::max_value(), None, None,
)?;
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), controller.clone())
verify {
assert!(!Validators::<T>::contains_key(controller));
}
}

#[cfg(test)]
Expand All @@ -603,7 +626,7 @@ mod tests {

#[test]
fn create_validators_with_nominators_for_era_works() {
ExtBuilder::default().has_stakers(true).build().execute_with(|| {
ExtBuilder::default().has_stakers(true).build_and_execute(|| {
let v = 10;
let n = 100;

Expand All @@ -625,7 +648,7 @@ mod tests {

#[test]
fn create_validator_with_nominators_works() {
ExtBuilder::default().has_stakers(true).build().execute_with(|| {
ExtBuilder::default().has_stakers(true).build_and_execute(|| {
let n = 10;

let (validator_stash, nominators) = create_validator_with_nominators::<Test>(
Expand All @@ -649,7 +672,7 @@ mod tests {

#[test]
fn add_slashing_spans_works() {
ExtBuilder::default().has_stakers(true).build().execute_with(|| {
ExtBuilder::default().has_stakers(true).build_and_execute(|| {
let n = 10;

let (validator_stash, _nominators) = create_validator_with_nominators::<Test>(
Expand Down Expand Up @@ -680,7 +703,7 @@ mod tests {

#[test]
fn test_payout_all() {
ExtBuilder::default().has_stakers(true).build().execute_with(|| {
ExtBuilder::default().has_stakers(true).build_and_execute(|| {
let v = 10;
let n = 100;

Expand All @@ -700,6 +723,7 @@ mod tests {

impl_benchmark_test_suite!(
Staking,
crate::mock::ExtBuilder::default().has_stakers(true).build(),
crate::mock::ExtBuilder::default().has_stakers(true),
crate::mock::Test,
exec_name = build_and_execute
);
Loading