From b4f79c0b14e7cb73e499e292096db950ef7364a3 Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Tue, 29 Jul 2025 07:04:00 +0700 Subject: [PATCH] improve logs --- consensus/XDPoS/engines/engine_v2/timeout.go | 2 +- consensus/XDPoS/engines/engine_v2/vote.go | 2 ++ eth/bft/bft_handler.go | 15 ++++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/consensus/XDPoS/engines/engine_v2/timeout.go b/consensus/XDPoS/engines/engine_v2/timeout.go index 51bc211777..2a28e4e22d 100644 --- a/consensus/XDPoS/engines/engine_v2/timeout.go +++ b/consensus/XDPoS/engines/engine_v2/timeout.go @@ -324,8 +324,8 @@ func (x *XDPoS_v2) OnCountdownTimeout(time time.Time, chain interface{}) error { x.timeoutCount++ if x.timeoutCount%x.config.V2.CurrentConfig.TimeoutSyncThreshold == 0 { - log.Warn("[OnCountdownTimeout] timeout sync threadhold reached, send syncInfo message") syncInfo := x.getSyncInfo() + log.Info("[OnCountdownTimeout] Timeout sync threshold reached, send syncInfo message", "QC round", syncInfo.HighestQuorumCert.ProposedBlockInfo.Round, "QC num", syncInfo.HighestQuorumCert.ProposedBlockInfo.Number, "QC sigs", len(syncInfo.HighestQuorumCert.Signatures), "TC round", syncInfo.HighestTimeoutCert.Round, "TC sigs", len(syncInfo.HighestTimeoutCert.Signatures)) x.broadcastToBftChannel(syncInfo) } diff --git a/consensus/XDPoS/engines/engine_v2/vote.go b/consensus/XDPoS/engines/engine_v2/vote.go index 2715d861c5..181c680ae7 100644 --- a/consensus/XDPoS/engines/engine_v2/vote.go +++ b/consensus/XDPoS/engines/engine_v2/vote.go @@ -110,7 +110,9 @@ func (x *XDPoS_v2) voteHandler(chain consensus.ChainReader, voteMsg *types.Vote) // Collect vote numberOfVotesInPool, pooledVotes := x.votePool.Add(voteMsg) + log.Trace("[voteHandler] New vote", "signer", voteMsg.GetSigner().Hex(), "proposedBlockInfoRound", voteMsg.ProposedBlockInfo.Round, "proposedBlockInfoNumber", voteMsg.ProposedBlockInfo.Number.Uint64(), "proposedBlockInfoHash", voteMsg.ProposedBlockInfo.Hash.Hex()) log.Debug("[voteHandler] collect votes", "number", numberOfVotesInPool) + go x.ForensicsProcessor.DetectEquivocationInVotePool(voteMsg, x.votePool) go x.ForensicsProcessor.ProcessVoteEquivocation(chain, x, voteMsg) diff --git a/eth/bft/bft_handler.go b/eth/bft/bft_handler.go index ae3d190cac..788a2981ac 100644 --- a/eth/bft/bft_handler.go +++ b/eth/bft/bft_handler.go @@ -78,7 +78,7 @@ func (b *Bfter) SetConsensusFuns(engine consensus.Engine) { } func (b *Bfter) Vote(peer string, vote *types.Vote) error { - log.Trace("[Vote] Receive Vote", "hash", vote.Hash().Hex(), "voted block hash", vote.ProposedBlockInfo.Hash.Hex(), "number", vote.ProposedBlockInfo.Number, "round", vote.ProposedBlockInfo.Round) + log.Trace("[Vote] Received Vote", "hash", vote.Hash().Hex(), "voted block hash", vote.ProposedBlockInfo.Hash.Hex(), "number", vote.ProposedBlockInfo.Number, "round", vote.ProposedBlockInfo.Round) voteBlockNum := vote.ProposedBlockInfo.Number.Int64() if dist := voteBlockNum - int64(b.chainHeight()); dist < -maxBlockDist || dist > maxBlockDist { @@ -126,7 +126,7 @@ func (b *Bfter) Timeout(peer string, timeout *types.Timeout) error { log.Error("[Timeout] Verify BFT Timeout", "timeoutRound", timeout.Round, "timeoutGapNum", gapNum, "error", err) return err } - log.Debug("[Timeout] Receive Timeout", "gap", gapNum, "hash", timeout.Hash().Hex(), "round", timeout.Round, "signer", timeout.GetSigner().Hex()) //get signer after verifyTimeout + log.Debug("[Timeout] Received Timeout", "gap", gapNum, "hash", timeout.Hash().Hex(), "round", timeout.Round, "signer", timeout.GetSigner().Hex()) //get signer after verifyTimeout if verified { b.broadcastCh <- timeout @@ -144,16 +144,21 @@ func (b *Bfter) Timeout(peer string, timeout *types.Timeout) error { return nil } func (b *Bfter) SyncInfo(peer string, syncInfo *types.SyncInfo) error { - log.Debug("[SyncInfo] Receive SyncInfo") - if syncInfo == nil || syncInfo.HighestQuorumCert == nil { log.Warn("[SyncInfo] Received nil SyncInfo or missing QC", "syncInfo", syncInfo) return nil } + log.Debug("[SyncInfo] Received SyncInfo", "syncInfo", syncInfo, "syncInfoHash", syncInfo.Hash().Hex()) + if syncInfo.HighestQuorumCert != nil { + log.Debug("[SyncInfo] Received SyncInfo", "qcRound", syncInfo.HighestQuorumCert.ProposedBlockInfo.Round, "qcBlocknum", syncInfo.HighestQuorumCert.ProposedBlockInfo.Number, "qcBlockhash", syncInfo.HighestQuorumCert.ProposedBlockInfo.Hash.Hex()) + } + if syncInfo.HighestTimeoutCert != nil { + log.Debug("[SyncInfo] Received SyncInfo", "tcRound", syncInfo.HighestTimeoutCert.Round) + } qcBlockNum := syncInfo.HighestQuorumCert.ProposedBlockInfo.Number.Int64() if dist := qcBlockNum - int64(b.chainHeight()); dist < -maxBlockDist || dist > maxBlockDist { - log.Debug("[SyncInfo] Discarded propagated syncInfo, too far away", "peer", peer, "blockNum", syncInfo.HighestQuorumCert.ProposedBlockInfo.Number, "hash", syncInfo.Hash, "qcRound", syncInfo.HighestQuorumCert.ProposedBlockInfo.Round, "distance", dist) + log.Debug("[SyncInfo] Discarded propagated syncInfo, too far away", "peer", peer, "distance", dist, "hash", syncInfo.Hash().Hex()) return nil }