Crates.io | pallet-session |
lib.rs | pallet-session |
version | 38.0.0 |
source | src |
created_at | 2020-02-27 09:30:50.199549 |
updated_at | 2024-09-26 09:16:07.474589 |
description | FRAME sessions pallet |
homepage | https://paritytech.github.io/polkadot-sdk/ |
repository | https://github.com/paritytech/polkadot-sdk.git |
max_upload_size | |
id | 213023 |
size | 107,101 |
The Session module allows validators to manage their session keys, provides a function for changing the session length, and handles session rotation.
ShouldEndSession
trait. When the session is ending, a new validator set can be chosen by OnSessionEnding
implementations.set_keys
for use not in the next session, but the
session after next. They are stored in NextKeys
, a mapping between the caller's ValidatorId
and the session keys
provided. set_keys
allows users to set their session key prior to being selected as validator. It is a public call
since it uses ensure_signed
, which checks that the origin is a signed account. As such, the account ID of the origin
stored in NextKeys
may not necessarily be associated with a block author or a validator. The session keys of accounts
are removed once their account balance is zero.ShouldEndSession
to dictate a new session's start. This pallet provides the PeriodicSessions
struct for simple periodic sessions.on_initialize
function queries the provided
implementation of ShouldEndSession
. If the session is to end the newly activated validator IDs and session keys are
taken from storage and passed to the SessionHandler
. The validator set supplied by SessionManager::new_session
and
the corresponding session keys, which may have been registered via set_keys
during the previous session, are written
to storage where they will wait one session before being passed to the SessionHandler
themselves.The Session pallet is designed to make the following possible:
set_keys
- Set a validator's session keys for upcoming sessions.rotate_session
- Change to the next session. Register the new authority set. Queue changes for next session
rotation.disable_index
- Disable a validator by index.disable
- Disable a validator by Validator IDThe Staking pallet uses the Session pallet to get the validator set.
use pallet_session as session;
fn validators<T: pallet_session::Config>() -> Vec<<T as pallet_session::Config>::ValidatorId> {
pallet_session::Validators::<T>::get()
}
License: Apache-2.0
Polkadot SDK stable2409