diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index 31332b2e6..7b17e7a4b 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -812,7 +812,7 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi registry = setupChain(hc, nodeConfig, registry) if registry.GetShardChainCollection() == nil { - panic("shard chain collection is nil1111111") + panic("shard chain collection is nil") } registry.SetWebHooks(nodeConfig.WebHooks.Hooks) cxPool := core.NewCxPool(core.CxPoolSize) @@ -862,14 +862,6 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi currentNode.NodeConfig.SetClientGroupID(nodeconfig.NewClientGroupIDByShardID(shard.BeaconChainShardID)) currentNode.NodeConfig.ConsensusPriKey = nodeConfig.ConsensusPriKey - // This needs to be executed after consensus setup - if err := currentConsensus.InitConsensusWithValidators(); err != nil { - utils.Logger().Warn(). - Int("shardID", hc.General.ShardID). - Err(err). - Msg("InitConsensusWithMembers failed") - } - // Set the consensus ID to be the current block number viewID := currentNode.Blockchain().CurrentBlock().Header().ViewID().Uint64() currentConsensus.SetViewIDs(viewID + 1) diff --git a/consensus/consensus.go b/consensus/consensus.go index 20fe3f542..2bb669e3a 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -313,6 +313,11 @@ func New( initMetrics() consensus.AddPubkeyMetrics() + err := consensus.InitConsensusWithValidators() + if err != nil { + return nil, errors.WithMessage(err, "failed to init consensus with validators") + } + return &consensus, nil }