Skip to content
Snippets Groups Projects
Unverified Commit c29b74dc authored by Ross Bulat's avatar Ross Bulat Committed by GitHub
Browse files

Amend staking docs to account for state of controller deprecation (#2451)

Amends some staking pallet docs, and deprecation comment, to adjust to
the latest controller deprecation state.

Note, do we need the `README.md` file, which is a duplicate of the
pallet docs? Docs would be easier to maintain, and less ambiguity for
devs to refer to, if we had one source of truth in the generated pallet
docs.
parent 19c05e8d
Branches
No related merge requests found
Pipeline #417525 failed with stages
in 1 hour, 19 minutes, and 53 seconds
...@@ -24,7 +24,7 @@ be found not to be discharging its duties properly. ...@@ -24,7 +24,7 @@ be found not to be discharging its duties properly.
- Nominating: The process of placing staked funds behind one or more validators in order to share in any reward, and - Nominating: The process of placing staked funds behind one or more validators in order to share in any reward, and
punishment, they take. punishment, they take.
- Stash account: The account holding an owner's funds used for staking. - Stash account: The account holding an owner's funds used for staking.
- Controller account: The account that controls an owner's funds for staking. - Controller account (being deprecated): The account that controls an owner's funds for staking.
- Era: A (whole) number of sessions, which is the period that the validator set (and each validator's active nominator - Era: A (whole) number of sessions, which is the period that the validator set (and each validator's active nominator
set) is recalculated and where rewards are paid out. set) is recalculated and where rewards are paid out.
- Slash: The punishment of a staker by reducing its funds. - Slash: The punishment of a staker by reducing its funds.
...@@ -45,10 +45,10 @@ The staking system in Substrate NPoS is designed to make the following possible: ...@@ -45,10 +45,10 @@ The staking system in Substrate NPoS is designed to make the following possible:
Almost any interaction with the Staking module requires a process of _**bonding**_ (also known as being a _staker_). To Almost any interaction with the Staking module requires a process of _**bonding**_ (also known as being a _staker_). To
become *bonded*, a fund-holding account known as the _stash account_, which holds some or all of the funds that become become *bonded*, a fund-holding account known as the _stash account_, which holds some or all of the funds that become
frozen in place as part of the staking process, is paired with an active **controller** account, which issues frozen in place as part of the staking process. The controller account, which this pallet now assigns the stash account to,
instructions on how they shall be used. issues instructions on how funds shall be used.
An account pair can become bonded using the An account can become a bonded stash account using the
[`bond`](https://docs.rs/pallet-staking/latest/pallet_staking/enum.Call.html#variant.bond) call. [`bond`](https://docs.rs/pallet-staking/latest/pallet_staking/enum.Call.html#variant.bond) call.
Stash accounts can update their associated controller back to their stash account using the Stash accounts can update their associated controller back to their stash account using the
...@@ -231,8 +231,8 @@ following: ...@@ -231,8 +231,8 @@ following:
Any funds already placed into stash can be the target of the following operations: Any funds already placed into stash can be the target of the following operations:
The controller account can free a portion (or all) of the funds using the The controller account can free a portion (or all) of the funds using the
[`unbond`](https://docs.rs/pallet-staking/latest/pallet_staking/enum.Call.html#variant.unbond) call. Note that the funds [`unbond`](https://docs.rs/pallet-staking/latest/pallet_staking/enum.Call.html#variant.unbond) call. Note that the
are not immediately accessible. Instead, a duration denoted by funds are not immediately accessible. Instead, a duration denoted by
[`BondingDuration`](https://docs.rs/pallet-staking/latest/pallet_staking/trait.Config.html#associatedtype.BondingDuration) [`BondingDuration`](https://docs.rs/pallet-staking/latest/pallet_staking/trait.Config.html#associatedtype.BondingDuration)
(in number of eras) must pass until the funds can actually be removed. Once the `BondingDuration` is over, the (in number of eras) must pass until the funds can actually be removed. Once the `BondingDuration` is over, the
[`withdraw_unbonded`](https://docs.rs/pallet-staking/latest/pallet_staking/enum.Call.html#variant.withdraw_unbonded) [`withdraw_unbonded`](https://docs.rs/pallet-staking/latest/pallet_staking/enum.Call.html#variant.withdraw_unbonded)
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
//! - Nominating: The process of placing staked funds behind one or more validators in order to //! - Nominating: The process of placing staked funds behind one or more validators in order to
//! share in any reward, and punishment, they take. //! share in any reward, and punishment, they take.
//! - Stash account: The account holding an owner's funds used for staking. //! - Stash account: The account holding an owner's funds used for staking.
//! - Controller account: The account that controls an owner's funds for staking. //! - Controller account (being deprecated): The account that controls an owner's funds for staking.
//! - Era: A (whole) number of sessions, which is the period that the validator set (and each //! - Era: A (whole) number of sessions, which is the period that the validator set (and each
//! validator's active nominator set) is recalculated and where rewards are paid out. //! validator's active nominator set) is recalculated and where rewards are paid out.
//! - Slash: The punishment of a staker by reducing its funds. //! - Slash: The punishment of a staker by reducing its funds.
...@@ -61,20 +61,20 @@ ...@@ -61,20 +61,20 @@
//! //!
//! Almost any interaction with the Staking pallet requires a process of _**bonding**_ (also known //! Almost any interaction with the Staking pallet requires a process of _**bonding**_ (also known
//! as being a _staker_). To become *bonded*, a fund-holding register known as the _stash account_, //! as being a _staker_). To become *bonded*, a fund-holding register known as the _stash account_,
//! which holds some or all of the funds that become frozen in place as part of the staking process, //! which holds some or all of the funds that become frozen in place as part of the staking process.
//! is paired with an active **controller** account, which issues instructions on how they shall be //! The controller account, which this pallet now assigns the stash account to, issues instructions
//! used. //! on how funds shall be used.
//! //!
//! An account pair can become bonded using the [`bond`](Call::bond) call. //! An account can become a bonded stash account using the [`bond`](Call::bond) call.
//! //!
//! Stash accounts can update their associated controller back to the stash account using the //! In the event stash accounts registered a unique controller account before the controller account
//! deprecation, they can update their associated controller back to the stash account using the
//! [`set_controller`](Call::set_controller) call. //! [`set_controller`](Call::set_controller) call.
//! //!
//! There are three possible roles that any staked account pair can be in: `Validator`, `Nominator` //! There are three possible roles that any staked account pair can be in: `Validator`, `Nominator`
//! and `Idle` (defined in [`StakerStatus`]). There are three //! and `Idle` (defined in [`StakerStatus`]). There are three corresponding instructions to change
//! corresponding instructions to change between roles, namely: //! between roles, namely: [`validate`](Call::validate), [`nominate`](Call::nominate), and
//! [`validate`](Call::validate), //! [`chill`](Call::chill).
//! [`nominate`](Call::nominate), and [`chill`](Call::chill).
//! //!
//! #### Validating //! #### Validating
//! //!
...@@ -85,14 +85,13 @@ ...@@ -85,14 +85,13 @@
//! _might_ get elected at the _next era_ as a validator. The result of the election is determined //! _might_ get elected at the _next era_ as a validator. The result of the election is determined
//! by nominators and their votes. //! by nominators and their votes.
//! //!
//! An account can become a validator candidate via the //! An account can become a validator candidate via the [`validate`](Call::validate) call.
//! [`validate`](Call::validate) call.
//! //!
//! #### Nomination //! #### Nomination
//! //!
//! A **nominator** does not take any _direct_ role in maintaining the network, instead, it votes on //! 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 //! a set of validators to be elected. Once interest in nomination is stated by an account, it takes
//! takes effect at the next election round. The funds in the nominator's stash account indicate the //! 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 //! _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 //! between the validator and its nominators. This rule incentivizes the nominators to NOT vote for
//! the misbehaving/offline validators as much as possible, simply because the nominators will also //! the misbehaving/offline validators as much as possible, simply because the nominators will also
...@@ -104,8 +103,8 @@ ...@@ -104,8 +103,8 @@
//! //!
//! Staking is closely related to elections; actual validators are chosen from among all potential //! Staking is closely related to elections; actual validators are chosen from among all potential
//! validators via election by the potential validators and nominators. To reduce use of the phrase //! validators via election by the potential validators and nominators. To reduce use of the phrase
//! "potential validators and nominators", we often use the term **voters**, who are simply //! "potential validators and nominators", we often use the term **voters**, who are simply the
//! the union of potential validators and nominators. //! union of potential validators and nominators.
//! //!
//! #### Rewards and Slash //! #### Rewards and Slash
//! //!
...@@ -117,10 +116,9 @@ ...@@ -117,10 +116,9 @@
//! `payout_stakers`, which pays the reward to the validator as well as its nominators. Only //! `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 //! [`Config::MaxExposurePageSize`] nominator rewards can be claimed in a single call. When the
//! number of nominators exceeds [`Config::MaxExposurePageSize`], then the exposed nominators are //! number of nominators exceeds [`Config::MaxExposurePageSize`], then the exposed nominators are
//! stored in multiple pages, with each page containing up to //! stored in multiple pages, with each page containing up to [`Config::MaxExposurePageSize`]
//! [`Config::MaxExposurePageSize`] nominators. To pay out all nominators, `payout_stakers` must be //! nominators. To pay out all nominators, `payout_stakers` must be called once for each available
//! called once for each available page. Paging exists to limit the i/o cost to mutate storage for //! page. Paging exists to limit the i/o cost to mutate storage for each nominator's account.
//! each nominator's account.
//! //!
//! Slashing can occur at any point in time, once misbehavior is reported. Once slashing is //! 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 //! determined, a value is deducted from the balance of the validator and all the nominators who
...@@ -165,18 +163,18 @@ ...@@ -165,18 +163,18 @@
//! //!
//! #[frame_support::pallet(dev_mode)] //! #[frame_support::pallet(dev_mode)]
//! pub mod pallet { //! pub mod pallet {
//! use super::*; //! use super::*;
//! use frame_support::pallet_prelude::*; //! use frame_support::pallet_prelude::*;
//! use frame_system::pallet_prelude::*; //! use frame_system::pallet_prelude::*;
//! //!
//! #[pallet::pallet] //! #[pallet::pallet]
//! pub struct Pallet<T>(_); //! pub struct Pallet<T>(_);
//! //!
//! #[pallet::config] //! #[pallet::config]
//! pub trait Config: frame_system::Config + staking::Config {} //! pub trait Config: frame_system::Config + staking::Config {}
//! //!
//! #[pallet::call] //! #[pallet::call]
//! impl<T: Config> Pallet<T> { //! impl<T: Config> Pallet<T> {
//! /// Reward a validator. //! /// Reward a validator.
//! #[pallet::weight(0)] //! #[pallet::weight(0)]
//! pub fn reward_myself(origin: OriginFor<T>) -> DispatchResult { //! pub fn reward_myself(origin: OriginFor<T>) -> DispatchResult {
...@@ -193,8 +191,8 @@ ...@@ -193,8 +191,8 @@
//! //!
//! ### Era payout //! ### Era payout
//! //!
//! The era payout is computed using yearly inflation curve defined at //! The era payout is computed using yearly inflation curve defined at [`Config::EraPayout`] as
//! [`Config::EraPayout`] as such: //! such:
//! //!
//! ```nocompile //! ```nocompile
//! staker_payout = yearly_inflation(npos_token_staked / total_tokens) * total_tokens / era_per_year //! staker_payout = yearly_inflation(npos_token_staked / total_tokens) * total_tokens / era_per_year
...@@ -204,8 +202,7 @@ ...@@ -204,8 +202,7 @@
//! ```nocompile //! ```nocompile
//! remaining_payout = max_yearly_inflation * total_tokens / era_per_year - staker_payout //! remaining_payout = max_yearly_inflation * total_tokens / era_per_year - staker_payout
//! ``` //! ```
//! The remaining reward is send to the configurable end-point //! The remaining reward is send to the configurable end-point [`Config::RewardRemainder`].
//! [`Config::RewardRemainder`].
//! //!
//! ### Reward Calculation //! ### Reward Calculation
//! //!
...@@ -219,9 +216,8 @@ ...@@ -219,9 +216,8 @@
//! they received during the era. Points are added to a validator using //! they received during the era. Points are added to a validator using
//! [`reward_by_ids`](Pallet::reward_by_ids). //! [`reward_by_ids`](Pallet::reward_by_ids).
//! //!
//! [`Pallet`] implements //! [`Pallet`] implements [`pallet_authorship::EventHandler`] to add reward points to block producer
//! [`pallet_authorship::EventHandler`] to add reward //! and block producer of referenced uncles.
//! points to block producer and block producer of referenced uncles.
//! //!
//! The validator and its nominator split their reward as following: //! The validator and its nominator split their reward as following:
//! //!
...@@ -232,13 +228,12 @@ ...@@ -232,13 +228,12 @@
//! validator, proportional to the value staked behind the validator (_i.e._ dividing 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 //! [`own`](Exposure::own) or [`others`](Exposure::others) by [`total`](Exposure::total) in
//! [`Exposure`]). Note that payouts are made in pages with each page capped at //! [`Exposure`]). Note that payouts are made in pages with each page capped at
//! [`Config::MaxExposurePageSize`] nominators. The distribution of nominators across //! [`Config::MaxExposurePageSize`] nominators. The distribution of nominators across pages may be
//! pages may be unsorted. The total commission is paid out proportionally across pages based on the //! unsorted. The total commission is paid out proportionally across pages based on the total stake
//! total stake of the page. //! of the page.
//! //!
//! All entities who receive a reward have the option to choose their reward destination through the //! All entities who receive a reward have the option to choose their reward destination through the
//! [`Payee`] storage item (see //! [`Payee`] storage item (see [`set_payee`](Call::set_payee)), to be one of the following:
//! [`set_payee`](Call::set_payee)), to be one of the following:
//! //!
//! - Stash account, not increasing the staked value. //! - Stash account, not increasing the staked value.
//! - Stash account, also increasing the staked value. //! - Stash account, also increasing the staked value.
...@@ -249,12 +244,10 @@ ...@@ -249,12 +244,10 @@
//! Any funds already placed into stash can be the target of the following operations: //! Any funds already placed into stash can be the target of the following operations:
//! //!
//! The controller account can free a portion (or all) of the funds using the //! The controller account can free a portion (or all) of the funds using the
//! [`unbond`](Call::unbond) call. Note that the funds are not immediately //! [`unbond`](Call::unbond) call. Note that the funds are not immediately accessible. Instead, a
//! accessible. Instead, a duration denoted by //! duration denoted by [`Config::BondingDuration`] (in number of eras) must pass until the funds
//! [`Config::BondingDuration`] (in number of eras) must //! can actually be removed. Once the `BondingDuration` is over, the
//! pass until the funds can actually be removed. Once the `BondingDuration` is over, the //! [`withdraw_unbonded`](Call::withdraw_unbonded) call can be used to actually withdraw the funds.
//! [`withdraw_unbonded`](Call::withdraw_unbonded) call can be used to actually
//! withdraw the funds.
//! //!
//! Note that there is a limitation to the number of fund-chunks that can be scheduled to be //! Note that there is a limitation to the number of fund-chunks that can be scheduled to be
//! unlocked in the future via [`unbond`](Call::unbond). In case this maximum //! unlocked in the future via [`unbond`](Call::unbond). In case this maximum
...@@ -274,8 +267,8 @@ ...@@ -274,8 +267,8 @@
//! //!
//! ## GenesisConfig //! ## GenesisConfig
//! //!
//! The Staking pallet depends on the [`GenesisConfig`]. The //! The Staking pallet depends on the [`GenesisConfig`]. The `GenesisConfig` is optional and allow
//! `GenesisConfig` is optional and allow to set some initial stakers. //! to set some initial stakers.
//! //!
//! ## Related Modules //! ## Related Modules
//! //!
...@@ -405,7 +398,7 @@ pub enum RewardDestination<AccountId> { ...@@ -405,7 +398,7 @@ pub enum RewardDestination<AccountId> {
/// Pay into the stash account, not increasing the amount at stake. /// Pay into the stash account, not increasing the amount at stake.
Stash, Stash,
#[deprecated( #[deprecated(
note = "`Controller` will be removed after January 2024. Use `Account(controller)` instead. This variant now behaves the same as `Stash` variant." note = "`Controller` will be removed after January 2024. Use `Account(controller)` instead."
)] )]
Controller, Controller,
/// Pay into a specified account. /// Pay into a specified account.
......
...@@ -359,7 +359,7 @@ impl<T: Config> Pallet<T> { ...@@ -359,7 +359,7 @@ impl<T: Config> Pallet<T> {
#[allow(deprecated)] #[allow(deprecated)]
RewardDestination::Controller => Self::bonded(stash) RewardDestination::Controller => Self::bonded(stash)
.map(|controller| { .map(|controller| {
defensive!("Paying out controller as reward destination which is deprecated and should be migrated"); defensive!("Paying out controller as reward destination which is deprecated and should be migrated.");
// This should never happen once payees with a `Controller` variant have been migrated. // This should never happen once payees with a `Controller` variant have been migrated.
// But if it does, just pay the controller account. // But if it does, just pay the controller account.
T::Currency::deposit_creating(&controller, amount) T::Currency::deposit_creating(&controller, amount)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment