mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-24 17:04:20 +00:00
consensus: Groom Logs (#5917)
Executed a local network using simapp and looked for logs that seemed superfluous. This isn't by any means an exhaustive grooming, but should drastically help legibility of logs. ref: #5912
This commit is contained in:
committed by
Marko
parent
1030072dd0
commit
bedb00d252
+48
-45
@@ -920,7 +920,7 @@ func (cs *State) enterNewRound(height int64, round int32) {
|
||||
}
|
||||
|
||||
if now := tmtime.Now(); cs.StartTime.After(now) {
|
||||
logger.Info("Need to set a buffer and log message here for sanity.", "startTime", cs.StartTime, "now", now)
|
||||
logger.Debug("need to set a buffer and log message here for sanity", "startTime", cs.StartTime, "now", now)
|
||||
}
|
||||
|
||||
logger.Info(fmt.Sprintf("enterNewRound(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
@@ -1040,18 +1040,16 @@ func (cs *State) enterPropose(height int64, round int32) {
|
||||
}
|
||||
|
||||
if cs.isProposer(address) {
|
||||
logger.Info("enterPropose: Our turn to propose",
|
||||
"proposer",
|
||||
address,
|
||||
"privValidator",
|
||||
cs.privValidator)
|
||||
logger.Debug("enterPropose: our turn to propose",
|
||||
"proposer", address,
|
||||
"privValidator", cs.privValidator,
|
||||
)
|
||||
cs.decideProposal(height, round)
|
||||
} else {
|
||||
logger.Info("enterPropose: Not our turn to propose",
|
||||
"proposer",
|
||||
cs.Validators.GetProposer().Address,
|
||||
"privValidator",
|
||||
cs.privValidator)
|
||||
logger.Debug("enterPropose: not our turn to propose",
|
||||
"proposer", cs.Validators.GetProposer().Address,
|
||||
"privValidator", cs.privValidator,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,7 +1174,7 @@ func (cs *State) enterPrevote(height int64, round int32) {
|
||||
cs.newStep()
|
||||
}()
|
||||
|
||||
cs.Logger.Info(fmt.Sprintf("enterPrevote(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
cs.Logger.Debug(fmt.Sprintf("enterPrevote(%v/%v); current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
|
||||
// Sign and broadcast vote as necessary
|
||||
cs.doPrevote(height, round)
|
||||
@@ -1190,14 +1188,14 @@ func (cs *State) defaultDoPrevote(height int64, round int32) {
|
||||
|
||||
// If a block is locked, prevote that.
|
||||
if cs.LockedBlock != nil {
|
||||
logger.Info("enterPrevote: Already locked on a block, prevoting locked block")
|
||||
logger.Debug("enterPrevote: already locked on a block; prevoting locked block")
|
||||
cs.signAddVote(tmproto.PrevoteType, cs.LockedBlock.Hash(), cs.LockedBlockParts.Header())
|
||||
return
|
||||
}
|
||||
|
||||
// If ProposalBlock is nil, prevote nil.
|
||||
if cs.ProposalBlock == nil {
|
||||
logger.Info("enterPrevote: ProposalBlock is nil")
|
||||
logger.Debug("enterPrevote: ProposalBlock is nil")
|
||||
cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{})
|
||||
return
|
||||
}
|
||||
@@ -1214,7 +1212,7 @@ func (cs *State) defaultDoPrevote(height int64, round int32) {
|
||||
// Prevote cs.ProposalBlock
|
||||
// NOTE: the proposal signature is validated when it is received,
|
||||
// and the proposal block parts are validated as they are received (against the merkle hash in the proposal)
|
||||
logger.Info("enterPrevote: ProposalBlock is valid")
|
||||
logger.Debug("enterPrevote: ProposalBlock is valid")
|
||||
cs.signAddVote(tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockParts.Header())
|
||||
}
|
||||
|
||||
@@ -1235,7 +1233,8 @@ func (cs *State) enterPrevoteWait(height int64, round int32) {
|
||||
if !cs.Votes.Prevotes(round).HasTwoThirdsAny() {
|
||||
panic(fmt.Sprintf("enterPrevoteWait(%v/%v), but Prevotes does not have any +2/3 votes", height, round))
|
||||
}
|
||||
logger.Info(fmt.Sprintf("enterPrevoteWait(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
|
||||
logger.Debug(fmt.Sprintf("enterPrevoteWait(%v/%v); current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
|
||||
defer func() {
|
||||
// Done enterPrevoteWait:
|
||||
@@ -1267,7 +1266,7 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
||||
return
|
||||
}
|
||||
|
||||
logger.Info(fmt.Sprintf("enterPrecommit(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
logger.Debug(fmt.Sprintf("enterPrecommit(%v/%v); current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
|
||||
defer func() {
|
||||
// Done enterPrecommit:
|
||||
@@ -1281,9 +1280,9 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
||||
// If we don't have a polka, we must precommit nil.
|
||||
if !ok {
|
||||
if cs.LockedBlock != nil {
|
||||
logger.Info("enterPrecommit: No +2/3 prevotes during enterPrecommit while we're locked. Precommitting nil")
|
||||
logger.Debug("enterPrecommit: no +2/3 prevotes during enterPrecommit while we're locked. Precommitting nil")
|
||||
} else {
|
||||
logger.Info("enterPrecommit: No +2/3 prevotes during enterPrecommit. Precommitting nil.")
|
||||
logger.Debug("enterPrecommit: no +2/3 prevotes during enterPrecommit. Precommitting nil.")
|
||||
}
|
||||
cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{})
|
||||
return
|
||||
@@ -1303,9 +1302,9 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
||||
// +2/3 prevoted nil. Unlock and precommit nil.
|
||||
if len(blockID.Hash) == 0 {
|
||||
if cs.LockedBlock == nil {
|
||||
logger.Info("enterPrecommit: +2/3 prevoted for nil.")
|
||||
logger.Debug("enterPrecommit: +2/3 prevoted for nil")
|
||||
} else {
|
||||
logger.Info("enterPrecommit: +2/3 prevoted for nil. Unlocking")
|
||||
logger.Debug("enterPrecommit: +2/3 prevoted for nil; unlocking")
|
||||
cs.LockedRound = -1
|
||||
cs.LockedBlock = nil
|
||||
cs.LockedBlockParts = nil
|
||||
@@ -1321,7 +1320,7 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
||||
|
||||
// If we're already locked on that block, precommit it, and update the LockedRound
|
||||
if cs.LockedBlock.HashesTo(blockID.Hash) {
|
||||
logger.Info("enterPrecommit: +2/3 prevoted locked block. Relocking")
|
||||
logger.Debug("enterPrecommit: +2/3 prevoted locked block; relocking")
|
||||
cs.LockedRound = round
|
||||
if err := cs.eventBus.PublishEventRelock(cs.RoundStateEvent()); err != nil {
|
||||
cs.Logger.Error("Error publishing event relock", "err", err)
|
||||
@@ -1332,7 +1331,7 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
||||
|
||||
// If +2/3 prevoted for proposal block, stage and precommit it
|
||||
if cs.ProposalBlock.HashesTo(blockID.Hash) {
|
||||
logger.Info("enterPrecommit: +2/3 prevoted proposal block. Locking", "hash", blockID.Hash)
|
||||
logger.Debug("enterPrecommit: +2/3 prevoted proposal block; locking", "hash", blockID.Hash)
|
||||
// Validate the block.
|
||||
if err := cs.blockExec.ValidateBlock(cs.state, cs.ProposalBlock); err != nil {
|
||||
panic(fmt.Sprintf("enterPrecommit: +2/3 prevoted for an invalid block: %v", err))
|
||||
@@ -1350,7 +1349,7 @@ func (cs *State) enterPrecommit(height int64, round int32) {
|
||||
// There was a polka in this round for a block we don't have.
|
||||
// Fetch that block, unlock, and precommit nil.
|
||||
// The +2/3 prevotes for this round is the POL for our unlock.
|
||||
logger.Info("enterPrecommit: +2/3 prevotes for a block we don't have. Voting nil", "blockID", blockID)
|
||||
logger.Debug("enterPrecommit: +2/3 prevotes for a block we do not have; voting nil", "blockID", blockID)
|
||||
cs.LockedRound = -1
|
||||
cs.LockedBlock = nil
|
||||
cs.LockedBlockParts = nil
|
||||
@@ -1379,7 +1378,7 @@ func (cs *State) enterPrecommitWait(height int64, round int32) {
|
||||
if !cs.Votes.Precommits(round).HasTwoThirdsAny() {
|
||||
panic(fmt.Sprintf("enterPrecommitWait(%v/%v), but Precommits does not have any +2/3 votes", height, round))
|
||||
}
|
||||
logger.Info(fmt.Sprintf("enterPrecommitWait(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
logger.Debug(fmt.Sprintf("enterPrecommitWait(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
|
||||
defer func() {
|
||||
// Done enterPrecommitWait:
|
||||
@@ -1428,7 +1427,7 @@ func (cs *State) enterCommit(height int64, commitRound int32) {
|
||||
// Move them over to ProposalBlock if they match the commit hash,
|
||||
// otherwise they'll be cleared in updateToState.
|
||||
if cs.LockedBlock.HashesTo(blockID.Hash) {
|
||||
logger.Info("Commit is for locked block. Set ProposalBlock=LockedBlock", "blockHash", blockID.Hash)
|
||||
logger.Debug("commit is for a locked block; set ProposalBlock=LockedBlock", "blockHash", blockID.Hash)
|
||||
cs.ProposalBlock = cs.LockedBlock
|
||||
cs.ProposalBlockParts = cs.LockedBlockParts
|
||||
}
|
||||
@@ -1437,11 +1436,11 @@ func (cs *State) enterCommit(height int64, commitRound int32) {
|
||||
if !cs.ProposalBlock.HashesTo(blockID.Hash) {
|
||||
if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) {
|
||||
logger.Info(
|
||||
"Commit is for a block we don't know about. Set ProposalBlock=nil",
|
||||
"proposal",
|
||||
cs.ProposalBlock.Hash(),
|
||||
"commit",
|
||||
blockID.Hash)
|
||||
"commit is for a block we do not know about; set ProposalBlock=nil",
|
||||
"proposal", cs.ProposalBlock.Hash(),
|
||||
"commit", blockID.Hash,
|
||||
)
|
||||
|
||||
// We're getting the wrong block.
|
||||
// Set up ProposalBlockParts and keep waiting.
|
||||
cs.ProposalBlock = nil
|
||||
@@ -1473,12 +1472,11 @@ func (cs *State) tryFinalizeCommit(height int64) {
|
||||
if !cs.ProposalBlock.HashesTo(blockID.Hash) {
|
||||
// TODO: this happens every time if we're not a validator (ugly logs)
|
||||
// TODO: ^^ wait, why does it matter that we're a validator?
|
||||
logger.Info(
|
||||
"Attempt to finalize failed. We don't have the commit block.",
|
||||
"proposal-block",
|
||||
cs.ProposalBlock.Hash(),
|
||||
"commit-block",
|
||||
blockID.Hash)
|
||||
logger.Debug(
|
||||
"attempt to finalize failed; we do not have the commit block",
|
||||
"proposal-block", cs.ProposalBlock.Hash(),
|
||||
"commit-block", blockID.Hash,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1514,12 +1512,13 @@ func (cs *State) finalizeCommit(height int64) {
|
||||
panic(fmt.Errorf("+2/3 committed an invalid block: %w", err))
|
||||
}
|
||||
|
||||
cs.Logger.Info("Finalizing commit of block with N txs",
|
||||
cs.Logger.Info("finalizing commit of block with N txs",
|
||||
"height", block.Height,
|
||||
"hash", block.Hash(),
|
||||
"root", block.AppHash,
|
||||
"N", len(block.Txs))
|
||||
cs.Logger.Info(fmt.Sprintf("%v", block))
|
||||
"N", len(block.Txs),
|
||||
)
|
||||
cs.Logger.Debug(fmt.Sprintf("%v", block))
|
||||
|
||||
fail.Fail() // XXX
|
||||
|
||||
@@ -1532,7 +1531,7 @@ func (cs *State) finalizeCommit(height int64) {
|
||||
cs.blockStore.SaveBlock(block, blockParts, seenCommit)
|
||||
} else {
|
||||
// Happens during replay if we already saved the block but didn't commit
|
||||
cs.Logger.Info("Calling finalizeCommit on already stored block", "height", block.Height)
|
||||
cs.Logger.Debug("calling finalizeCommit on already stored block", "height", block.Height)
|
||||
}
|
||||
|
||||
fail.Fail() // XXX
|
||||
@@ -1749,7 +1748,8 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error {
|
||||
if cs.ProposalBlockParts == nil {
|
||||
cs.ProposalBlockParts = types.NewPartSetFromHeader(proposal.BlockID.PartSetHeader)
|
||||
}
|
||||
cs.Logger.Info("Received proposal", "proposal", proposal)
|
||||
|
||||
cs.Logger.Info("received proposal", "proposal", proposal)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1935,7 +1935,7 @@ func (cs *State) addVote(
|
||||
// Height mismatch is ignored.
|
||||
// Not necessarily a bad peer, but not favourable behaviour.
|
||||
if vote.Height != cs.Height {
|
||||
cs.Logger.Info("Vote ignored and not added", "voteHeight", vote.Height, "csHeight", cs.Height, "peerID", peerID)
|
||||
cs.Logger.Debug("vote ignored and not added", "voteHeight", vote.Height, "csHeight", cs.Height, "peerID", peerID)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1991,8 +1991,11 @@ func (cs *State) addVote(
|
||||
cs.ValidBlockParts = cs.ProposalBlockParts
|
||||
} else {
|
||||
cs.Logger.Info(
|
||||
"Valid block we don't know about. Set ProposalBlock=nil",
|
||||
"proposal", cs.ProposalBlock.Hash(), "blockID", blockID.Hash)
|
||||
"valid block we do not know about; set ProposalBlock=nil",
|
||||
"proposal", cs.ProposalBlock.Hash(),
|
||||
"blockID", blockID.Hash,
|
||||
)
|
||||
|
||||
// We're getting the wrong block.
|
||||
cs.ProposalBlock = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user