From d6f59871396e2a1ffd1e27d545d98d94c6e27ea0 Mon Sep 17 00:00:00 2001
From: girazoki <gorka.irazoki@gmail.com>
Date: Mon, 29 Jul 2024 20:48:44 +0200
Subject: [PATCH] add possibility to inject non-authorities session-keys in
 genesis (#5078)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add the possibility of injecting session-keys in genesis for
non-validators. Currently all keys injected in genesis were considered
as part of the initial validators set, this PR allows to inject a new
vector with non-authority keys

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
---
 .../pallets/collator-selection/src/mock.rs    |  2 +-
 .../assets/asset-hub-rococo/src/genesis.rs    |  1 +
 .../assets/asset-hub-westend/src/genesis.rs   |  1 +
 .../bridges/bridge-hub-rococo/src/genesis.rs  |  1 +
 .../bridges/bridge-hub-westend/src/genesis.rs |  1 +
 .../collectives-westend/src/genesis.rs        |  1 +
 .../coretime/coretime-rococo/src/genesis.rs   |  1 +
 .../coretime/coretime-westend/src/genesis.rs  |  1 +
 .../people/people-rococo/src/genesis.rs       |  1 +
 .../people/people-westend/src/genesis.rs      |  1 +
 .../parachains/testing/penpal/src/genesis.rs  |  1 +
 .../chains/relays/rococo/src/genesis.rs       |  1 +
 .../chains/relays/westend/src/genesis.rs      |  1 +
 .../parachains/runtimes/test-utils/src/lib.rs |  2 +-
 .../src/chain_spec/asset_hubs.rs              |  1 +
 prdoc/pr_5078.prdoc                           | 34 +++++++++++++++++++
 .../cli/tests/res/default_genesis_config.json |  4 ++-
 substrate/bin/node/testing/src/genesis.rs     |  1 +
 substrate/frame/babe/src/mock.rs              |  2 +-
 substrate/frame/beefy-mmr/src/mock.rs         |  2 +-
 substrate/frame/beefy/src/mock.rs             |  2 +-
 .../test-staking-e2e/src/mock.rs              |  1 +
 substrate/frame/grandpa/src/mock.rs           |  2 +-
 substrate/frame/root-offences/src/mock.rs     |  1 +
 substrate/frame/session/src/historical/mod.rs |  2 +-
 .../frame/session/src/historical/offchain.rs  |  4 ++-
 substrate/frame/session/src/lib.rs            | 13 +++++--
 substrate/frame/session/src/mock.rs           |  2 +-
 substrate/frame/staking/src/mock.rs           |  1 +
 29 files changed, 76 insertions(+), 12 deletions(-)
 create mode 100644 prdoc/pr_5078.prdoc

diff --git a/cumulus/pallets/collator-selection/src/mock.rs b/cumulus/pallets/collator-selection/src/mock.rs
index 459b1cb5fdf..d13f9e9d8c4 100644
--- a/cumulus/pallets/collator-selection/src/mock.rs
+++ b/cumulus/pallets/collator-selection/src/mock.rs
@@ -187,7 +187,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
 		candidacy_bond: 10,
 		invulnerables,
 	};
-	let session = pallet_session::GenesisConfig::<Test> { keys };
+	let session = pallet_session::GenesisConfig::<Test> { keys, ..Default::default() };
 	pallet_balances::GenesisConfig::<Test> { balances }
 		.assimilate_storage(&mut t)
 		.unwrap();
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/genesis.rs
index 3a87322664d..82f86e2b32e 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/genesis.rs
@@ -62,6 +62,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: asset_hub_rococo_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/genesis.rs
index 219d1306906..fd84030ed13 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/genesis.rs
@@ -58,6 +58,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: asset_hub_westend_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/genesis.rs
index 12778215b13..3786d529ea6 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/genesis.rs
@@ -52,6 +52,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: bridge_hub_rococo_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/genesis.rs
index 4be68e510f4..a160d18d4cf 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/genesis.rs
@@ -51,6 +51,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: bridge_hub_westend_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend/src/genesis.rs
index 6a28b1a9ddd..d4ef184ea39 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend/src/genesis.rs
@@ -51,6 +51,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: collectives_westend_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-rococo/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-rococo/src/genesis.rs
index f72de52c493..e0f035c368e 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-rococo/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-rococo/src/genesis.rs
@@ -51,6 +51,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: coretime_rococo_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-westend/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-westend/src/genesis.rs
index 222ffe7a63a..239ad3760c1 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-westend/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-westend/src/genesis.rs
@@ -51,6 +51,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: coretime_westend_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo/src/genesis.rs
index b1400993302..43d182facdd 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo/src/genesis.rs
@@ -47,6 +47,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: people_rococo_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend/src/genesis.rs
index d385fbebc82..0b99f19bc13 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend/src/genesis.rs
@@ -47,6 +47,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: people_westend_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/genesis.rs
index 450439f5ea3..260875088bb 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/genesis.rs
@@ -59,6 +59,7 @@ pub fn genesis(para_id: u32) -> Storage {
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		polkadot_xcm: penpal_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/genesis.rs
index 074a1de5e18..9cb25b40360 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/genesis.rs
@@ -75,6 +75,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect::<Vec<_>>(),
+			..Default::default()
 		},
 		babe: rococo_runtime::BabeConfig {
 			authorities: Default::default(),
diff --git a/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs
index b9f12932b84..172e6e0ac93 100644
--- a/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs
+++ b/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs
@@ -77,6 +77,7 @@ pub fn genesis() -> Storage {
 					)
 				})
 				.collect::<Vec<_>>(),
