From 3dc9a9937d97e27d0be58f0b6763c9236b28d054 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 29 May 2021 11:38:22 +0200 Subject: [PATCH 1/2] Session key should be settable at genesis even for non-endowed accounts --- frame/session/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index cbe70598a91b3..3e4379f3d32fb 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -442,11 +442,12 @@ decl_storage! { for (account, val, keys) in config.keys.iter().cloned() { >::inner_set_keys(&val, keys) .expect("genesis config must not contain duplicates; qed"); - assert!( - frame_system::Pallet::::inc_consumers(&account).is_ok(), - "Account ({:?}) does not exist at genesis to set key. Account not endowed?", - account, - ); + if frame_system::Pallet::::inc_consumers(&account).is_err() { + // This will lead a provider reference, however we assume that the user wants to + // do this since it's the only way a non-endowed account can contain a session + // key. + frame_system::Pallet::::inc_providers(&account); + } } let initial_validators_0 = T::SessionManager::new_session(0) From 1560aace95a0ca3bb353392e1b9ef4e447244994 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 29 May 2021 11:41:52 +0200 Subject: [PATCH 2/2] Docs --- frame/session/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 3e4379f3d32fb..8574979ef2fea 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -443,7 +443,8 @@ decl_storage! { >::inner_set_keys(&val, keys) .expect("genesis config must not contain duplicates; qed"); if frame_system::Pallet::::inc_consumers(&account).is_err() { - // This will lead a provider reference, however we assume that the user wants to + // This will leak a provider reference, however it only happens once (at + // genesis) so it's really not a big deal and we assume that the user wants to // do this since it's the only way a non-endowed account can contain a session // key. frame_system::Pallet::::inc_providers(&account);