[log] add additional logs in consensus

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3520/head
Leo Chen 4 years ago
parent 8946054f7d
commit c1fbc64cef
  1. 12
      consensus/config.go
  2. 11
      consensus/consensus_service.go
  3. 4
      node/node.go

@ -33,6 +33,18 @@ const (
timeoutBootstrap
)
func (t TimeoutType) String() string {
switch t {
case timeoutConsensus:
return "timeoutConsensus"
case timeoutViewChange:
return "timeoutViewChange"
case timeoutBootstrap:
return "timeoutBootstrap"
}
return "unknown"
}
var (
// NIL is the m2 type message, which suppose to be nil/empty, however
// we cannot sign on empty message, instead we sign on some default "nil" message

@ -298,6 +298,10 @@ func (consensus *Consensus) UpdateConsensusInformation() Mode {
if curHeader.IsLastBlockInEpoch() {
nextShardState, err := curHeader.GetShardState()
if err != nil {
consensus.getLogger().Error().
Err(err).
Uint32("shard", consensus.ShardID).
Msg("[UpdateConsensusInformation] Error retrieving current shard state in the first block")
return Syncing
}
if nextShardState.Epoch != nil {
@ -439,6 +443,10 @@ func (consensus *Consensus) UpdateConsensusInformation() Mode {
myPubKeys := consensus.GetPublicKeys()
if myPubKeys.Contains(key.Object) {
if hasError {
consensus.getLogger().Error().
Str("myKey", myPubKeys.SerializeToHexStr()).
Msg("[UpdateConsensusInformation] hasError")
return Syncing
}
@ -455,6 +463,9 @@ func (consensus *Consensus) UpdateConsensusInformation() Mode {
return Normal
}
}
consensus.getLogger().Info().
Msg("[UpdateConsensusInformation] not in committee, Listening")
// not in committee
return Listening
}

@ -1050,6 +1050,9 @@ func (node *Node) InitConsensusWithValidators() (err error) {
}
subComm, err := shardState.FindCommitteeByID(shardID)
if err != nil {
utils.Logger().Err(err).
Interface("shardState", shardState).
Msg("[InitConsensusWithValidators] Find CommitteeByID")
return err
}
pubKeys, err := subComm.BLSPublicKeys()
@ -1069,6 +1072,7 @@ func (node *Node) InitConsensusWithValidators() (err error) {
utils.Logger().Info().
Uint64("blockNum", blockNum).
Int("numPubKeys", len(pubKeys)).
Str("mode", node.Consensus.Mode().String()).
Msg("[InitConsensusWithValidators] Successfully updated public keys")
node.Consensus.UpdatePublicKeys(pubKeys)
node.Consensus.SetMode(consensus.Normal)

Loading…
Cancel
Save