Skip to content

Commit

Permalink
chore: improve logs (#866)
Browse files Browse the repository at this point in the history
* chore(consensus): log peer_id on received proposal

* chore(p2p): remove some trace logs that don't bring value
  • Loading branch information
lklimek authored Aug 12, 2024
1 parent 5313b53 commit f286feb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions internal/consensus/state_add_prop_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func (c *AddProposalBlockPartAction) addProposalBlockPart(
"height", stateData.RoundState.Height,
"round", stateData.RoundState.Round,
"hash", stateData.ProposalBlock.Hash(),
"peer", peerID,
)
// We received a commit before the block
// Transit to AddCommit
Expand All @@ -180,6 +181,7 @@ func (c *AddProposalBlockPartAction) addProposalBlockPart(
"hash", stateData.ProposalBlock.Hash(),
"round_height", stateData.RoundState.GetHeight(),
"num_txs", len(stateData.ProposalBlock.Txs),
"peer", peerID,
)

c.eventPublisher.PublishCompleteProposalEvent(stateData.CompleteProposalEvent())
Expand Down
2 changes: 1 addition & 1 deletion internal/consensus/state_prevoter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newPrevote(logger log.Logger, voteSigner *voteSigner, blockExec *blockExecu
func (p *prevoter) Do(ctx context.Context, stateData *StateData) error {
err := stateData.isValidForPrevote()
if err != nil {
keyVals := append(prevoteKeyVals(stateData), "error", err)
keyVals := append(prevoteKeyVals(stateData), "err", err)

if !errors.Is(err, errPrevoteProposalBlockNil) {
p.logger.Error("prevote is invalid", keyVals...)
Expand Down
8 changes: 4 additions & 4 deletions internal/p2p/conn/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (c *MConnection) String() string {
}

func (c *MConnection) flush() {
c.logger.Trace("Flush", "conn", c)
// c.logger.Trace("Flush", "conn", c)
err := c.bufConnWriter.Flush()
if err != nil {
c.logger.Debug("MConnection flush failed", "err", err)
Expand Down Expand Up @@ -304,7 +304,7 @@ func (c *MConnection) Send(chID ChannelID, msgBytes []byte) bool {
return false
}

c.logger.Trace("Send", "channel", chID, "conn", c, "msgBytes", msgBytes)
// c.logger.Trace("Send", "channel", chID, "conn", c, "msgBytes", msgBytes)

// Send message to channel.
channel, ok := c.channelsIdx[chID]
Expand Down Expand Up @@ -557,7 +557,7 @@ FOR_LOOP:
break FOR_LOOP
}
if msgBytes != nil {
c.logger.Trace("Received bytes", "chID", channelID, "msgBytes", msgBytes)
// c.logger.Trace("Received bytes", "chID", channelID, "msgBytes", msgBytes)
// NOTE: This means the reactor.Receive runs in the same thread as the p2p recv routine
c.onReceive(ctx, channelID, msgBytes)
}
Expand Down Expand Up @@ -735,7 +735,7 @@ func (ch *channel) writePacketMsgTo(w io.Writer) (n int, err error) {
// complete, which is owned by the caller and will not be modified.
// Not goroutine-safe
func (ch *channel) recvPacketMsg(packet tmp2p.PacketMsg) ([]byte, error) {
ch.logger.Trace("Read PacketMsg", "conn", ch.conn, "packet", packet)
// ch.logger.Trace("Read PacketMsg", "conn", ch.conn, "packet", packet)
var recvCap, recvReceived = ch.desc.RecvMessageCapacity, len(ch.recving) + len(packet.Data)
if recvCap < recvReceived {
return nil, fmt.Errorf("received message exceeds available capacity: %v < %v", recvCap, recvReceived)
Expand Down

0 comments on commit f286feb

Please sign in to comment.