From 00b85c51dfbc0fecbb8a4dd3635d4c177a6527a6 Mon Sep 17 00:00:00 2001
From: Ankan <10196091+Ank4n@users.noreply.github.com>
Date: Wed, 1 Nov 2023 15:21:44 +0100
Subject: [PATCH] [NPoS] Paging reward payouts in order to scale rewardable
nominators (#1189)
helps https://github.com/paritytech/polkadot-sdk/issues/439.
closes https://github.com/paritytech/polkadot-sdk/issues/473.
PR link in the older substrate repository:
https://github.com/paritytech/substrate/pull/13498.
# Context
Rewards payout is processed today in a single block and limited to
`MaxNominatorRewardedPerValidator`. This number is currently 512 on both
Kusama and Polkadot.
This PR tries to scale the nominators payout to an unlimited count in a
multi-block fashion. Exposures are stored in pages, with each page
capped to a certain number (`MaxExposurePageSize`). Starting out, this
number would be the same as `MaxNominatorRewardedPerValidator`, but
eventually, this number can be lowered through new runtime upgrades to
limit the rewardeable nominators per dispatched call instruction.
The changes in the PR are backward compatible.
## How payouts would work like after this change
Staking exposes two calls, 1) the existing `payout_stakers` and 2)
`payout_stakers_by_page`.
### payout_stakers
This remains backward compatible with no signature change. If for a
given era a validator has multiple pages, they can call `payout_stakers`
multiple times. The pages are executed in an ascending sequence and the
runtime takes care of preventing double claims.
### payout_stakers_by_page
Very similar to `payout_stakers` but also accepts an extra param
`page_index`. An account can choose to payout rewards only for an
explicitly passed `page_index`.
**Lets look at an example scenario**
Given an active validator on Kusama had 1100 nominators,
`MaxExposurePageSize` set to 512 for Era e. In order to pay out rewards
to all nominators, the caller would need to call `payout_stakers` 3
times.
- `payout_stakers(origin, stash, e)` => will pay the first 512
nominators.
- `payout_stakers(origin, stash, e)` => will pay the second set of 512
nominators.
- `payout_stakers(origin, stash, e)` => will pay the last set of 76
nominators.
...
- `payout_stakers(origin, stash, e)` => calling it the 4th time would
return an error `InvalidPage`.
The above calls can also be replaced by `payout_stakers_by_page` and
passing a `page_index` explicitly.
## Commission note
Validator commission is paid out in chunks across all the pages where
each commission chunk is proportional to the total stake of the current
page. This implies higher the total stake of a page, higher will be the
commission. If all the pages of a validator's single era are paid out,
the sum of commission paid to the validator across all pages should be
equal to what the commission would have been if we had a non-paged
exposure.
### Migration Note
Strictly speaking, we did not need to bump our storage version since
there is no migration of storage in this PR. But it is still useful to
mark a storage upgrade for the following reasons:
- New storage items are introduced in this PR while some older storage
items are deprecated.
- For the next `HistoryDepth` eras, the exposure would be incrementally
migrated to its corresponding paged storage item.
- Runtimes using staking pallet would strictly need to wait at least
`HistoryDepth` eras with current upgraded version (14) for the migration
to complete. At some era `E` such that `E >
era_at_which_V14_gets_into_effect + HistoryDepth`, we will upgrade to
version X which will remove the deprecated storage items.
In other words, it is a strict requirement that Ex -
E14 > `HistoryDepth`, where
Ex = Era at which deprecated storages are removed from
runtime,
E14 = Era at which runtime is upgraded to version 14.
- For Polkadot and Kusama, there is a [tracker
ticket](https://github.com/paritytech/polkadot-sdk/issues/433) to clean
up the deprecated storage items.
### Storage Changes
#### Added
- ErasStakersOverview
- ClaimedRewards
- ErasStakersPaged
#### Deprecated
The following can be cleaned up after 84 eras which is tracked
[here](https://github.com/paritytech/polkadot-sdk/issues/433).
- ErasStakers.
- ErasStakersClipped.
- StakingLedger.claimed_rewards, renamed to
StakingLedger.legacy_claimed_rewards.
### Config Changes
- Renamed MaxNominatorRewardedPerValidator to MaxExposurePageSize.
### TODO
- [x] Tracker ticket for cleaning up the old code after 84 eras.
- [x] Add companion.
- [x] Redo benchmarks before merge.
- [x] Add Changelog for pallet_staking.
- [x] Pallet should be configurable to enable/disable paged rewards.
- [x] Commission payouts are distributed across pages.
- [x] Review documentation thoroughly.
- [x] Rename `MaxNominatorRewardedPerValidator` ->
`MaxExposurePageSize`.
- [x] NMap for `ErasStakersPaged`.
- [x] Deprecate ErasStakers.
- [x] Integrity tests.
### Followup issues
[Runtime api for deprecated ErasStakers storage
item](https://github.com/paritytech/polkadot-sdk/issues/426)
---------
Co-authored-by: Javier Viola
Co-authored-by: Ross Bulat
Co-authored-by: command-bot <>
---
Cargo.lock | 1 +
polkadot/runtime/test-runtime/src/lib.rs | 9 +-
polkadot/runtime/westend/src/lib.rs | 23 +-
.../westend/src/weights/pallet_staking.rs | 1055 ++++-----
prdoc/pr_1289.prdoc | 28 +
substrate/bin/node/runtime/src/lib.rs | 16 +-
substrate/frame/babe/src/mock.rs | 2 +-
substrate/frame/babe/src/tests.rs | 8 +-
substrate/frame/beefy/src/mock.rs | 2 +-
substrate/frame/beefy/src/tests.rs | 12 +-
.../test-staking-e2e/src/mock.rs | 5 +-
.../frame/fast-unstake/src/benchmarking.rs | 4 +-
substrate/frame/fast-unstake/src/lib.rs | 4 -
substrate/frame/fast-unstake/src/mock.rs | 4 +-
substrate/frame/grandpa/src/mock.rs | 2 +-
substrate/frame/grandpa/src/tests.rs | 12 +-
.../nomination-pools/benchmarking/src/mock.rs | 2 +-
substrate/frame/nomination-pools/src/mock.rs | 5 +
.../nomination-pools/test-staking/src/mock.rs | 2 +-
.../frame/offences/benchmarking/src/mock.rs | 2 +-
substrate/frame/root-offences/src/lib.rs | 2 +-
substrate/frame/root-offences/src/mock.rs | 2 +-
.../frame/session/benchmarking/src/mock.rs | 2 +-
substrate/frame/staking/CHANGELOG.md | 27 +
substrate/frame/staking/README.md | 16 +-
.../frame/staking/runtime-api/Cargo.toml | 5 +-
.../frame/staking/runtime-api/src/lib.rs | 6 +-
substrate/frame/staking/src/benchmarking.rs | 22 +-
substrate/frame/staking/src/ledger.rs | 19 +-
substrate/frame/staking/src/lib.rs | 301 ++-
substrate/frame/staking/src/migrations.rs | 50 +-
substrate/frame/staking/src/mock.rs | 18 +-
substrate/frame/staking/src/pallet/impls.rs | 228 +-
substrate/frame/staking/src/pallet/mod.rs | 185 +-
substrate/frame/staking/src/tests.rs | 1409 ++++++++---
substrate/frame/staking/src/weights.rs | 2051 +++++++++--------
substrate/primitives/staking/src/lib.rs | 133 +-
37 files changed, 3480 insertions(+), 2194 deletions(-)
create mode 100644 prdoc/pr_1289.prdoc
create mode 100644 substrate/frame/staking/CHANGELOG.md
diff --git a/Cargo.lock b/Cargo.lock
index 0f386c52b3..fb49533a7f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10619,6 +10619,7 @@ version = "4.0.0-dev"
dependencies = [
"parity-scale-codec",
"sp-api",
+ "sp-staking",
]
[[package]]
diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs
index 888477366d..596e65eca0 100644
--- a/polkadot/runtime/test-runtime/src/lib.rs
+++ b/polkadot/runtime/test-runtime/src/lib.rs
@@ -192,7 +192,7 @@ impl pallet_babe::Config for Runtime {
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
- type MaxNominators = MaxNominatorRewardedPerValidator;
+ type MaxNominators = MaxNominators;
type KeyOwnerProof =
>::Proof;
@@ -318,7 +318,8 @@ parameter_types! {
// 27 eras in which slashes can be cancelled (a bit less than 7 days).
pub storage SlashDeferDuration: sp_staking::EraIndex = 27;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
- pub storage MaxNominatorRewardedPerValidator: u32 = 64;
+ pub const MaxExposurePageSize: u32 = 64;
+ pub const MaxNominators: u32 = 256;
pub storage OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub const MaxAuthorities: u32 = 100_000;
pub const OnChainMaxWinners: u32 = u32::MAX;
@@ -354,7 +355,7 @@ impl pallet_staking::Config for Runtime {
type AdminOrigin = frame_system::EnsureNever<()>;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve;
- type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
+ type MaxExposurePageSize = MaxExposurePageSize;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainExecution;
@@ -380,7 +381,7 @@ impl pallet_grandpa::Config for Runtime {
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
- type MaxNominators = MaxNominatorRewardedPerValidator;
+ type MaxNominators = MaxNominators;
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
type KeyOwnerProof = sp_core::Void;
diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs
index b8b2e540e9..9dfc3389d5 100644
--- a/polkadot/runtime/westend/src/lib.rs
+++ b/polkadot/runtime/westend/src/lib.rs
@@ -255,7 +255,7 @@ impl pallet_babe::Config for Runtime {
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
- type MaxNominators = MaxNominatorRewardedPerValidator;
+ type MaxNominators = MaxNominators;
type KeyOwnerProof =
>::Proof;
@@ -306,7 +306,7 @@ parameter_types! {
impl pallet_beefy::Config for Runtime {
type BeefyId = BeefyId;
type MaxAuthorities = MaxAuthorities;
- type MaxNominators = MaxNominatorRewardedPerValidator;
+ type MaxNominators = MaxNominators;
type MaxSetIdSessionEntries = BeefySetIdSessionEntries;
type OnNewValidatorSet = BeefyMmrLeaf;
type WeightInfo = ();
@@ -645,7 +645,11 @@ parameter_types! {
// 1 era in which slashes can be cancelled (6 hours).
pub const SlashDeferDuration: sp_staking::EraIndex = 1;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
- pub const MaxNominatorRewardedPerValidator: u32 = 64;
+ pub const MaxExposurePageSize: u32 = 64;
+ // Note: this is not really correct as Max Nominators is (MaxExposurePageSize * page_count) but
+ // this is an unbounded number. We just set it to a reasonably high value, 1 full page
+ // of nominators.
+ pub const MaxNominators: u32 = 64;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub const MaxNominations: u32 = ::LIMIT as u32;
}
@@ -665,7 +669,7 @@ impl pallet_staking::Config for Runtime {
type AdminOrigin = EnsureRoot;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve;
- type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
+ type MaxExposurePageSize = MaxExposurePageSize;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = ElectionProviderMultiPhase;
@@ -688,8 +692,6 @@ impl pallet_fast_unstake::Config for Runtime {
type ControlOrigin = EnsureRoot;
type Staking = Staking;
type MaxErasToCheckPerBlock = ConstU32<1>;
- #[cfg(feature = "runtime-benchmarks")]
- type MaxBackersPerValidator = MaxNominatorRewardedPerValidator;
type WeightInfo = weights::pallet_fast_unstake::WeightInfo;
}
@@ -788,7 +790,7 @@ impl pallet_grandpa::Config for Runtime {
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
- type MaxNominators = MaxNominatorRewardedPerValidator;
+ type MaxNominators = MaxNominators;
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
type KeyOwnerProof = >::Proof;
@@ -1547,6 +1549,7 @@ pub mod migrations {
pub type Unreleased = (
pallet_im_online::migration::v1::Migration,
parachains_configuration::migration::v7::MigrateToV7,
+ pallet_staking::migrations::v14::MigrateToV14,
assigned_slots::migration::v1::VersionCheckedMigrateToV1,
parachains_scheduler::migration::v1::MigrateToV1,
parachains_configuration::migration::v8::MigrateToV8,
@@ -2100,10 +2103,14 @@ sp_api::impl_runtime_apis! {
}
}
- impl pallet_staking_runtime_api::StakingApi for Runtime {
+ impl pallet_staking_runtime_api::StakingApi for Runtime {
fn nominations_quota(balance: Balance) -> u32 {
Staking::api_nominations_quota(balance)
}
+
+ fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
+ Staking::api_eras_stakers_page_count(era, account)
+ }
}
#[cfg(feature = "try-runtime")]
diff --git a/polkadot/runtime/westend/src/weights/pallet_staking.rs b/polkadot/runtime/westend/src/weights/pallet_staking.rs
index 099693d26b..3c4542c6d6 100644
--- a/polkadot/runtime/westend/src/weights/pallet_staking.rs
+++ b/polkadot/runtime/westend/src/weights/pallet_staking.rs
@@ -17,27 +17,25 @@
//! Autogenerated weights for `pallet_staking`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-06-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-10-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `runner--ss9ysm1-project-163-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
-//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024
+//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot
+// target/production/polkadot
// benchmark
// pallet
-// --chain=westend-dev
// --steps=50
// --repeat=20
-// --no-storage-info
-// --no-median-slopes
-// --no-min-squares
-// --pallet=pallet_staking
// --extrinsic=*
-// --execution=wasm
// --wasm-execution=compiled
-// --header=./file_header.txt
-// --output=./runtime/westend/src/weights/
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_staking
+// --chain=westend-dev
+// --header=./polkadot/file_header.txt
+// --output=./polkadot/runtime/westend/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -50,746 +48,755 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_staking`.
pub struct WeightInfo(PhantomData);
impl pallet_staking::WeightInfo for WeightInfo {
- /// Storage: Staking Bonded (r:1 w:1)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:1 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking CurrentEra (r:1 w:0)
- /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:1 w:1)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:1 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
- /// Storage: Staking Payee (r:0 w:1)
- /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
+ /// Storage: `Staking::Bonded` (r:1 w:1)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:0 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Payee` (r:0 w:1)
+ /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
fn bond() -> Weight {
// Proof Size summary in bytes:
- // Measured: `1014`
+ // Measured: `894`
// Estimated: `4764`
- // Minimum execution time: 51_108_000 picoseconds.
- Weight::from_parts(52_521_000, 0)
+ // Minimum execution time: 39_950_000 picoseconds.
+ Weight::from_parts(41_107_000, 0)
.saturating_add(Weight::from_parts(0, 4764))
- .saturating_add(T::DbWeight::get().reads(5))
+ .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(4))
}
- /// Storage: Staking Bonded (r:1 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:1 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:1 w:1)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:1 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:3 w:3)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:2 w:2)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
+ /// Storage: `Staking::Bonded` (r:1 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:1 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:3 w:3)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:2 w:2)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
fn bond_extra() -> Weight {
// Proof Size summary in bytes:
- // Measured: `1959`
+ // Measured: `1921`
// Estimated: `8877`
- // Minimum execution time: 96_564_000 picoseconds.
- Weight::from_parts(100_133_000, 0)
+ // Minimum execution time: 83_828_000 picoseconds.
+ Weight::from_parts(85_733_000, 0)
.saturating_add(Weight::from_parts(0, 8877))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(7))
}
- /// Storage: Staking Ledger (r:1 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:1 w:0)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking MinNominatorBond (r:1 w:0)
- /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
- /// Storage: Staking CurrentEra (r:1 w:0)
- /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:1 w:1)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:1 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:3 w:3)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:1 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:2 w:2)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:1 w:0)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinNominatorBond` (r:1 w:0)
+ /// Proof: `Staking::MinNominatorBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CurrentEra` (r:1 w:0)
+ /// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:1 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:3 w:3)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:2 w:2)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
fn unbond() -> Weight {
// Proof Size summary in bytes:
- // Measured: `2166`
+ // Measured: `2128`
// Estimated: `8877`
- // Minimum execution time: 97_705_000 picoseconds.
- Weight::from_parts(102_055_000, 0)
+ // Minimum execution time: 89_002_000 picoseconds.
+ Weight::from_parts(91_556_000, 0)
.saturating_add(Weight::from_parts(0, 8877))
.saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().writes(7))
}
- /// Storage: Staking Ledger (r:1 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking CurrentEra (r:1 w:0)
- /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:1 w:1)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:1 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CurrentEra` (r:1 w:0)
+ /// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:1 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 100]`.
fn withdraw_unbonded_update(s: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `981`
+ // Measured: `1075`
// Estimated: `4764`
- // Minimum execution time: 45_257_000 picoseconds.
- Weight::from_parts(47_309_508, 0)
+ // Minimum execution time: 40_839_000 picoseconds.
+ Weight::from_parts(42_122_428, 0)
.saturating_add(Weight::from_parts(0, 4764))
- // Standard Error: 2_343
- .saturating_add(Weight::from_parts(61_484, 0).saturating_mul(s.into()))
- .saturating_add(T::DbWeight::get().reads(4))
+ // Standard Error: 884
+ .saturating_add(Weight::from_parts(46_036, 0).saturating_mul(s.into()))
+ .saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
- /// Storage: Staking Ledger (r:1 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking CurrentEra (r:1 w:0)
- /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:1 w:1)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking SlashingSpans (r:1 w:1)
- /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking Validators (r:1 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:1 w:1)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking CounterForNominators (r:1 w:1)
- /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:2 w:2)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:1 w:1)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList CounterForListNodes (r:1 w:1)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:1 w:1)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:1 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
- /// Storage: Staking Payee (r:0 w:1)
- /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
- /// Storage: Staking SpanSlash (r:0 w:100)
- /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CurrentEra` (r:1 w:0)
+ /// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::SlashingSpans` (r:1 w:1)
+ /// Proof: `Staking::SlashingSpans` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::Bonded` (r:1 w:1)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:1 w:1)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CounterForNominators` (r:1 w:1)
+ /// Proof: `Staking::CounterForNominators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:2 w:2)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:1 w:1)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:1)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Payee` (r:0 w:1)
+ /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::SpanSlash` (r:0 w:100)
+ /// Proof: `Staking::SpanSlash` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 100]`.
fn withdraw_unbonded_kill(s: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `2221 + s * (4 ±0)`
+ // Measured: `2127 + s * (4 ±0)`
// Estimated: `6248 + s * (4 ±0)`
- // Minimum execution time: 94_800_000 picoseconds.
- Weight::from_parts(101_763_223, 0)
+ // Minimum execution time: 84_244_000 picoseconds.
+ Weight::from_parts(91_199_964, 0)
.saturating_add(Weight::from_parts(0, 6248))
- // Standard Error: 6_481
- .saturating_add(Weight::from_parts(1_450_372, 0).saturating_mul(s.into()))
+ // Standard Error: 3_381
+ .saturating_add(Weight::from_parts(1_327_289, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(13))
.saturating_add(T::DbWeight::get().writes(11))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
.saturating_add(Weight::from_parts(0, 4).saturating_mul(s.into()))
}
- /// Storage: Staking Ledger (r:1 w:0)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking MinValidatorBond (r:1 w:0)
- /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
- /// Storage: Staking MinCommission (r:1 w:0)
- /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking Validators (r:1 w:1)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: Staking MaxValidatorsCount (r:1 w:0)
- /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:1 w:0)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:1 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:1 w:1)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:1 w:1)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList CounterForListNodes (r:1 w:1)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking CounterForValidators (r:1 w:1)
- /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:0)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinValidatorBond` (r:1 w:0)
+ /// Proof: `Staking::MinValidatorBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinCommission` (r:1 w:0)
+ /// Proof: `Staking::MinCommission` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1 w:1)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MaxValidatorsCount` (r:1 w:0)
+ /// Proof: `Staking::MaxValidatorsCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:1 w:0)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:1 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:1 w:1)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:1 w:1)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:1)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CounterForValidators` (r:1 w:1)
+ /// Proof: `Staking::CounterForValidators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn validate() -> Weight {
// Proof Size summary in bytes:
- // Measured: `1343`
+ // Measured: `1301`
// Estimated: `4556`
- // Minimum execution time: 57_763_000 picoseconds.
- Weight::from_parts(59_394_000, 0)
+ // Minimum execution time: 49_693_000 picoseconds.
+ Weight::from_parts(50_814_000, 0)
.saturating_add(Weight::from_parts(0, 4556))
.saturating_add(T::DbWeight::get().reads(11))
.saturating_add(T::DbWeight::get().writes(5))
}
- /// Storage: Staking Ledger (r:1 w:0)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:128 w:128)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:0)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:128 w:128)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
/// The range of component `k` is `[1, 128]`.
fn kick(k: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `1248 + k * (569 ±0)`
+ // Measured: `1243 + k * (569 ±0)`
// Estimated: `4556 + k * (3033 ±0)`
- // Minimum execution time: 35_501_000 picoseconds.
- Weight::from_parts(32_260_525, 0)
+ // Minimum execution time: 29_140_000 picoseconds.
+ Weight::from_parts(28_309_627, 0)
.saturating_add(Weight::from_parts(0, 4556))
- // Standard Error: 34_554
- .saturating_add(Weight::from_parts(10_625_386, 0).saturating_mul(k.into()))
+ // Standard Error: 5_780
+ .saturating_add(Weight::from_parts(6_509_869, 0).saturating_mul(k.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into())))
.saturating_add(Weight::from_parts(0, 3033).saturating_mul(k.into()))
}
- /// Storage: Staking Ledger (r:1 w:0)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking MinNominatorBond (r:1 w:0)
- /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:1 w:1)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking MaxNominatorsCount (r:1 w:0)
- /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking Validators (r:17 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: Staking CurrentEra (r:1 w:0)
- /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:1 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:2 w:2)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:1 w:1)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList CounterForListNodes (r:1 w:1)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking CounterForNominators (r:1 w:1)
- /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:0)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinNominatorBond` (r:1 w:0)
+ /// Proof: `Staking::MinNominatorBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:1 w:1)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MaxNominatorsCount` (r:1 w:0)
+ /// Proof: `Staking::MaxNominatorsCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:17 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CurrentEra` (r:1 w:0)
+ /// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:1 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:2 w:2)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:1 w:1)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:1)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CounterForNominators` (r:1 w:1)
+ /// Proof: `Staking::CounterForNominators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// The range of component `n` is `[1, 16]`.
fn nominate(n: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `1839 + n * (102 ±0)`
+ // Measured: `1797 + n * (102 ±0)`
// Estimated: `6248 + n * (2520 ±0)`
- // Minimum execution time: 67_970_000 picoseconds.
- Weight::from_parts(65_110_939, 0)
+ // Minimum execution time: 61_377_000 picoseconds.
+ Weight::from_parts(58_805_232, 0)
.saturating_add(Weight::from_parts(0, 6248))
- // Standard Error: 32_193
- .saturating_add(Weight::from_parts(4_688_614, 0).saturating_mul(n.into()))
+ // Standard Error: 14_197
+ .saturating_add(Weight::from_parts(4_090_197, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into())))
.saturating_add(T::DbWeight::get().writes(6))
.saturating_add(Weight::from_parts(0, 2520).saturating_mul(n.into()))
}
- /// Storage: Staking Ledger (r:1 w:0)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking Validators (r:1 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:1 w:1)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking CounterForNominators (r:1 w:1)
- /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:2 w:2)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:1 w:1)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList CounterForListNodes (r:1 w:1)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:0)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:1 w:1)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CounterForNominators` (r:1 w:1)
+ /// Proof: `Staking::CounterForNominators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:2 w:2)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:1 w:1)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:1)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn chill() -> Weight {
// Proof Size summary in bytes:
- // Measured: `1675`
+ // Measured: `1581`
// Estimated: `6248`
- // Minimum execution time: 59_515_000 picoseconds.
- Weight::from_parts(62_462_000, 0)
+ // Minimum execution time: 52_736_000 picoseconds.
+ Weight::from_parts(54_573_000, 0)
.saturating_add(Weight::from_parts(0, 6248))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(6))
}
- /// Storage: Staking Ledger (r:1 w:0)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking Payee (r:0 w:1)
- /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:0)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:1 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Payee` (r:0 w:1)
+ /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
fn set_payee() -> Weight {
// Proof Size summary in bytes:
- // Measured: `771`
+ // Measured: `865`
// Estimated: `4556`
- // Minimum execution time: 13_943_000 picoseconds.
- Weight::from_parts(14_384_000, 0)
+ // Minimum execution time: 16_496_000 picoseconds.
+ Weight::from_parts(17_045_000, 0)
.saturating_add(Weight::from_parts(0, 4556))
- .saturating_add(T::DbWeight::get().reads(1))
+ .saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
- /// Storage: Staking Bonded (r:1 w:1)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:2 w:2)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
+ /// Storage: `Staking::Bonded` (r:1 w:1)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:1 w:2)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
fn set_controller() -> Weight {
// Proof Size summary in bytes:
- // Measured: `870`
- // Estimated: `8122`
- // Minimum execution time: 21_212_000 picoseconds.
- Weight::from_parts(22_061_000, 0)
- .saturating_add(Weight::from_parts(0, 8122))
- .saturating_add(T::DbWeight::get().reads(3))
+ // Measured: `865`
+ // Estimated: `4556`
+ // Minimum execution time: 19_339_000 picoseconds.
+ Weight::from_parts(20_187_000, 0)
+ .saturating_add(Weight::from_parts(0, 4556))
+ .saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
- /// Storage: Staking ValidatorCount (r:0 w:1)
- /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
+ /// Storage: `Staking::ValidatorCount` (r:0 w:1)
+ /// Proof: `Staking::ValidatorCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn set_validator_count() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 2_977_000 picoseconds.
- Weight::from_parts(3_217_000, 0)
+ // Minimum execution time: 2_340_000 picoseconds.
+ Weight::from_parts(2_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
- /// Storage: Staking ForceEra (r:0 w:1)
- /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)
+ /// Storage: `Staking::ForceEra` (r:0 w:1)
+ /// Proof: `Staking::ForceEra` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
fn force_no_eras() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 9_152_000 picoseconds.
- Weight::from_parts(9_949_000, 0)
+ // Minimum execution time: 7_483_000 picoseconds.
+ Weight::from_parts(8_101_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
- /// Storage: Staking ForceEra (r:0 w:1)
- /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)
+ /// Storage: `Staking::ForceEra` (r:0 w:1)
+ /// Proof: `Staking::ForceEra` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
fn force_new_era() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 9_509_000 picoseconds.
- Weight::from_parts(9_838_000, 0)
+ // Minimum execution time: 7_773_000 picoseconds.
+ Weight::from_parts(8_610_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
- /// Storage: Staking ForceEra (r:0 w:1)
- /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)
+ /// Storage: `Staking::ForceEra` (r:0 w:1)
+ /// Proof: `Staking::ForceEra` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
fn force_new_era_always() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 9_480_000 picoseconds.
- Weight::from_parts(9_755_000, 0)
+ // Minimum execution time: 7_577_000 picoseconds.
+ Weight::from_parts(7_937_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
- /// Storage: Staking Invulnerables (r:0 w:1)
- /// Proof Skipped: Staking Invulnerables (max_values: Some(1), max_size: None, mode: Measured)
+ /// Storage: `Staking::Invulnerables` (r:0 w:1)
+ /// Proof: `Staking::Invulnerables` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// The range of component `v` is `[0, 1000]`.
fn set_invulnerables(v: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 3_140_000 picoseconds.
- Weight::from_parts(3_438_665, 0)
+ // Minimum execution time: 2_522_000 picoseconds.
+ Weight::from_parts(2_735_307, 0)
.saturating_add(Weight::from_parts(0, 0))
- // Standard Error: 93
- .saturating_add(Weight::from_parts(15_688, 0).saturating_mul(v.into()))
+ // Standard Error: 38
+ .saturating_add(Weight::from_parts(10_553, 0).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().writes(1))
}
- /// Storage: Staking Bonded (r:1 w:1)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking SlashingSpans (r:1 w:1)
- /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking Validators (r:1 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:1 w:1)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking CounterForNominators (r:1 w:1)
- /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:2 w:2)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:1 w:1)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList CounterForListNodes (r:1 w:1)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: System Account (r:1 w:1)
- /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:1 w:1)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:1 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:0 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking Payee (r:0 w:1)
- /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
- /// Storage: Staking SpanSlash (r:0 w:100)
- /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen)
+ /// Storage: `Staking::SlashingSpans` (r:1 w:1)
+ /// Proof: `Staking::SlashingSpans` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::Bonded` (r:1 w:1)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:1 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `System::Account` (r:1 w:1)
+ /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:1 w:1)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CounterForNominators` (r:1 w:1)
+ /// Proof: `Staking::CounterForNominators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:2 w:2)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:1 w:1)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:1)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Payee` (r:0 w:1)
+ /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::SpanSlash` (r:0 w:100)
+ /// Proof: `Staking::SpanSlash` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 100]`.
fn force_unstake(s: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `1947 + s * (4 ±0)`
+ // Measured: `2127 + s * (4 ±0)`
// Estimated: `6248 + s * (4 ±0)`
- // Minimum execution time: 86_729_000 picoseconds.
- Weight::from_parts(93_633_668, 0)
+ // Minimum execution time: 82_547_000 picoseconds.
+ Weight::from_parts(89_373_781, 0)
.saturating_add(Weight::from_parts(0, 6248))
- // Standard Error: 6_522
- .saturating_add(Weight::from_parts(1_421_038, 0).saturating_mul(s.into()))
- .saturating_add(T::DbWeight::get().reads(12))
+ // Standard Error: 3_589
+ .saturating_add(Weight::from_parts(1_258_878, 0).saturating_mul(s.into()))
+ .saturating_add(T::DbWeight::get().reads(13))
.saturating_add(T::DbWeight::get().writes(12))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
.saturating_add(Weight::from_parts(0, 4).saturating_mul(s.into()))
}
- /// Storage: Staking UnappliedSlashes (r:1 w:1)
- /// Proof Skipped: Staking UnappliedSlashes (max_values: None, max_size: None, mode: Measured)
+ /// Storage: `Staking::UnappliedSlashes` (r:1 w:1)
+ /// Proof: `Staking::UnappliedSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `s` is `[1, 1000]`.
fn cancel_deferred_slash(s: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `66606`
- // Estimated: `70071`
- // Minimum execution time: 135_155_000 picoseconds.
- Weight::from_parts(960_317_735, 0)
- .saturating_add(Weight::from_parts(0, 70071))
- // Standard Error: 59_264
- .saturating_add(Weight::from_parts(4_884_888, 0).saturating_mul(s.into()))
+ // Measured: `66639`
+ // Estimated: `70104`
+ // Minimum execution time: 134_619_000 picoseconds.
+ Weight::from_parts(1_194_949_665, 0)
+ .saturating_add(Weight::from_parts(0, 70104))
+ // Standard Error: 76_719
+ .saturating_add(Weight::from_parts(6_455_953, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
- /// Storage: Staking CurrentEra (r:1 w:0)
- /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking ErasValidatorReward (r:1 w:0)
- /// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:65 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:1 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking ErasStakersClipped (r:1 w:0)
- /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking ErasRewardPoints (r:1 w:0)
- /// Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking ErasValidatorPrefs (r:1 w:0)
- /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Staking Payee (r:65 w:0)
- /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
- /// Storage: System Account (r:65 w:65)
- /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
+ /// Storage: `Staking::CurrentEra` (r:1 w:0)
+ /// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasStakersOverview` (r:1 w:0)
+ /// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasValidatorReward` (r:1 w:0)
+ /// Proof: `Staking::ErasValidatorReward` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:65 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:1 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `System::Account` (r:66 w:66)
+ /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ClaimedRewards` (r:1 w:1)
+ /// Proof: `Staking::ClaimedRewards` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::ErasStakersPaged` (r:1 w:0)
+ /// Proof: `Staking::ErasStakersPaged` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::ErasRewardPoints` (r:1 w:0)
+ /// Proof: `Staking::ErasRewardPoints` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::ErasValidatorPrefs` (r:1 w:0)
+ /// Proof: `Staking::ErasValidatorPrefs` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Payee` (r:65 w:0)
+ /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 64]`.
fn payout_stakers_dead_controller(n: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `5773 + n * (151 ±0)`
- // Estimated: `8579 + n * (2603 ±0)`
- // Minimum execution time: 92_788_000 picoseconds.
- Weight::from_parts(129_527_249, 0)
- .saturating_add(Weight::from_parts(0, 8579))
- // Standard Error: 73_346
- .saturating_add(Weight::from_parts(33_413_624, 0).saturating_mul(n.into()))
- .saturating_add(T::DbWeight::get().reads(9))
+ // Measured: `6895 + n * (156 ±0)`
+ // Estimated: `9802 + n * (2603 ±0)`
+ // Minimum execution time: 114_338_000 picoseconds.
+ Weight::from_parts(138_518_124, 0)
+ .saturating_add(Weight::from_parts(0, 9802))
+ // Standard Error: 53_621
+ .saturating_add(Weight::from_parts(25_676_781, 0).saturating_mul(n.into()))
+ .saturating_add(T::DbWeight::get().reads(14))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into())))
- .saturating_add(T::DbWeight::get().writes(2))
+ .saturating_add(T::DbWeight::get().writes(5))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(n.into()))
}
- /// Storage: Staking CurrentEra (r:1 w:0)
- /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking ErasValidatorReward (r:1 w:0)
- /// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:65 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:65 w:65)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking ErasStakersClipped (r:1 w:0)
- /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking ErasRewardPoints (r:1 w:0)
- /// Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking ErasValidatorPrefs (r:1 w:0)
- /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Staking Payee (r:65 w:0)
- /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
- /// Storage: System Account (r:65 w:65)
- /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:65 w:65)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:65 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
+ /// Storage: `Staking::Bonded` (r:65 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:65 w:65)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasStakersClipped` (r:1 w:0)
+ /// Proof: `Staking::ErasStakersClipped` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::ErasStakersOverview` (r:1 w:0)
+ /// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ClaimedRewards` (r:1 w:1)
+ /// Proof: `Staking::ClaimedRewards` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::CurrentEra` (r:1 w:0)
+ /// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasValidatorReward` (r:1 w:0)
+ /// Proof: `Staking::ErasValidatorReward` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:65 w:65)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:65 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `System::Account` (r:65 w:65)
+ /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasStakersPaged` (r:1 w:0)
+ /// Proof: `Staking::ErasStakersPaged` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::ErasRewardPoints` (r:1 w:0)
+ /// Proof: `Staking::ErasRewardPoints` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::ErasValidatorPrefs` (r:1 w:0)
+ /// Proof: `Staking::ErasValidatorPrefs` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Payee` (r:65 w:0)
+ /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 64]`.
fn payout_stakers_alive_staked(n: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `8056 + n * (396 ±0)`
- // Estimated: `10634 + n * (3774 ±0)`
- // Minimum execution time: 118_795_000 picoseconds.
- Weight::from_parts(181_663_036, 0)
- .saturating_add(Weight::from_parts(0, 10634))
- // Standard Error: 132_894
- .saturating_add(Weight::from_parts(51_369_596, 0).saturating_mul(n.into()))
- .saturating_add(T::DbWeight::get().reads(11))
+ // Measured: `8249 + n * (396 ±0)`
+ // Estimated: `10779 + n * (3774 ±3)`
+ // Minimum execution time: 132_719_000 picoseconds.
+ Weight::from_parts(170_505_880, 0)
+ .saturating_add(Weight::from_parts(0, 10779))
+ // Standard Error: 32_527
+ .saturating_add(Weight::from_parts(42_453_136, 0).saturating_mul(n.into()))
+ .saturating_add(T::DbWeight::get().reads(14))
.saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(n.into())))
- .saturating_add(T::DbWeight::get().writes(3))
+ .saturating_add(T::DbWeight::get().writes(4))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 3774).saturating_mul(n.into()))
}
- /// Storage: Staking Ledger (r:1 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:1 w:1)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:1 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:3 w:3)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:1 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:2 w:2)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:1 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:3 w:3)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:2 w:2)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
/// The range of component `l` is `[1, 32]`.
fn rebond(l: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `1960 + l * (5 ±0)`
+ // Measured: `1922 + l * (5 ±0)`
// Estimated: `8877`
- // Minimum execution time: 88_870_000 picoseconds.
- Weight::from_parts(92_783_195, 0)
+ // Minimum execution time: 78_438_000 picoseconds.
+ Weight::from_parts(81_774_734, 0)
.saturating_add(Weight::from_parts(0, 8877))
- // Standard Error: 7_412
- .saturating_add(Weight::from_parts(49_785, 0).saturating_mul(l.into()))
+ // Standard Error: 3_706
+ .saturating_add(Weight::from_parts(51_358, 0).saturating_mul(l.into()))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(7))
}
- /// Storage: Staking Bonded (r:1 w:1)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:1 w:1)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking SlashingSpans (r:1 w:1)
- /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking Validators (r:1 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:1 w:1)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking CounterForNominators (r:1 w:1)
- /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:2 w:2)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:1 w:1)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList CounterForListNodes (r:1 w:1)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Balances Locks (r:1 w:1)
- /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
- /// Storage: Balances Freezes (r:1 w:0)
- /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
- /// Storage: Staking Payee (r:0 w:1)
- /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
- /// Storage: Staking SpanSlash (r:0 w:100)
- /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen)
+ /// Storage: `Staking::Bonded` (r:1 w:1)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:1 w:1)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::SlashingSpans` (r:1 w:1)
+ /// Proof: `Staking::SlashingSpans` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Balances::Locks` (r:1 w:1)
+ /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Freezes` (r:1 w:0)
+ /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:1 w:1)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CounterForNominators` (r:1 w:1)
+ /// Proof: `Staking::CounterForNominators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:2 w:2)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:1 w:1)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:1)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Payee` (r:0 w:1)
+ /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::SpanSlash` (r:0 w:100)
+ /// Proof: `Staking::SpanSlash` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`)
/// The range of component `s` is `[1, 100]`.
fn reap_stash(s: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `2221 + s * (4 ±0)`
+ // Measured: `2127 + s * (4 ±0)`
// Estimated: `6248 + s * (4 ±0)`
- // Minimum execution time: 102_112_000 picoseconds.
- Weight::from_parts(103_755_459, 0)
+ // Minimum execution time: 92_129_000 picoseconds.
+ Weight::from_parts(94_137_611, 0)
.saturating_add(Weight::from_parts(0, 6248))
- // Standard Error: 6_107
- .saturating_add(Weight::from_parts(1_436_139, 0).saturating_mul(s.into()))
+ // Standard Error: 4_141
+ .saturating_add(Weight::from_parts(1_283_823, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().writes(11))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into())))
.saturating_add(Weight::from_parts(0, 4).saturating_mul(s.into()))
}
- /// Storage: VoterList CounterForListNodes (r:1 w:0)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:178 w:0)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:110 w:0)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:110 w:0)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking Validators (r:11 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:110 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:110 w:0)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: System BlockWeight (r:1 w:1)
- /// Proof: System BlockWeight (max_values: Some(1), max_size: Some(48), added: 543, mode: MaxEncodedLen)
- /// Storage: Staking CounterForValidators (r:1 w:0)
- /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking ValidatorCount (r:1 w:0)
- /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking MinimumValidatorCount (r:1 w:0)
- /// Proof: Staking MinimumValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking CurrentEra (r:1 w:1)
- /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking ErasStakersClipped (r:0 w:10)
- /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking ErasValidatorPrefs (r:0 w:10)
- /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Staking ErasStakers (r:0 w:10)
- /// Proof Skipped: Staking ErasStakers (max_values: None, max_size: None, mode: Measured)
- /// Storage: Staking ErasTotalStake (r:0 w:1)
- /// Proof: Staking ErasTotalStake (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
- /// Storage: Staking ErasStartSessionIndex (r:0 w:1)
- /// Proof: Staking ErasStartSessionIndex (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Staking MinimumActiveStake (r:0 w:1)
- /// Proof: Staking MinimumActiveStake (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:0)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:178 w:0)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:110 w:0)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:110 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:110 w:0)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:110 w:0)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:11 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CounterForValidators` (r:1 w:0)
+ /// Proof: `Staking::CounterForValidators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ValidatorCount` (r:1 w:0)
+ /// Proof: `Staking::ValidatorCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinimumValidatorCount` (r:1 w:0)
+ /// Proof: `Staking::MinimumValidatorCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CurrentEra` (r:1 w:1)
+ /// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasValidatorPrefs` (r:0 w:10)
+ /// Proof: `Staking::ErasValidatorPrefs` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasStakersPaged` (r:0 w:20)
+ /// Proof: `Staking::ErasStakersPaged` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `Staking::ErasStakersOverview` (r:0 w:10)
+ /// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasTotalStake` (r:0 w:1)
+ /// Proof: `Staking::ErasTotalStake` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ErasStartSessionIndex` (r:0 w:1)
+ /// Proof: `Staking::ErasStartSessionIndex` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinimumActiveStake` (r:0 w:1)
+ /// Proof: `Staking::MinimumActiveStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// The range of component `v` is `[1, 10]`.
/// The range of component `n` is `[0, 100]`.
fn new_era(v: u32, n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + n * (716 ±0) + v * (3594 ±0)`
// Estimated: `456136 + n * (3566 ±0) + v * (3566 ±0)`
- // Minimum execution time: 547_465_000 picoseconds.
- Weight::from_parts(557_541_000, 0)
+ // Minimum execution time: 527_896_000 picoseconds.
+ Weight::from_parts(533_325_000, 0)
.saturating_add(Weight::from_parts(0, 456136))
- // Standard Error: 2_380_806
- .saturating_add(Weight::from_parts(78_379_807, 0).saturating_mul(v.into()))
- // Standard Error: 237_234
- .saturating_add(Weight::from_parts(22_772_283, 0).saturating_mul(n.into()))
- .saturating_add(T::DbWeight::get().reads(185))
+ // Standard Error: 2_064_813
+ .saturating_add(Weight::from_parts(68_484_503, 0).saturating_mul(v.into()))
+ // Standard Error: 205_747
+ .saturating_add(Weight::from_parts(18_833_735, 0).saturating_mul(n.into()))
+ .saturating_add(T::DbWeight::get().reads(184))
.saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into())))
- .saturating_add(T::DbWeight::get().writes(5))
+ .saturating_add(T::DbWeight::get().writes(8))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(v.into())))
.saturating_add(Weight::from_parts(0, 3566).saturating_mul(n.into()))
.saturating_add(Weight::from_parts(0, 3566).saturating_mul(v.into()))
}
- /// Storage: VoterList CounterForListNodes (r:1 w:0)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:178 w:0)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:2000 w:0)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:2000 w:0)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking Validators (r:1000 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: Staking Bonded (r:2000 w:0)
- /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
- /// Storage: Staking Ledger (r:2000 w:0)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: System BlockWeight (r:1 w:1)
- /// Proof: System BlockWeight (max_values: Some(1), max_size: Some(48), added: 543, mode: MaxEncodedLen)
- /// Storage: Staking MinimumActiveStake (r:0 w:1)
- /// Proof: Staking MinimumActiveStake (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:0)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:178 w:0)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:2000 w:0)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Bonded` (r:2000 w:0)
+ /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Ledger` (r:2000 w:0)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:2000 w:0)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1000 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinimumActiveStake` (r:0 w:1)
+ /// Proof: `Staking::MinimumActiveStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// The range of component `v` is `[500, 1000]`.
/// The range of component `n` is `[500, 1000]`.
fn get_npos_voters(v: u32, n: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `3151 + n * (907 ±0) + v * (391 ±0)`
+ // Measured: `3108 + n * (907 ±0) + v * (391 ±0)`
// Estimated: `456136 + n * (3566 ±0) + v * (3566 ±0)`
- // Minimum execution time: 39_710_080_000 picoseconds.
- Weight::from_parts(42_191_823_000, 0)
+ // Minimum execution time: 35_302_472_000 picoseconds.
+ Weight::from_parts(35_651_169_000, 0)
.saturating_add(Weight::from_parts(0, 456136))
- // Standard Error: 506_609
- .saturating_add(Weight::from_parts(7_688_462, 0).saturating_mul(v.into()))
- // Standard Error: 506_609
- .saturating_add(Weight::from_parts(6_303_908, 0).saturating_mul(n.into()))
- .saturating_add(T::DbWeight::get().reads(180))
+ // Standard Error: 412_098
+ .saturating_add(Weight::from_parts(5_172_265, 0).saturating_mul(v.into()))
+ // Standard Error: 412_098
+ .saturating_add(Weight::from_parts(4_142_772, 0).saturating_mul(n.into()))
+ .saturating_add(T::DbWeight::get().reads(179))
.saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into())))
- .saturating_add(T::DbWeight::get().writes(2))
+ .saturating_add(T::DbWeight::get().writes(1))
.saturating_add(Weight::from_parts(0, 3566).saturating_mul(n.into()))
.saturating_add(Weight::from_parts(0, 3566).saturating_mul(v.into()))
}
- /// Storage: Staking CounterForValidators (r:1 w:0)
- /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking Validators (r:1001 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: System BlockWeight (r:1 w:1)
- /// Proof: System BlockWeight (max_values: Some(1), max_size: Some(48), added: 543, mode: MaxEncodedLen)
+ /// Storage: `Staking::CounterForValidators` (r:1 w:0)
+ /// Proof: `Staking::CounterForValidators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1001 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
/// The range of component `v` is `[500, 1000]`.
fn get_npos_targets(v: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `951 + v * (50 ±0)`
+ // Measured: `946 + v * (50 ±0)`
// Estimated: `3510 + v * (2520 ±0)`
- // Minimum execution time: 2_603_304_000 picoseconds.
- Weight::from_parts(481_860_383, 0)
+ // Minimum execution time: 2_522_650_000 picoseconds.
+ Weight::from_parts(97_022_833, 0)
.saturating_add(Weight::from_parts(0, 3510))
- // Standard Error: 55_189
- .saturating_add(Weight::from_parts(4_786_173, 0).saturating_mul(v.into()))
- .saturating_add(T::DbWeight::get().reads(3))
+ // Standard Error: 6_751
+ .saturating_add(Weight::from_parts(4_990_018, 0).saturating_mul(v.into()))
+ .saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into())))
- .saturating_add(T::DbWeight::get().writes(1))
.saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into()))
}
- /// Storage: Staking MinCommission (r:0 w:1)
- /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking MinValidatorBond (r:0 w:1)
- /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
- /// Storage: Staking MaxValidatorsCount (r:0 w:1)
- /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking ChillThreshold (r:0 w:1)
- /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)
- /// Storage: Staking MaxNominatorsCount (r:0 w:1)
- /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking MinNominatorBond (r:0 w:1)
- /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
+ /// Storage: `Staking::MinCommission` (r:0 w:1)
+ /// Proof: `Staking::MinCommission` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinValidatorBond` (r:0 w:1)
+ /// Proof: `Staking::MinValidatorBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MaxValidatorsCount` (r:0 w:1)
+ /// Proof: `Staking::MaxValidatorsCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ChillThreshold` (r:0 w:1)
+ /// Proof: `Staking::ChillThreshold` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MaxNominatorsCount` (r:0 w:1)
+ /// Proof: `Staking::MaxNominatorsCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinNominatorBond` (r:0 w:1)
+ /// Proof: `Staking::MinNominatorBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
fn set_staking_configs_all_set() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 6_453_000 picoseconds.
- Weight::from_parts(6_857_000, 0)
+ // Minimum execution time: 3_833_000 picoseconds.
+ Weight::from_parts(4_108_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(6))
}
- /// Storage: Staking MinCommission (r:0 w:1)
- /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking MinValidatorBond (r:0 w:1)
- /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
- /// Storage: Staking MaxValidatorsCount (r:0 w:1)
- /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking ChillThreshold (r:0 w:1)
- /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)
- /// Storage: Staking MaxNominatorsCount (r:0 w:1)
- /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking MinNominatorBond (r:0 w:1)
- /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
+ /// Storage: `Staking::MinCommission` (r:0 w:1)
+ /// Proof: `Staking::MinCommission` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinValidatorBond` (r:0 w:1)
+ /// Proof: `Staking::MinValidatorBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MaxValidatorsCount` (r:0 w:1)
+ /// Proof: `Staking::MaxValidatorsCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ChillThreshold` (r:0 w:1)
+ /// Proof: `Staking::ChillThreshold` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MaxNominatorsCount` (r:0 w:1)
+ /// Proof: `Staking::MaxNominatorsCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinNominatorBond` (r:0 w:1)
+ /// Proof: `Staking::MinNominatorBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
fn set_staking_configs_all_remove() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 6_037_000 picoseconds.
- Weight::from_parts(6_303_000, 0)
+ // Minimum execution time: 3_520_000 picoseconds.
+ Weight::from_parts(3_686_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(6))
}
- /// Storage: Staking Ledger (r:1 w:0)
- /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
- /// Storage: Staking Nominators (r:1 w:1)
- /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen)
- /// Storage: Staking ChillThreshold (r:1 w:0)
- /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)
- /// Storage: Staking MaxNominatorsCount (r:1 w:0)
- /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking CounterForNominators (r:1 w:1)
- /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking MinNominatorBond (r:1 w:0)
- /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
- /// Storage: Staking Validators (r:1 w:0)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
- /// Storage: VoterList ListNodes (r:2 w:2)
- /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen)
- /// Storage: VoterList ListBags (r:1 w:1)
- /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen)
- /// Storage: VoterList CounterForListNodes (r:1 w:1)
- /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
+ /// Storage: `Staking::Ledger` (r:1 w:0)
+ /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Nominators` (r:1 w:1)
+ /// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::ChillThreshold` (r:1 w:0)
+ /// Proof: `Staking::ChillThreshold` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MaxNominatorsCount` (r:1 w:0)
+ /// Proof: `Staking::MaxNominatorsCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::CounterForNominators` (r:1 w:1)
+ /// Proof: `Staking::CounterForNominators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::MinNominatorBond` (r:1 w:0)
+ /// Proof: `Staking::MinNominatorBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1 w:0)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListNodes` (r:2 w:2)
+ /// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::ListBags` (r:1 w:1)
+ /// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
+ /// Storage: `VoterList::CounterForListNodes` (r:1 w:1)
+ /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn chill_other() -> Weight {
// Proof Size summary in bytes:
- // Measured: `1798`
+ // Measured: `1704`
// Estimated: `6248`
- // Minimum execution time: 72_578_000 picoseconds.
- Weight::from_parts(74_232_000, 0)
+ // Minimum execution time: 63_983_000 picoseconds.
+ Weight::from_parts(66_140_000, 0)
.saturating_add(Weight::from_parts(0, 6248))
.saturating_add(T::DbWeight::get().reads(11))
.saturating_add(T::DbWeight::get().writes(6))
}
- /// Storage: Staking MinCommission (r:1 w:0)
- /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
- /// Storage: Staking Validators (r:1 w:1)
- /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen)
+ /// Storage: `Staking::MinCommission` (r:1 w:0)
+ /// Proof: `Staking::MinCommission` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `Staking::Validators` (r:1 w:1)
+ /// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
fn force_apply_min_commission() -> Weight {
// Proof Size summary in bytes:
- // Measured: `661`
+ // Measured: `658`
// Estimated: `3510`
- // Minimum execution time: 13_066_000 picoseconds.
- Weight::from_parts(13_421_000, 0)
+ // Minimum execution time: 11_830_000 picoseconds.
+ Weight::from_parts(12_210_000, 0)
.saturating_add(Weight::from_parts(0, 3510))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
- /// Storage: Staking MinCommission (r:0 w:1)
- /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
+ /// Storage: `Staking::MinCommission` (r:0 w:1)
+ /// Proof: `Staking::MinCommission` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn set_min_commission() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 3_057_000 picoseconds.
- Weight::from_parts(3_488_000, 0)
+ // Minimum execution time: 2_364_000 picoseconds.
+ Weight::from_parts(2_555_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
diff --git a/prdoc/pr_1289.prdoc b/prdoc/pr_1289.prdoc
new file mode 100644
index 0000000000..f3d8801d9d
--- /dev/null
+++ b/prdoc/pr_1289.prdoc
@@ -0,0 +1,28 @@
+# Schema: Parity PR Documentation Schema (prdoc)
+# See doc at https://github.com/paritytech/prdoc
+
+title: Supporting paged rewards allowing all nominators to be rewarded
+
+doc:
+ - audience: Validator
+ description: |
+ We used to clip top `MaxNominatorRewardedPerValidator` nominators by stake that are eligible for staking reward.
+ This was done to limit computation cost of paying out rewards. This PR introduces paging to reward payouts,
+ meaning we still clip nominators upto MaxExposurePageSize per page and there could be multiple pages of rewards to
+ be paid out. Validators get commission pro-rata to the amount of reward that is paid out for the page.
+
+ notes:
+ - payout_stakers should be called multiple times, once for each page of nominators.
+ - payout_stakers_by_page can be used to pay out rewards for a specific page.
+ - Some old non-paged era storage items are deprecated, and can be removed in a future upgrade.
+
+migrations:
+ db: []
+
+ runtime:
+ - { pallet: "pallet-staking", description: "v14: Migration of era exposure storage items to paged exposures."}
+
+crates:
+ - name: pallet-staking
+
+host_functions: []
\ No newline at end of file
diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs
index cb8d7f6b1d..127faec356 100644
--- a/substrate/bin/node/runtime/src/lib.rs
+++ b/substrate/bin/node/runtime/src/lib.rs
@@ -485,7 +485,7 @@ impl pallet_babe::Config for Runtime {
type DisabledValidators = Session;
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
- type MaxNominators = MaxNominatorRewardedPerValidator;
+ type MaxNominators = MaxNominators;
type KeyOwnerProof =
>::Proof;
type EquivocationReportSystem =
@@ -628,7 +628,7 @@ parameter_types! {
pub const BondingDuration: sp_staking::EraIndex = 24 * 28;
pub const SlashDeferDuration: sp_staking::EraIndex = 24 * 7; // 1/4 the bonding duration.
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
- pub const MaxNominatorRewardedPerValidator: u32 = 256;
+ pub const MaxNominators: u32 = 64;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub OffchainRepeat: BlockNumber = 5;
pub HistoryDepth: u32 = 84;
@@ -663,7 +663,7 @@ impl pallet_staking::Config for Runtime {
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve;
type NextNewSession = Session;
- type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
+ type MaxExposurePageSize = ConstU32<256>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type ElectionProvider = ElectionProviderMultiPhase;
type GenesisElectionProvider = onchain::OnChainExecution;
@@ -686,8 +686,6 @@ impl pallet_fast_unstake::Config for Runtime {
type Currency = Balances;
type Staking = Staking;
type MaxErasToCheckPerBlock = ConstU32<1>;
- #[cfg(feature = "runtime-benchmarks")]
- type MaxBackersPerValidator = MaxNominatorRewardedPerValidator;
type WeightInfo = ();
}
@@ -1453,7 +1451,7 @@ impl pallet_grandpa::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
- type MaxNominators = MaxNominatorRewardedPerValidator;
+ type MaxNominators = MaxNominators;
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
type KeyOwnerProof = >::Proof;
type EquivocationReportSystem =
@@ -2392,10 +2390,14 @@ impl_runtime_apis! {
}
}
- impl pallet_staking_runtime_api::StakingApi for Runtime {
+ impl pallet_staking_runtime_api::StakingApi for Runtime {
fn nominations_quota(balance: Balance) -> u32 {
Staking::api_nominations_quota(balance)
}
+
+ fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
+ Staking::api_eras_stakers_page_count(era, account)
+ }
}
impl sp_consensus_babe::BabeApi for Runtime {
diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs
index e0b23afaf6..0003c6f9f1 100644
--- a/substrate/frame/babe/src/mock.rs
+++ b/substrate/frame/babe/src/mock.rs
@@ -174,7 +174,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet;
type EraPayout = pallet_staking::ConvertCurve;
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainExecution;
diff --git a/substrate/frame/babe/src/tests.rs b/substrate/frame/babe/src/tests.rs
index ec4e6fd972..e65f1844f8 100644
--- a/substrate/frame/babe/src/tests.rs
+++ b/substrate/frame/babe/src/tests.rs
@@ -440,7 +440,7 @@ fn report_equivocation_current_session_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(1, validator),
+ Staking::eras_stakers(1, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
@@ -481,7 +481,7 @@ fn report_equivocation_current_session_works() {
assert_eq!(Balances::total_balance(&offending_validator_id), 10_000_000 - 10_000);
assert_eq!(Staking::slashable_balance_of(&offending_validator_id), 0);
assert_eq!(
- Staking::eras_stakers(2, offending_validator_id),
+ Staking::eras_stakers(2, &offending_validator_id),
pallet_staking::Exposure { total: 0, own: 0, others: vec![] },
);
@@ -494,7 +494,7 @@ fn report_equivocation_current_session_works() {
assert_eq!(Balances::total_balance(validator), 10_000_000);
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(2, validator),
+ Staking::eras_stakers(2, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
@@ -553,7 +553,7 @@ fn report_equivocation_old_session_works() {
assert_eq!(Balances::total_balance(&offending_validator_id), 10_000_000 - 10_000);
assert_eq!(Staking::slashable_balance_of(&offending_validator_id), 0);
assert_eq!(
- Staking::eras_stakers(3, offending_validator_id),
+ Staking::eras_stakers(3, &offending_validator_id),
pallet_staking::Exposure { total: 0, own: 0, others: vec![] },
);
})
diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs
index 8618fdab19..53d523cf72 100644
--- a/substrate/frame/beefy/src/mock.rs
+++ b/substrate/frame/beefy/src/mock.rs
@@ -192,7 +192,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet;
type EraPayout = pallet_staking::ConvertCurve;
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainExecution;
diff --git a/substrate/frame/beefy/src/tests.rs b/substrate/frame/beefy/src/tests.rs
index bf1b204e02..bf5ae19510 100644
--- a/substrate/frame/beefy/src/tests.rs
+++ b/substrate/frame/beefy/src/tests.rs
@@ -277,7 +277,7 @@ fn report_equivocation_current_set_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(1, validator),
+ Staking::eras_stakers(1, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
@@ -314,7 +314,7 @@ fn report_equivocation_current_set_works() {
assert_eq!(Balances::total_balance(&equivocation_validator_id), 10_000_000 - 10_000);
assert_eq!(Staking::slashable_balance_of(&equivocation_validator_id), 0);
assert_eq!(
- Staking::eras_stakers(2, equivocation_validator_id),
+ Staking::eras_stakers(2, &equivocation_validator_id),
pallet_staking::Exposure { total: 0, own: 0, others: vec![] },
);
@@ -328,7 +328,7 @@ fn report_equivocation_current_set_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(2, validator),
+ Staking::eras_stakers(2, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
@@ -363,7 +363,7 @@ fn report_equivocation_old_set_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(2, validator),
+ Staking::eras_stakers(2, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
@@ -397,7 +397,7 @@ fn report_equivocation_old_set_works() {
assert_eq!(Balances::total_balance(&equivocation_validator_id), 10_000_000 - 10_000);
assert_eq!(Staking::slashable_balance_of(&equivocation_validator_id), 0);
assert_eq!(
- Staking::eras_stakers(3, equivocation_validator_id),
+ Staking::eras_stakers(3, &equivocation_validator_id),
pallet_staking::Exposure { total: 0, own: 0, others: vec![] },
);
@@ -411,7 +411,7 @@ fn report_equivocation_old_set_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(3, validator),
+ Staking::eras_stakers(3, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
index 9195945f6c..751ffc07aa 100644
--- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
+++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
@@ -237,7 +237,6 @@ parameter_types! {
pub const SessionsPerEra: sp_staking::SessionIndex = 2;
pub const BondingDuration: sp_staking::EraIndex = 28;
pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration.
- pub const MaxNominatorRewardedPerValidator: u32 = 256;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(40);
pub HistoryDepth: u32 = 84;
}
@@ -269,7 +268,7 @@ impl pallet_staking::Config for Runtime {
type SessionInterface = Self;
type EraPayout = ();
type NextNewSession = Session;
- type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
+ type MaxExposurePageSize = ConstU32<256>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type ElectionProvider = ElectionProviderMultiPhase;
type GenesisElectionProvider = onchain::OnChainExecution;
@@ -809,7 +808,7 @@ pub(crate) fn on_offence_now(
pub(crate) fn add_slash(who: &AccountId) {
on_offence_now(
&[OffenceDetails {
- offender: (*who, Staking::eras_stakers(active_era(), *who)),
+ offender: (*who, Staking::eras_stakers(active_era(), who)),
reporters: vec![],
}],
&[Perbill::from_percent(10)],
diff --git a/substrate/frame/fast-unstake/src/benchmarking.rs b/substrate/frame/fast-unstake/src/benchmarking.rs
index 5ec997e8ea..851483e369 100644
--- a/substrate/frame/fast-unstake/src/benchmarking.rs
+++ b/substrate/frame/fast-unstake/src/benchmarking.rs
@@ -74,9 +74,9 @@ fn setup_staking(v: u32, until: EraIndex) {
.collect::>();
for era in 0..=until {
- let others = (0..T::MaxBackersPerValidator::get())
+ let others = (0..T::Staking::max_exposure_page_size())
.map(|s| {
- let who = frame_benchmarking::account::("nominator", era, s);
+ let who = frame_benchmarking::account::("nominator", era, s.into());
let value = ed;
(who, value)
})
diff --git a/substrate/frame/fast-unstake/src/lib.rs b/substrate/frame/fast-unstake/src/lib.rs
index 2b99ad79a7..153b6c2c35 100644
--- a/substrate/frame/fast-unstake/src/lib.rs
+++ b/substrate/frame/fast-unstake/src/lib.rs
@@ -203,10 +203,6 @@ pub mod pallet {
/// The weight information of this pallet.
type WeightInfo: WeightInfo;
-
- /// Use only for benchmarking.
- #[cfg(feature = "runtime-benchmarks")]
- type MaxBackersPerValidator: Get;
}
/// The current "head of the queue" being unstaked.
diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs
index 6b866224ab..df133bdfd4 100644
--- a/substrate/frame/fast-unstake/src/mock.rs
+++ b/substrate/frame/fast-unstake/src/mock.rs
@@ -134,7 +134,7 @@ impl pallet_staking::Config for Runtime {
type EraPayout = pallet_staking::ConvertCurve;
type NextNewSession = ();
type HistoryDepth = ConstU32<84>;
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = ();
type ElectionProvider = MockElection;
type GenesisElectionProvider = Self::ElectionProvider;
@@ -175,8 +175,6 @@ impl fast_unstake::Config for Runtime {
type BatchSize = BatchSize;
type WeightInfo = ();
type MaxErasToCheckPerBlock = ConstU32<16>;
- #[cfg(feature = "runtime-benchmarks")]
- type MaxBackersPerValidator = ConstU32<128>;
}
type Block = frame_system::mocking::MockBlock;
diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs
index 79e3069d01..9afcec1c79 100644
--- a/substrate/frame/grandpa/src/mock.rs
+++ b/substrate/frame/grandpa/src/mock.rs
@@ -196,7 +196,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet;
type EraPayout = pallet_staking::ConvertCurve;
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainExecution;
diff --git a/substrate/frame/grandpa/src/tests.rs b/substrate/frame/grandpa/src/tests.rs
index 59d73ee729..993d72af6d 100644
--- a/substrate/frame/grandpa/src/tests.rs
+++ b/substrate/frame/grandpa/src/tests.rs
@@ -333,7 +333,7 @@ fn report_equivocation_current_set_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(1, validator),
+ Staking::eras_stakers(1, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
@@ -371,7 +371,7 @@ fn report_equivocation_current_set_works() {
assert_eq!(Balances::total_balance(&equivocation_validator_id), 10_000_000 - 10_000);
assert_eq!(Staking::slashable_balance_of(&equivocation_validator_id), 0);
assert_eq!(
- Staking::eras_stakers(2, equivocation_validator_id),
+ Staking::eras_stakers(2, &equivocation_validator_id),
pallet_staking::Exposure { total: 0, own: 0, others: vec![] },
);
@@ -385,7 +385,7 @@ fn report_equivocation_current_set_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(2, validator),
+ Staking::eras_stakers(2, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
@@ -417,7 +417,7 @@ fn report_equivocation_old_set_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(2, validator),
+ Staking::eras_stakers(2, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
@@ -450,7 +450,7 @@ fn report_equivocation_old_set_works() {
assert_eq!(Staking::slashable_balance_of(&equivocation_validator_id), 0);
assert_eq!(
- Staking::eras_stakers(3, equivocation_validator_id),
+ Staking::eras_stakers(3, &equivocation_validator_id),
pallet_staking::Exposure { total: 0, own: 0, others: vec![] },
);
@@ -464,7 +464,7 @@ fn report_equivocation_old_set_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
- Staking::eras_stakers(3, validator),
+ Staking::eras_stakers(3, &validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
);
}
diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs
index 3cbaed2383..9a7f2197a7 100644
--- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs
+++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs
@@ -110,7 +110,7 @@ impl pallet_staking::Config for Runtime {
type SessionInterface = ();
type EraPayout = pallet_staking::ConvertCurve;
type NextNewSession = ();
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = ();
type ElectionProvider =
frame_election_provider_support::NoElection<(AccountId, BlockNumber, Staking, ())>;
diff --git a/substrate/frame/nomination-pools/src/mock.rs b/substrate/frame/nomination-pools/src/mock.rs
index d683994c28..24bea0b87f 100644
--- a/substrate/frame/nomination-pools/src/mock.rs
+++ b/substrate/frame/nomination-pools/src/mock.rs
@@ -202,6 +202,11 @@ impl sp_staking::StakingInterface for StakingMock {
fn set_current_era(_era: EraIndex) {
unimplemented!("method currently not used in testing")
}
+
+ #[cfg(feature = "runtime-benchmarks")]
+ fn max_exposure_page_size() -> sp_staking::Page {
+ unimplemented!("method currently not used in testing")
+ }
}
impl frame_system::Config for Runtime {
diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs
index c36dc70cb4..0db24e9c24 100644
--- a/substrate/frame/nomination-pools/test-staking/src/mock.rs
+++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs
@@ -124,7 +124,7 @@ impl pallet_staking::Config for Runtime {
type SessionInterface = ();
type EraPayout = pallet_staking::ConvertCurve;
type NextNewSession = ();
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = ();
type ElectionProvider =
frame_election_provider_support::NoElection<(AccountId, BlockNumber, Staking, ())>;
diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs
index c877f955fb..1a458ec90d 100644
--- a/substrate/frame/offences/benchmarking/src/mock.rs
+++ b/substrate/frame/offences/benchmarking/src/mock.rs
@@ -176,7 +176,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve;
type NextNewSession = Session;
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = ();
type ElectionProvider = onchain::OnChainExecution;
type GenesisElectionProvider = Self::ElectionProvider;
diff --git a/substrate/frame/root-offences/src/lib.rs b/substrate/frame/root-offences/src/lib.rs
index a93e7ff848..e6bb5bb188 100644
--- a/substrate/frame/root-offences/src/lib.rs
+++ b/substrate/frame/root-offences/src/lib.rs
@@ -111,7 +111,7 @@ pub mod pallet {
.clone()
.into_iter()
.map(|(o, _)| OffenceDetails:: {
- offender: (o.clone(), Staking::::eras_stakers(now, o)),
+ offender: (o.clone(), Staking::::eras_stakers(now, &o)),
reporters: vec![],
})
.collect())
diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs
index 59ab539fcf..82da429e00 100644
--- a/substrate/frame/root-offences/src/mock.rs
+++ b/substrate/frame/root-offences/src/mock.rs
@@ -179,7 +179,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve;
type NextNewSession = Session;
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type ElectionProvider = onchain::OnChainExecution;
type GenesisElectionProvider = Self::ElectionProvider;
diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs
index d3da12ef9a..47c337569a 100644
--- a/substrate/frame/session/benchmarking/src/mock.rs
+++ b/substrate/frame/session/benchmarking/src/mock.rs
@@ -173,7 +173,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve;
type NextNewSession = Session;
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = ConstU32<64>;
type OffendingValidatorsThreshold = ();
type ElectionProvider = onchain::OnChainExecution;
type GenesisElectionProvider = Self::ElectionProvider;
diff --git a/substrate/frame/staking/CHANGELOG.md b/substrate/frame/staking/CHANGELOG.md
new file mode 100644
index 0000000000..719aa38875
--- /dev/null
+++ b/substrate/frame/staking/CHANGELOG.md
@@ -0,0 +1,27 @@
+# Changelog
+
+All notable changes and migrations to pallet-staking will be documented in this file.
+
+The format is loosely based
+on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). We maintain a
+single integer version number for staking pallet to keep track of all storage
+migrations.
+
+## [v14]
+
+### Added
+
+- New item `ErasStakersPaged` that keeps up to `MaxExposurePageSize`
+ individual nominator exposures by era, validator and page.
+- New item `ErasStakersOverview` complementary to `ErasStakersPaged` which keeps
+ state of own and total stake of the validator across pages.
+- New item `ClaimedRewards` to support paged rewards payout.
+
+### Deprecated
+
+- `ErasStakers` and `ErasStakersClipped` is deprecated, will not be used any longer for the exposures of the new era
+ post v14 and can be removed after 84 eras once all the exposures are stale.
+- Field `claimed_rewards` in item `Ledger` is renamed
+ to `legacy_claimed_rewards` and can be removed after 84 eras.
+
+[v14]: https://github.com/paritytech/substrate/pull/13498
diff --git a/substrate/frame/staking/README.md b/substrate/frame/staking/README.md
index 387b94b6a6..8c91cfcaa7 100644
--- a/substrate/frame/staking/README.md
+++ b/substrate/frame/staking/README.md
@@ -14,6 +14,7 @@ funds are rewarded under normal operation but are held at pain of _slash_ (expro
be found not to be discharging its duties properly.
### Terminology
+
- Staking: The process of locking up funds for some time, placing them at risk of slashing (loss) in order to become a
@@ -29,6 +30,7 @@ be found not to be discharging its duties properly.
- Slash: The punishment of a staker by reducing its funds.
### Goals
+
The staking system in Substrate NPoS is designed to make the following possible:
@@ -75,7 +77,7 @@ An account can become a validator candidate via the
#### Nomination
-A **nominator** does not take any _direct_ role in maintaining the network, instead, it votes on a set of validators to
+A **nominator** does not take any _direct_ role in maintaining the network, instead, it votes on a set of validators to
be elected. Once interest in nomination is stated by an account, it takes effect at the next election round. The funds
in the nominator's stash account indicate the _weight_ of its vote. Both the rewards and any punishment that a validator
earns are shared between the validator and its nominators. This rule incentivizes the nominators to NOT vote for the
@@ -90,10 +92,12 @@ An account can become a nominator via the
The **reward and slashing** procedure is the core of the Staking module, attempting to _embrace valid behavior_ while
_punishing any misbehavior or lack of availability_.
-Rewards must be claimed for each era before it gets too old by `$HISTORY_DEPTH` using the `payout_stakers` call. Any
-account can call `payout_stakers`, which pays the reward to the validator as well as its nominators. Only the
-[`Config::MaxNominatorRewardedPerValidator`] biggest stakers can claim their reward. This is to limit the i/o cost to
-mutate storage for each nominator's account.
+Rewards must be claimed for each era before it gets too old by `$HISTORY_DEPTH` using the `payout_stakers` call. When a
+validator has more than [`Config::MaxExposurePageSize`] nominators, nominators are divided into pages with each call to
+`payout_stakers` paying rewards to one page of nominators in a sequential and ascending manner. Any account can also
+call `payout_stakers_by_page` to explicitly pay reward for a given page. As evident, this means only the
+[`Config::MaxExposurePageSize`] nominators are rewarded per call. This is to limit the i/o cost to mutate storage for
+each nominator's account.
Slashing can occur at any point in time, once misbehavior is reported. Once slashing is determined, a value is deducted
from the balance of the validator and all the nominators who voted for this validator (values are deducted from the
@@ -173,11 +177,13 @@ such:
```nocompile
staker_payout = yearly_inflation(npos_token_staked / total_tokens) * total_tokens / era_per_year
```
+
This payout is used to reward stakers as defined in next section
```nocompile
remaining_payout = max_yearly_inflation * total_tokens / era_per_year - staker_payout
```
+
The remaining reward is send to the configurable end-point
[`T::RewardRemainder`](https://docs.rs/pallet-staking/latest/pallet_staking/trait.Config.html#associatedtype.RewardRemainder).
diff --git a/substrate/frame/staking/runtime-api/Cargo.toml b/substrate/frame/staking/runtime-api/Cargo.toml
index 5f49df254c..746b463b8c 100644
--- a/substrate/frame/staking/runtime-api/Cargo.toml
+++ b/substrate/frame/staking/runtime-api/Cargo.toml
@@ -14,8 +14,9 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
-sp-api = { path = "../../../primitives/api", default-features = false}
+sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" }
+sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/staking" }
[features]
default = [ "std" ]
-std = [ "codec/std", "sp-api/std" ]
+std = [ "codec/std", "sp-api/std", "sp-staking/std" ]
diff --git a/substrate/frame/staking/runtime-api/src/lib.rs b/substrate/frame/staking/runtime-api/src/lib.rs
index c669d222ec..b04c383a07 100644
--- a/substrate/frame/staking/runtime-api/src/lib.rs
+++ b/substrate/frame/staking/runtime-api/src/lib.rs
@@ -22,11 +22,15 @@
use codec::Codec;
sp_api::decl_runtime_apis! {
- pub trait StakingApi
+ pub trait StakingApi
where
Balance: Codec,
+ AccountId: Codec,
{
/// Returns the nominations quota for a nominator with a given balance.
fn nominations_quota(balance: Balance) -> u32;
+
+ /// Returns the page count of exposures for a validator in a given era.
+ fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page;
}
}
diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs
index f94d9bf4b3..05c6bc3970 100644
--- a/substrate/frame/staking/src/benchmarking.rs
+++ b/substrate/frame/staking/src/benchmarking.rs
@@ -552,10 +552,10 @@ benchmarks! {
}
payout_stakers_dead_controller {
- let n in 0 .. T::MaxNominatorRewardedPerValidator::get() as u32;
+ let n in 0 .. T::MaxExposurePageSize::get() as u32;
let (validator, nominators) = create_validator_with_nominators::(
n,
- T::MaxNominatorRewardedPerValidator::get() as u32,
+ T::MaxExposurePageSize::get() as u32,
true,
true,
RewardDestination::Controller,
@@ -572,7 +572,7 @@ benchmarks! {
let balance = T::Currency::free_balance(controller);
ensure!(balance.is_zero(), "Controller has balance, but should be dead.");
}
- }: payout_stakers(RawOrigin::Signed(caller), validator, current_era)
+ }: payout_stakers_by_page(RawOrigin::Signed(caller), validator, current_era, 0)
verify {
let balance_after = T::Currency::free_balance(&validator_controller);
ensure!(
@@ -586,10 +586,10 @@ benchmarks! {
}
payout_stakers_alive_staked {
- let n in 0 .. T::MaxNominatorRewardedPerValidator::get() as u32;
+ let n in 0 .. T::MaxExposurePageSize::get() as u32;
let (validator, nominators) = create_validator_with_nominators::(
n,
- T::MaxNominatorRewardedPerValidator::get() as u32,
+ T::MaxExposurePageSize::get() as u32,
false,
true,
RewardDestination::Staked,
@@ -687,7 +687,6 @@ benchmarks! {
let l = StakingLedger::::new(
stash.clone(),
T::Currency::minimum_balance() - One::one(),
- Default::default(),
);
Ledger::::insert(&controller, l);
@@ -760,7 +759,7 @@ benchmarks! {
let caller: T::AccountId = whitelisted_caller();
let origin = RawOrigin::Signed(caller);
let calls: Vec<_> = payout_calls_arg.iter().map(|arg|
- Call::::payout_stakers { validator_stash: arg.0.clone(), era: arg.1 }.encode()
+ Call::::payout_stakers_by_page { validator_stash: arg.0.clone(), era: arg.1, page: 0 }.encode()
).collect();
}: {
for call in calls {
@@ -984,7 +983,7 @@ mod tests {
let (validator_stash, nominators) = create_validator_with_nominators::(
n,
- <::MaxNominatorRewardedPerValidator as Get<_>>::get(),
+ <::MaxExposurePageSize as Get<_>>::get(),
false,
false,
RewardDestination::Staked,
@@ -996,10 +995,11 @@ mod tests {
let current_era = CurrentEra::::get().unwrap();
let original_free_balance = Balances::free_balance(&validator_stash);
- assert_ok!(Staking::payout_stakers(
+ assert_ok!(Staking::payout_stakers_by_page(
RuntimeOrigin::signed(1337),
validator_stash,
- current_era
+ current_era,
+ 0
));
let new_free_balance = Balances::free_balance(&validator_stash);
@@ -1014,7 +1014,7 @@ mod tests {
let (validator_stash, _nominators) = create_validator_with_nominators::(
n,
- <::MaxNominatorRewardedPerValidator as Get<_>>::get(),
+ <::MaxExposurePageSize as Get<_>>::get(),
false,
false,
RewardDestination::Staked,
diff --git a/substrate/frame/staking/src/ledger.rs b/substrate/frame/staking/src/ledger.rs
index cf9b4635bf..84bb4d167d 100644
--- a/substrate/frame/staking/src/ledger.rs
+++ b/substrate/frame/staking/src/ledger.rs
@@ -34,9 +34,8 @@
use frame_support::{
defensive,
traits::{LockableCurrency, WithdrawReasons},
- BoundedVec,
};
-use sp_staking::{EraIndex, StakingAccount};
+use sp_staking::StakingAccount;
use sp_std::prelude::*;
use crate::{
@@ -54,7 +53,7 @@ impl StakingLedger {
total: Zero::zero(),
active: Zero::zero(),
unlocking: Default::default(),
- claimed_rewards: Default::default(),
+ legacy_claimed_rewards: Default::default(),
controller: Some(stash),
}
}
@@ -66,17 +65,13 @@ impl StakingLedger {
///
/// Note: as the controller accounts are being deprecated, the stash account is the same as the
/// controller account.
- pub fn new(
- stash: T::AccountId,
- stake: BalanceOf,
- claimed_rewards: BoundedVec,
- ) -> Self {
+ pub fn new(stash: T::AccountId, stake: BalanceOf) -> Self {
Self {
stash: stash.clone(),
active: stake,
total: stake,
unlocking: Default::default(),
- claimed_rewards,
+ legacy_claimed_rewards: Default::default(),
// controllers are deprecated and mapped 1-1 to stashes.
controller: Some(stash),
}
@@ -240,8 +235,8 @@ pub struct StakingLedgerInspect {
pub total: BalanceOf,
#[codec(compact)]
pub active: BalanceOf,
- pub unlocking: BoundedVec>, T::MaxUnlockingChunks>,
- pub claimed_rewards: BoundedVec,
+ pub unlocking: frame_support::BoundedVec>, T::MaxUnlockingChunks>,
+ pub legacy_claimed_rewards: frame_support::BoundedVec,
}
#[cfg(test)]
@@ -251,7 +246,7 @@ impl PartialEq> for StakingLedger {
self.total == other.total &&
self.active == other.active &&
self.unlocking == other.unlocking &&
- self.claimed_rewards == other.claimed_rewards
+ self.legacy_claimed_rewards == other.legacy_claimed_rewards
}
}
diff --git a/substrate/frame/staking/src/lib.rs b/substrate/frame/staking/src/lib.rs
index 227326763a..9e4697e845 100644
--- a/substrate/frame/staking/src/lib.rs
+++ b/substrate/frame/staking/src/lib.rs
@@ -112,11 +112,15 @@
//! The **reward and slashing** procedure is the core of the Staking pallet, attempting to _embrace
//! valid behavior_ while _punishing any misbehavior or lack of availability_.
//!
-//! Rewards must be claimed for each era before it gets too old by `$HISTORY_DEPTH` using the
-//! `payout_stakers` call. Any account can call `payout_stakers`, which pays the reward to the
-//! validator as well as its nominators. Only the [`Config::MaxNominatorRewardedPerValidator`]
-//! biggest stakers can claim their reward. This is to limit the i/o cost to mutate storage for each
-//! nominator's account.
+//! Rewards must be claimed for each era before it gets too old by
+//! [`HistoryDepth`](`Config::HistoryDepth`) using the `payout_stakers` call. Any account can call
+//! `payout_stakers`, which pays the reward to the validator as well as its nominators. Only
+//! [`Config::MaxExposurePageSize`] nominator rewards can be claimed in a single call. When the
+//! number of nominators exceeds [`Config::MaxExposurePageSize`], then the exposed nominators are
+//! stored in multiple pages, with each page containing up to
+//! [`Config::MaxExposurePageSize`] nominators. To pay out all nominators, `payout_stakers` must be
+//! called once for each available page. Paging exists to limit the i/o cost to mutate storage for
+//! each nominator's account.
//!
//! Slashing can occur at any point in time, once misbehavior is reported. Once slashing is
//! determined, a value is deducted from the balance of the validator and all the nominators who
@@ -224,13 +228,13 @@
//! The validator can declare an amount, named [`commission`](ValidatorPrefs::commission), that does
//! not get shared with the nominators at each reward payout through its [`ValidatorPrefs`]. This
//! value gets deducted from the total reward that is paid to the validator and its nominators. The
-//! remaining portion is split pro rata among the validator and the top
-//! [`Config::MaxNominatorRewardedPerValidator`] nominators that nominated the validator,
-//! proportional to the value staked behind the validator (_i.e._ dividing the
+//! remaining portion is split pro rata among the validator and the nominators that nominated the
+//! validator, proportional to the value staked behind the validator (_i.e._ dividing the
//! [`own`](Exposure::own) or [`others`](Exposure::others) by [`total`](Exposure::total) in
-//! [`Exposure`]). Note that the pro rata division of rewards uses the total exposure behind the
-//! validator, *not* just the exposure of the validator and the top
-//! [`Config::MaxNominatorRewardedPerValidator`] nominators.
+//! [`Exposure`]). Note that payouts are made in pages with each page capped at
+//! [`Config::MaxExposurePageSize`] nominators. The distribution of nominators across
+//! pages may be unsorted. The total commission is paid out proportionally across pages based on the
+//! total stake of the page.
//!
//! All entities who receive a reward have the option to choose their reward destination through the
//! [`Payee`] storage item (see
@@ -303,7 +307,10 @@ mod pallet;
use codec::{Decode, Encode, HasCompact, MaxEncodedLen};
use frame_support::{
- traits::{ConstU32, Currency, Defensive, Get, LockIdentifier},
+ defensive, defensive_assert,
+ traits::{
+ ConstU32, Currency, Defensive, DefensiveMax, DefensiveSaturating, Get, LockIdentifier,
+ },
weights::Weight,
BoundedVec, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
};
@@ -313,11 +320,12 @@ use sp_runtime::{
traits::{AtLeast32BitUnsigned, Convert, StaticLookup, Zero},
Perbill, Perquintill, Rounding, RuntimeDebug, Saturating,
};
-pub use sp_staking::StakerStatus;
use sp_staking::{
offence::{Offence, OffenceError, ReportOffence},
- EraIndex, OnStakingUpdate, SessionIndex, StakingAccount,
+ EraIndex, ExposurePage, OnStakingUpdate, Page, PagedExposureMetadata, SessionIndex,
+ StakingAccount,
};
+pub use sp_staking::{Exposure, IndividualExposure, StakerStatus};
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
pub use weights::WeightInfo;
@@ -457,21 +465,29 @@ pub struct UnlockChunk {
pub struct StakingLedger {
/// The stash account whose balance is actually locked and at stake.
pub stash: T::AccountId,
+
/// The total amount of the stash's balance that we are currently accounting for.
/// It's just `active` plus all the `unlocking` balances.
#[codec(compact)]
pub total: BalanceOf,
+
/// The total amount of the stash's balance that will be at stake in any forthcoming
/// rounds.
#[codec(compact)]
pub active: BalanceOf,
+
/// Any balance that is becoming free, which may eventually be transferred out of the stash
/// (assuming it doesn't get slashed first). It is assumed that this will be treated as a first
/// in, first out queue where the new (higher value) eras get pushed on the back.
pub unlocking: BoundedVec>, T::MaxUnlockingChunks>,
+
/// List of eras for which the stakers behind a validator have claimed rewards. Only updated
/// for validators.
- pub claimed_rewards: BoundedVec,
+ ///
+ /// This is deprecated as of V14 in favor of `T::ClaimedRewards` and will be removed in future.
+ /// Refer to issue
+ pub legacy_claimed_rewards: BoundedVec,
+
/// The controller associated with this ledger's stash.
///
/// This is not stored on-chain, and is only bundled when the ledger is read from storage.
@@ -507,7 +523,7 @@ impl StakingLedger {
total,
active: self.active,
unlocking,
- claimed_rewards: self.claimed_rewards,
+ legacy_claimed_rewards: self.legacy_claimed_rewards,
controller: self.controller,
}
}
@@ -708,32 +724,50 @@ pub struct Nominations {
pub suppressed: bool,
}
-/// The amount of exposure (to slashing) than an individual nominator has.
-#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
-pub struct IndividualExposure {
- /// The stash account of the nominator in question.
- pub who: AccountId,
- /// Amount of funds exposed.
- #[codec(compact)]
- pub value: Balance,
+/// Facade struct to encapsulate `PagedExposureMetadata` and a single page of `ExposurePage`.
+///
+/// This is useful where we need to take into account the validator's own stake and total exposure
+/// in consideration, in addition to the individual nominators backing them.
+#[derive(Encode, Decode, RuntimeDebug, TypeInfo, PartialEq, Eq)]
+struct PagedExposure {
+ exposure_metadata: PagedExposureMetadata,
+ exposure_page: ExposurePage,
}
-/// A snapshot of the stake backing a single validator in the system.
-#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
-pub struct Exposure {
- /// The total balance backing this validator.
- #[codec(compact)]
- pub total: Balance,
- /// The validator's own stash that is exposed.
- #[codec(compact)]
- pub own: Balance,
- /// The portions of nominators stashes that are exposed.
- pub others: Vec>,
-}
+impl
+ PagedExposure
+{
+ /// Create a new instance of `PagedExposure` from legacy clipped exposures.
+ pub fn from_clipped(exposure: Exposure) -> Self {
+ Self {
+ exposure_metadata: PagedExposureMetadata {
+ total: exposure.total,
+ own: exposure.own,
+ nominator_count: exposure.others.len() as u32,
+ page_count: 1,
+ },
+ exposure_page: ExposurePage { page_total: exposure.total, others: exposure.others },
+ }
+ }
-impl Default for Exposure {
- fn default() -> Self {
- Self { total: Default::default(), own: Default::default(), others: vec![] }
+ /// Returns total exposure of this validator across pages
+ pub fn total(&self) -> Balance {
+ self.exposure_metadata.total
+ }
+
+ /// Returns total exposure of this validator for the current page
+ pub fn page_total(&self) -> Balance {
+ self.exposure_page.page_total + self.exposure_metadata.own
+ }
+
+ /// Returns validator's own stake that is exposed
+ pub fn own(&self) -> Balance {
+ self.exposure_metadata.own
+ }
+
+ /// Returns the portions of nominators stashes that are exposed in this page.
+ pub fn others(&self) -> &Vec> {
+ &self.exposure_page.others
}
}
@@ -985,6 +1019,195 @@ where
}
}
+/// Wrapper struct for Era related information. It is not a pure encapsulation as these storage
+/// items can be accessed directly but nevertheless, its recommended to use `EraInfo` where we
+/// can and add more functions to it as needed.
+pub(crate) struct EraInfo(sp_std::marker::PhantomData);
+impl EraInfo {
+ /// Temporary function which looks at both (1) passed param `T::StakingLedger` for legacy
+ /// non-paged rewards, and (2) `T::ClaimedRewards` for paged rewards. This function can be
+ /// removed once `T::HistoryDepth` eras have passed and none of the older non-paged rewards
+ /// are relevant/claimable.
+ // Refer tracker issue for cleanup: #13034
+ pub(crate) fn is_rewards_claimed_with_legacy_fallback(
+ era: EraIndex,
+ ledger: &StakingLedger,
+ validator: &T::AccountId,
+ page: Page,
+ ) -> bool {
+ ledger.legacy_claimed_rewards.binary_search(&era).is_ok() ||
+ Self::is_rewards_claimed(era, validator, page)
+ }
+
+ /// Check if the rewards for the given era and page index have been claimed.
+ ///
+ /// This is only used for paged rewards. Once older non-paged rewards are no longer
+ /// relevant, `is_rewards_claimed_with_legacy_fallback` can be removed and this function can
+ /// be made public.
+ fn is_rewards_claimed(era: EraIndex, validator: &T::AccountId, page: Page) -> bool {
+ ClaimedRewards::::get(era, validator).contains(&page)
+ }
+
+ /// Get exposure for a validator at a given era and page.
+ ///
+ /// This builds a paged exposure from `PagedExposureMetadata` and `ExposurePage` of the
+ /// validator. For older non-paged exposure, it returns the clipped exposure directly.
+ pub(crate) fn get_paged_exposure(
+ era: EraIndex,
+ validator: &T::AccountId,
+ page: Page,
+ ) -> Option>> {
+ let overview = >::get(&era, validator);
+
+ // return clipped exposure if page zero and paged exposure does not exist
+ // exists for backward compatibility and can be removed as part of #13034
+ if overview.is_none() && page == 0 {
+ return Some(PagedExposure::from_clipped(>::get(era, validator)))
+ }
+
+ // no exposure for this validator
+ if overview.is_none() {
+ return None
+ }
+
+ let overview = overview.expect("checked above; qed");
+
+ // validator stake is added only in page zero
+ let validator_stake = if page == 0 { overview.own } else { Zero::zero() };
+
+ // since overview is present, paged exposure will always be present except when a
+ // validator has only own stake and no nominator stake.
+ let exposure_page = >::get((era, validator, page)).unwrap_or_default();
+
+ // build the exposure
+ Some(PagedExposure {
+ exposure_metadata: PagedExposureMetadata { own: validator_stake, ..overview },
+ exposure_page,
+ })
+ }
+
+ /// Get full exposure of the validator at a given era.
+ pub(crate) fn get_full_exposure(
+ era: EraIndex,
+ validator: &T::AccountId,
+ ) -> Exposure> {
+ let overview = >::get(&era, validator);
+
+ if overview.is_none() {
+ return ErasStakers::::get(era, validator)
+ }
+
+ let overview = overview.expect("checked above; qed");
+
+ let mut others = Vec::with_capacity(overview.nominator_count as usize);
+ for page in 0..overview.page_count {
+ let nominators = >::get((era, validator, page));
+ others.append(&mut nominators.map(|n| n.others).defensive_unwrap_or_default());
+ }
+
+ Exposure { total: overview.total, own: overview.own, others }
+ }
+
+ /// Returns the number of pages of exposure a validator has for the given era.
+ ///
+ /// For eras where paged exposure does not exist, this returns 1 to keep backward compatibility.
+ pub(crate) fn get_page_count(era: EraIndex, validator: &T::AccountId) -> Page {
+ >::get(&era, validator)
+ .map(|overview| {
+ if overview.page_count == 0 && overview.own > Zero::zero() {
+ // Even though there are no nominator pages, there is still validator's own
+ // stake exposed which needs to be paid out in a page.
+ 1
+ } else {
+ overview.page_count
+ }
+ })
+ // Always returns 1 page for older non-paged exposure.
+ // FIXME: Can be cleaned up with issue #13034.
+ .unwrap_or(1)
+ }
+
+ /// Returns the next page that can be claimed or `None` if nothing to claim.
+ pub(crate) fn get_next_claimable_page(
+ era: EraIndex,
+ validator: &T::AccountId,
+ ledger: &StakingLedger,
+ ) -> Option {
+ if Self::is_non_paged_exposure(era, validator) {
+ return match ledger.legacy_claimed_rewards.binary_search(&era) {
+ // already claimed
+ Ok(_) => None,
+ // Non-paged exposure is considered as a single page
+ Err(_) => Some(0),
+ }
+ }
+
+ // Find next claimable page of paged exposure.
+ let page_count = Self::get_page_count(era, validator);
+ let all_claimable_pages: Vec = (0..page_count).collect();
+ let claimed_pages = ClaimedRewards::::get(era, validator);
+
+ all_claimable_pages.into_iter().find(|p| !claimed_pages.contains(p))
+ }
+
+ /// Checks if exposure is paged or not.
+ fn is_non_paged_exposure(era: EraIndex, validator: &T::AccountId) -> bool {
+ >::contains_key(&era, validator)
+ }
+
+ /// Returns validator commission for this era and page.
+ pub(crate) fn get_validator_commission(
+ era: EraIndex,
+ validator_stash: &T::AccountId,
+ ) -> Perbill {
+ >::get(&era, validator_stash).commission
+ }
+
+ /// Creates an entry to track validator reward has been claimed for a given era and page.
+ /// Noop if already claimed.
+ pub(crate) fn set_rewards_as_claimed(era: EraIndex, validator: &T::AccountId, page: Page) {
+ let mut claimed_pages = ClaimedRewards::::get(era, validator);
+
+ // this should never be called if the reward has already been claimed
+ if claimed_pages.contains(&page) {
+ defensive!("Trying to set an already claimed reward");
+ // nevertheless don't do anything since the page already exist in claimed rewards.
+ return
+ }
+
+ // add page to claimed entries
+ claimed_pages.push(page);
+ ClaimedRewards::::insert(era, validator, claimed_pages);
+ }
+
+ /// Store exposure for elected validators at start of an era.
+ pub(crate) fn set_exposure(
+ era: EraIndex,
+ validator: &T::AccountId,
+ exposure: Exposure>,
+ ) {
+ let page_size = T::MaxExposurePageSize::get().defensive_max(1);
+
+ let nominator_count = exposure.others.len();
+ // expected page count is the number of nominators divided by the page size, rounded up.
+ let expected_page_count =
+ nominator_count.defensive_saturating_add(page_size as usize - 1) / page_size as usize;
+
+ let (exposure_metadata, exposure_pages) = exposure.into_pages(page_size);
+ defensive_assert!(exposure_pages.len() == expected_page_count, "unexpected page count");
+
+ >::insert(era, &validator, &exposure_metadata);
+ exposure_pages.iter().enumerate().for_each(|(page, paged_exposure)| {
+ >::insert((era, &validator, page as Page), &paged_exposure);
+ });
+ }
+
+ /// Store total exposure for all the elected validators in the era.
+ pub(crate) fn set_total_stake(era: EraIndex, total_stake: BalanceOf) {
+ >::insert(era, total_stake);
+ }
+}
+
/// Configurations of the benchmarking of the pallet.
pub trait BenchmarkingConfig {
/// The maximum number of validators to use.
diff --git a/substrate/frame/staking/src/migrations.rs b/substrate/frame/staking/src/migrations.rs
index 89520028b9..84b0025412 100644
--- a/substrate/frame/staking/src/migrations.rs
+++ b/substrate/frame/staking/src/migrations.rs
@@ -14,7 +14,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
-//! Storage migrations for the Staking pallet.
+//! Storage migrations for the Staking pallet. The changelog for this is maintained at
+//! [CHANGELOG.md](https://github.com/paritytech/substrate/blob/master/frame/staking/CHANGELOG.md).
use super::*;
use frame_election_provider_support::SortedListProvider;
@@ -58,6 +59,49 @@ impl Default for ObsoleteReleases {
#[storage_alias]
type StorageVersion = StorageValue, ObsoleteReleases, ValueQuery>;
+/// Migration of era exposure storage items to paged exposures.
+/// Changelog: [v14.](https://github.com/paritytech/substrate/blob/ankan/paged-rewards-rebased2/frame/staking/CHANGELOG.md#14)
+pub mod v14 {
+ use super::*;
+
+ pub struct MigrateToV14(sp_std::marker::PhantomData);
+ impl OnRuntimeUpgrade for MigrateToV14 {
+ fn on_runtime_upgrade() -> Weight {
+ let current = Pallet::::current_storage_version();
+ let on_chain = Pallet::::on_chain_storage_version();
+
+ if current == 14 && on_chain == 13 {
+ current.put::>();
+
+ log!(info, "v14 applied successfully.");
+ T::DbWeight::get().reads_writes(1, 1)
+ } else {
+ log!(warn, "v14 not applied.");
+ T::DbWeight::get().reads(1)
+ }
+ }
+
+ #[cfg(feature = "try-runtime")]
+ fn pre_upgrade() -> Result, TryRuntimeError> {
+ frame_support::ensure!(
+ Pallet::::on_chain_storage_version() == 13,
+ "Required v13 before upgrading to v14."
+ );
+
+ Ok(Default::default())
+ }
+
+ #[cfg(feature = "try-runtime")]
+ fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> {
+ frame_support::ensure!(
+ Pallet::::on_chain_storage_version() == 14,
+ "v14 not applied"
+ );
+ Ok(())
+ }
+ }
+}
+
pub mod v13 {
use super::*;
@@ -113,9 +157,9 @@ pub mod v12 {
#[storage_alias]
type HistoryDepth = StorageValue, u32, ValueQuery>;
- /// Clean up `HistoryDepth` from storage.
+ /// Clean up `T::HistoryDepth` from storage.
///
- /// We will be depending on the configurable value of `HistoryDepth` post
+ /// We will be depending on the configurable value of `T::HistoryDepth` post
/// this release.
pub struct MigrateToV12(sp_std::marker::PhantomData);
impl OnRuntimeUpgrade for MigrateToV12 {
diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs
index c694ce004d..d2afd8f26e 100644
--- a/substrate/frame/staking/src/mock.rs
+++ b/substrate/frame/staking/src/mock.rs
@@ -25,8 +25,8 @@ use frame_election_provider_support::{
use frame_support::{
assert_ok, ord_parameter_types, parameter_types,
traits::{
- ConstU32, ConstU64, Currency, EitherOfDiverse, FindAuthor, Get, Hooks, Imbalance,
- OnUnbalanced, OneSessionHandler,
+ ConstU64, Currency, EitherOfDiverse, FindAuthor, Get, Hooks, Imbalance, OnUnbalanced,
+ OneSessionHandler,
},
weights::constants::RocksDbWeight,
};
@@ -236,6 +236,7 @@ const THRESHOLDS: [sp_npos_elections::VoteWeight; 9] =
parameter_types! {
pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS;
pub static HistoryDepth: u32 = 80;
+ pub static MaxExposurePageSize: u32 = 64;
pub static MaxUnlockingChunks: u32 = 32;
pub static RewardOnUnbalanceWasCalled: bool = false;
pub static MaxWinners: u32 = 100;
@@ -304,7 +305,7 @@ impl crate::pallet::pallet::Config for Test {
type SessionInterface = Self;
type EraPayout = ConvertCurve;
type NextNewSession = Session;
- type MaxNominatorRewardedPerValidator = ConstU32<64>;
+ type MaxExposurePageSize = MaxExposurePageSize;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type ElectionProvider = onchain::OnChainExecution;
type GenesisElectionProvider = Self::ElectionProvider;
@@ -760,7 +761,7 @@ pub(crate) fn on_offence_now(
pub(crate) fn add_slash(who: &AccountId) {
on_offence_now(
&[OffenceDetails {
- offender: (*who, Staking::eras_stakers(active_era(), *who)),
+ offender: (*who, Staking::eras_stakers(active_era(), who)),
reporters: vec![],
}],
&[Perbill::from_percent(10)],
@@ -778,7 +779,14 @@ pub(crate) fn make_all_reward_payment(era: EraIndex) {
// reward validators
for validator_controller in validators_with_reward.iter().filter_map(Staking::bonded) {
let ledger = >::get(&validator_controller).unwrap();
- assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(1337), ledger.stash, era));
+ for page in 0..EraInfo::::get_page_count(era, &ledger.stash) {
+ assert_ok!(Staking::payout_stakers_by_page(
+ RuntimeOrigin::signed(1337),
+ ledger.stash,
+ era,
+ page
+ ));
+ }
}
}
diff --git a/substrate/frame/staking/src/pallet/impls.rs b/substrate/frame/staking/src/pallet/impls.rs
index ad2de1d593..bb16fe56d5 100644
--- a/substrate/frame/staking/src/pallet/impls.rs
+++ b/substrate/frame/staking/src/pallet/impls.rs
@@ -27,8 +27,8 @@ use frame_support::{
dispatch::WithPostDispatchInfo,
pallet_prelude::*,
traits::{
- Currency, Defensive, DefensiveResult, EstimateNextNewSession, Get, Imbalance, OnUnbalanced,
- TryCollect, UnixTime,
+ Currency, Defensive, EstimateNextNewSession, Get, Imbalance, Len, OnUnbalanced, TryCollect,
+ UnixTime,
},
weights::Weight,
};
@@ -41,7 +41,7 @@ use sp_runtime::{
use sp_staking::{
currency_to_vote::CurrencyToVote,
offence::{DisableStrategy, OffenceDetails, OnOffenceHandler},
- EraIndex, SessionIndex, Stake,
+ EraIndex, Page, SessionIndex, Stake,
StakingAccount::{self, Controller, Stash},
StakingInterface,
};
@@ -49,9 +49,9 @@ use sp_std::prelude::*;
use crate::{
election_size_tracker::StaticTracker, log, slashing, weights::WeightInfo, ActiveEraInfo,
- BalanceOf, EraPayout, Exposure, ExposureOf, Forcing, IndividualExposure, MaxNominationsOf,
- MaxWinnersOf, Nominations, NominationsQuota, PositiveImbalanceOf, RewardDestination,
- SessionInterface, StakingLedger, ValidatorPrefs,
+ BalanceOf, EraInfo, EraPayout, Exposure, ExposureOf, Forcing, IndividualExposure,
+ MaxNominationsOf, MaxWinnersOf, Nominations, NominationsQuota, PositiveImbalanceOf,
+ RewardDestination, SessionInterface, StakingLedger, ValidatorPrefs,
};
use super::pallet::*;
@@ -158,12 +158,31 @@ impl Pallet {
pub(super) fn do_payout_stakers(
validator_stash: T::AccountId,
era: EraIndex,
+ ) -> DispatchResultWithPostInfo {
+ let controller = Self::bonded(&validator_stash).ok_or_else(|| {
+ Error::::NotStash.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
+ })?;
+ let ledger = >::get(&controller).ok_or(Error::::NotController)?;
+ let page = EraInfo::::get_next_claimable_page(era, &validator_stash, &ledger)
+ .ok_or_else(|| {
+ Error::::AlreadyClaimed
+ .with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
+ })?;
+
+ Self::do_payout_stakers_by_page(validator_stash, era, page)
+ }
+
+ pub(super) fn do_payout_stakers_by_page(
+ validator_stash: T::AccountId,
+ era: EraIndex,
+ page: Page,
) -> DispatchResultWithPostInfo {
// Validate input data
let current_era = CurrentEra::::get().ok_or_else(|| {
Error::::InvalidEraToReward
.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
})?;
+
let history_depth = T::HistoryDepth::get();
ensure!(
era <= current_era && era >= current_era.saturating_sub(history_depth),
@@ -171,8 +190,13 @@ impl Pallet {
.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
);
+ ensure!(
+ page < EraInfo::::get_page_count(era, &validator_stash),
+ Error::::InvalidPage.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
+ );
+
// Note: if era has no reward to be claimed, era may be future. better not to update
- // `ledger.claimed_rewards` in this case.
+ // `ledger.legacy_claimed_rewards` in this case.
let era_payout = >::get(&era).ok_or_else(|| {
Error::::InvalidEraToReward
.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
@@ -186,31 +210,29 @@ impl Pallet {
Err(Error::::NotStash.with_weight(T::WeightInfo::payout_stakers_alive_staked(0)))
}
})?;
+
+ // clean up older claimed rewards
+ ledger
+ .legacy_claimed_rewards
+ .retain(|&x| x >= current_era.saturating_sub(history_depth));
+ ledger.clone().update()?;
+
let stash = ledger.stash.clone();
- ledger
- .claimed_rewards
- .retain(|&x| x >= current_era.saturating_sub(history_depth));
-
- match ledger.claimed_rewards.binary_search(&era) {
- Ok(_) =>
- return Err(Error::::AlreadyClaimed
- .with_weight(T::WeightInfo::payout_stakers_alive_staked(0))),
- Err(pos) => ledger
- .claimed_rewards
- .try_insert(pos, era)
- // Since we retain era entries in `claimed_rewards` only upto
- // `HistoryDepth`, following bound is always expected to be
- // satisfied.
- .defensive_map_err(|_| Error::::BoundNotMet)?,
+ if EraInfo::::is_rewards_claimed_with_legacy_fallback(era, &ledger, &stash, page) {
+ return Err(Error::::AlreadyClaimed
+ .with_weight(T::WeightInfo::payout_stakers_alive_staked(0)))
+ } else {
+ EraInfo::::set_rewards_as_claimed(era, &stash, page);
}
- let exposure = >::get(&era, &stash);
+ let exposure = EraInfo::::get_paged_exposure(era, &stash, page).ok_or_else(|| {
+ Error::::InvalidEraToReward
+ .with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
+ })?;
// Input data seems good, no errors allowed after this point
- ledger.update()?;
-
// Get Era reward points. It has TOTAL and INDIVIDUAL
// Find the fraction of the era reward that belongs to the validator
// Take that fraction of the eras rewards to split to nominator and validator
@@ -236,15 +258,17 @@ impl Pallet {
// This is how much validator + nominators are entitled to.
let validator_total_payout = validator_total_reward_part * era_payout;
- let validator_prefs = Self::eras_validator_prefs(&era, &validator_stash);
- // Validator first gets a cut off the top.
- let validator_commission = validator_prefs.commission;
- let validator_commission_payout = validator_commission * validator_total_payout;
+ let validator_commission = EraInfo::::get_validator_commission(era, &ledger.stash);
+ // total commission validator takes across all nominator pages
+ let validator_total_commission_payout = validator_commission * validator_total_payout;
- let validator_leftover_payout = validator_total_payout - validator_commission_payout;
+ let validator_leftover_payout = validator_total_payout - validator_total_commission_payout;
// Now let's calculate how this is split to the validator.
- let validator_exposure_part = Perbill::from_rational(exposure.own, exposure.total);
+ let validator_exposure_part = Perbill::from_rational(exposure.own(), exposure.total());
let validator_staking_payout = validator_exposure_part * validator_leftover_payout;
+ let page_stake_part = Perbill::from_rational(exposure.page_total(), exposure.total());
+ // validator commission is paid out in fraction across pages proportional to the page stake.
+ let validator_commission_payout = page_stake_part * validator_total_commission_payout;
Self::deposit_event(Event::::PayoutStarted {
era_index: era,
@@ -267,8 +291,8 @@ impl Pallet {
// Lets now calculate how this is split to the nominators.
// Reward only the clipped exposures. Note this is not necessarily sorted.
- for nominator in exposure.others.iter() {
- let nominator_exposure_part = Perbill::from_rational(nominator.value, exposure.total);
+ for nominator in exposure.others().iter() {
+ let nominator_exposure_part = Perbill::from_rational(nominator.value, exposure.total());
let nominator_reward: BalanceOf =
nominator_exposure_part * validator_leftover_payout;
@@ -287,7 +311,8 @@ impl Pallet {
}
T::Reward::on_unbalanced(total_imbalance);
- debug_assert!(nominator_payout_count <= T::MaxNominatorRewardedPerValidator::get());
+ debug_assert!(nominator_payout_count <= T::MaxExposurePageSize::get());
+
Ok(Some(T::WeightInfo::payout_stakers_alive_staked(nominator_payout_count)).into())
}
@@ -306,6 +331,11 @@ impl Pallet {
stash: &T::AccountId,
amount: BalanceOf,
) -> Option<(PositiveImbalanceOf, RewardDestination)> {
+ // noop if amount is zero
+ if amount.is_zero() {
+ return None
+ }
+
let dest = Self::payee(StakingAccount::Stash(stash.clone()));
let maybe_imbalance = match dest {
RewardDestination::Controller => Self::bonded(stash)
@@ -587,31 +617,24 @@ impl Pallet {
>,
new_planned_era: EraIndex,
) -> BoundedVec> {
- let elected_stashes: BoundedVec<_, MaxWinnersOf> = exposures
- .iter()
- .cloned()
- .map(|(x, _)| x)
- .collect::>()
- .try_into()
- .expect("since we only map through exposures, size of elected_stashes is always same as exposures; qed");
-
- // Populate stakers, exposures, and the snapshot of validator prefs.
+ // Populate elected stash, stakers, exposures, and the snapshot of validator prefs.
let mut total_stake: BalanceOf = Zero::zero();
- exposures.into_iter().for_each(|(stash, exposure)| {
- total_stake = total_stake.saturating_add(exposure.total);
- >::insert(new_planned_era, &stash, &exposure);
+ let mut elected_stashes = Vec::with_capacity(exposures.len());
- let mut exposure_clipped = exposure;
- let clipped_max_len = T::MaxNominatorRewardedPerValidator::get() as usize;
- if exposure_clipped.others.len() > clipped_max_len {
- exposure_clipped.others.sort_by(|a, b| a.value.cmp(&b.value).reverse());
- exposure_clipped.others.truncate(clipped_max_len);
- }
- >::insert(&new_planned_era, &stash, exposure_clipped);
+ exposures.into_iter().for_each(|(stash, exposure)| {
+ // build elected stash
+ elected_stashes.push(stash.clone());
+ // accumulate total stake
+ total_stake = total_stake.saturating_add(exposure.total);
+ // store staker exposure for this era
+ EraInfo::::set_exposure(new_planned_era, &stash, exposure);
});
- // Insert current era staking information
- >::insert(&new_planned_era, total_stake);
+ let elected_stashes: BoundedVec<_, MaxWinnersOf> = elected_stashes
+ .try_into()
+ .expect("elected_stashes.len() always equal to exposures.len(); qed");
+
+ EraInfo::::set_total_stake(new_planned_era, total_stake);
// Collect the pref of all winners.
for stash in &elected_stashes {
@@ -692,12 +715,21 @@ impl Pallet {
/// Clear all era information for given era.
pub(crate) fn clear_era_information(era_index: EraIndex) {
+ // FIXME: We can possibly set a reasonable limit since we do this only once per era and
+ // clean up state across multiple blocks.
let mut cursor = >::clear_prefix(era_index, u32::MAX, None);
debug_assert!(cursor.maybe_cursor.is_none());
cursor = >::clear_prefix(era_index, u32::MAX, None);
debug_assert!(cursor.maybe_cursor.is_none());
cursor = >::clear_prefix(era_index, u32::MAX, None);
debug_assert!(cursor.maybe_cursor.is_none());
+ cursor = >::clear_prefix(era_index, u32::MAX, None);
+ debug_assert!(cursor.maybe_cursor.is_none());
+ cursor = >::clear_prefix((era_index,), u32::MAX, None);
+ debug_assert!(cursor.maybe_cursor.is_none());
+ cursor = >::clear_prefix(era_index, u32::MAX, None);
+ debug_assert!(cursor.maybe_cursor.is_none());
+
>::remove(era_index);
>::remove(era_index);
>::remove(era_index);
@@ -1036,6 +1068,18 @@ impl Pallet {
DispatchClass::Mandatory,
);
}
+
+ /// Returns full exposure of a validator for a given era.
+ ///
+ /// History note: This used to be a getter for old storage item `ErasStakers` deprecated in v14.
+ /// Since this function is used in the codebase at various places, we kept it as a custom getter
+ /// that takes care of getting the full exposure of the validator in a backward compatible way.
+ pub fn eras_stakers(
+ era: EraIndex,
+ account: &T::AccountId,
+ ) -> Exposure> {
+ EraInfo::::get_full_exposure(era, account)
+ }
}
impl Pallet {
@@ -1045,6 +1089,17 @@ impl Pallet {
pub fn api_nominations_quota(balance: BalanceOf) -> u32 {
T::NominationsQuota::get_quota(balance)
}
+
+ pub fn api_eras_stakers(
+ era: EraIndex,
+ account: T::AccountId,
+ ) -> Exposure> {
+ Self::eras_stakers(era, &account)
+ }
+
+ pub fn api_eras_stakers_page_count(era: EraIndex, account: T::AccountId) -> Page {
+ EraInfo::::get_page_count(era, &account)
+ }
}
impl ElectionDataProvider for Pallet {
@@ -1129,10 +1184,7 @@ impl ElectionDataProvider for Pallet {
panic!("cannot convert a VoteWeight into BalanceOf, benchmark needs reconfiguring.")
});
>::insert(voter.clone(), voter.clone());
- >::insert(
- voter.clone(),
- StakingLedger::::new(voter.clone(), stake, Default::default()),
- );
+ >::insert(voter.clone(), StakingLedger::::new(voter.clone(), stake));
Self::do_add_nominator(&voter, Nominations { targets, submitted_in: 0, suppressed: false });
}
@@ -1141,10 +1193,7 @@ impl ElectionDataProvider for Pallet {
fn add_target(target: T::AccountId) {
let stake = MinValidatorBond::::get() * 100u32.into();
>::insert(target.clone(), target.clone());
- >::insert(
- target.clone(),
- StakingLedger::::new(target.clone(), stake, Default::default()),
- );
+