Skip to content

Commit

Permalink
fix it (#13325)
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas authored Dec 13, 2023
1 parent 381116a commit 8aaab86
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions beacon-chain/sync/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"reflect"
"runtime/debug"
"strings"

libp2pcore "github.com/libp2p/go-libp2p/core"
"github.com/libp2p/go-libp2p/core/network"
Expand Down Expand Up @@ -206,7 +207,7 @@ func (s *Service) registerRPC(baseTopic string, handle rpcHandler) {
return
}
if err := s.cfg.p2p.Encoding().DecodeWithMaxLength(stream, msg); err != nil {
log.WithError(err).WithField("topic", topic).Debug("Could not decode stream message")
logStreamErrors(err, topic)
tracing.AnnotateError(span, err)
s.cfg.p2p.Peers().Scorers().BadResponsesScorer().Increment(stream.Conn().RemotePeer())
return
Expand All @@ -226,7 +227,7 @@ func (s *Service) registerRPC(baseTopic string, handle rpcHandler) {
return
}
if err := s.cfg.p2p.Encoding().DecodeWithMaxLength(stream, msg); err != nil {
log.WithError(err).WithField("topic", topic).Debug("Could not decode stream message")
logStreamErrors(err, topic)
tracing.AnnotateError(span, err)
s.cfg.p2p.Peers().Scorers().BadResponsesScorer().Increment(stream.Conn().RemotePeer())
return
Expand All @@ -241,3 +242,11 @@ func (s *Service) registerRPC(baseTopic string, handle rpcHandler) {
}
})
}

func logStreamErrors(err error, topic string) {
if strings.Contains(topic, p2p.RPCGoodByeTopicV1) {
log.WithError(err).WithField("topic", topic).Trace("Could not decode goodbye stream message")
return
}
log.WithError(err).WithField("topic", topic).Debug("Could not decode stream message")
}

0 comments on commit 8aaab86

Please sign in to comment.