pub type Session = Pallet<Runtime>;
Aliased Type§
struct Session(/* private fields */);
Implementations
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn set_keys(
origin: <T as Config>::RuntimeOrigin,
keys: <T as Config>::Keys,
proof: Vec<u8>,
) -> Result<(), DispatchError>
pub fn set_keys( origin: <T as Config>::RuntimeOrigin, keys: <T as Config>::Keys, proof: Vec<u8>, ) -> Result<(), DispatchError>
Sets the session key(s) of the function caller to keys
.
Allows an account to set its session key prior to becoming a validator.
This doesn’t take effect until the next session.
The dispatch origin of this function must be signed.
§Complexity
O(1)
. Actual cost depends on the number of length ofT::Keys::key_ids()
which is fixed.
Sourcepub fn purge_keys(
origin: <T as Config>::RuntimeOrigin,
) -> Result<(), DispatchError>
pub fn purge_keys( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>
Removes any session key(s) of the function caller.
This doesn’t take effect until the next session.
The dispatch origin of this function must be Signed and the account must be either be convertible to a validator ID using the chain’s typical addressing system (this usually means being a controller account) or directly convertible into a validator ID (which usually means being a stash account).
§Complexity
O(1)
in number of key types. Actual cost depends on the number of length ofT::Keys::key_ids()
which is fixed.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn validators() -> Vec<<T as Config>::ValidatorId>
pub fn validators() -> Vec<<T as Config>::ValidatorId>
Public function to access the current set of validators.
Sourcepub fn current_index() -> u32
pub fn current_index() -> u32
Public function to access the current session index.
Sourcepub fn queued_keys() -> Vec<(<T as Config>::ValidatorId, <T as Config>::Keys)>
pub fn queued_keys() -> Vec<(<T as Config>::ValidatorId, <T as Config>::Keys)>
Public function to access the queued keys.
Sourcepub fn disabled_validators() -> Vec<u32>
pub fn disabled_validators() -> Vec<u32>
Public function to access the disabled validators.
Sourcepub fn rotate_session()
pub fn rotate_session()
Move on to next session. Register new validator set and session keys. Changes to the validator set have a session of delay to take effect. This allows for equivocation punishment after a fork.
Sourcepub fn disable_index(i: u32) -> bool
pub fn disable_index(i: u32) -> bool
Disable the validator of index i
, returns false
if the validator was already disabled.
Note: This sets the OffenceSeverity to the lowest value.
Sourcepub fn disable(c: &<T as Config>::ValidatorId) -> bool
pub fn disable(c: &<T as Config>::ValidatorId) -> bool
Disable the validator identified by c
. (If using with the staking pallet,
this would be their stash account.)
Returns false
either if the validator could not be found or it was already
disabled.
Sourcepub fn upgrade_keys<Old, F>(upgrade: F)where
Old: OpaqueKeys + Member + Decode,
F: Fn(<T as Config>::ValidatorId, Old) -> <T as Config>::Keys,
pub fn upgrade_keys<Old, F>(upgrade: F)where
Old: OpaqueKeys + Member + Decode,
F: Fn(<T as Config>::ValidatorId, Old) -> <T as Config>::Keys,
Upgrade the key type from some old type to a new type. Supports adding and removing key types.
This function should be used with extreme care and only during an
on_runtime_upgrade
block. Misuse of this function can put your blockchain
into an unrecoverable state.
Care should be taken that the raw versions of the
added keys are unique for every ValidatorId, KeyTypeId
combination.
This is an invariant that the session pallet typically maintains internally.
As the actual values of the keys are typically not known at runtime upgrade,
it’s recommended to initialize the keys to a (unique) dummy value with the expectation
that all validators should invoke set_keys
before those keys are actually
required.
Sourcepub fn key_owner(
id: KeyTypeId,
key_data: &[u8],
) -> Option<<T as Config>::ValidatorId>
pub fn key_owner( id: KeyTypeId, key_data: &[u8], ) -> Option<<T as Config>::ValidatorId>
Query the owner of a session key by returning the owner’s validator ID.
pub fn report_offence( validator: <T as Config>::ValidatorId, severity: OffenceSeverity, )
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> DisabledValidators for Pallet<T>where
T: Config,
impl<T> DisabledValidators for Pallet<T>where
T: Config,
Source§fn is_disabled(index: u32) -> bool
fn is_disabled(index: u32) -> bool
Source§fn disabled_validators() -> Vec<u32>
fn disabled_validators() -> Vec<u32>
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> EstimateNextNewSession<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> EstimateNextNewSession<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn estimate_next_new_session(
now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> (Option<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number>, Weight)
fn estimate_next_new_session( now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> (Option<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number>, Weight)
This session pallet always calls new_session and next_session at the same time, hence we do a simple proxy and pass the function to next rotation.
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(
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
Called when a block is initialized. Will rotate session if it is the last block of the current session.
Source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
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 try_state(_n: BlockNumber) -> Result<(), DispatchError>
fn try_state(_n: BlockNumber) -> Result<(), DispatchError>
Source§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§fn integrity_test()
fn integrity_test()
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> 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> 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> ValidatorRegistration<<T as Config>::ValidatorId> for Pallet<T>where
T: Config,
impl<T> ValidatorRegistration<<T as Config>::ValidatorId> for Pallet<T>where
T: Config,
Source§fn is_registered(id: &<T as Config>::ValidatorId) -> bool
fn is_registered(id: &<T as Config>::ValidatorId) -> bool
Source§impl<T> ValidatorSet<<T as Config>::AccountId> for Pallet<T>where
T: Config,
impl<T> ValidatorSet<<T as Config>::AccountId> for Pallet<T>where
T: Config,
Source§type ValidatorId = <T as Config>::ValidatorId
type ValidatorId = <T as Config>::ValidatorId
Source§type ValidatorIdOf = <T as Config>::ValidatorIdOf
type ValidatorIdOf = <T as Config>::ValidatorIdOf
AccountId
to ValidatorId
.Source§fn session_index() -> u32
fn session_index() -> u32
Source§fn validators() -> Vec<<Pallet<T> as ValidatorSet<<T as Config>::AccountId>>::ValidatorId>
fn validators() -> Vec<<Pallet<T> as ValidatorSet<<T as Config>::AccountId>>::ValidatorId>
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.