+			..Default::default()
 		},
 		staking: westend_runtime::StakingConfig {
 			validator_count: validators::initial_authorities().len() as u32,
diff --git a/cumulus/parachains/runtimes/test-utils/src/lib.rs b/cumulus/parachains/runtimes/test-utils/src/lib.rs
index 3fc3822a63e..940aa1b734d 100644
--- a/cumulus/parachains/runtimes/test-utils/src/lib.rs
+++ b/cumulus/parachains/runtimes/test-utils/src/lib.rs
@@ -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();
 
diff --git a/cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs b/cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs
index 45920cdb614..af5bccdc416 100644
--- a/cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs
+++ b/cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs
@@ -389,6 +389,7 @@ fn asset_hub_rococo_genesis(
 					)
 				})
 				.collect(),
+			..Default::default()
 		},
 		"polkadotXcm": asset_hub_rococo_runtime::PolkadotXcmConfig {
 			safe_xcm_version: Some(SAFE_XCM_VERSION),
diff --git a/prdoc/pr_5078.prdoc b/prdoc/pr_5078.prdoc
new file mode 100644
index 00000000000..1805a27c3f2
--- /dev/null
+++ b/prdoc/pr_5078.prdoc
@@ -0,0 +1,34 @@
+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: pallet-session
+  bump: major
+- name: parachains-runtimes-test-utils
+  bump: patch
+- name: pallet-staking
+  bump: none
+- name: pallet-collator-selection
+  bump: none
+- name: pallet-root-offences
+  bump: none
+- name: pallet-babe
+  bump: none
+- name: pallet-staking
+  bump: none
+- name: pallet-grandpa
+  bump: none
+- name: pallet-collator-selection
+  bump: none
+- name: pallet-beefy
+  bump: none
+- name: pallet-beefy-mmr
+  bump: none
+- name: pallet-root-offences
+  bump: none
+- name: polkadot-parachain-bin
+  bump: none
\ No newline at end of file
diff --git a/substrate/bin/node/cli/tests/res/default_genesis_config.json b/substrate/bin/node/cli/tests/res/default_genesis_config.json
index b63e5ff549e..a2e52837d88 100644
--- a/substrate/bin/node/cli/tests/res/default_genesis_config.json
+++ b/substrate/bin/node/cli/tests/res/default_genesis_config.json
@@ -34,7 +34,9 @@
     "maxNominatorCount": null
   },
   "session": {
-    "keys": []
+    "keys": [],
+    "nonAuthorityKeys": []
+
   },
   "democracy": {},
   "council": {
diff --git a/substrate/bin/node/testing/src/genesis.rs b/substrate/bin/node/testing/src/genesis.rs
index c79612d6844..7f5364744c6 100644
--- a/substrate/bin/node/testing/src/genesis.rs
+++ b/substrate/bin/node/testing/src/genesis.rs
@@ -54,6 +54,7 @@ pub fn config_endowed(extra_endowed: Vec<AccountId>) -> RuntimeGenesisConfig {
 				(bob(), eve(), session_keys_from_seed(Ed25519Keyring::Bob.into())),
 				(charlie(), ferdie(), session_keys_from_seed(Ed25519Keyring::Charlie.into())),
 			],
+			..Default::default()
 		},
 		staking: StakingConfig {
 			stakers: vec![
diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs
index e193a2e3b64..912cb3e27cd 100644
--- a/substrate/frame/babe/src/mock.rs
+++ b/substrate/frame/babe/src/mock.rs
@@ -319,7 +319,7 @@ pub fn new_test_ext_raw_authorities(authorities: Vec<AuthorityId>) -> sp_io::Tes
 
 	// NOTE: this will initialize the babe authorities
 	// through OneSessionHandler::on_genesis_session
-	pallet_session::GenesisConfig::<Test> { keys: session_keys }
+	pallet_session::GenesisConfig::<Test> { keys: session_keys, ..Default::default() }
 		.assimilate_storage(&mut t)
 		.unwrap();
 
diff --git a/substrate/frame/beefy-mmr/src/mock.rs b/substrate/frame/beefy-mmr/src/mock.rs
index 3adef4f32bf..1102f9677aa 100644
--- a/substrate/frame/beefy-mmr/src/mock.rs
+++ b/substrate/frame/beefy-mmr/src/mock.rs
@@ -187,7 +187,7 @@ pub fn new_test_ext_raw_authorities(authorities: Vec<(u64, BeefyId)>) -> TestExt
 		}
 	});
 
