Clean Up Metadata logs (#7109)

* clean errors

* cleaner

* gazelle

* go check

* Update beacon-chain/sync/error.go

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
This commit is contained in:
Nishant Das 2020-08-26 17:59:16 +08:00 committed by GitHub
parent 900e7114da
commit 8a8edf3743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View File

@ -5,6 +5,8 @@ import (
"errors"
libp2pcore "github.com/libp2p/go-libp2p-core"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/mux"
"github.com/libp2p/go-libp2p-core/network"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
@ -16,6 +18,7 @@ const genericError = "internal service error"
const rateLimitedError = "rate limited"
const stepError = "invalid range or step"
const seqError = "invalid sequence number provided"
const deadlineError = "i/o deadline exceeded"
var errWrongForkDigestVersion = errors.New("wrong fork digest version")
var errInvalidEpoch = errors.New("invalid epoch")
@ -102,3 +105,8 @@ func readStatusCodeNoDeadline(stream network.Stream, encoding encoder.NetworkEnc
return b[0], string(msg.Message), nil
}
// only returns true for errors that are valid (no resets or expectedEOF errors).
func isValidStreamError(err error) bool {
return err != nil && !errors.Is(err, mux.ErrReset) && !errors.Is(err, helpers.ErrExpectedEOF)
}

View File

@ -5,7 +5,6 @@ import (
libp2pcore "github.com/libp2p/go-libp2p-core"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/mux"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
@ -47,7 +46,7 @@ func (s *Service) sendMetaDataRequest(ctx context.Context, id peer.ID) (*pb.Meta
// metadata requests send no payload, so closing the
// stream early leads it to a reset.
defer func() {
if err := helpers.FullClose(stream); err != nil && err.Error() != mux.ErrReset.Error() {
if err := helpers.FullClose(stream); isValidStreamError(err) {
log.WithError(err).Debugf("Failed to reset stream for protocol %s", stream.Protocol())
}
}()

View File

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"
libp2pcore "github.com/libp2p/go-libp2p-core"
"github.com/libp2p/go-libp2p-core/helpers"
@ -73,7 +74,9 @@ func (s *Service) pingHandler(ctx context.Context, msg interface{}, stream libp2
defer cancel()
md, err := s.sendMetaDataRequest(ctx, stream.Conn().RemotePeer())
if err != nil {
log.WithField("peer", stream.Conn().RemotePeer()).WithError(err).Debug("Failed to send metadata request")
if !strings.Contains(err.Error(), deadlineError) {
log.WithField("peer", stream.Conn().RemotePeer()).WithError(err).Debug("Failed to send metadata request")
}
return
}
// update metadata if there is no error

View File

@ -3,8 +3,8 @@ package v2
import (
"context"
"github.com/prysmaticlabs/prysm/validator/flags"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/validator/flags"
v2keymanager "github.com/prysmaticlabs/prysm/validator/keymanager/v2"
"github.com/prysmaticlabs/prysm/validator/keymanager/v2/derived"
"github.com/prysmaticlabs/prysm/validator/keymanager/v2/direct"