mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
657d99202c
* bounding election provider with kian * multi phase implement bounded election provider * election provider blanket implementation * staking compiles * fix test for election provider support * fmt * fixing epmp tests, does not compile yet * fix epmp tests * fix staking tests * fmt * fix runtime tests * fmt * remove outdated wip tags * add enum error * sort and truncate supports * comment * error when unsupported number of election winners * compiling wip after kian's suggestions * fix TODOs * remove,fix tags * ensure validator count does not exceed maxwinners * clean up * some more clean up and todos * handle too many winners * rename parameter for mock * todo * add sort and truncate rule if there are too many winners * fmt * fail, not swallow emergency result bound not met * remove too many winners resolution as it can be guaranteed to be bounded * fix benchmark * give MaxWinners more contextual name * make ready solution generic over T * kian feedback * fix stuff * Kian's way of solvign this * comment fix * fix compile * remove use of BoundedExecution * fmt * comment out failing integrity test * cap validator count increment to max winners * dont panic * add test for bad data provider * Update frame/staking/src/pallet/impls.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * fix namespace conflict and add test for onchain max winners less than desired targets * defensive unwrap * early convert to bounded vec * fix syntax * fmt * fix doc * fix rustdoc * fmt * fix maxwinner count for benchmarking * add instant election for noelection * fmt * fix compile * pr feedbacks * always error at validator count exceeding max winners * add useful error message * pr comments * import fix * add checked_desired_targets * fmt * fmt * fix rust doc Co-authored-by: parity-processbot <> Co-authored-by: kianenigma <kian@parity.io> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Session Pallet
The Session module allows validators to manage their session keys, provides a function for changing the session length, and handles session rotation.
Overview
Terminology
- Session: A session is a period of time that has a constant set of validators. Validators can only join
or exit the validator set at a session change. It is measured in block numbers. The block where a session is
ended is determined by the
ShouldEndSessiontrait. When the session is ending, a new validator set can be chosen byOnSessionEndingimplementations. - Session key: A session key is actually several keys kept together that provide the various signing functions required by network authorities/validators in pursuit of their duties.
- Validator ID: Every account has an associated validator ID. For some simple staking systems, this may just be the same as the account ID. For staking systems using a stash/controller model, the validator ID would be the stash account ID of the controller.
- Session key configuration process: Session keys are set using
set_keysfor use not in the next session, but the session after next. They are stored inNextKeys, a mapping between the caller'sValidatorIdand the session keys provided.set_keysallows users to set their session key prior to being selected as validator. It is a public call since it usesensure_signed, which checks that the origin is a signed account. As such, the account ID of the origin stored inNextKeysmay not necessarily be associated with a block author or a validator. The session keys of accounts are removed once their account balance is zero. - Session length: This pallet does not assume anything about the length of each session.
Rather, it relies on an implementation of
ShouldEndSessionto dictate a new session's start. This pallet provides thePeriodicSessionsstruct for simple periodic sessions. - Session rotation configuration: Configure as either a 'normal' (rewardable session where rewards are applied) or 'exceptional' (slashable) session rotation.
- Session rotation process: At the beginning of each block, the
on_initializefunction queries the provided implementation ofShouldEndSession. If the session is to end the newly activated validator IDs and session keys are taken from storage and passed to theSessionHandler. The validator set supplied bySessionManager::new_sessionand the corresponding session keys, which may have been registered viaset_keysduring the previous session, are written to storage where they will wait one session before being passed to theSessionHandlerthemselves.
Goals
The Session pallet is designed to make the following possible:
- Set session keys of the validator set for upcoming sessions.
- Control the length of sessions.
- Configure and switch between either normal or exceptional session rotations.
Interface
Dispatchable Functions
set_keys- Set a validator's session keys for upcoming sessions.
Public Functions
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 ID
Usage
Example from the FRAME
The 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::Pallet<T>>::validators()
}
Related Pallets
License: Apache-2.0