Skip to content

Commit

Permalink
Less Noisy P2P Logs (#5607)
Browse files Browse the repository at this point in the history
* fix logging issues
* change again
* fix errors
* Merge refs/heads/master into lessNoisy
* gaz
* Merge branch 'lessNoisy' of https://github.com/prysmaticlabs/geth-sharding into lessNoisy
  • Loading branch information
nisdas authored Apr 24, 2020
1 parent 9212638 commit f9eb546
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion beacon-chain/p2p/encoder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ go_library(
"@com_github_golang_snappy//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)

Expand Down
12 changes: 5 additions & 7 deletions beacon-chain/p2p/encoder/ssz.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
errors "github.com/pkg/errors"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/sirupsen/logrus"
)

var _ = NetworkEncoding(&SszNetworkEncoder{})
Expand Down Expand Up @@ -192,10 +191,9 @@ func (e SszNetworkEncoder) MaxLength(length int) int {
// Writes a bytes value through a snappy buffered writer.
func writeSnappyBuffer(w io.Writer, b []byte) (int, error) {
bufWriter := snappy.NewBufferedWriter(w)
defer func() {
if err := bufWriter.Close(); err != nil {
logrus.WithError(err).Error("Failed to close snappy buffered writer")
}
}()
return bufWriter.Write(b)
num, err := bufWriter.Write(b)
if err != nil {
return 0, err
}
return num, bufWriter.Close()
}
2 changes: 1 addition & 1 deletion beacon-chain/p2p/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer
go func() {
log.WithField("reason", "at peer limit").Trace("Ignoring connection request")
if err := goodbyeFunc(context.Background(), conn.RemotePeer()); err != nil {
log.WithError(err).Error("Unable to send goodbye message to peer")
log.WithError(err).Trace("Unable to send goodbye message to peer")
}
if err := s.Disconnect(conn.RemotePeer()); err != nil {
log.WithError(err).Error("Unable to disconnect from peer")
Expand Down
6 changes: 6 additions & 0 deletions beacon-chain/sync/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ func (r *Service) registerRPC(topic string, base interface{}, handle rpcHandler)
if t.Kind() == reflect.Ptr {
msg := reflect.New(t.Elem())
if err := r.p2p.Encoding().DecodeWithLength(stream, msg.Interface()); err != nil {
// Debug logs for goodbye/status errors
if strings.Contains(topic, p2p.RPCGoodByeTopic) || strings.Contains(topic, p2p.RPCStatusTopic) {
log.WithError(err).Debug("Failed to decode goodbye stream message")
traceutil.AnnotateError(span, err)
return
}
log.WithError(err).Warn("Failed to decode stream message")
traceutil.AnnotateError(span, err)
return
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/sync/rpc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (r *Service) maintainPeerStatuses() {
}
if roughtime.Now().After(lastUpdated.Add(interval)) {
if err := r.reValidatePeer(r.ctx, id); err != nil {
log.WithField("peer", id).WithError(err).Error("Failed to reValidate peer")
log.WithField("peer", id).WithError(err).Error("Failed to revalidate peer")
}
}
}(pid)
Expand Down

0 comments on commit f9eb546

Please sign in to comment.