referrerpolicy=no-referrer-when-downgrade

Function apply_slash

Source
pub fn apply_slash<T: Config>(
    slash_era: EraIndex,
    slash_key: (T::AccountId, Perbill, u32),
)
Expand description

Manually and permissionlessly applies a deferred slash for a given era.

Normally, slashes are automatically applied shortly after the start of the slash_era. The automatic application of slashes is handled by the pallet’s internal logic, and it tries to apply one slash page per block of the era. If for some reason, one era is not enough for applying all slash pages, the remaining slashes need to be manually (permissionlessly) applied.

For a given era x, if at era x+1, slashes are still unapplied, all withdrawals get blocked, and these need to be manually applied by calling this function. This function exists as a fallback mechanism for this extreme situation, but we never expect to encounter this in normal scenarios.

The parameters for this call can be queried by looking at the UnappliedSlashes storage for eras older than the active era.

§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 with EraNotStarted.
  • The fee is waived if the slash is successfully applied.

§Future Improvement

  • Implement an off-chain worker (OCW) task to automatically apply slashes when there is unused block space, improving efficiency.

§Warning: Doc-Only

This function is an automatically generated, and is doc-only, uncallable stub. See the real version in Pallet::apply_slash.