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

Commit

Permalink
Scale and increase validator count (#6417)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork authored Jun 19, 2020
1 parent 7a4bd76 commit 4f0b601
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ use frame_support::{
};
use pallet_session::historical;
use sp_runtime::{
Perbill, PerU16, PerThing, RuntimeDebug, DispatchError,
Percent, Perbill, PerU16, PerThing, RuntimeDebug, DispatchError,
curve::PiecewiseLinear,
traits::{
Convert, Zero, StaticLookup, CheckedSub, Saturating, SaturatedConversion, AtLeast32Bit,
Expand Down Expand Up @@ -1794,6 +1794,34 @@ decl_module! {
ValidatorCount::put(new);
}

/// Increments the ideal number of validators.
///
/// The dispatch origin must be Root.
///
/// # <weight>
/// Base Weight: 1.717 µs
/// Read/Write: Validator Count
/// # </weight>
#[weight = 2 * WEIGHT_PER_MICROS + T::DbWeight::get().reads_writes(1, 1)]
fn increase_validator_count(origin, #[compact] additional: u32) {
ensure_root(origin)?;
ValidatorCount::mutate(|n| *n += additional);
}

/// Scale up the ideal number of validators by a factor.
///
/// The dispatch origin must be Root.
///
/// # <weight>
/// Base Weight: 1.717 µs
/// Read/Write: Validator Count
/// # </weight>
#[weight = 2 * WEIGHT_PER_MICROS + T::DbWeight::get().reads_writes(1, 1)]
fn scale_validator_count(origin, factor: Percent) {
ensure_root(origin)?;
ValidatorCount::mutate(|n| *n += factor * *n);
}

/// Force there to be no new eras indefinitely.
///
/// The dispatch origin must be Root.
Expand Down

0 comments on commit 4f0b601

Please sign in to comment.