diff --git a/beacon-chain/sync/error.go b/beacon-chain/sync/error.go index d7de2cf80..c240280b2 100644 --- a/beacon-chain/sync/error.go +++ b/beacon-chain/sync/error.go @@ -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) +} diff --git a/beacon-chain/sync/rpc_metadata.go b/beacon-chain/sync/rpc_metadata.go index d38e602ad..4713b531c 100644 --- a/beacon-chain/sync/rpc_metadata.go +++ b/beacon-chain/sync/rpc_metadata.go @@ -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()) } }() diff --git a/beacon-chain/sync/rpc_ping.go b/beacon-chain/sync/rpc_ping.go index 7f6ef73d4..f7618241e 100644 --- a/beacon-chain/sync/rpc_ping.go +++ b/beacon-chain/sync/rpc_ping.go @@ -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 diff --git a/validator/accounts/v2/wallet_create.go b/validator/accounts/v2/wallet_create.go index e58655bec..ee12e2140 100644 --- a/validator/accounts/v2/wallet_create.go +++ b/validator/accounts/v2/wallet_create.go @@ -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"