Skip to content

Commit

Permalink
Improve log (ethereum#368)
Browse files Browse the repository at this point in the history
* improve log
  • Loading branch information
liam-lai authored Nov 26, 2023
1 parent 9268994 commit b4bd070
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
16 changes: 14 additions & 2 deletions consensus/XDPoS/engines/engine_v1/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,16 @@ func (x *XDPoS_v1) checkSignersOnCheckpoint(chain consensus.ChainReader, header
validSigners := utils.CompareSignersLists(masternodesFromCheckpointHeader, signers)

if !validSigners {
log.Error("Masternodes lists are different in checkpoint header and snapshot", "number", number, "masternodes_from_checkpoint_header", masternodesFromCheckpointHeader, "masternodes_in_snapshot", signers, "penList", penPenalties)
log.Error("Masternodes lists are different in checkpoint header and snapshot", "number", number)
for i, v := range masternodesFromCheckpointHeader {
log.Error("masternodes_from_checkpoint_header", "i", i, "addr", v.Hex())
}
for i, v := range signers {
log.Error("masternodes_in_snapshot", "i", i, "addr", v.Hex())
}
for i, v := range penPenalties {
log.Error("penPenalties", "i", i, "addr", v.Hex())
}
return utils.ErrInvalidCheckpointSigners
}
if x.HookVerifyMNs != nil {
Expand Down Expand Up @@ -816,7 +825,10 @@ func (x *XDPoS_v1) UpdateMasternodes(chain consensus.ChainReader, header *types.
nm = append(nm, n.Address.String())
}
x.recents.Add(snap.Hash, snap)
log.Info("New set of masternodes has been updated to snapshot", "number", snap.Number, "hash", snap.Hash, "new masternodes", nm)
log.Info("New set of masternodes has been updated to snapshot", "number", snap.Number, "hash", snap.Hash)
for i, v := range nm {
log.Info("masternodes", "i", i, "addr", v)
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/XDPoS/engines/engine_v2/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (x *XDPoS_v2) voteHandler(chain consensus.ChainReader, voteMsg *types.Vote)
// Check if the block already exist, otherwise we try luck with the next vote
proposedBlockHeader := chain.GetHeaderByHash(voteMsg.ProposedBlockInfo.Hash)
if proposedBlockHeader == nil {
log.Warn("[voteHandler] The proposed block from vote message does not exist yet, wait for the next vote to try again", "blockNum", voteMsg.ProposedBlockInfo.Number, "Hash", voteMsg.ProposedBlockInfo.Hash, "Round", voteMsg.ProposedBlockInfo.Round)
log.Info("[voteHandler] The proposed block from vote message does not exist yet, wait for the next vote to try again", "blockNum", voteMsg.ProposedBlockInfo.Number, "Hash", voteMsg.ProposedBlockInfo.Hash, "Round", voteMsg.ProposedBlockInfo.Round)
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (pm *ProtocolManager) removePeer(id string) {
// Unregister the peer from the downloader and Ethereum peer set
pm.downloader.UnregisterPeer(id)
if err := pm.peers.Unregister(id); err != nil {
log.Warn("Peer removal failed", "peer", id, "err", err)
log.Debug("Peer removal failed", "peer", id, "err", err)
}
// Hard disconnect at the networking layer
if peer != nil {
Expand Down Expand Up @@ -962,7 +962,7 @@ func (pm *ProtocolManager) BroadcastVote(vote *types.Vote) {
for _, peer := range peers {
err := peer.SendVote(vote)
if err != nil {
log.Error("[BroadcastVote] Fail to broadcast vote message", "peerId", peer.id, "version", peer.version, "blockNum", vote.ProposedBlockInfo.Number, "err", err)
log.Debug("[BroadcastVote] Fail to broadcast vote message", "peerId", peer.id, "version", peer.version, "blockNum", vote.ProposedBlockInfo.Number, "err", err)
pm.removePeer(peer.id)
}
}
Expand All @@ -979,7 +979,7 @@ func (pm *ProtocolManager) BroadcastTimeout(timeout *types.Timeout) {
for _, peer := range peers {
err := peer.SendTimeout(timeout)
if err != nil {
log.Error("[BroadcastTimeout] Fail to broadcast timeout message, remove peer", "peerId", peer.id, "version", peer.version, "timeout", timeout, "err", err)
log.Debug("[BroadcastTimeout] Fail to broadcast timeout message, remove peer", "peerId", peer.id, "version", peer.version, "timeout", timeout, "err", err)
pm.removePeer(peer.id)
}
}
Expand All @@ -996,7 +996,7 @@ func (pm *ProtocolManager) BroadcastSyncInfo(syncInfo *types.SyncInfo) {
for _, peer := range peers {
err := peer.SendSyncInfo(syncInfo)
if err != nil {
log.Error("[BroadcastSyncInfo] Fail to broadcast syncInfo message, remove peer", "peerId", peer.id, "version", peer.version, "syncInfo", syncInfo, "err", err)
log.Debug("[BroadcastSyncInfo] Fail to broadcast syncInfo message, remove peer", "peerId", peer.id, "version", peer.version, "syncInfo", syncInfo, "err", err)
pm.removePeer(peer.id)
}
}
Expand Down

0 comments on commit b4bd070

Please sign in to comment.