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

Commit

Permalink
Set new staking limits (#3299)
Browse files Browse the repository at this point in the history
* Set staking limits

* Set westend limits as well

* Update runtime/kusama/src/lib.rs

Co-authored-by: Gavin Wood <gavin@parity.io>

Co-authored-by: Gavin Wood <gavin@parity.io>
  • Loading branch information
2 people authored and shawntabrizi committed Jun 18, 2021
1 parent 293b769 commit c09df04
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
21 changes: 21 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,10 +1509,31 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
SetStakingLimits,
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

pub struct SetStakingLimits;
impl frame_support::traits::OnRuntimeUpgrade for SetStakingLimits {
fn on_runtime_upgrade() -> Weight {
// This will be the threshold needed henceforth to become a nominator. All nominators will
// less than this amount bonded are at the risk of being chilled by another reporter.
let min_nominator_bond = UNITS / 10;
// The absolute maximum number of nominators. This number is set rather conservatively, and
// is expected to increase soon after this runtime upgrade via another governance proposal.
// The current Polkadot state has more than 30_000 nominators, therefore no other nominator
// can join.
let max_nominators = 20_000;
<pallet_staking::MinNominatorBond<Runtime>>::put(min_nominator_bond);
<pallet_staking::MaxNominatorsCount<Runtime>>::put(max_nominators);

// we set no limits on validators for now.

<Runtime as frame_system::Config>::DbWeight::get().writes(2)
}
}

#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
Expand Down
22 changes: 21 additions & 1 deletion runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,11 +1096,31 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
GrandpaStoragePrefixMigration,
(GrandpaStoragePrefixMigration, SetStakingLimits),
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

pub struct SetStakingLimits;
impl frame_support::traits::OnRuntimeUpgrade for SetStakingLimits {
fn on_runtime_upgrade() -> Weight {
// This will be the threshold needed henceforth to become a nominator. All nominators will
// less than this amount bonded are at the risk of being chilled by another reporter.
let min_nominator_bond = 20 * UNITS;
// The absolute maximum number of nominators. This number is set rather conservatively, and
// is expected to increase soon after this runtime upgrade via another governance proposal.
// The current Polkadot state has more than 30_000 nominators, therefore no other nominator
// can join.
let max_nominators = 20_000;
<pallet_staking::MinNominatorBond<Runtime>>::put(min_nominator_bond);
<pallet_staking::MaxNominatorsCount<Runtime>>::put(max_nominators);

// we set no limits on validators for now.

<Runtime as frame_system::Config>::DbWeight::get().writes(2)
}
}

#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
Expand Down
13 changes: 13 additions & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,10 +1107,23 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
SetStakingLimits,
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

pub struct SetStakingLimits;
impl frame_support::traits::OnRuntimeUpgrade for SetStakingLimits {
fn on_runtime_upgrade() -> Weight {
<pallet_staking::MinNominatorBond<Runtime>>::put(1 * UNITS);
<pallet_staking::MaxNominatorsCount<Runtime>>::put(1000);
<pallet_staking::MinValidatorBond<Runtime>>::put(10 * UNITS);
<pallet_staking::MaxValidatorsCount<Runtime>>::put(10);

<Runtime as frame_system::Config>::DbWeight::get().writes(4)
}
}

#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
Expand Down

0 comments on commit c09df04

Please sign in to comment.