pub type Staking = Pallet<Runtime>;
Aliased Type§
struct Staking(/* private fields */);
Implementations
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn api_nominations_quota(balance: <T as Config>::CurrencyBalance) -> u32
pub fn api_nominations_quota(balance: <T as Config>::CurrencyBalance) -> u32
Returns the current nominations quota for nominators.
Used by the runtime API.
pub fn api_eras_stakers( era: u32, account: <T as Config>::AccountId, ) -> Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>
pub fn api_eras_stakers_page_count( era: u32, account: <T as Config>::AccountId, ) -> u32
pub fn api_pending_rewards(era: u32, account: <T as Config>::AccountId) -> bool
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn on_offence(
offenders: impl Iterator<Item = OffenceDetails<<T as Config>::AccountId, <T as Config>::AccountId>>,
slash_fractions: &[Perbill],
slash_session: u32,
) -> Weight
pub fn on_offence( offenders: impl Iterator<Item = OffenceDetails<<T as Config>::AccountId, <T as Config>::AccountId>>, slash_fractions: &[Perbill], slash_session: u32, ) -> Weight
When an offence is reported, it is split into pages and put in the offence queue.
As offence queue is processed, computed slashes are queued to be applied after the
SlashDeferDuration
.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn ensure_snapshot_metadata_state(
now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Result<(), DispatchError>
pub fn ensure_snapshot_metadata_state( now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Result<(), DispatchError>
Test invariants of:
NextElectionPage
: should only be set if pages > 1 and if we are withinpages-election -> election
VoterSnapshotStatus
: cannot be argued about as we don’t know when we get a call to data provider, but we know it should never be set if we have 1 page.
– SHOULD ONLY BE CALLED AT THE END OF A GIVEN BLOCK.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn election_pages() -> u32
pub fn election_pages() -> u32
Fetches the number of pages configured by the election provider.
Sourcepub fn ledger(
account: StakingAccount<<T as Config>::AccountId>,
) -> Result<StakingLedger<T>, Error<T>>
pub fn ledger( account: StakingAccount<<T as Config>::AccountId>, ) -> Result<StakingLedger<T>, Error<T>>
Fetches the ledger associated with a controller or stash account, if any.
pub fn payee( account: StakingAccount<<T as Config>::AccountId>, ) -> Option<RewardDestination<<T as Config>::AccountId>>
Sourcepub fn bonded(
stash: &<T as Config>::AccountId,
) -> Option<<T as Config>::AccountId>
pub fn bonded( stash: &<T as Config>::AccountId, ) -> Option<<T as Config>::AccountId>
Fetches the controller bonded to a stash account, if any.
Sourcepub fn slashable_balance_of(
stash: &<T as Config>::AccountId,
) -> <T as Config>::CurrencyBalance
pub fn slashable_balance_of( stash: &<T as Config>::AccountId, ) -> <T as Config>::CurrencyBalance
The total balance that can be slashed from a stash account as of right now.
Sourcepub fn slashable_balance_of_vote_weight(
stash: &<T as Config>::AccountId,
issuance: <T as Config>::CurrencyBalance,
) -> u64
pub fn slashable_balance_of_vote_weight( stash: &<T as Config>::AccountId, issuance: <T as Config>::CurrencyBalance, ) -> u64
Internal impl of Self::slashable_balance_of
that returns VoteWeight
.
Sourcepub fn weight_of_fn() -> Box<dyn Fn(&<T as Config>::AccountId) -> u64>
pub fn weight_of_fn() -> Box<dyn Fn(&<T as Config>::AccountId) -> u64>
Returns a closure around slashable_balance_of_vote_weight
that can be passed around.
This prevents call sites from repeatedly requesting total_issuance
from backend. But it is
important to be only used while the total issuance is not changing.
Sourcepub fn weight_of(who: &<T as Config>::AccountId) -> u64
pub fn weight_of(who: &<T as Config>::AccountId) -> u64
Same as weight_of_fn
, but made for one time use.
Sourcepub fn populate_staking_election_testing_benchmarking_only() -> Result<(), &'static str>
pub fn populate_staking_election_testing_benchmarking_only() -> Result<(), &'static str>
Helper function provided to other pallets that want to rely on pallet-stkaing for
testing/benchmarking, and wish to populate ElectableStashes
, such that a next call (post
genesis) to try_plan_new_era
works.
This uses GenesisElectionProvider
which should always be set to something reasonable and
instant.
Sourcepub fn plan_new_era(start_session_index: u32)
pub fn plan_new_era(start_session_index: u32)
Plan a new era.
- Bump the current era storage (which holds the latest planned era).
- Store start session index for the new planned era.
- Clean old era information.
The new validator set for this era is stored under ElectableStashes
.
Sourcepub fn store_stakers_info(
exposures: BoundedVec<(<T as Config>::AccountId, Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>), <<T as Config>::ElectionProvider as ElectionProvider>::MaxWinnersPerPage>,
new_planned_era: u32,
) -> BoundedVec<<T as Config>::AccountId, <<T as Config>::ElectionProvider as ElectionProvider>::MaxWinnersPerPage>
pub fn store_stakers_info( exposures: BoundedVec<(<T as Config>::AccountId, Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>), <<T as Config>::ElectionProvider as ElectionProvider>::MaxWinnersPerPage>, new_planned_era: u32, ) -> BoundedVec<<T as Config>::AccountId, <<T as Config>::ElectionProvider as ElectionProvider>::MaxWinnersPerPage>
Process the output of a paged election.
Store staking information for the new planned era of a single election page.
Sourcepub fn reward_by_ids(
validators_points: impl IntoIterator<Item = (<T as Config>::AccountId, u32)>,
)
pub fn reward_by_ids( validators_points: impl IntoIterator<Item = (<T as Config>::AccountId, u32)>, )
Add reward points to validators using their stash account ID.
Validators are keyed by stash account ID and must be in the current elected set.
For each element in the iterator the given number of points in u32 is added to the validator, thus duplicates are handled.
At the end of the era each the total payout will be distributed among validator relatively to their points.
COMPLEXITY: Complexity is number_of_validator_to_reward x current_elected_len
.
pub fn add_era_stakers( current_era: u32, stash: <T as Config>::AccountId, exposure: Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>, )
pub fn set_slash_reward_fraction(fraction: Perbill)
Sourcepub fn get_npos_targets(
bounds: DataProviderBounds,
) -> Vec<<T as Config>::AccountId>
pub fn get_npos_targets( bounds: DataProviderBounds, ) -> Vec<<T as Config>::AccountId>
Get all the targets associated are eligible for the npos election.
The target snapshot is always single paged.
This function is self-weighing as DispatchClass::Mandatory
.
Sourcepub fn do_add_nominator(
who: &<T as Config>::AccountId,
nominations: Nominations<T>,
)
pub fn do_add_nominator( who: &<T as Config>::AccountId, nominations: Nominations<T>, )
This function will add a nominator to the Nominators
storage map,
and VoterList
.
If the nominator already exists, their nominations will be updated.
NOTE: you must ALWAYS use this function to add nominator or update their targets. Any access
to Nominators
or VoterList
outside of this function is almost certainly
wrong.
Sourcepub fn do_remove_nominator(who: &<T as Config>::AccountId) -> bool
pub fn do_remove_nominator(who: &<T as Config>::AccountId) -> bool
This function will remove a nominator from the Nominators
storage map,
and VoterList
.
Returns true if who
was removed from Nominators
, otherwise false.
NOTE: you must ALWAYS use this function to remove a nominator from the system. Any access to
Nominators
or VoterList
outside of this function is almost certainly
wrong.
Sourcepub fn do_add_validator(who: &<T as Config>::AccountId, prefs: ValidatorPrefs)
pub fn do_add_validator(who: &<T as Config>::AccountId, prefs: ValidatorPrefs)
This function will add a validator to the Validators
storage map.
If the validator already exists, their preferences will be updated.
NOTE: you must ALWAYS use this function to add a validator to the system. Any access to
Validators
or VoterList
outside of this function is almost certainly
wrong.
Sourcepub fn do_remove_validator(who: &<T as Config>::AccountId) -> bool
pub fn do_remove_validator(who: &<T as Config>::AccountId) -> bool
This function will remove a validator from the Validators
storage map.
Returns true if who
was removed from Validators
, otherwise false.
NOTE: you must ALWAYS use this function to remove a validator from the system. Any access to
Validators
or VoterList
outside of this function is almost certainly
wrong.
Sourcepub fn eras_stakers(
era: u32,
account: &<T as Config>::AccountId,
) -> Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>
pub fn eras_stakers( era: u32, account: &<T as Config>::AccountId, ) -> Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>
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
and deleted in v17. 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.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn validator_count() -> u32
pub fn validator_count() -> u32
Get the ideal number of active validators.
Sourcepub fn minimum_validator_count() -> u32
pub fn minimum_validator_count() -> u32
Get the minimum number of staking participants before emergency conditions are imposed.
Sourcepub fn invulnerables() -> BoundedVec<<T as Config>::AccountId, <T as Config>::MaxInvulnerables>
pub fn invulnerables() -> BoundedVec<<T as Config>::AccountId, <T as Config>::MaxInvulnerables>
Get the validators that may never be slashed or forcibly kicked out.
Sourcepub fn validators<EncodeLikeAccountId>(
account_id: EncodeLikeAccountId,
) -> ValidatorPrefs
pub fn validators<EncodeLikeAccountId>( account_id: EncodeLikeAccountId, ) -> ValidatorPrefs
Get the preferences of a given validator.
Sourcepub fn nominators<EncodeLikeAccountId>(
account_id: EncodeLikeAccountId,
) -> Option<Nominations<T>>
pub fn nominators<EncodeLikeAccountId>( account_id: EncodeLikeAccountId, ) -> Option<Nominations<T>>
Get the nomination preferences of a given nominator.
Sourcepub fn current_era() -> Option<u32>
pub fn current_era() -> Option<u32>
Get the current era index.
Sourcepub fn active_era() -> Option<ActiveEraInfo>
pub fn active_era() -> Option<ActiveEraInfo>
Get the active era information.
Sourcepub fn eras_start_session_index<EncodeLikeEraIndex>(
era_index: EncodeLikeEraIndex,
) -> Option<u32>where
EncodeLikeEraIndex: EncodeLike<u32>,
pub fn eras_start_session_index<EncodeLikeEraIndex>(
era_index: EncodeLikeEraIndex,
) -> Option<u32>where
EncodeLikeEraIndex: EncodeLike<u32>,
Get the session index at which the era starts for the last Config::HistoryDepth
eras.
Sourcepub fn claimed_rewards<EncodeLikeEraIndex, EncodeLikeAccountId>(
era_index: EncodeLikeEraIndex,
account_id: EncodeLikeAccountId,
) -> Vec<u32>
pub fn claimed_rewards<EncodeLikeEraIndex, EncodeLikeAccountId>( era_index: EncodeLikeEraIndex, account_id: EncodeLikeAccountId, ) -> Vec<u32>
Get the paged history of claimed rewards by era for given validator.
Sourcepub fn eras_validator_prefs<EncodeLikeEraIndex, EncodeLikeAccountId>(
era_index: EncodeLikeEraIndex,
account_id: EncodeLikeAccountId,
) -> ValidatorPrefs
pub fn eras_validator_prefs<EncodeLikeEraIndex, EncodeLikeAccountId>( era_index: EncodeLikeEraIndex, account_id: EncodeLikeAccountId, ) -> ValidatorPrefs
Get the preferences of given validator at given era.
Sourcepub fn eras_validator_reward<EncodeLikeEraIndex>(
era_index: EncodeLikeEraIndex,
) -> Option<<T as Config>::CurrencyBalance>where
EncodeLikeEraIndex: EncodeLike<u32>,
pub fn eras_validator_reward<EncodeLikeEraIndex>(
era_index: EncodeLikeEraIndex,
) -> Option<<T as Config>::CurrencyBalance>where
EncodeLikeEraIndex: EncodeLike<u32>,
Get the total validator era payout for the last Config::HistoryDepth
eras.
Sourcepub fn eras_reward_points<EncodeLikeEraIndex>(
era_index: EncodeLikeEraIndex,
) -> EraRewardPoints<<T as Config>::AccountId>where
EncodeLikeEraIndex: EncodeLike<u32>,
pub fn eras_reward_points<EncodeLikeEraIndex>(
era_index: EncodeLikeEraIndex,
) -> EraRewardPoints<<T as Config>::AccountId>where
EncodeLikeEraIndex: EncodeLike<u32>,
Get the rewards for the last Config::HistoryDepth
eras.
Sourcepub fn eras_total_stake<EncodeLikeEraIndex>(
era_index: EncodeLikeEraIndex,
) -> <T as Config>::CurrencyBalancewhere
EncodeLikeEraIndex: EncodeLike<u32>,
pub fn eras_total_stake<EncodeLikeEraIndex>(
era_index: EncodeLikeEraIndex,
) -> <T as Config>::CurrencyBalancewhere
EncodeLikeEraIndex: EncodeLike<u32>,
Get the total amount staked for the last Config::HistoryDepth
eras.
Sourcepub fn slash_reward_fraction() -> Perbill
pub fn slash_reward_fraction() -> Perbill
Get the percentage of the slash that is distributed to reporters.
Sourcepub fn canceled_payout() -> <T as Config>::CurrencyBalance
pub fn canceled_payout() -> <T as Config>::CurrencyBalance
Get the amount of canceled slash payout.
Sourcepub fn slashing_spans<EncodeLikeAccountId>(
account_id: EncodeLikeAccountId,
) -> Option<SlashingSpans>
pub fn slashing_spans<EncodeLikeAccountId>( account_id: EncodeLikeAccountId, ) -> Option<SlashingSpans>
Get the slashing spans for given account.
Sourcepub fn current_planned_session() -> u32
pub fn current_planned_session() -> u32
Get the last planned session scheduled by the session pallet.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn bond(
origin: <T as Config>::RuntimeOrigin,
value: <T as Config>::CurrencyBalance,
payee: RewardDestination<<T as Config>::AccountId>,
) -> Result<(), DispatchError>
pub fn bond( origin: <T as Config>::RuntimeOrigin, value: <T as Config>::CurrencyBalance, payee: RewardDestination<<T as Config>::AccountId>, ) -> Result<(), DispatchError>
Take the origin account as a stash and lock up value
of its balance. controller
will
be the account that controls it.
value
must be more than the minimum_balance
specified by T::Currency
.
The dispatch origin for this call must be Signed by the stash account.
Emits Bonded
.
§Complexity
- Independent of the arguments. Moderate complexity.
- O(1).
- Three extra DB entries.
NOTE: Two of the storage writes (Self::bonded
, Self::payee
) are never cleaned
unless the origin
falls below existential deposit (or equal to 0) and gets removed
as dust.
Sourcepub fn bond_extra(
origin: <T as Config>::RuntimeOrigin,
max_additional: <T as Config>::CurrencyBalance,
) -> Result<(), DispatchError>
pub fn bond_extra( origin: <T as Config>::RuntimeOrigin, max_additional: <T as Config>::CurrencyBalance, ) -> Result<(), DispatchError>
Add some extra amount that have appeared in the stash free_balance
into the balance up
for staking.
The dispatch origin for this call must be Signed by the stash, not the controller.
Use this if there are additional funds in your stash account that you wish to bond.
Unlike bond
or unbond
this function does not impose
any limitation on the amount that can be added.
Emits Bonded
.
§Complexity
- Independent of the arguments. Insignificant complexity.
- O(1).
Sourcepub fn unbond(
origin: <T as Config>::RuntimeOrigin,
value: <T as Config>::CurrencyBalance,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn unbond( origin: <T as Config>::RuntimeOrigin, value: <T as Config>::CurrencyBalance, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Schedule a portion of the stash to be unlocked ready for transfer out after the bond
period ends. If this leaves an amount actively bonded less than
asset::existential_deposit
, then it is increased to the full amount.
The dispatch origin for this call must be Signed by the controller, not the stash.
Once the unlock period is done, you can call withdraw_unbonded
to actually move
the funds out of management ready for transfer.
No more than a limited number of unlocking chunks (see MaxUnlockingChunks
)
can co-exists at the same time. If there are no unlocking chunks slots available
Call::withdraw_unbonded
is called to remove some of the chunks (if possible).
If a user encounters the InsufficientBond
error when calling this extrinsic,
they should call chill
first in order to free up their bonded funds.
Emits Unbonded
.
See also Call::withdraw_unbonded
.
Sourcepub fn withdraw_unbonded(
origin: <T as Config>::RuntimeOrigin,
num_slashing_spans: u32,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn withdraw_unbonded( origin: <T as Config>::RuntimeOrigin, num_slashing_spans: u32, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Remove any unlocked chunks from the unlocking
queue from our management.
This essentially frees up that balance to be used by the stash account to do whatever it wants.
The dispatch origin for this call must be Signed by the controller.
Emits Withdrawn
.
See also Call::unbond
.
§Parameters
num_slashing_spans
indicates the number of metadata slashing spans to clear when this call results in a complete removal of all the data related to the stash account. In this case, thenum_slashing_spans
must be larger or equal to the number of slashing spans associated with the stash account in theSlashingSpans
storage type, otherwise the call will fail. The call weight is directly proportional tonum_slashing_spans
.
§Complexity
O(S) where S is the number of slashing spans to remove NOTE: Weight annotation is the kill scenario, we refund otherwise.
Sourcepub fn validate(
origin: <T as Config>::RuntimeOrigin,
prefs: ValidatorPrefs,
) -> Result<(), DispatchError>
pub fn validate( origin: <T as Config>::RuntimeOrigin, prefs: ValidatorPrefs, ) -> Result<(), DispatchError>
Declare the desire to validate for the origin controller.
Effects will be felt at the beginning of the next era.
The dispatch origin for this call must be Signed by the controller, not the stash.
Sourcepub fn nominate(
origin: <T as Config>::RuntimeOrigin,
targets: Vec<<<T as Config>::Lookup as StaticLookup>::Source>,
) -> Result<(), DispatchError>
pub fn nominate( origin: <T as Config>::RuntimeOrigin, targets: Vec<<<T as Config>::Lookup as StaticLookup>::Source>, ) -> Result<(), DispatchError>
Declare the desire to nominate targets
for the origin controller.
Effects will be felt at the beginning of the next era.
The dispatch origin for this call must be Signed by the controller, not the stash.
§Complexity
- The transaction’s complexity is proportional to the size of
targets
(N) which is capped at CompactAssignments::LIMIT (T::MaxNominations). - Both the reads and writes follow a similar pattern.
Sourcepub fn chill(origin: <T as Config>::RuntimeOrigin) -> Result<(), DispatchError>
pub fn chill(origin: <T as Config>::RuntimeOrigin) -> Result<(), DispatchError>
Declare no desire to either validate or nominate.
Effects will be felt at the beginning of the next era.
The dispatch origin for this call must be Signed by the controller, not the stash.
§Complexity
- Independent of the arguments. Insignificant complexity.
- Contains one read.
- Writes are limited to the
origin
account key.
Sourcepub fn set_payee(
origin: <T as Config>::RuntimeOrigin,
payee: RewardDestination<<T as Config>::AccountId>,
) -> Result<(), DispatchError>
pub fn set_payee( origin: <T as Config>::RuntimeOrigin, payee: RewardDestination<<T as Config>::AccountId>, ) -> Result<(), DispatchError>
(Re-)set the payment target for a controller.
Effects will be felt instantly (as soon as this function is completed successfully).
The dispatch origin for this call must be Signed by the controller, not the stash.
§Complexity
- O(1)
- Independent of the arguments. Insignificant complexity.
- Contains a limited number of reads.
- Writes are limited to the
origin
account key.
Sourcepub fn set_controller(
origin: <T as Config>::RuntimeOrigin,
) -> Result<(), DispatchError>
pub fn set_controller( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>
(Re-)sets the controller of a stash to the stash itself. This function previously
accepted a controller
argument to set the controller to an account other than the
stash itself. This functionality has now been removed, now only setting the controller
to the stash, if it is not already.
Effects will be felt instantly (as soon as this function is completed successfully).
The dispatch origin for this call must be Signed by the stash, not the controller.
§Complexity
O(1)
- Independent of the arguments. Insignificant complexity.
- Contains a limited number of reads.
- Writes are limited to the
origin
account key.
Sourcepub fn set_validator_count(
origin: <T as Config>::RuntimeOrigin,
new: u32,
) -> Result<(), DispatchError>
pub fn set_validator_count( origin: <T as Config>::RuntimeOrigin, new: u32, ) -> Result<(), DispatchError>
Sourcepub fn increase_validator_count(
origin: <T as Config>::RuntimeOrigin,
additional: u32,
) -> Result<(), DispatchError>
pub fn increase_validator_count( origin: <T as Config>::RuntimeOrigin, additional: u32, ) -> Result<(), DispatchError>
Increments the ideal number of validators up to maximum of
T::MaxValidatorSet
.
The dispatch origin must be Root.
§Complexity
Same as Self::set_validator_count
.
Sourcepub fn scale_validator_count(
origin: <T as Config>::RuntimeOrigin,
factor: Percent,
) -> Result<(), DispatchError>
pub fn scale_validator_count( origin: <T as Config>::RuntimeOrigin, factor: Percent, ) -> Result<(), DispatchError>
Scale up the ideal number of validators by a factor up to maximum of
T::MaxValidatorSet
.
The dispatch origin must be Root.
§Complexity
Same as Self::set_validator_count
.
Sourcepub fn force_no_eras(
origin: <T as Config>::RuntimeOrigin,
) -> Result<(), DispatchError>
pub fn force_no_eras( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>
Force there to be no new eras indefinitely.
The dispatch origin must be Root.
§Warning
The election process starts multiple blocks before the end of the era. Thus the election process may be ongoing when this is called. In this case the election will continue until the next era is triggered.
§Complexity
- No arguments.
- Weight: O(1)
Sourcepub fn force_new_era(
origin: <T as Config>::RuntimeOrigin,
) -> Result<(), DispatchError>
pub fn force_new_era( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>
Force there to be a new era at the end of the next session. After this, it will be reset to normal (non-forced) behaviour.
The dispatch origin must be Root.
§Warning
The election process starts multiple blocks before the end of the era. If this is called just before a new era is triggered, the election process may not have enough blocks to get a result.
§Complexity
- No arguments.
- Weight: O(1)
Sourcepub fn set_invulnerables(
origin: <T as Config>::RuntimeOrigin,
invulnerables: Vec<<T as Config>::AccountId>,
) -> Result<(), DispatchError>
pub fn set_invulnerables( origin: <T as Config>::RuntimeOrigin, invulnerables: Vec<<T as Config>::AccountId>, ) -> Result<(), DispatchError>
Set the validators who cannot be slashed (if any).
The dispatch origin must be Root.
Sourcepub fn force_unstake(
origin: <T as Config>::RuntimeOrigin,
stash: <T as Config>::AccountId,
num_slashing_spans: u32,
) -> Result<(), DispatchError>
pub fn force_unstake( origin: <T as Config>::RuntimeOrigin, stash: <T as Config>::AccountId, num_slashing_spans: u32, ) -> Result<(), DispatchError>
Force a current staker to become completely unstaked, immediately.
The dispatch origin must be Root.
§Parameters
num_slashing_spans
: Refer to comments onCall::withdraw_unbonded
for more details.
Sourcepub fn force_new_era_always(
origin: <T as Config>::RuntimeOrigin,
) -> Result<(), DispatchError>
pub fn force_new_era_always( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>
Force there to be a new era at the end of sessions indefinitely.
The dispatch origin must be Root.
§Warning
The election process starts multiple blocks before the end of the era. If this is called just before a new era is triggered, the election process may not have enough blocks to get a result.
Sourcepub fn cancel_deferred_slash(
origin: <T as Config>::RuntimeOrigin,
era: u32,
slash_keys: Vec<(<T as Config>::AccountId, Perbill, u32)>,
) -> Result<(), DispatchError>
pub fn cancel_deferred_slash( origin: <T as Config>::RuntimeOrigin, era: u32, slash_keys: Vec<(<T as Config>::AccountId, Perbill, u32)>, ) -> Result<(), DispatchError>
Cancels scheduled slashes for a given era before they are applied.
This function allows T::AdminOrigin
to selectively remove pending slashes from
the UnappliedSlashes
storage, preventing their enactment.
§Parameters
era
: The staking era for which slashes were deferred.slash_keys
: A list of slash keys identifying the slashes to remove. This is a tuple of(stash, slash_fraction, page_index)
.
Sourcepub fn payout_stakers(
origin: <T as Config>::RuntimeOrigin,
validator_stash: <T as Config>::AccountId,
era: u32,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn payout_stakers( origin: <T as Config>::RuntimeOrigin, validator_stash: <T as Config>::AccountId, era: u32, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Pay out next page of the stakers behind a validator for the given era.
validator_stash
is the stash account of the validator.era
may be any era between[current_era - history_depth; current_era]
.
The origin of this call must be Signed. Any account can call this function, even if it is not one of the stakers.
The reward payout could be paged in case there are too many nominators backing the
validator_stash
. This call will payout unpaid pages in an ascending order. To claim a
specific page, use payout_stakers_by_page
.`
If all pages are claimed, it returns an error InvalidPage
.
Sourcepub fn rebond(
origin: <T as Config>::RuntimeOrigin,
value: <T as Config>::CurrencyBalance,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn rebond( origin: <T as Config>::RuntimeOrigin, value: <T as Config>::CurrencyBalance, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Rebond a portion of the stash scheduled to be unlocked.
The dispatch origin must be signed by the controller.
§Complexity
- Time complexity: O(L), where L is unlocking chunks
- Bounded by
MaxUnlockingChunks
.
Sourcepub fn reap_stash(
origin: <T as Config>::RuntimeOrigin,
stash: <T as Config>::AccountId,
num_slashing_spans: u32,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn reap_stash( origin: <T as Config>::RuntimeOrigin, stash: <T as Config>::AccountId, num_slashing_spans: u32, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Remove all data structures concerning a staker/stash once it is at a state where it can
be considered dust
in the staking system. The requirements are:
- the
total_balance
of the stash is below existential deposit. - or, the
ledger.total
of the stash is below existential deposit. - or, existential deposit is zero and either
total_balance
orledger.total
is zero.
The former can happen in cases like a slash; the latter when a fully unbonded account
is still receiving staking rewards in RewardDestination::Staked
.
It can be called by anyone, as long as stash
meets the above requirements.
Refunds the transaction fees upon successful execution.
§Parameters
num_slashing_spans
: Refer to comments onCall::withdraw_unbonded
for more details.
Sourcepub fn kick(
origin: <T as Config>::RuntimeOrigin,
who: Vec<<<T as Config>::Lookup as StaticLookup>::Source>,
) -> Result<(), DispatchError>
pub fn kick( origin: <T as Config>::RuntimeOrigin, who: Vec<<<T as Config>::Lookup as StaticLookup>::Source>, ) -> Result<(), DispatchError>
Remove the given nominations from the calling validator.
Effects will be felt at the beginning of the next era.
The dispatch origin for this call must be Signed by the controller, not the stash.
who
: A list of nominator stash accounts who are nominating this validator which should no longer be nominating this validator.
Note: Making this call only makes sense if you first set the validator preferences to block any further nominations.
Sourcepub fn set_staking_configs(
origin: <T as Config>::RuntimeOrigin,
min_nominator_bond: ConfigOp<<T as Config>::CurrencyBalance>,
min_validator_bond: ConfigOp<<T as Config>::CurrencyBalance>,
max_nominator_count: ConfigOp<u32>,
max_validator_count: ConfigOp<u32>,
chill_threshold: ConfigOp<Percent>,
min_commission: ConfigOp<Perbill>,
max_staked_rewards: ConfigOp<Percent>,
) -> Result<(), DispatchError>
pub fn set_staking_configs( origin: <T as Config>::RuntimeOrigin, min_nominator_bond: ConfigOp<<T as Config>::CurrencyBalance>, min_validator_bond: ConfigOp<<T as Config>::CurrencyBalance>, max_nominator_count: ConfigOp<u32>, max_validator_count: ConfigOp<u32>, chill_threshold: ConfigOp<Percent>, min_commission: ConfigOp<Perbill>, max_staked_rewards: ConfigOp<Percent>, ) -> Result<(), DispatchError>
Update the various staking configurations .
min_nominator_bond
: The minimum active bond needed to be a nominator.min_validator_bond
: The minimum active bond needed to be a validator.max_nominator_count
: The max number of users who can be a nominator at once. When set toNone
, no limit is enforced.max_validator_count
: The max number of users who can be a validator at once. When set toNone
, no limit is enforced.chill_threshold
: The ratio ofmax_nominator_count
ormax_validator_count
which should be filled in order for thechill_other
transaction to work.min_commission
: The minimum amount of commission that each validators must maintain. This is checked only upon callingvalidate
. Existing validators are not affected.
RuntimeOrigin must be Root to call this function.
NOTE: Existing nominators and validators will not be affected by this update.
to kick people under the new limits, chill_other
should be called.
Sourcepub fn chill_other(
origin: <T as Config>::RuntimeOrigin,
stash: <T as Config>::AccountId,
) -> Result<(), DispatchError>
pub fn chill_other( origin: <T as Config>::RuntimeOrigin, stash: <T as Config>::AccountId, ) -> Result<(), DispatchError>
Declare a controller
to stop participating as either a validator or nominator.
Effects will be felt at the beginning of the next era.
The dispatch origin for this call must be Signed, but can be called by anyone.
If the caller is the same as the controller being targeted, then no further checks are
enforced, and this function behaves just like chill
.
If the caller is different than the controller being targeted, the following conditions must be met:
controller
must belong to a nominator who has become non-decodable,
Or:
- A
ChillThreshold
must be set and checked which defines how close to the max nominators or validators we must reach before users can start chilling one-another. - A
MaxNominatorCount
andMaxValidatorCount
must be set which is used to determine how close we are to the threshold. - A
MinNominatorBond
andMinValidatorBond
must be set and checked, which determines if this is a person that should be chilled because they have not met the threshold bond required.
This can be helpful if bond requirements are updated, and we need to remove old users who do not satisfy these requirements.
Sourcepub fn force_apply_min_commission(
origin: <T as Config>::RuntimeOrigin,
validator_stash: <T as Config>::AccountId,
) -> Result<(), DispatchError>
pub fn force_apply_min_commission( origin: <T as Config>::RuntimeOrigin, validator_stash: <T as Config>::AccountId, ) -> Result<(), DispatchError>
Force a validator to have at least the minimum commission. This will not affect a validator who already has a commission greater than or equal to the minimum. Any account can call this.
Sourcepub fn set_min_commission(
origin: <T as Config>::RuntimeOrigin,
new: Perbill,
) -> Result<(), DispatchError>
pub fn set_min_commission( origin: <T as Config>::RuntimeOrigin, new: Perbill, ) -> Result<(), DispatchError>
Sets the minimum amount of commission that each validators must maintain.
This call has lower privilege requirements than set_staking_config
and can be called
by the T::AdminOrigin
. Root can always call this.
Sourcepub fn payout_stakers_by_page(
origin: <T as Config>::RuntimeOrigin,
validator_stash: <T as Config>::AccountId,
era: u32,
page: u32,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn payout_stakers_by_page( origin: <T as Config>::RuntimeOrigin, validator_stash: <T as Config>::AccountId, era: u32, page: u32, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Pay out a page of the stakers behind a validator for the given era and page.
validator_stash
is the stash account of the validator.era
may be any era between[current_era - history_depth; current_era]
.page
is the page index of nominators to pay out with value between 0 andnum_nominators / T::MaxExposurePageSize
.
The origin of this call must be Signed. Any account can call this function, even if it is not one of the stakers.
If a validator has more than Config::MaxExposurePageSize
nominators backing
them, then the list of nominators is paged, with each page being capped at
[Config::MaxExposurePageSize
.] If a validator has more than one page of nominators,
the call needs to be made for each page separately in order for all the nominators
backing a validator to receive the reward. The nominators are not sorted across pages
and so it should not be assumed the highest staker would be on the topmost page and vice
versa. If rewards are not claimed in Config::HistoryDepth
eras, they are lost.
Sourcepub fn update_payee(
origin: <T as Config>::RuntimeOrigin,
controller: <T as Config>::AccountId,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn update_payee( origin: <T as Config>::RuntimeOrigin, controller: <T as Config>::AccountId, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Migrates an account’s RewardDestination::Controller
to
RewardDestination::Account(controller)
.
Effects will be felt instantly (as soon as this function is completed successfully).
This will waive the transaction fee if the payee
is successfully migrated.
Sourcepub fn deprecate_controller_batch(
origin: <T as Config>::RuntimeOrigin,
controllers: BoundedVec<<T as Config>::AccountId, <T as Config>::MaxControllersInDeprecationBatch>,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn deprecate_controller_batch( origin: <T as Config>::RuntimeOrigin, controllers: BoundedVec<<T as Config>::AccountId, <T as Config>::MaxControllersInDeprecationBatch>, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Updates a batch of controller accounts to their corresponding stash account if they are not the same. Ignores any controller accounts that do not exist, and does not operate if the stash and controller are already the same.
Effects will be felt instantly (as soon as this function is completed successfully).
The dispatch origin must be T::AdminOrigin
.
Sourcepub fn restore_ledger(
origin: <T as Config>::RuntimeOrigin,
stash: <T as Config>::AccountId,
maybe_controller: Option<<T as Config>::AccountId>,
maybe_total: Option<<T as Config>::CurrencyBalance>,
maybe_unlocking: Option<BoundedVec<UnlockChunk<<T as Config>::CurrencyBalance>, <T as Config>::MaxUnlockingChunks>>,
) -> Result<(), DispatchError>
pub fn restore_ledger( origin: <T as Config>::RuntimeOrigin, stash: <T as Config>::AccountId, maybe_controller: Option<<T as Config>::AccountId>, maybe_total: Option<<T as Config>::CurrencyBalance>, maybe_unlocking: Option<BoundedVec<UnlockChunk<<T as Config>::CurrencyBalance>, <T as Config>::MaxUnlockingChunks>>, ) -> Result<(), DispatchError>
Restores the state of a ledger which is in an inconsistent state.
The requirements to restore a ledger are the following:
- The stash is bonded; or
- The stash is not bonded but it has a staking lock left behind; or
- If the stash has an associated ledger and its state is inconsistent; or
- If the ledger is not corrupted but its staking lock is out of sync.
The maybe_*
input parameters will overwrite the corresponding data and metadata of the
ledger associated with the stash. If the input parameters are not set, the ledger will
be reset values from on-chain state.
Sourcepub fn migrate_currency(
origin: <T as Config>::RuntimeOrigin,
stash: <T as Config>::AccountId,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn migrate_currency( origin: <T as Config>::RuntimeOrigin, stash: <T as Config>::AccountId, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Migrates permissionlessly a stash from locks to holds.
This removes the old lock on the stake and creates a hold on it atomically. If all stake cannot be held, the best effort is made to hold as much as possible. The remaining stake is removed from the ledger.
The fee is waived if the migration is successful.
Sourcepub fn apply_slash(
origin: <T as Config>::RuntimeOrigin,
slash_era: u32,
slash_key: (<T as Config>::AccountId, Perbill, u32),
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn apply_slash( origin: <T as Config>::RuntimeOrigin, slash_era: u32, slash_key: (<T as Config>::AccountId, Perbill, u32), ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Manually applies a deferred slash for a given era.
Normally, slashes are automatically applied shortly after the start of the slash_era
.
This function exists as a fallback mechanism in case slashes were not applied due to
unexpected reasons. It allows anyone to manually apply an unapplied slash.
§Parameters
slash_era
: The staking era in which the slash was originally scheduled.slash_key
: A unique identifier for the slash, represented as a tuple:stash
: The stash account of the validator being slashed.slash_fraction
: The fraction of the stake that was slashed.page_index
: The index of the exposure page being processed.
§Behavior
- The function is permissionless—anyone can call it.
- The
slash_era
must be the current era or a past era. If it is in the future, the call fails withEraNotStarted
. - The fee is waived if the slash is successfully applied.
§TODO: Future Improvement
- Implement an off-chain worker (OCW) task to automatically apply slashes when there is unused block space, improving efficiency.
Sourcepub fn manual_slash(
origin: <T as Config>::RuntimeOrigin,
validator_stash: <T as Config>::AccountId,
era: u32,
slash_fraction: Perbill,
) -> Result<(), DispatchError>
pub fn manual_slash( origin: <T as Config>::RuntimeOrigin, validator_stash: <T as Config>::AccountId, era: u32, slash_fraction: Perbill, ) -> Result<(), DispatchError>
This function allows governance to manually slash a validator and is a fallback mechanism.
The dispatch origin must be T::AdminOrigin
.
§Parameters
validator_stash
- The stash account of the validator to slash.era
- The era in which the validator was in the active set.slash_fraction
- The percentage of the stake to slash, expressed as a Perbill.
§Behavior
The slash will be applied using the standard slashing mechanics, respecting the
configured SlashDeferDuration
.
This means:
- If the validator was already slashed by a higher percentage for the same era, this slash will have no additional effect.
- If the validator was previously slashed by a lower percentage, only the difference will be applied.
- The slash will be deferred by
SlashDeferDuration
eras before being enacted.
Trait Implementations
Source§impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
Source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
Source§impl<T> Benchmarking for Pallet<T>
impl<T> Benchmarking for Pallet<T>
Source§fn benchmarks(extra: bool) -> Vec<BenchmarkMetadata>
fn benchmarks(extra: bool) -> Vec<BenchmarkMetadata>
Source§fn run_benchmark(
extrinsic: &[u8],
c: &[(BenchmarkParameter, u32)],
whitelist: &[TrackedStorageKey],
verify: bool,
internal_repeats: u32,
) -> Result<Vec<BenchmarkResult>, BenchmarkError>
fn run_benchmark( extrinsic: &[u8], c: &[(BenchmarkParameter, u32)], whitelist: &[TrackedStorageKey], verify: bool, internal_repeats: u32, ) -> Result<Vec<BenchmarkResult>, BenchmarkError>
Source§impl<T> DispatchViewFunction for Pallet<T>where
T: Config,
impl<T> DispatchViewFunction for Pallet<T>where
T: Config,
fn dispatch_view_function<O>(
id: &ViewFunctionId,
input: &mut &[u8],
output: &mut O,
) -> Result<(), ViewFunctionDispatchError>where
O: Output,
Source§impl<T> ElectionDataProvider for Pallet<T>where
T: Config,
impl<T> ElectionDataProvider for Pallet<T>where
T: Config,
Source§type BlockNumber = <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
type BlockNumber = <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
Source§type MaxVotesPerVoter = <<T as Config>::NominationsQuota as NominationsQuota<<T as Config>::CurrencyBalance>>::MaxNominations
type MaxVotesPerVoter = <<T as Config>::NominationsQuota as NominationsQuota<<T as Config>::CurrencyBalance>>::MaxNominations
Source§fn electing_voters(
bounds: DataProviderBounds,
page: u32,
) -> Result<Vec<(<Pallet<T> as ElectionDataProvider>::AccountId, u64, BoundedVec<<Pallet<T> as ElectionDataProvider>::AccountId, <Pallet<T> as ElectionDataProvider>::MaxVotesPerVoter>)>, &'static str>
fn electing_voters( bounds: DataProviderBounds, page: u32, ) -> Result<Vec<(<Pallet<T> as ElectionDataProvider>::AccountId, u64, BoundedVec<<Pallet<T> as ElectionDataProvider>::AccountId, <Pallet<T> as ElectionDataProvider>::MaxVotesPerVoter>)>, &'static str>
page
, thus
“electing”. Read moreSource§fn electing_voters_stateless(
bounds: DataProviderBounds,
) -> Result<Vec<(<Pallet<T> as ElectionDataProvider>::AccountId, u64, BoundedVec<<Pallet<T> as ElectionDataProvider>::AccountId, <Pallet<T> as ElectionDataProvider>::MaxVotesPerVoter>)>, &'static str>
fn electing_voters_stateless( bounds: DataProviderBounds, ) -> Result<Vec<(<Pallet<T> as ElectionDataProvider>::AccountId, u64, BoundedVec<<Pallet<T> as ElectionDataProvider>::AccountId, <Pallet<T> as ElectionDataProvider>::MaxVotesPerVoter>)>, &'static str>
Self::electing_voters
.Source§fn electable_targets(
bounds: DataProviderBounds,
page: u32,
) -> Result<Vec<<T as Config>::AccountId>, &'static str>
fn electable_targets( bounds: DataProviderBounds, page: u32, ) -> Result<Vec<<T as Config>::AccountId>, &'static str>
page
, i.e. the
targets that could become elected, thus “electable”. Read moreSource§fn next_election_prediction(
now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
fn next_election_prediction( now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
fn set_next_election(to: u32)
Source§fn add_voter(
voter: <T as Config>::AccountId,
weight: u64,
targets: BoundedVec<<T as Config>::AccountId, <Pallet<T> as ElectionDataProvider>::MaxVotesPerVoter>,
)
fn add_voter( voter: <T as Config>::AccountId, weight: u64, targets: BoundedVec<<T as Config>::AccountId, <Pallet<T> as ElectionDataProvider>::MaxVotesPerVoter>, )
Source§fn add_target(target: <T as Config>::AccountId)
fn add_target(target: <T as Config>::AccountId)
Source§fn put_snapshot(
voters: Vec<(<Pallet<T> as ElectionDataProvider>::AccountId, u64, BoundedVec<<Pallet<T> as ElectionDataProvider>::AccountId, <Pallet<T> as ElectionDataProvider>::MaxVotesPerVoter>)>,
targets: Vec<<T as Config>::AccountId>,
target_stake: Option<u64>,
)
fn put_snapshot( voters: Vec<(<Pallet<T> as ElectionDataProvider>::AccountId, u64, BoundedVec<<Pallet<T> as ElectionDataProvider>::AccountId, <Pallet<T> as ElectionDataProvider>::MaxVotesPerVoter>)>, targets: Vec<<T as Config>::AccountId>, target_stake: Option<u64>, )
fn set_desired_targets(count: u32)
Source§fn electable_targets_stateless(
bounds: DataProviderBounds,
) -> Result<Vec<Self::AccountId>, &'static str>
fn electable_targets_stateless( bounds: DataProviderBounds, ) -> Result<Vec<Self::AccountId>, &'static str>
Self::electable_targets
. Read moreSource§impl<T> EventHandler<<T as Config>::AccountId, <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T> EventHandler<<T as Config>::AccountId, <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Add reward points to block authors:
- 20 points to the block producer for producing a (non-uncle) block,
Source§impl<T> GetStorageVersion for Pallet<T>where
T: Config,
impl<T> GetStorageVersion for Pallet<T>where
T: Config,
Source§fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion
fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion
storage_version
attribute, or
NoStorageVersionSet
if the attribute is missing.Source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
Source§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version
and will be removed after March 2024.Self::current_storage_version
instead. Read moreSource§impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn on_initialize(
now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Weight
fn on_initialize( now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight
Start fetching the election pages Pages
blocks before the election prediction, so
that the ElectableStashes
has been populated with all validators from all pages at
the time of the election.
Source§fn on_finalize(
_n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
)
fn on_finalize( _n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )
Source§fn integrity_test()
fn integrity_test()
Source§fn try_state(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Result<(), DispatchError>
fn try_state( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Result<(), DispatchError>
Source§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize
). Read moreSource§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive
pallet. Read moreSource§fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
Source§fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>
fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>
Source§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Source§impl<T> IntegrityTest for Pallet<T>where
T: Config,
impl<T> IntegrityTest for Pallet<T>where
T: Config,
Source§impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn on_finalize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
)
fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )
Hooks::on_finalize
.Source§impl<T> OnGenesis for Pallet<T>where
T: Config,
impl<T> OnGenesis for Pallet<T>where
T: Config,
Source§fn on_genesis()
fn on_genesis()
Source§impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn on_initialize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Weight
fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight
Hooks::on_initialize
.Source§impl<T> OnOffenceHandler<<T as Config>::AccountId, (<T as Config>::ValidatorId, <T as Config>::FullIdentification), Weight> for Pallet<T>where
T: Config + Config<ValidatorId = <T as Config>::AccountId> + Config,
<T as Config>::SessionHandler: SessionHandler<<T as Config>::AccountId>,
<T as Config>::SessionManager: SessionManager<<T as Config>::AccountId>,
<T as Config>::ValidatorIdOf: Convert<<T as Config>::AccountId, Option<<T as Config>::AccountId>>,
impl<T> OnOffenceHandler<<T as Config>::AccountId, (<T as Config>::ValidatorId, <T as Config>::FullIdentification), Weight> for Pallet<T>where
T: Config + Config<ValidatorId = <T as Config>::AccountId> + Config,
<T as Config>::SessionHandler: SessionHandler<<T as Config>::AccountId>,
<T as Config>::SessionManager: SessionManager<<T as Config>::AccountId>,
<T as Config>::ValidatorIdOf: Convert<<T as Config>::AccountId, Option<<T as Config>::AccountId>>,
This is intended to be used with FilterHistoricalOffences
.
Source§fn on_offence(
offenders: &[OffenceDetails<<T as Config>::AccountId, (<T as Config>::ValidatorId, <T as Config>::FullIdentification)>],
slash_fractions: &[Perbill],
slash_session: u32,
) -> Weight
fn on_offence( offenders: &[OffenceDetails<<T as Config>::AccountId, (<T as Config>::ValidatorId, <T as Config>::FullIdentification)>], slash_fractions: &[Perbill], slash_session: u32, ) -> Weight
When an offence is reported, it is split into pages and put in the offence queue.
As offence queue is processed, computed slashes are queued to be applied after the
SlashDeferDuration
.
Source§impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Source§fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
Hooks::pre_upgrade
.Source§fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>
fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>
Hooks::post_upgrade
.Source§fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
pre_upgrade
->
on_runtime_upgrade
-> post_upgrade
hooks for a migration. Read moreSource§impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
Source§fn module_name() -> &'static str
fn module_name() -> &'static str
Source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
Source§impl<T> PalletsInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletsInfoAccess for Pallet<T>where
T: Config,
Source§impl<T> ScoreProvider<<T as Config>::AccountId> for Pallet<T>where
T: Config,
impl<T> ScoreProvider<<T as Config>::AccountId> for Pallet<T>where
T: Config,
type Score = u64
Source§fn score(
who: &<T as Config>::AccountId,
) -> <Pallet<T> as ScoreProvider<<T as Config>::AccountId>>::Score
fn score( who: &<T as Config>::AccountId, ) -> <Pallet<T> as ScoreProvider<<T as Config>::AccountId>>::Score
Score
of who
.Source§fn set_score_of(
who: &<T as Config>::AccountId,
weight: <Pallet<T> as ScoreProvider<<T as Config>::AccountId>>::Score,
)
fn set_score_of( who: &<T as Config>::AccountId, weight: <Pallet<T> as ScoreProvider<<T as Config>::AccountId>>::Score, )
score
.Source§impl<T> SessionManager<<T as Config>::AccountId> for Pallet<T>where
T: Config,
impl<T> SessionManager<<T as Config>::AccountId> for Pallet<T>where
T: Config,
In this implementation new_session(session)
must be called before end_session(session-1)
i.e. the new session must be planned before the ending of the previous session.
Once the first new_session is planned, all session must start and then end in order, though some session can lag in between the newest session planned and the latest session started.
Source§fn new_session(new_index: u32) -> Option<Vec<<T as Config>::AccountId>>
fn new_session(new_index: u32) -> Option<Vec<<T as Config>::AccountId>>
Source§fn new_session_genesis(new_index: u32) -> Option<Vec<<T as Config>::AccountId>>
fn new_session_genesis(new_index: u32) -> Option<Vec<<T as Config>::AccountId>>
new_session
, but it this should only be called at genesis. Read moreSource§fn start_session(start_index: u32)
fn start_session(start_index: u32)
Source§fn end_session(end_index: u32)
fn end_session(end_index: u32)
Source§impl<T> SessionManager<<T as Config>::AccountId, ()> for Pallet<T>where
T: Config,
impl<T> SessionManager<<T as Config>::AccountId, ()> for Pallet<T>where
T: Config,
Source§fn new_session(new_index: u32) -> Option<Vec<(<T as Config>::AccountId, ())>>
fn new_session(new_index: u32) -> Option<Vec<(<T as Config>::AccountId, ())>>
fn new_session_genesis( new_index: u32, ) -> Option<Vec<(<T as Config>::AccountId, ())>>
fn start_session(start_index: u32)
fn end_session(end_index: u32)
Source§impl<T> SessionManager<<T as Config>::AccountId, Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>> for Pallet<T>where
T: Config,
impl<T> SessionManager<<T as Config>::AccountId, Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>> for Pallet<T>where
T: Config,
Source§fn new_session(
new_index: u32,
) -> Option<Vec<(<T as Config>::AccountId, Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>)>>
fn new_session( new_index: u32, ) -> Option<Vec<(<T as Config>::AccountId, Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>)>>
fn new_session_genesis( new_index: u32, ) -> Option<Vec<(<T as Config>::AccountId, Exposure<<T as Config>::AccountId, <T as Config>::CurrencyBalance>)>>
fn start_session(start_index: u32)
fn end_session(end_index: u32)
Source§impl<T> StakingInterface for Pallet<T>where
T: Config,
impl<T> StakingInterface for Pallet<T>where
T: Config,
Source§fn is_virtual_staker(who: &<T as Config>::AccountId) -> bool
fn is_virtual_staker(who: &<T as Config>::AccountId) -> bool
Whether who
is a virtual staker whose funds are managed by another pallet.
There is an assumption that, this account is keyless and managed by another pallet in the runtime. Hence, it can never sign its own transactions.
Source§type Balance = <T as Config>::CurrencyBalance
type Balance = <T as Config>::CurrencyBalance
Source§type CurrencyToVote = <T as Config>::CurrencyToVote
type CurrencyToVote = <T as Config>::CurrencyToVote
Source§fn minimum_nominator_bond() -> <Pallet<T> as StakingInterface>::Balance
fn minimum_nominator_bond() -> <Pallet<T> as StakingInterface>::Balance
Source§fn minimum_validator_bond() -> <Pallet<T> as StakingInterface>::Balance
fn minimum_validator_bond() -> <Pallet<T> as StakingInterface>::Balance
Source§fn stash_by_ctrl(
controller: &<Pallet<T> as StakingInterface>::AccountId,
) -> Result<<Pallet<T> as StakingInterface>::AccountId, DispatchError>
fn stash_by_ctrl( controller: &<Pallet<T> as StakingInterface>::AccountId, ) -> Result<<Pallet<T> as StakingInterface>::AccountId, DispatchError>
controller
. Read moreSource§fn bonding_duration() -> u32
fn bonding_duration() -> u32
Source§fn current_era() -> u32
fn current_era() -> u32
Source§fn stake(
who: &<Pallet<T> as StakingInterface>::AccountId,
) -> Result<Stake<<T as Config>::CurrencyBalance>, DispatchError>
fn stake( who: &<Pallet<T> as StakingInterface>::AccountId, ) -> Result<Stake<<T as Config>::CurrencyBalance>, DispatchError>
Stake
of who
.Source§fn bond_extra(
who: &<Pallet<T> as StakingInterface>::AccountId,
extra: <Pallet<T> as StakingInterface>::Balance,
) -> Result<(), DispatchError>
fn bond_extra( who: &<Pallet<T> as StakingInterface>::AccountId, extra: <Pallet<T> as StakingInterface>::Balance, ) -> Result<(), DispatchError>
who
’s free balance against the active bonded balance of
the account. The amount extra actually bonded will never be more than who
’s free
balance.Source§fn unbond(
who: &<Pallet<T> as StakingInterface>::AccountId,
value: <Pallet<T> as StakingInterface>::Balance,
) -> Result<(), DispatchError>
fn unbond( who: &<Pallet<T> as StakingInterface>::AccountId, value: <Pallet<T> as StakingInterface>::Balance, ) -> Result<(), DispatchError>
Self::bonding_duration
. Read moreSource§fn set_payee(
stash: &<Pallet<T> as StakingInterface>::AccountId,
reward_acc: &<Pallet<T> as StakingInterface>::AccountId,
) -> Result<(), DispatchError>
fn set_payee( stash: &<Pallet<T> as StakingInterface>::AccountId, reward_acc: &<Pallet<T> as StakingInterface>::AccountId, ) -> Result<(), DispatchError>
Source§fn chill(
who: &<Pallet<T> as StakingInterface>::AccountId,
) -> Result<(), DispatchError>
fn chill( who: &<Pallet<T> as StakingInterface>::AccountId, ) -> Result<(), DispatchError>
who
.Source§fn withdraw_unbonded(
who: <Pallet<T> as StakingInterface>::AccountId,
num_slashing_spans: u32,
) -> Result<bool, DispatchError>
fn withdraw_unbonded( who: <Pallet<T> as StakingInterface>::AccountId, num_slashing_spans: u32, ) -> Result<bool, DispatchError>
Source§fn bond(
who: &<Pallet<T> as StakingInterface>::AccountId,
value: <Pallet<T> as StakingInterface>::Balance,
payee: &<Pallet<T> as StakingInterface>::AccountId,
) -> Result<(), DispatchError>
fn bond( who: &<Pallet<T> as StakingInterface>::AccountId, value: <Pallet<T> as StakingInterface>::Balance, payee: &<Pallet<T> as StakingInterface>::AccountId, ) -> Result<(), DispatchError>
value
of who
’s balance, while forwarding any rewards to payee
.Source§fn nominate(
who: &<Pallet<T> as StakingInterface>::AccountId,
targets: Vec<<Pallet<T> as StakingInterface>::AccountId>,
) -> Result<(), DispatchError>
fn nominate( who: &<Pallet<T> as StakingInterface>::AccountId, targets: Vec<<Pallet<T> as StakingInterface>::AccountId>, ) -> Result<(), DispatchError>
who
nominate validators
.Source§fn desired_validator_count() -> u32
fn desired_validator_count() -> u32
Source§fn election_ongoing() -> bool
fn election_ongoing() -> bool
Source§fn force_unstake(
who: <Pallet<T> as StakingInterface>::AccountId,
) -> Result<(), DispatchError>
fn force_unstake( who: <Pallet<T> as StakingInterface>::AccountId, ) -> Result<(), DispatchError>
Source§fn is_exposed_in_era(
who: &<Pallet<T> as StakingInterface>::AccountId,
era: &u32,
) -> bool
fn is_exposed_in_era( who: &<Pallet<T> as StakingInterface>::AccountId, era: &u32, ) -> bool
staker
has been exposed in an era.Source§fn status(
who: &<Pallet<T> as StakingInterface>::AccountId,
) -> Result<StakerStatus<<Pallet<T> as StakingInterface>::AccountId>, DispatchError>
fn status( who: &<Pallet<T> as StakingInterface>::AccountId, ) -> Result<StakerStatus<<Pallet<T> as StakingInterface>::AccountId>, DispatchError>
Err
if not staked at all.Source§fn slash_reward_fraction() -> Perbill
fn slash_reward_fraction() -> Perbill
Source§fn nominations(
who: &<Pallet<T> as StakingInterface>::AccountId,
) -> Option<Vec<<T as Config>::AccountId>>
fn nominations( who: &<Pallet<T> as StakingInterface>::AccountId, ) -> Option<Vec<<T as Config>::AccountId>>
None
otherwise.fn add_era_stakers( current_era: &u32, stash: &<T as Config>::AccountId, exposures: Vec<(<Pallet<T> as StakingInterface>::AccountId, <Pallet<T> as StakingInterface>::Balance)>, )
fn set_current_era(era: u32)
fn max_exposure_page_size() -> u32
Source§fn total_stake(who: &Self::AccountId) -> Result<Self::Balance, DispatchError>
fn total_stake(who: &Self::AccountId) -> Result<Self::Balance, DispatchError>
Err
if not a staker.Source§fn active_stake(who: &Self::AccountId) -> Result<Self::Balance, DispatchError>
fn active_stake(who: &Self::AccountId) -> Result<Self::Balance, DispatchError>
Stake
, Err
if not a staker.Source§fn is_unbonding(who: &Self::AccountId) -> Result<bool, DispatchError>
fn is_unbonding(who: &Self::AccountId) -> Result<bool, DispatchError>
Err
if not a staker at all.Source§fn fully_unbond(who: &Self::AccountId) -> Result<(), DispatchError>
fn fully_unbond(who: &Self::AccountId) -> Result<(), DispatchError>
Err
if not a staker at all.Source§fn is_validator(who: &Self::AccountId) -> bool
fn is_validator(who: &Self::AccountId) -> bool
Source§impl<T> StakingUnchecked for Pallet<T>where
T: Config,
impl<T> StakingUnchecked for Pallet<T>where
T: Config,
Source§fn virtual_bond(
keyless_who: &<Pallet<T> as StakingInterface>::AccountId,
value: <Pallet<T> as StakingInterface>::Balance,
payee: &<Pallet<T> as StakingInterface>::AccountId,
) -> Result<(), DispatchError>
fn virtual_bond( keyless_who: &<Pallet<T> as StakingInterface>::AccountId, value: <Pallet<T> as StakingInterface>::Balance, payee: &<Pallet<T> as StakingInterface>::AccountId, ) -> Result<(), DispatchError>
Virtually bonds keyless_who
to payee
with value
.
The payee must not be the same as the keyless_who
.
Source§fn migrate_to_direct_staker(who: &<Pallet<T> as StakingInterface>::AccountId)
fn migrate_to_direct_staker(who: &<Pallet<T> as StakingInterface>::AccountId)
Only meant to be used in tests.
Source§fn migrate_to_virtual_staker(
who: &<Pallet<T> as StakingInterface>::AccountId,
) -> Result<(), DispatchError>
fn migrate_to_virtual_staker( who: &<Pallet<T> as StakingInterface>::AccountId, ) -> Result<(), DispatchError>
Source§impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
fn storage_info() -> Vec<StorageInfo>
Source§impl<T> TryDecodeEntireStorage for Pallet<T>where
T: Config,
impl<T> TryDecodeEntireStorage for Pallet<T>where
T: Config,
Source§fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
Ok(bytes_decoded)
if success.Source§impl<T> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
Source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.