From 2f64717bb5ae3108ed938648291ba577e70fa8c6 Mon Sep 17 00:00:00 2001 From: Leo Wang Date: Fri, 7 Dec 2018 16:30:58 +0800 Subject: [PATCH] return an error if validator set is empty in genesis file and after InitChain (#2971) Fixes #2951 --- consensus/replay.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/consensus/replay.go b/consensus/replay.go index c9a779e34..ba118e660 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -303,7 +303,13 @@ func (h *Handshaker) ReplayBlocks( } state.Validators = types.NewValidatorSet(vals) state.NextValidators = types.NewValidatorSet(vals) + } else { + // If validator set is not set in genesis and still empty after InitChain, exit. + if len(h.genDoc.Validators) == 0 { + return nil, fmt.Errorf("Validator set is nil in genesis and still empty after InitChain") + } } + if res.ConsensusParams != nil { state.ConsensusParams = types.PB2TM.ConsensusParams(res.ConsensusParams) }