From 63d1d490b436f4e89ec5cc6ba228c0aa7d094db8 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Fri, 18 Jun 2021 14:16:26 +0200 Subject: [PATCH] Set new staking limits (#3299) * Set staking limits * Set westend limits as well * Update runtime/kusama/src/lib.rs Co-authored-by: Gavin Wood Co-authored-by: Gavin Wood --- runtime/kusama/src/lib.rs | 21 +++++++++++++++++++++ runtime/polkadot/src/lib.rs | 22 +++++++++++++++++++++- runtime/westend/src/lib.rs | 13 +++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 20c0e590d8a3..84841f028ff8 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1513,10 +1513,31 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, + SetStakingLimits, >; /// The payload being signed in the transactions. pub type SignedPayload = generic::SignedPayload; +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; + >::put(min_nominator_bond); + >::put(max_nominators); + + // we set no limits on validators for now. + + ::DbWeight::get().writes(2) + } +} + #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index b27b089fdaf8..9ab67a2491fb 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1099,11 +1099,31 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - GrandpaStoragePrefixMigration, + (GrandpaStoragePrefixMigration, SetStakingLimits), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; +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; + >::put(min_nominator_bond); + >::put(max_nominators); + + // we set no limits on validators for now. + + ::DbWeight::get().writes(2) + } +} + #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 51cf9719721d..1199d640efb0 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1105,10 +1105,23 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, + SetStakingLimits, >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; +pub struct SetStakingLimits; +impl frame_support::traits::OnRuntimeUpgrade for SetStakingLimits { + fn on_runtime_upgrade() -> Weight { + >::put(1 * UNITS); + >::put(1000); + >::put(10 * UNITS); + >::put(10); + + ::DbWeight::get().writes(4) + } +} + #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime {