Check that validator set is not empty at genesis (#3083)

* Check that the returned validator set is not empty

* Move assert to session module

* Clean up
This commit is contained in:
Bastian Köcher
2019-07-10 14:38:07 +02:00
committed by Gavin Wood
parent df93867620
commit 0366f7b35c
3 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -411,8 +411,8 @@ construct_runtime!(
Authorship: authorship::{Module, Call, Storage},
Indices: indices,
Balances: balances,
Session: session::{Module, Call, Storage, Event, Config<T>},
Staking: staking::{default, OfflineWorker},
Session: session::{Module, Call, Storage, Event, Config<T>},
Democracy: democracy::{Module, Call, Storage, Config, Event<T>},
Council: collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
TechnicalCommittee: collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
+2
View File
@@ -316,6 +316,8 @@ decl_storage! {
let initial_validators = T::SelectInitialValidators::select_initial_validators()
.unwrap_or_else(|| config.keys.iter().map(|(ref v, _)| v.clone()).collect());
assert!(!initial_validators.is_empty(), "Empty validator set in genesis block!");
let queued_keys: Vec<_> = initial_validators
.iter()
.cloned()
+4 -1
View File
@@ -599,7 +599,10 @@ decl_storage! {
| {
with_storage(storage, || {
for &(ref stash, ref controller, balance, ref status) in &config.stakers {
assert!(T::Currency::free_balance(&stash) >= balance);
assert!(
T::Currency::free_balance(&stash) >= balance,
"Stash does not have enough balance to bond."
);
let _ = <Module<T>>::bond(
T::Origin::from(Some(stash.clone()).into()),
T::Lookup::unlookup(controller.clone()),