Skip to content

Commit

Permalink
Log proposer's address when correctly accepting a proposal (cometbft#…
Browse files Browse the repository at this point in the history
…1079)

* Log proposer when logging received proposal

* Addressed review comments

* Promote updates to validator to Info level
  • Loading branch information
sergio-mena authored Aug 7, 2023
1 parent b976685 commit cf23082
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ func (cs *State) enterNewRound(height int64, round int32) {
logger.Debug("need to set a buffer and log message here for sanity", "start_time", cs.StartTime, "now", now)
}

logger.Debug("entering new round", "current", log.NewLazySprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step))
prevHeight, prevRound, prevStep := cs.Height, cs.Round, cs.Step

// increment validators if necessary
validators := cs.Validators
Expand All @@ -1055,13 +1055,19 @@ func (cs *State) enterNewRound(height int64, round int32) {
cs.Validators = validators
// If round == 0, we've already reset these upon new height, and meanwhile
// we might have received a proposal for round 0.
propAddress := validators.GetProposer().PubKey.Address()
if round != 0 {
logger.Debug("resetting proposal info")
logger.Info("resetting proposal info", "proposer", propAddress)
cs.Proposal = nil
cs.ProposalBlock = nil
cs.ProposalBlockParts = nil
}

logger.Debug("entering new round",
"previous", log.NewLazySprintf("%v/%v/%v", prevHeight, prevRound, prevStep),
"proposer", propAddress,
)

cs.Votes.SetRound(cmtmath.SafeAddInt32(round, 1)) // also track next round (round+1) to allow round-skipping
cs.TriggeredTimeoutPrecommit = false

Expand Down Expand Up @@ -1864,7 +1870,8 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error {

p := proposal.ToProto()
// Verify signature
if !cs.Validators.GetProposer().PubKey.VerifySignature(
pubKey := cs.Validators.GetProposer().PubKey
if !pubKey.VerifySignature(
types.ProposalSignBytes(cs.state.ChainID, p), proposal.Signature,
) {
return ErrInvalidProposalSignature
Expand All @@ -1879,7 +1886,7 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error {
cs.ProposalBlockParts = types.NewPartSetFromHeader(proposal.BlockID.PartSetHeader)
}

cs.Logger.Info("received proposal", "proposal", proposal)
cs.Logger.Info("received proposal", "proposal", proposal, "proposer", pubKey.Address())
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (blockExec *BlockExecutor) ApplyBlock(
return state, err
}
if len(validatorUpdates) > 0 {
blockExec.logger.Debug("updates to validators", "updates", types.ValidatorListString(validatorUpdates))
blockExec.logger.Info("updates to validators", "updates", types.ValidatorListString(validatorUpdates))
blockExec.metrics.ValidatorSetUpdates.Add(1)
}
if abciResponse.ConsensusParamUpdates != nil {
Expand Down

0 comments on commit cf23082

Please sign in to comment.