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

Scale and increase validator count #6417

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Changes from all commits
Commits
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
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