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

Set new staking limits #3299

Merged
merged 3 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 21 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1513,10 +1513,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 / 1000;
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
// 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are currently around 22418 active nominators on Polkadot, I wonder from where 30 000 number comes from?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not about active nominators, its about number of nominators in the underlying Nominators storage map.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not about active nominators, its about number of nominators in the underlying Nominators storage map.

I see, thank you! So new nominators would not be able to start staking, or those who have higher stake would be stored, and this will be recalculated for each era?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume that only 20 000 with the highest stake will be counted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This limit would make it so that only 20_000 accounts could exist in that nominators map. Once we hit that limit, other nominators would not be able to register.

// 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 @@ -1099,11 +1099,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