diff --git a/mod/consensus/pkg/cometbft/service/abci.go b/mod/consensus/pkg/cometbft/service/abci.go index 5b4c1fb9b4..89609bb48f 100644 --- a/mod/consensus/pkg/cometbft/service/abci.go +++ b/mod/consensus/pkg/cometbft/service/abci.go @@ -112,34 +112,31 @@ func (s *Service[LoggerT]) InitChain( } // check validators - if len(resValidators) == 0 { - return nil, errors.New( - "application init chain handler returned no validators", - ) - } - if len(req.Validators) != len(resValidators) { - return nil, fmt.Errorf( - "len(RequestInitChain.Validators) != len(GenesisValidators) (%d != %d)", - len(req.Validators), - len(resValidators), - ) - } - - sort.Sort(cmtabci.ValidatorUpdates(req.Validators)) - - for i := range resValidators { - if req.Validators[i].Power != resValidators[i].Power { - return nil, errors.New("mismatched power") - } - if !bytes.Equal( - req.Validators[i].PubKeyBytes, resValidators[i]. - PubKeyBytes) { - return nil, errors.New("mismatched pubkey bytes") + if len(req.Validators) > 0 { + if len(req.Validators) != len(resValidators) { + return nil, fmt.Errorf( + "len(RequestInitChain.Validators) != len(GenesisValidators) (%d != %d)", + len(req.Validators), + len(resValidators), + ) } - if req.Validators[i].PubKeyType != - resValidators[i].PubKeyType { - return nil, errors.New("mismatched pubkey types") + sort.Sort(cmtabci.ValidatorUpdates(req.Validators)) + + for i := range resValidators { + if req.Validators[i].Power != resValidators[i].Power { + return nil, errors.New("mismatched power") + } + if !bytes.Equal( + req.Validators[i].PubKeyBytes, resValidators[i]. + PubKeyBytes) { + return nil, errors.New("mismatched pubkey bytes") + } + + if req.Validators[i].PubKeyType != + resValidators[i].PubKeyType { + return nil, errors.New("mismatched pubkey types") + } } }