Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<Runtime: BasicParachainRuntime> ExtBuilder<Runtime> {
.assimilate_storage(&mut t)
.unwrap();

pallet_session::GenesisConfig::<Runtime> { keys: self.keys }
pallet_session::GenesisConfig::<Runtime> { keys: self.keys, ..Default::default() }
.assimilate_storage(&mut t)
.unwrap();

Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_5078.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Add possibility to inject non-authorities session-keys in genesis

doc:
- audience: Runtime Dev
description: |
Allows to inject a set of registered session-keys in pallet-session that are not
part of the first initial set of validators
crates:
- name: frame-session
bump: minor
Comment thread
bkchr marked this conversation as resolved.
Outdated
12 changes: 10 additions & 2 deletions substrate/frame/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,13 @@ pub mod pallet {
#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
/// Initial list of validator at genesis representing by their `(AccountId, ValidatorId, Keys)`.
/// These keys will be considered authorities for the first two sessions and they will be valid
/// at least until session 2
pub keys: Vec<(T::AccountId, T::ValidatorId, T::Keys)>,
Comment thread
girazoki marked this conversation as resolved.
/// List of (AccountId, ValidatorId, Keys) that will be registered at genesis, but not as active validators.
/// These keys are set, together with `keys`, as authority candidates for future sessions (enactable from session 2 onwards)
pub non_authority_keys: Vec<(T::AccountId, T::ValidatorId, T::Keys)>,
}

#[pallet::genesis_build]
Expand All @@ -446,7 +452,9 @@ pub mod pallet {
}
});

for (account, val, keys) in self.keys.iter().cloned() {
for (account, val, keys) in
self.keys.iter().chain(self.non_authority_keys.iter()).cloned()
{
Pallet::<T>::inner_set_keys(&val, keys)
.expect("genesis config must not contain duplicates; qed");
if frame_system::Pallet::<T>::inc_consumers_without_limit(&account).is_err() {
Expand Down Expand Up @@ -676,7 +684,7 @@ impl<T: Config> Pallet<T> {
let mut now_session_keys = session_keys.iter();
let mut check_next_changed = |keys: &T::Keys| {
if changed {
return
return;
}
// since a new validator set always leads to `changed` starting
// as true, we can ensure that `now_session_keys` and `next_validators`
Expand Down