-	pallet_session::GenesisConfig::<Test> { keys: session_keys }
+	pallet_session::GenesisConfig::<Test> { keys: session_keys, ..Default::default() }
 		.assimilate_storage(&mut t)
 		.unwrap();
 
diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs
index a0880660d05..b423fa0bda8 100644
--- a/substrate/frame/beefy/src/mock.rs
+++ b/substrate/frame/beefy/src/mock.rs
@@ -269,7 +269,7 @@ impl ExtBuilder {
 			}
 		});
 
-		pallet_session::GenesisConfig::<Test> { keys: session_keys }
+		pallet_session::GenesisConfig::<Test> { keys: session_keys, ..Default::default() }
 			.assimilate_storage(&mut t)
 			.unwrap();
 
diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
index 5c64f2a0bc2..d148c05e4d0 100644
--- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
+++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
@@ -573,6 +573,7 @@ impl ExtBuilder {
 				.into_iter()
 				.map(|(id, ..)| (id, id, SessionKeys { other: (id as u64).into() }))
 				.collect(),
+			..Default::default()
 		}
 		.assimilate_storage(&mut storage);
 
diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs
index 5ba7da7f9fd..ae230a0209a 100644
--- a/substrate/frame/grandpa/src/mock.rs
+++ b/substrate/frame/grandpa/src/mock.rs
@@ -235,7 +235,7 @@ pub fn new_test_ext_raw_authorities(authorities: AuthorityList) -> sp_io::TestEx
 
 	// NOTE: this will initialize the grandpa authorities
 	// through OneSessionHandler::on_genesis_session
-	pallet_session::GenesisConfig::<Test> { keys: session_keys }
+	pallet_session::GenesisConfig::<Test> { keys: session_keys, ..Default::default() }
 		.assimilate_storage(&mut t)
 		.unwrap();
 
diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs
index ab43b723e8a..af073d7672c 100644
--- a/substrate/frame/root-offences/src/mock.rs
+++ b/substrate/frame/root-offences/src/mock.rs
@@ -246,6 +246,7 @@ impl ExtBuilder {
 				.into_iter()
 				.map(|(id, ..)| (id, id, SessionKeys { other: id.into() }))
 				.collect(),
+			..Default::default()
 		}
 		.assimilate_storage(&mut storage);
 
diff --git a/substrate/frame/session/src/historical/mod.rs b/substrate/frame/session/src/historical/mod.rs
index fac580b49b3..a19364d577f 100644
--- a/substrate/frame/session/src/historical/mod.rs
+++ b/substrate/frame/session/src/historical/mod.rs
@@ -396,7 +396,7 @@ pub(crate) mod tests {
 				frame_system::Pallet::<Test>::inc_providers(k);
 			}
 		});
-		pallet_session::GenesisConfig::<Test> { keys }
+		pallet_session::GenesisConfig::<Test> { keys, ..Default::default() }
 			.assimilate_storage(&mut t)
 			.unwrap();
 		sp_io::TestExternalities::new(t)
diff --git a/substrate/frame/session/src/historical/offchain.rs b/substrate/frame/session/src/historical/offchain.rs
index 685a0be8e19..e9ced89a8f1 100644
--- a/substrate/frame/session/src/historical/offchain.rs
+++ b/substrate/frame/session/src/historical/offchain.rs
@@ -171,7 +171,9 @@ mod tests {
 			}
 		});
 
-		crate::GenesisConfig::<Test> { keys }.assimilate_storage(&mut t).unwrap();
+		crate::GenesisConfig::<Test> { keys, ..Default::default() }
+			.assimilate_storage(&mut t)
+			.unwrap();
 
 		let mut ext = sp_io::TestExternalities::new(t);
 
diff --git a/substrate/frame/session/src/lib.rs b/substrate/frame/session/src/lib.rs
index e1a2a31911f..325758d54dd 100644
--- a/substrate/frame/session/src/lib.rs
+++ b/substrate/frame/session/src/lib.rs
@@ -423,7 +423,14 @@ 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)>,
+		/// 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]
@@ -446,7 +453,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() {
@@ -676,7 +685,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`
diff --git a/substrate/frame/session/src/mock.rs b/substrate/frame/session/src/mock.rs
index 25b81668cc0..745b57d1be4 100644
--- a/substrate/frame/session/src/mock.rs
+++ b/substrate/frame/session/src/mock.rs
@@ -215,7 +215,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
 		// An additional identity that we use.
 		frame_system::Pallet::<Test>::inc_providers(&69);
 	});
-	pallet_session::GenesisConfig::<Test> { keys }
+	pallet_session::GenesisConfig::<Test> { keys, ..Default::default() }
 		.assimilate_storage(&mut t)
 		.unwrap();
 
diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs
index 7e6a87955b0..7cc8e865916 100644
--- a/substrate/frame/staking/src/mock.rs
+++ b/substrate/frame/staking/src/mock.rs
@@ -535,6 +535,7 @@ impl ExtBuilder {
 					.map(|id| (id, id, SessionKeys { other: id.into() }))
 					.collect()
 			},
+			..Default::default()
 		}
 		.assimilate_storage(&mut storage);
 
-- 
GitLab