mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-04 12:13:57 +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
@@ -200,28 +200,35 @@ func setupNode() (*config.Config, log.Logger, *p2p.NodeKey, error) {
|
||||
if home == "" {
|
||||
return nil, nil, nil, errors.New("TMHOME not set")
|
||||
}
|
||||
|
||||
viper.AddConfigPath(filepath.Join(home, "config"))
|
||||
viper.SetConfigName("config")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
tmcfg = config.DefaultConfig()
|
||||
err = viper.Unmarshal(tmcfg)
|
||||
if err != nil {
|
||||
|
||||
if err := viper.Unmarshal(tmcfg); err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
tmcfg.SetRoot(home)
|
||||
if err = tmcfg.ValidateBasic(); err != nil {
|
||||
|
||||
if err := tmcfg.ValidateBasic(); err != nil {
|
||||
return nil, nil, nil, fmt.Errorf("error in config file: %w", err)
|
||||
}
|
||||
|
||||
if tmcfg.LogFormat == config.LogFormatJSON {
|
||||
logger = log.NewTMJSONLogger(log.NewSyncWriter(os.Stdout))
|
||||
}
|
||||
nodeLogger, err := tmflags.ParseLogLevel(tmcfg.LogLevel, logger, config.DefaultLogLevel())
|
||||
|
||||
nodeLogger, err := tmflags.ParseLogLevel(tmcfg.LogLevel, logger, config.DefaultLogLevel)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
nodeLogger = nodeLogger.With("module", "main")
|
||||
|
||||
nodeKey, err := p2p.LoadOrGenNodeKey(tmcfg.NodeKeyFile())
|
||||
|
||||
@@ -53,14 +53,14 @@ func DoublePrevoteMisbehavior() Misbehavior {
|
||||
|
||||
// If a block is locked, prevote that.
|
||||
if cs.LockedBlock != nil {
|
||||
cs.Logger.Info("enterPrevote: Already locked on a block, prevoting locked block")
|
||||
cs.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 {
|
||||
cs.Logger.Info("enterPrevote: ProposalBlock is nil")
|
||||
cs.Logger.Debug("enterPrevote: ProposalBlock is nil")
|
||||
cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{})
|
||||
return
|
||||
}
|
||||
@@ -136,18 +136,16 @@ func defaultEnterPropose(cs *State, 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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,14 +154,14 @@ func defaultEnterPrevote(cs *State, 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
|
||||
}
|
||||
@@ -180,7 +178,7 @@ func defaultEnterPrevote(cs *State, 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())
|
||||
}
|
||||
|
||||
@@ -193,9 +191,9 @@ func defaultEnterPrecommit(cs *State, 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
|
||||
@@ -213,9 +211,9 @@ func defaultEnterPrecommit(cs *State, 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
|
||||
@@ -229,7 +227,7 @@ func defaultEnterPrecommit(cs *State, 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
|
||||
_ = cs.eventBus.PublishEventRelock(cs.RoundStateEvent())
|
||||
cs.signAddVote(tmproto.PrecommitType, blockID.Hash, blockID.PartSetHeader)
|
||||
@@ -238,7 +236,7 @@ func defaultEnterPrecommit(cs *State, 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))
|
||||
@@ -254,7 +252,7 @@ func defaultEnterPrecommit(cs *State, 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 don't have; voting nil", "blockID", blockID)
|
||||
cs.LockedRound = -1
|
||||
cs.LockedBlock = nil
|
||||
cs.LockedBlockParts = nil
|
||||
@@ -303,8 +301,11 @@ func defaultReceivePrevote(cs *State, vote *types.Vote) {
|
||||
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
|
||||
}
|
||||
@@ -394,6 +395,7 @@ func defaultReceiveProposal(cs *State, 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
|
||||
}
|
||||
|
||||
@@ -295,7 +295,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
|
||||
if b, ok := cs.misbehaviors[cs.Height]; ok {
|
||||
@@ -389,7 +389,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
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,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))
|
||||
@@ -1293,7 +1293,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:
|
||||
@@ -1378,11 +1379,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
|
||||
@@ -1414,12 +1415,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
|
||||
}
|
||||
|
||||
@@ -1455,12 +1455,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
|
||||
|
||||
@@ -1473,7 +1474,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
|
||||
|
||||
@@ -60,20 +60,25 @@ var RootCmd = &cobra.Command{
|
||||
"through a flag. See maverick node --help for how the misbehavior flag is constructured",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
fmt.Printf("use: %v, args: %v", cmd.Use, cmd.Args)
|
||||
|
||||
config, err = ParseConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if config.LogFormat == cfg.LogFormatJSON {
|
||||
logger = log.NewTMJSONLogger(log.NewSyncWriter(os.Stdout))
|
||||
}
|
||||
logger, err = tmflags.ParseLogLevel(config.LogLevel, logger, cfg.DefaultLogLevel())
|
||||
|
||||
logger, err = tmflags.ParseLogLevel(config.LogLevel, logger, cfg.DefaultLogLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if viper.GetBool(cli.TraceFlag) {
|
||||
logger = log.NewTracingLogger(logger)
|
||||
}
|
||||
|
||||
logger = logger.With("module", "main")
|
||||
return nil
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user