diff --git a/consensus/state.go b/consensus/state.go index 780fc3af5..146344437 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -2128,7 +2128,12 @@ func (cs *State) addVote(vote *types.Vote, peerID p2p.NodeID) (added bool, err e case tmproto.PrecommitType: precommits := cs.Votes.Precommits(vote.Round) - cs.Logger.Debug("added vote to precommit", "vote", vote, "precommits", precommits.StringShort()) + cs.Logger.Debug("added vote to precommit", + "height", vote.Height, + "round", vote.Round, + "validator", vote.ValidatorAddress.String(), + "vote_timestamp", vote.Timestamp, + "data", precommits.LogString()) blockID, ok := precommits.TwoThirdsMajority() if ok { diff --git a/types/block.go b/types/block.go index dae8830b7..7716fda16 100644 --- a/types/block.go +++ b/types/block.go @@ -1189,7 +1189,7 @@ func (blockID BlockID) Key() string { panic(err) } - return string(blockID.Hash) + string(bz) + return fmt.Sprint(string(blockID.Hash), string(bz)) } // ValidateBasic performs basic validation. diff --git a/types/vote_set.go b/types/vote_set.go index 4449612e1..3e023a735 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -442,12 +442,14 @@ func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool) { //-------------------------------------------------------------------------------- // Strings and JSON +const nilVoteSetString = "nil-VoteSet" + // String returns a string representation of VoteSet. // // See StringIndented. func (voteSet *VoteSet) String() string { if voteSet == nil { - return "nil-VoteSet" + return nilVoteSetString } return voteSet.StringIndented("") } @@ -551,7 +553,7 @@ func (voteSet *VoteSet) voteStrings() []string { // 7. 2/3+ majority for each peer func (voteSet *VoteSet) StringShort() string { if voteSet == nil { - return "nil-VoteSet" + return nilVoteSetString } voteSet.mtx.Lock() defer voteSet.mtx.Unlock() @@ -560,6 +562,19 @@ func (voteSet *VoteSet) StringShort() string { voteSet.height, voteSet.round, voteSet.signedMsgType, voteSet.maj23, frac, voteSet.votesBitArray, voteSet.peerMaj23s) } +// LogString produces a logging suitable string representation of the +// vote set. +func (voteSet *VoteSet) LogString() string { + if voteSet == nil { + return nilVoteSetString + } + voteSet.mtx.Lock() + defer voteSet.mtx.Unlock() + voted, total, frac := voteSet.sumTotalFrac() + + return fmt.Sprintf("Votes:%d/%d(%.3f)", voted, total, frac) +} + // return the power voted, the total, and the fraction func (voteSet *VoteSet) sumTotalFrac() (int64, int64, float64) { voted, total := voteSet.sum, voteSet.valSet.TotalVotingPower()