[#521] *: use stdlib errors package

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-05-18 11:12:51 +03:00 committed by Alex Vanin
parent 43e575cec2
commit 71b87155ef
171 changed files with 819 additions and 670 deletions

View file

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math" "math"
@ -22,7 +23,6 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-node/pkg/policy" "github.com/nspcc-dev/neofs-node/pkg/policy"
"github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -307,7 +307,7 @@ var getContainerInfoCmd = &cobra.Command{
cnr = container.New() cnr = container.New()
if err := cnr.Unmarshal(data); err != nil { if err := cnr.Unmarshal(data); err != nil {
return errors.Wrap(err, "can't unmarshal container") return fmt.Errorf("can't unmarshal container: %w", err)
} }
} else { } else {
key, err := getKey() key, err := getKey()

View file

@ -7,7 +7,6 @@ import (
"github.com/nspcc-dev/neofs-api-go/util/signature" "github.com/nspcc-dev/neofs-api-go/util/signature"
"github.com/nspcc-dev/neofs-node/pkg/services/control" "github.com/nspcc-dev/neofs-node/pkg/services/control"
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server" controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
"github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -112,7 +111,7 @@ func setNetmapStatus(cmd *cobra.Command, _ []string) error {
switch netmapStatus { switch netmapStatus {
default: default:
return errors.Errorf("unsupported status %s", netmapStatus) return fmt.Errorf("unsupported status %s", netmapStatus)
case netmapStatusOnline: case netmapStatusOnline:
status = control.NetmapStatus_ONLINE status = control.NetmapStatus_ONLINE
case netmapStatusOffline: case netmapStatusOffline:
@ -174,12 +173,12 @@ var dropObjectsCmd = &cobra.Command{
err := a.Parse(dropObjectsList[i]) err := a.Parse(dropObjectsList[i])
if err != nil { if err != nil {
return errors.Wrapf(err, "could not parse address #%d", i) return fmt.Errorf("could not parse address #%d: %w", i, err)
} }
binAddr, err := a.Marshal() binAddr, err := a.Marshal()
if err != nil { if err != nil {
return errors.Wrap(err, "could not marshal the address") return fmt.Errorf("could not marshal the address: %w", err)
} }
binAddrList = append(binAddrList, binAddr) binAddrList = append(binAddrList, binAddr)

View file

@ -2,6 +2,7 @@ package cmd
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/client" "github.com/nspcc-dev/neofs-api-go/pkg/client"
@ -10,7 +11,6 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/token" "github.com/nspcc-dev/neofs-api-go/pkg/token"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/storagegroup" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/storagegroup"
"github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )

View file

@ -1,11 +1,11 @@
package main package main
import ( import (
"fmt"
"strconv" "strconv"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
"github.com/nspcc-dev/neofs-node/pkg/util/attributes" "github.com/nspcc-dev/neofs-node/pkg/util/attributes"
"github.com/pkg/errors"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@ -65,7 +65,7 @@ func addWellKnownAttributes(attrs []*netmap.NodeAttribute) []*netmap.NodeAttribu
for key, desc := range mWellKnown { for key, desc := range mWellKnown {
// check if required attribute is set // check if required attribute is set
if desc.explicit { if desc.explicit {
fatalOnErr(errors.Errorf("missing explicit value of required node attribute %s", key)) fatalOnErr(fmt.Errorf("missing explicit value of required node attribute %s", key))
} }
// set default value of the attribute // set default value of the attribute

View file

@ -3,6 +3,7 @@ package main
import ( import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"errors"
"net" "net"
"os" "os"
"path" "path"
@ -40,7 +41,6 @@ import (
util2 "github.com/nspcc-dev/neofs-node/pkg/util" util2 "github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"github.com/spf13/viper" "github.com/spf13/viper"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
"go.uber.org/atomic" "go.uber.org/atomic"

View file

@ -4,6 +4,8 @@ import (
"bytes" "bytes"
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"errors"
"fmt"
"strconv" "strconv"
apiClient "github.com/nspcc-dev/neofs-api-go/pkg/client" apiClient "github.com/nspcc-dev/neofs-api-go/pkg/client"
@ -30,7 +32,6 @@ import (
loadstorage "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/storage" loadstorage "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/storage"
containerMorph "github.com/nspcc-dev/neofs-node/pkg/services/container/morph" containerMorph "github.com/nspcc-dev/neofs-node/pkg/services/container/morph"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -230,12 +231,12 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc
hostAddr, err := network.HostAddrFromMultiaddr(addr) hostAddr, err := network.HostAddrFromMultiaddr(addr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not convert address to IP format") return nil, fmt.Errorf("could not convert address to IP format: %w", err)
} }
c, err := r.clientCache.Get(hostAddr) c, err := r.clientCache.Get(hostAddr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not initialize API client") return nil, fmt.Errorf("could not initialize API client: %w", err)
} }
return &remoteLoadAnnounceWriterProvider{ return &remoteLoadAnnounceWriterProvider{
@ -298,7 +299,7 @@ func (l *loadPlacementBuilder) BuildPlacement(epoch uint64, cid *containerSDK.ID
placement, err := nm.GetPlacementVectors(cnrNodes, pivot) placement, err := nm.GetPlacementVectors(cnrNodes, pivot)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not build placement vectors") return nil, fmt.Errorf("could not build placement vectors: %w", err)
} }
return placement, nil return placement, nil
@ -312,12 +313,12 @@ func (l *loadPlacementBuilder) buildPlacement(epoch uint64, cid *containerSDK.ID
nm, err := l.nmSrc.GetNetMapByEpoch(epoch) nm, err := l.nmSrc.GetNetMapByEpoch(epoch)
if err != nil { if err != nil {
return nil, nil, errors.Wrap(err, "could not get network map") return nil, nil, fmt.Errorf("could not get network map: %w", err)
} }
cnrNodes, err := nm.GetContainerNodes(cnr.PlacementPolicy(), cid.ToV2().GetValue()) cnrNodes, err := nm.GetContainerNodes(cnr.PlacementPolicy(), cid.ToV2().GetValue())
if err != nil { if err != nil {
return nil, nil, errors.Wrap(err, "could not build container nodes") return nil, nil, fmt.Errorf("could not build container nodes: %w", err)
} }
return cnrNodes, nm, nil return cnrNodes, nm, nil
@ -407,7 +408,7 @@ func (c *usedSpaceService) AnnounceUsedSpace(ctx context.Context, req *container
w, err := c.loadWriterProvider.InitWriter(loadroute.NewRouteContext(ctx, passedRoute)) w, err := c.loadWriterProvider.InitWriter(loadroute.NewRouteContext(ctx, passedRoute))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not initialize container's used space writer") return nil, fmt.Errorf("could not initialize container's used space writer: %w", err)
} }
for _, aV2 := range req.GetBody().GetAnnouncements() { for _, aV2 := range req.GetBody().GetAnnouncements() {
@ -459,19 +460,19 @@ func (c *usedSpaceService) processLoadValue(ctx context.Context, a containerSDK.
route []loadroute.ServerInfo, w loadcontroller.Writer) error { route []loadroute.ServerInfo, w loadcontroller.Writer) error {
fromCnr, err := c.loadPlacementBuilder.isNodeFromContainerKey(a.Epoch(), a.ContainerID(), route[0].PublicKey()) fromCnr, err := c.loadPlacementBuilder.isNodeFromContainerKey(a.Epoch(), a.ContainerID(), route[0].PublicKey())
if err != nil { if err != nil {
return errors.Wrap(err, "could not verify that the sender belongs to the container") return fmt.Errorf("could not verify that the sender belongs to the container: %w", err)
} else if !fromCnr { } else if !fromCnr {
return errNodeOutsideContainer return errNodeOutsideContainer
} }
err = loadroute.CheckRoute(c.routeBuilder, a, route) err = loadroute.CheckRoute(c.routeBuilder, a, route)
if err != nil { if err != nil {
return errors.Wrap(err, "wrong route of container's used space value") return fmt.Errorf("wrong route of container's used space value: %w", err)
} }
err = w.Put(a) err = w.Put(a)
if err != nil { if err != nil {
return errors.Wrap(err, "could not write container's used space value") return fmt.Errorf("could not write container's used space value: %w", err)
} }
return nil return nil

View file

@ -3,6 +3,7 @@ package main
import ( import (
"context" "context"
"encoding/hex" "encoding/hex"
"fmt"
"net" "net"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
@ -10,7 +11,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/services/control" "github.com/nspcc-dev/neofs-node/pkg/services/control"
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server" controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
"github.com/pkg/errors"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@ -34,7 +34,7 @@ func initControlService(c *cfg) {
fatalOnErr(err) fatalOnErr(err)
if crypto.UnmarshalPublicKey(key) == nil { if crypto.UnmarshalPublicKey(key) == nil {
fatalOnErr(errors.Errorf("invalid permitted key for Control service %s", strKeys[i])) fatalOnErr(fmt.Errorf("invalid permitted key for Control service %s", strKeys[i]))
} }
keys = append(keys, key) keys = append(keys, key)

View file

@ -2,6 +2,7 @@ package main
import ( import (
"bytes" "bytes"
"fmt"
netmapSDK "github.com/nspcc-dev/neofs-api-go/pkg/netmap" netmapSDK "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap" netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap"
@ -13,7 +14,6 @@ import (
netmapTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/netmap/grpc" netmapTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/netmap/grpc"
"github.com/nspcc-dev/neofs-node/pkg/services/control" "github.com/nspcc-dev/neofs-node/pkg/services/control"
netmapService "github.com/nspcc-dev/neofs-node/pkg/services/netmap" netmapService "github.com/nspcc-dev/neofs-node/pkg/services/netmap"
"github.com/pkg/errors"
"go.uber.org/atomic" "go.uber.org/atomic"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -111,7 +111,7 @@ func bootstrapNode(c *cfg) {
initState(c) initState(c)
err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo()) err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo())
fatalOnErr(errors.Wrap(err, "bootstrap error")) fatalOnErr(fmt.Errorf("bootstrap error: %w", err))
} }
func addNetmapNotificationHandler(c *cfg, sTyp string, h event.Handler) { func addNetmapNotificationHandler(c *cfg, sTyp string, h event.Handler) {
@ -136,10 +136,10 @@ func setNetmapNotificationParser(c *cfg, sTyp string, p event.Parser) {
func initState(c *cfg) { func initState(c *cfg) {
epoch, err := c.cfgNetmap.wrapper.Epoch() epoch, err := c.cfgNetmap.wrapper.Epoch()
fatalOnErr(errors.Wrap(err, "could not initialize current epoch number")) fatalOnErr(fmt.Errorf("could not initialize current epoch number: %w", err))
ni, err := c.netmapLocalNodeState(epoch) ni, err := c.netmapLocalNodeState(epoch)
fatalOnErr(errors.Wrap(err, "could not init network state")) fatalOnErr(fmt.Errorf("could not init network state: %w", err))
c.handleNodeInfoStatus(ni) c.handleNodeInfoStatus(ni)

View file

@ -3,6 +3,7 @@ package main
import ( import (
"context" "context"
"crypto/sha256" "crypto/sha256"
"fmt"
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
"github.com/nspcc-dev/neofs-api-go/pkg/client" "github.com/nspcc-dev/neofs-api-go/pkg/client"
@ -40,7 +41,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation"
truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage" truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -131,7 +131,7 @@ type innerRingFetcher struct {
func (n *innerRingFetcher) InnerRingKeys() ([][]byte, error) { func (n *innerRingFetcher) InnerRingKeys() ([][]byte, error) {
keys, err := n.sidechain.NeoFSAlphabetList() keys, err := n.sidechain.NeoFSAlphabetList()
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't get inner ring keys") return nil, fmt.Errorf("can't get inner ring keys: %w", err)
} }
result := make([][]byte, 0, len(keys)) result := make([][]byte, 0, len(keys))
@ -383,7 +383,7 @@ func (s *morphEACLStorage) GetEACL(cid *container.ID) (*eaclSDK.Table, error) {
}, },
signature.SignWithRFC6979(), signature.SignWithRFC6979(),
); err != nil { ); err != nil {
return nil, errors.Wrap(err, "incorrect signature") return nil, fmt.Errorf("incorrect signature: %w", err)
} }
return table, nil return table, nil

View file

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
v2reputation "github.com/nspcc-dev/neofs-api-go/v2/reputation" v2reputation "github.com/nspcc-dev/neofs-api-go/v2/reputation"
@ -33,7 +34,6 @@ import (
truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage" truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage"
reputationrpc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/rpc" reputationrpc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/rpc"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -272,13 +272,13 @@ func (s *reputationServer) AnnounceLocalTrust(ctx context.Context, req *v2reputa
w, err := s.localRouter.InitWriter(reputationrouter.NewRouteContext(eCtx, passedRoute)) w, err := s.localRouter.InitWriter(reputationrouter.NewRouteContext(eCtx, passedRoute))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not initialize local trust writer") return nil, fmt.Errorf("could not initialize local trust writer: %w", err)
} }
for _, trust := range body.GetTrusts() { for _, trust := range body.GetTrusts() {
err = s.processLocalTrust(body.GetEpoch(), apiToLocalTrust(trust, passedRoute[0].PublicKey()), passedRoute, w) err = s.processLocalTrust(body.GetEpoch(), apiToLocalTrust(trust, passedRoute[0].PublicKey()), passedRoute, w)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not write one of local trusts") return nil, fmt.Errorf("could not write one of local trusts: %w", err)
} }
} }
@ -298,7 +298,7 @@ func (s *reputationServer) AnnounceIntermediateResult(ctx context.Context, req *
w, err := s.intermediateRouter.InitWriter(reputationrouter.NewRouteContext(eiCtx, passedRoute)) w, err := s.intermediateRouter.InitWriter(reputationrouter.NewRouteContext(eiCtx, passedRoute))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not initialize intermediate trust writer") return nil, fmt.Errorf("could not initialize intermediate trust writer: %w", err)
} }
v2Trust := body.GetTrust() v2Trust := body.GetTrust()
@ -307,7 +307,7 @@ func (s *reputationServer) AnnounceIntermediateResult(ctx context.Context, req *
err = w.Write(trust) err = w.Write(trust)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not write intermediate trust") return nil, fmt.Errorf("could not write intermediate trust: %w", err)
} }
resp := new(v2reputation.AnnounceIntermediateResultResponse) resp := new(v2reputation.AnnounceIntermediateResultResponse)
@ -320,7 +320,7 @@ func (s *reputationServer) processLocalTrust(epoch uint64, t reputation.Trust,
passedRoute []reputationcommon.ServerInfo, w reputationcommon.Writer) error { passedRoute []reputationcommon.ServerInfo, w reputationcommon.Writer) error {
err := reputationrouter.CheckRoute(s.routeBuilder, epoch, t, passedRoute) err := reputationrouter.CheckRoute(s.routeBuilder, epoch, t, passedRoute)
if err != nil { if err != nil {
return errors.Wrap(err, "wrong route of reputation trust value") return fmt.Errorf("wrong route of reputation trust value: %w", err)
} }
return w.Write(t) return w.Write(t)

View file

@ -1,12 +1,13 @@
package common package common
import ( import (
"fmt"
apiClient "github.com/nspcc-dev/neofs-api-go/pkg/client" apiClient "github.com/nspcc-dev/neofs-api-go/pkg/client"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
reputationrouter "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router" reputationrouter "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router"
trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller" trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller"
"github.com/pkg/errors"
) )
type clientCache interface { type clientCache interface {
@ -78,12 +79,12 @@ func (rtp *remoteTrustProvider) InitRemote(srv reputationcommon.ServerInfo) (rep
hostAddr, err := network.HostAddrFromMultiaddr(addr) hostAddr, err := network.HostAddrFromMultiaddr(addr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not convert address to IP format") return nil, fmt.Errorf("could not convert address to IP format: %w", err)
} }
c, err := rtp.clientCache.Get(hostAddr) c, err := rtp.clientCache.Get(hostAddr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not initialize API client") return nil, fmt.Errorf("could not initialize API client: %w", err)
} }
return rtp.remoteProvider.WithClient(c), nil return rtp.remoteProvider.WithClient(c), nil

View file

@ -2,6 +2,7 @@ package local
import ( import (
"bytes" "bytes"
"errors"
netmapcore "github.com/nspcc-dev/neofs-node/pkg/core/netmap" netmapcore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation"
@ -9,7 +10,6 @@ import (
trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller" trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller"
truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage" truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors"
) )
type TrustStorage struct { type TrustStorage struct {

1
go.mod
View file

@ -19,7 +19,6 @@ require (
github.com/nspcc-dev/tzhash v1.4.0 github.com/nspcc-dev/tzhash v1.4.0
github.com/panjf2000/ants/v2 v2.3.0 github.com/panjf2000/ants/v2 v2.3.0
github.com/paulmach/orb v0.2.1 github.com/paulmach/orb v0.2.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.6.0 github.com/prometheus/client_golang v1.6.0
github.com/spf13/cobra v1.0.0 github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect

View file

@ -1,10 +1,12 @@
package container package container
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/pkg/errors"
) )
var errNilPolicy = errors.New("placement policy is nil") var errNilPolicy = errors.New("placement policy is nil")
@ -19,15 +21,15 @@ func CheckFormat(c *container.Container) error {
} }
if err := pkg.IsSupportedVersion(c.Version()); err != nil { if err := pkg.IsSupportedVersion(c.Version()); err != nil {
return errors.Wrap(err, "incorrect version") return fmt.Errorf("incorrect version: %w", err)
} }
if ln := len(c.OwnerID().ToV2().GetValue()); ln != owner.NEO3WalletSize { if ln := len(c.OwnerID().ToV2().GetValue()); ln != owner.NEO3WalletSize {
return errors.Errorf("incorrect owner identifier: expected length %d != %d", owner.NEO3WalletSize, ln) return fmt.Errorf("incorrect owner identifier: expected length %d != %d", owner.NEO3WalletSize, ln)
} }
if _, err := c.NonceUUID(); err != nil { if _, err := c.NonceUUID(); err != nil {
return errors.Wrap(err, "incorrect nonce") return fmt.Errorf("incorrect nonce: %w", err)
} }
return nil return nil

View file

@ -1,6 +1,6 @@
package object package object
import "github.com/pkg/errors" import "errors"
// ErrNotFound is a basic "not found" error returned by // ErrNotFound is a basic "not found" error returned by
// object read functions. // object read functions.

View file

@ -2,6 +2,8 @@ package object
import ( import (
"bytes" "bytes"
"errors"
"fmt"
"strconv" "strconv"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
@ -10,7 +12,6 @@ import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
crypto "github.com/nspcc-dev/neofs-crypto" crypto "github.com/nspcc-dev/neofs-crypto"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/pkg/errors"
) )
// FormatValidator represents object format validator. // FormatValidator represents object format validator.
@ -75,16 +76,16 @@ func (v *FormatValidator) Validate(obj *Object) error {
for ; obj != nil; obj = obj.GetParent() { for ; obj != nil; obj = obj.GetParent() {
if err := v.validateSignatureKey(obj); err != nil { if err := v.validateSignatureKey(obj); err != nil {
return errors.Wrapf(err, "(%T) could not validate signature key", v) return fmt.Errorf("(%T) could not validate signature key: %w", v, err)
} }
// TODO: combine small checks // TODO: combine small checks
if err := v.checkExpiration(obj); err != nil { if err := v.checkExpiration(obj); err != nil {
return errors.Wrapf(err, "object did not pass expiration check") return fmt.Errorf("object did not pass expiration ch: %weck", err)
} }
if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil { if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
return errors.Wrapf(err, "(%T) could not validate header fields", v) return fmt.Errorf("(%T) could not validate header fields: %w", v, err)
} }
} }
@ -116,7 +117,7 @@ func (v *FormatValidator) checkOwnerKey(id *owner.ID, key []byte) error {
// FIXME: implement Equal method // FIXME: implement Equal method
if s1, s2 := id.String(), id2.String(); s1 != s2 { if s1, s2 := id.String(), id2.String(); s1 != s2 {
return errors.Errorf("(%T) different owner identifiers %s/%s", v, s1, s2) return fmt.Errorf("(%T) different owner identifiers %s/%s", v, s1, s2)
} }
return nil return nil
@ -127,13 +128,13 @@ func (v *FormatValidator) ValidateContent(o *Object) error {
switch o.Type() { switch o.Type() {
case object.TypeTombstone: case object.TypeTombstone:
if len(o.Payload()) == 0 { if len(o.Payload()) == 0 {
return errors.Errorf("(%T) empty payload in tombstone", v) return fmt.Errorf("(%T) empty payload in tombstone", v)
} }
tombstone := object.NewTombstone() tombstone := object.NewTombstone()
if err := tombstone.Unmarshal(o.Payload()); err != nil { if err := tombstone.Unmarshal(o.Payload()); err != nil {
return errors.Wrapf(err, "(%T) could not unmarshal tombstone content", v) return fmt.Errorf("(%T) could not unmarshal tombstone content: %w", v, err)
} }
// check if tombstone has the same expiration in body and header // check if tombstone has the same expiration in body and header
@ -153,7 +154,7 @@ func (v *FormatValidator) ValidateContent(o *Object) error {
for _, id := range idList { for _, id := range idList {
if id == nil { if id == nil {
return errors.Errorf("(%T) empty member in tombstone", v) return fmt.Errorf("(%T) empty member in tombstone", v)
} }
a := object.NewAddress() a := object.NewAddress()
@ -168,18 +169,18 @@ func (v *FormatValidator) ValidateContent(o *Object) error {
} }
case object.TypeStorageGroup: case object.TypeStorageGroup:
if len(o.Payload()) == 0 { if len(o.Payload()) == 0 {
return errors.Errorf("(%T) empty payload in SG", v) return fmt.Errorf("(%T) empty payload in SG", v)
} }
sg := storagegroup.New() sg := storagegroup.New()
if err := sg.Unmarshal(o.Payload()); err != nil { if err := sg.Unmarshal(o.Payload()); err != nil {
return errors.Wrapf(err, "(%T) could not unmarshal SG content", v) return fmt.Errorf("(%T) could not unmarshal SG content: %w", v, err)
} }
for _, id := range sg.Members() { for _, id := range sg.Members() {
if id == nil { if id == nil {
return errors.Errorf("(%T) empty member in SG", v) return fmt.Errorf("(%T) empty member in SG", v)
} }
} }
default: default:

View file

@ -4,6 +4,7 @@ import (
"crypto/ecdsa" "crypto/ecdsa"
"crypto/rand" "crypto/rand"
"crypto/sha256" "crypto/sha256"
"errors"
"strconv" "strconv"
"testing" "testing"
@ -15,7 +16,6 @@ import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
crypto "github.com/nspcc-dev/neofs-crypto" crypto "github.com/nspcc-dev/neofs-crypto"
"github.com/nspcc-dev/neofs-node/pkg/util/test" "github.com/nspcc-dev/neofs-node/pkg/util/test"
"github.com/pkg/errors"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View file

@ -2,12 +2,12 @@ package innerring
import ( import (
"crypto/ecdsa" "crypto/ecdsa"
"fmt"
"sync" "sync"
"time" "time"
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke" "github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
type ( type (
@ -72,7 +72,7 @@ func (s *innerRingIndexer) update() (ind indexes, err error) {
func (s *innerRingIndexer) InnerRingIndex() (int32, error) { func (s *innerRingIndexer) InnerRingIndex() (int32, error) {
ind, err := s.update() ind, err := s.update()
if err != nil { if err != nil {
return 0, errors.Wrap(err, "can't update index state") return 0, fmt.Errorf("can't update index state: %w", err)
} }
return ind.innerRingIndex, nil return ind.innerRingIndex, nil
@ -81,7 +81,7 @@ func (s *innerRingIndexer) InnerRingIndex() (int32, error) {
func (s *innerRingIndexer) InnerRingSize() (int32, error) { func (s *innerRingIndexer) InnerRingSize() (int32, error) {
ind, err := s.update() ind, err := s.update()
if err != nil { if err != nil {
return 0, errors.Wrap(err, "can't update index state") return 0, fmt.Errorf("can't update index state: %w", err)
} }
return ind.innerRingSize, nil return ind.innerRingSize, nil
@ -90,7 +90,7 @@ func (s *innerRingIndexer) InnerRingSize() (int32, error) {
func (s *innerRingIndexer) AlphabetIndex() (int32, error) { func (s *innerRingIndexer) AlphabetIndex() (int32, error) {
ind, err := s.update() ind, err := s.update()
if err != nil { if err != nil {
return 0, errors.Wrap(err, "can't update index state") return 0, fmt.Errorf("can't update index state: %w", err)
} }
return ind.alphabetIndex, nil return ind.alphabetIndex, nil

View file

@ -3,6 +3,8 @@ package innerring
import ( import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"errors"
"fmt"
"io" "io"
"github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/block"
@ -31,7 +33,6 @@ import (
util2 "github.com/nspcc-dev/neofs-node/pkg/util" util2 "github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/precision" "github.com/nspcc-dev/neofs-node/pkg/util/precision"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"github.com/spf13/viper" "github.com/spf13/viper"
"go.uber.org/atomic" "go.uber.org/atomic"
"go.uber.org/zap" "go.uber.org/zap"
@ -179,9 +180,9 @@ func (s *Server) Start(ctx context.Context, intError chan<- error) error {
case <-ctx.Done(): case <-ctx.Done():
return return
case err := <-morphErr: case err := <-morphErr:
intError <- errors.Wrap(err, "sidechain") intError <- fmt.Errorf("sidechain: %w", err)
case err := <-mainnnetErr: case err := <-mainnnetErr:
intError <- errors.Wrap(err, "mainnet") intError <- fmt.Errorf("mainnet: %w", err)
} }
}() }()
@ -197,7 +198,7 @@ func (s *Server) Start(ctx context.Context, intError chan<- error) error {
go s.mainnetListener.ListenWithError(ctx, mainnnetErr) // listen for neo:mainnet events go s.mainnetListener.ListenWithError(ctx, mainnnetErr) // listen for neo:mainnet events
if err := s.startBlockTimers(); err != nil { if err := s.startBlockTimers(); err != nil {
return errors.Wrap(err, "could not start block timers") return fmt.Errorf("could not start block timers: %w", err)
} }
s.startWorkers(ctx) s.startWorkers(ctx)
@ -249,7 +250,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
// prepare inner ring node private key // prepare inner ring node private key
server.key, err = crypto.LoadPrivateKey(cfg.GetString("key")) server.key, err = crypto.LoadPrivateKey(cfg.GetString("key"))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't create private key") return nil, fmt.Errorf("ir: can't create private key: %w", err)
} }
// get all script hashes of contracts // get all script hashes of contracts
@ -261,7 +262,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
// parse default validators // parse default validators
server.predefinedValidators, err = parsePredefinedValidators(cfg) server.predefinedValidators, err = parsePredefinedValidators(cfg)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't parse predefined validators list") return nil, fmt.Errorf("ir: can't parse predefined validators list: %w", err)
} }
morphChain := &chainParams{ morphChain := &chainParams{
@ -733,42 +734,42 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
result.netmap, err = util.Uint160DecodeStringLE(netmapContractStr) result.netmap, err = util.Uint160DecodeStringLE(netmapContractStr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't read netmap script-hash") return nil, fmt.Errorf("ir: can't read netmap script-hash: %w", err)
} }
result.neofs, err = util.Uint160DecodeStringLE(neofsContractStr) result.neofs, err = util.Uint160DecodeStringLE(neofsContractStr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't read neofs script-hash") return nil, fmt.Errorf("ir: can't read neofs script-hash: %w", err)
} }
result.balance, err = util.Uint160DecodeStringLE(balanceContractStr) result.balance, err = util.Uint160DecodeStringLE(balanceContractStr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't read balance script-hash") return nil, fmt.Errorf("ir: can't read balance script-hash: %w", err)
} }
result.container, err = util.Uint160DecodeStringLE(containerContractStr) result.container, err = util.Uint160DecodeStringLE(containerContractStr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't read container script-hash") return nil, fmt.Errorf("ir: can't read container script-hash: %w", err)
} }
result.audit, err = util.Uint160DecodeStringLE(auditContractStr) result.audit, err = util.Uint160DecodeStringLE(auditContractStr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't read audit script-hash") return nil, fmt.Errorf("ir: can't read audit script-hash: %w", err)
} }
result.proxy, err = util.Uint160DecodeStringLE(proxyContractStr) result.proxy, err = util.Uint160DecodeStringLE(proxyContractStr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't read proxy script-hash") return nil, fmt.Errorf("ir: can't read proxy script-hash: %w", err)
} }
result.processing, err = util.Uint160DecodeStringLE(processingContractStr) result.processing, err = util.Uint160DecodeStringLE(processingContractStr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't read processing script-hash") return nil, fmt.Errorf("ir: can't read processing script-hash: %w", err)
} }
result.reputation, err = util.Uint160DecodeStringLE(reputationContractStr) result.reputation, err = util.Uint160DecodeStringLE(reputationContractStr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir: can't read reputation script-hash") return nil, fmt.Errorf("ir: can't read reputation script-hash: %w", err)
} }
result.alphabet, err = parseAlphabetContracts(cfg) result.alphabet, err = parseAlphabetContracts(cfg)
@ -793,7 +794,7 @@ func ParsePublicKeysFromStrings(pubKeys []string) (keys.PublicKeys, error) {
for i := range pubKeys { for i := range pubKeys {
key, err := keys.NewPublicKeyFromString(pubKeys[i]) key, err := keys.NewPublicKeyFromString(pubKeys[i])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't decode public key") return nil, fmt.Errorf("can't decode public key: %w", err)
} }
publicKeys = append(publicKeys, key) publicKeys = append(publicKeys, key)
@ -807,7 +808,7 @@ func parseAlphabetContracts(cfg *viper.Viper) (alphabetContracts, error) {
alpha := newAlphabetContracts() alpha := newAlphabetContracts()
if num > lastLetterNum { if num > lastLetterNum {
return nil, errors.Errorf("amount of alphabet contracts overflows glagolitsa %d > %d", num, lastLetterNum) return nil, fmt.Errorf("amount of alphabet contracts overflows glagolitsa %d > %d", num, lastLetterNum)
} }
for letter := az; letter < num; letter++ { for letter := az; letter < num; letter++ {
@ -815,7 +816,7 @@ func parseAlphabetContracts(cfg *viper.Viper) (alphabetContracts, error) {
contractHash, err := util.Uint160DecodeStringLE(contractStr) contractHash, err := util.Uint160DecodeStringLE(contractStr)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "invalid alphabet %s contract: %s", letter.configString(), contractStr) return nil, fmt.Errorf("invalid alphabet %s contract: %s: %w", letter.configString(), contractStr, err)
} }
alpha.set(letter, contractHash) alpha.set(letter, contractHash)
@ -828,13 +829,13 @@ func (s *Server) initConfigFromBlockchain() error {
// get current epoch // get current epoch
epoch, err := invoke.Epoch(s.morphClient, s.contracts.netmap) epoch, err := invoke.Epoch(s.morphClient, s.contracts.netmap)
if err != nil { if err != nil {
return errors.Wrap(err, "can't read epoch") return fmt.Errorf("can't read epoch: %w", err)
} }
// get balance precision // get balance precision
balancePrecision, err := invoke.BalancePrecision(s.morphClient, s.contracts.balance) balancePrecision, err := invoke.BalancePrecision(s.morphClient, s.contracts.balance)
if err != nil { if err != nil {
return errors.Wrap(err, "can't read balance contract precision") return fmt.Errorf("can't read balance contract precision: %w", err)
} }
s.epochCounter.Store(uint64(epoch)) s.epochCounter.Store(uint64(epoch))

View file

@ -15,7 +15,6 @@ import (
wrapNetmap "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper" wrapNetmap "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation" "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
reputationWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation/wrapper" reputationWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation/wrapper"
"github.com/pkg/errors"
) )
// NewContainerClient creates wrapper to access data from container contract. // NewContainerClient creates wrapper to access data from container contract.
@ -62,12 +61,12 @@ func NewAuditClient(cli *client.Client, contract util.Uint160, fee SideFeeProvid
func NewBalanceClient(cli *client.Client, contract util.Uint160, fee SideFeeProvider) (*balanceWrapper.Wrapper, error) { func NewBalanceClient(cli *client.Client, contract util.Uint160, fee SideFeeProvider) (*balanceWrapper.Wrapper, error) {
staticClient, err := client.NewStatic(cli, contract, fee.SideChainFee()) staticClient, err := client.NewStatic(cli, contract, fee.SideChainFee())
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not create static client of Balance contract") return nil, fmt.Errorf("could not create static client of Balance contract: %w", err)
} }
enhancedBalanceClient, err := balance.New(staticClient) enhancedBalanceClient, err := balance.New(staticClient)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not create Balance contract client") return nil, fmt.Errorf("could not create Balance contract client: %w", err)
} }
return balanceWrapper.New(enhancedBalanceClient) return balanceWrapper.New(enhancedBalanceClient)
@ -77,12 +76,12 @@ func NewBalanceClient(cli *client.Client, contract util.Uint160, fee SideFeeProv
func NewReputationClient(cli *client.Client, contract util.Uint160, fee SideFeeProvider) (*reputationWrapper.ClientWrapper, error) { func NewReputationClient(cli *client.Client, contract util.Uint160, fee SideFeeProvider) (*reputationWrapper.ClientWrapper, error) {
staticClient, err := client.NewStatic(cli, contract, fee.SideChainFee()) staticClient, err := client.NewStatic(cli, contract, fee.SideChainFee())
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not create static client of reputation contract") return nil, fmt.Errorf("could not create static client of reputation contract: %w", err)
} }
enhancedRepurationClient, err := reputation.New(staticClient) enhancedRepurationClient, err := reputation.New(staticClient)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not create reputation contract client") return nil, fmt.Errorf("could not create reputation contract client: %w", err)
} }
return reputationWrapper.WrapClient(enhancedRepurationClient), nil return reputationWrapper.WrapClient(enhancedRepurationClient), nil

View file

@ -1,12 +1,14 @@
package invoke package invoke
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
type ( type (
@ -157,7 +159,7 @@ func NetmapSnapshot(cli *client.Client, con util.Uint160) (*netmap.Netmap, error
for i := range rawNodeInfos { for i := range rawNodeInfos {
nodeInfo, err := peerInfoFromStackItem(rawNodeInfos[i]) nodeInfo, err := peerInfoFromStackItem(rawNodeInfos[i])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "invalid RPC response") return nil, fmt.Errorf("invalid RPC response: %w", err)
} }
result = append(result, *nodeInfo) result = append(result, *nodeInfo)

View file

@ -1,11 +1,13 @@
package alphabet package alphabet
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -65,7 +67,7 @@ func New(p *Params) (*Processor, error) {
pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/neofs: can't create worker pool") return nil, fmt.Errorf("ir/neofs: can't create worker pool: %w", err)
} }
return &Processor{ return &Processor{

View file

@ -3,6 +3,8 @@ package audit
import ( import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"errors"
"fmt"
"time" "time"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
@ -15,7 +17,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/services/audit" "github.com/nspcc-dev/neofs-node/pkg/services/audit"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -110,7 +111,7 @@ func New(p *Params) (*Processor, error) {
pool, err := ants.NewPool(ProcessorPoolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(ProcessorPoolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/audit: can't create worker pool") return nil, fmt.Errorf("ir/audit: can't create worker pool: %w", err)
} }
// creating enhanced client for getting network map // creating enhanced client for getting network map

View file

@ -1,11 +1,12 @@
package audit package audit
import ( import (
"errors"
"fmt"
"sort" "sort"
"strings" "strings"
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -14,7 +15,7 @@ var ErrInvalidIRNode = errors.New("node is not in the inner ring list")
func (ap *Processor) selectContainersToAudit(epoch uint64) ([]*container.ID, error) { func (ap *Processor) selectContainersToAudit(epoch uint64) ([]*container.ID, error) {
containers, err := ap.containerClient.List(nil) containers, err := ap.containerClient.List(nil)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't get list of containers to start audit") return nil, fmt.Errorf("can't get list of containers to start audit: %w", err)
} }
// consider getting extra information about container complexity from // consider getting extra information about container complexity from

View file

@ -1,13 +1,15 @@
package balance package balance
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/innerring/config"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance" balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -70,7 +72,7 @@ func New(p *Params) (*Processor, error) {
pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/balance: can't create worker pool") return nil, fmt.Errorf("ir/balance: can't create worker pool: %w", err)
} }
return &Processor{ return &Processor{

View file

@ -1,13 +1,15 @@
package container package container
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/innerring/config"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container" containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -60,7 +62,7 @@ func New(p *Params) (*Processor, error) {
pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/container: can't create worker pool") return nil, fmt.Errorf("ir/container: can't create worker pool: %w", err)
} }
return &Processor{ return &Processor{

View file

@ -1,10 +1,11 @@
package governance package governance
import ( import (
"errors"
"fmt"
"sort" "sort"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/pkg/errors"
) )
var ( var (
@ -25,7 +26,7 @@ func newAlphabetList(sidechain, mainnet keys.PublicKeys) (keys.PublicKeys, error
} }
if len(mainnet) < ln { if len(mainnet) < ln {
return nil, errors.Wrapf(errNotEnoughKeys, "expecting %d keys", ln) return nil, fmt.Errorf("%w: expecting %d keys", errNotEnoughKeys, ln)
} }
hmap := make(map[string]bool, ln) hmap := make(map[string]bool, ln)

View file

@ -1,13 +1,15 @@
package governance package governance
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/innerring/config"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -89,7 +91,7 @@ func New(p *Params) (*Processor, error) {
pool, err := ants.NewPool(ProcessorPoolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(ProcessorPoolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/governance: can't create worker pool") return nil, fmt.Errorf("ir/governance: can't create worker pool: %w", err)
} }
return &Processor{ return &Processor{

View file

@ -1,6 +1,8 @@
package neofs package neofs
import ( import (
"errors"
"fmt"
"sync" "sync"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
@ -11,7 +13,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs" neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -97,12 +98,12 @@ func New(p *Params) (*Processor, error) {
pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/neofs: can't create worker pool") return nil, fmt.Errorf("ir/neofs: can't create worker pool: %w", err)
} }
lruCache, err := lru.New(p.MintEmitCacheSize) lruCache, err := lru.New(p.MintEmitCacheSize)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/neofs: can't create LRU cache for gas emission") return nil, fmt.Errorf("ir/neofs: can't create LRU cache for gas emission: %w", err)
} }
return &Processor{ return &Processor{

View file

@ -1,9 +1,11 @@
package locode package locode
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
"github.com/nspcc-dev/neofs-node/pkg/util/locode" "github.com/nspcc-dev/neofs-node/pkg/util/locode"
"github.com/pkg/errors"
) )
var errMissingRequiredAttr = errors.New("missing required attribute in DB record") var errMissingRequiredAttr = errors.New("missing required attribute in DB record")
@ -36,12 +38,12 @@ func (v *Validator) VerifyAndUpdate(n *netmap.NodeInfo) error {
lc, err := locode.FromString(attrLocode.Value()) lc, err := locode.FromString(attrLocode.Value())
if err != nil { if err != nil {
return errors.Wrap(err, "invalid locode value") return fmt.Errorf("invalid locode value: %w", err)
} }
record, err := v.db.Get(lc) record, err := v.db.Get(lc)
if err != nil { if err != nil {
return errors.Wrap(err, "could not get locode record from DB") return fmt.Errorf("could not get locode record from DB: %w", err)
} }
for attrKey, attrDesc := range v.mAttr { for attrKey, attrDesc := range v.mAttr {

View file

@ -1,6 +1,9 @@
package netmap package netmap
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
"github.com/nspcc-dev/neofs-node/pkg/innerring/config" "github.com/nspcc-dev/neofs-node/pkg/innerring/config"
@ -9,7 +12,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -131,7 +133,7 @@ func New(p *Params) (*Processor, error) {
pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/netmap: can't create worker pool") return nil, fmt.Errorf("ir/netmap: can't create worker pool: %w", err)
} }
return &Processor{ return &Processor{

View file

@ -1,12 +1,14 @@
package reputation package reputation
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
reputationWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation/wrapper" reputationWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation/wrapper"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
reputationEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/reputation" reputationEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/reputation"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -69,7 +71,7 @@ func New(p *Params) (*Processor, error) {
pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(p.PoolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "ir/reputation: can't create worker pool") return nil, fmt.Errorf("ir/reputation: can't create worker pool: %w", err)
} }
return &Processor{ return &Processor{

View file

@ -8,7 +8,6 @@ import (
nodeutil "github.com/nspcc-dev/neofs-node/pkg/util" nodeutil "github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -61,7 +60,7 @@ func New(prm Prm, opts ...Option) *Processor {
pool, err := ants.NewPool(o.poolSize, ants.WithNonblocking(true)) pool, err := ants.NewPool(o.poolSize, ants.WithNonblocking(true))
if err != nil { if err != nil {
panic(errors.Wrap(err, "could not create worker pool")) panic(fmt.Errorf("could not create worker pool: %w", err))
} }
o.log.Debug("worker pool for settlement processor successfully initialized", o.log.Debug("worker pool for settlement processor successfully initialized",

View file

@ -3,6 +3,7 @@ package innerring
import ( import (
"context" "context"
"encoding/hex" "encoding/hex"
"fmt"
"math/big" "math/big"
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit" auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
@ -22,7 +23,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -91,7 +91,7 @@ func (c *containerWrapper) Owner() *owner.ID {
func (s settlementDeps) AuditResultsForEpoch(epoch uint64) ([]*auditAPI.Result, error) { func (s settlementDeps) AuditResultsForEpoch(epoch uint64) ([]*auditAPI.Result, error) {
idList, err := s.auditClient.ListAuditResultIDByEpoch(epoch) idList, err := s.auditClient.ListAuditResultIDByEpoch(epoch)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not list audit results in sidechain") return nil, fmt.Errorf("could not list audit results in sidechain: %w", err)
} }
res := make([]*auditAPI.Result, 0, len(idList)) res := make([]*auditAPI.Result, 0, len(idList))
@ -99,7 +99,7 @@ func (s settlementDeps) AuditResultsForEpoch(epoch uint64) ([]*auditAPI.Result,
for i := range idList { for i := range idList {
r, err := s.auditClient.GetAuditResult(idList[i]) r, err := s.auditClient.GetAuditResult(idList[i])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not get audit result") return nil, fmt.Errorf("could not get audit result: %w", err)
} }
res = append(res, r) res = append(res, r)
@ -111,7 +111,7 @@ func (s settlementDeps) AuditResultsForEpoch(epoch uint64) ([]*auditAPI.Result,
func (s settlementDeps) ContainerInfo(cid *containerAPI.ID) (common.ContainerInfo, error) { func (s settlementDeps) ContainerInfo(cid *containerAPI.ID) (common.ContainerInfo, error) {
cnr, err := s.cnrSrc.Get(cid) cnr, err := s.cnrSrc.Get(cid)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not get container from storage") return nil, fmt.Errorf("could not get container from storage: %w", err)
} }
return (*containerWrapper)(cnr), nil return (*containerWrapper)(cnr), nil
@ -130,12 +130,12 @@ func (s settlementDeps) buildContainer(e uint64, cid *containerAPI.ID) (netmapAP
} }
if err != nil { if err != nil {
return nil, nil, errors.Wrap(err, "could not get network map from storage") return nil, nil, fmt.Errorf("could not get network map from storage: %w", err)
} }
cnr, err := s.cnrSrc.Get(cid) cnr, err := s.cnrSrc.Get(cid)
if err != nil { if err != nil {
return nil, nil, errors.Wrap(err, "could not get container from sidechain") return nil, nil, fmt.Errorf("could not get container from sidechain: %w", err)
} }
cn, err := nm.GetContainerNodes( cn, err := nm.GetContainerNodes(
@ -143,7 +143,7 @@ func (s settlementDeps) buildContainer(e uint64, cid *containerAPI.ID) (netmapAP
cid.ToV2().GetValue(), // may be replace pivot calculation to neofs-api-go cid.ToV2().GetValue(), // may be replace pivot calculation to neofs-api-go
) )
if err != nil { if err != nil {
return nil, nil, errors.Wrap(err, "could not calculate container nodes") return nil, nil, fmt.Errorf("could not calculate container nodes: %w", err)
} }
return cn, nm, nil return cn, nm, nil

View file

@ -2,6 +2,7 @@ package blobovnicza
import ( import (
"crypto/sha256" "crypto/sha256"
"errors"
"math/rand" "math/rand"
"os" "os"
"testing" "testing"
@ -10,7 +11,6 @@ import (
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test" "github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
"github.com/pkg/errors"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View file

@ -1,10 +1,11 @@
package blobovnicza package blobovnicza
import ( import (
"errors"
"fmt"
"os" "os"
"path" "path"
"github.com/pkg/errors"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -58,8 +59,11 @@ func (b *Blobovnicza) Init() error {
return true, b.syncFullnessCounter() return true, b.syncFullnessCounter()
} }
return false, errors.Wrapf(err, if err != nil {
"(%T) could not create bucket for bounds [%d:%d]", b, lower, upper) return false, fmt.Errorf("(%T) could not create bucket for bounds [%d:%d]: %w",
b, lower, upper, err)
}
return false, nil
}) })
}) })
} }

View file

@ -1,9 +1,10 @@
package blobovnicza package blobovnicza
import ( import (
"fmt"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/pkg/errors"
) )
// GetRangePrm groups the parameters of GetRange operation. // GetRangePrm groups the parameters of GetRange operation.
@ -59,7 +60,7 @@ func (b *Blobovnicza) GetRange(prm *GetRangePrm) (*GetRangeRes, error) {
payload := res.obj payload := res.obj
if from > to { if from > to {
return nil, errors.Errorf("invalid range [%d:%d]", from, to) return nil, fmt.Errorf("invalid range [%d:%d]", from, to)
} else if uint64(len(payload)) < to { } else if uint64(len(payload)) < to {
return nil, object.ErrRangeOutOfBounds return nil, object.ErrRangeOutOfBounds
} }

View file

@ -1,7 +1,8 @@
package blobovnicza package blobovnicza
import ( import (
"github.com/pkg/errors" "fmt"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
@ -12,7 +13,7 @@ func (b *Blobovnicza) iterateBuckets(tx *bbolt.Tx, f func(uint64, uint64, *bbolt
// expected to happen: // expected to happen:
// - before initialization step (incorrect usage by design) // - before initialization step (incorrect usage by design)
// - if DB is corrupted (in future this case should be handled) // - if DB is corrupted (in future this case should be handled)
return false, errors.Errorf("(%T) could not get bucket %s", b, stringifyBounds(lower, upper)) return false, fmt.Errorf("(%T) could not get bucket %s", b, stringifyBounds(lower, upper))
} }
return f(lower, upper, buck) return f(lower, upper, buck)

View file

@ -1,8 +1,10 @@
package blobovnicza package blobovnicza
import ( import (
"errors"
"fmt"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/pkg/errors"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
@ -65,12 +67,12 @@ func (b *Blobovnicza) Put(prm *PutPrm) (*PutRes, error) {
// expected to happen: // expected to happen:
// - before initialization step (incorrect usage by design) // - before initialization step (incorrect usage by design)
// - if DB is corrupted (in future this case should be handled) // - if DB is corrupted (in future this case should be handled)
return errors.Errorf("(%T) bucket for size %d not created", b, sz) return fmt.Errorf("(%T) bucket for size %d not created", b, sz)
} }
// save the object in bucket // save the object in bucket
if err := buck.Put(addressKey(addr), prm.objData); err != nil { if err := buck.Put(addressKey(addr), prm.objData); err != nil {
return errors.Wrapf(err, "(%T) could not save object in bucket", b) return fmt.Errorf("(%T) could not save object in bucket: %w", b, err)
} }
// increase fullness counter // increase fullness counter

View file

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"code.cloudfoundry.org/bytefmt" "code.cloudfoundry.org/bytefmt"
"github.com/pkg/errors"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
@ -54,13 +53,13 @@ func (b *Blobovnicza) full() bool {
} }
func (b *Blobovnicza) syncFullnessCounter() error { func (b *Blobovnicza) syncFullnessCounter() error {
return errors.Wrap(b.boltDB.View(func(tx *bbolt.Tx) error { err := b.boltDB.View(func(tx *bbolt.Tx) error {
sz := uint64(0) sz := uint64(0)
if err := b.iterateBucketKeys(func(lower, upper uint64, key []byte) (bool, error) { if err := b.iterateBucketKeys(func(lower, upper uint64, key []byte) (bool, error) {
buck := tx.Bucket(key) buck := tx.Bucket(key)
if buck == nil { if buck == nil {
return false, errors.Errorf("bucket not found %s", stringifyBounds(lower, upper)) return false, fmt.Errorf("bucket not found %s", stringifyBounds(lower, upper))
} }
sz += uint64(buck.Stats().KeyN) * (upper - lower) sz += uint64(buck.Stats().KeyN) * (upper - lower)
@ -73,5 +72,9 @@ func (b *Blobovnicza) syncFullnessCounter() error {
b.filled.Store(sz) b.filled.Store(sz)
return nil return nil
}), "(%T) could not sync fullness counter") })
if err != nil {
return fmt.Errorf("could not sync fullness counter: %w", err)
}
return nil
} }

View file

@ -1,6 +1,7 @@
package blobstor package blobstor
import ( import (
"errors"
"fmt" "fmt"
"path" "path"
"strconv" "strconv"
@ -11,7 +12,6 @@ import (
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -101,7 +101,7 @@ func newBlobovniczaTree(c *cfg) (blz *blobovniczas) {
}) })
if err != nil { if err != nil {
// occurs only if the size is not positive // occurs only if the size is not positive
panic(errors.Wrapf(err, "could not create LRU cache of size %d", c.openedCacheSize)) panic(fmt.Errorf("could not create LRU cache of size %d: %w", c.openedCacheSize, err))
} }
cp := uint64(1) cp := uint64(1)
@ -563,13 +563,13 @@ func (b *blobovniczas) getObject(blz *blobovnicza.Blobovnicza, prm *blobovnicza.
// decompress the data // decompress the data
data, err := b.decompressor(res.Object()) data, err := b.decompressor(res.Object())
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not decompress object data") return nil, fmt.Errorf("could not decompress object data: %w", err)
} }
// unmarshal the object // unmarshal the object
obj := object.New() obj := object.New()
if err := obj.Unmarshal(data); err != nil { if err := obj.Unmarshal(data); err != nil {
return nil, errors.Wrap(err, "could not unmarshal the object") return nil, fmt.Errorf("could not unmarshal the object: %w", err)
} }
return &GetSmallRes{ return &GetSmallRes{
@ -596,13 +596,13 @@ func (b *blobovniczas) getObjectRange(blz *blobovnicza.Blobovnicza, prm *GetRang
// decompress the data // decompress the data
data, err := b.decompressor(res.Object()) data, err := b.decompressor(res.Object())
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not decompress object data") return nil, fmt.Errorf("could not decompress object data: %w", err)
} }
// unmarshal the object // unmarshal the object
obj := object.New() obj := object.New()
if err := obj.Unmarshal(data); err != nil { if err := obj.Unmarshal(data); err != nil {
return nil, errors.Wrap(err, "could not unmarshal the object") return nil, fmt.Errorf("could not unmarshal the object: %w", err)
} }
from := prm.rng.GetOffset() from := prm.rng.GetOffset()
@ -766,9 +766,9 @@ func (b *blobovniczas) init() error {
return b.iterateLeaves(func(p string) (bool, error) { return b.iterateLeaves(func(p string) (bool, error) {
blz, err := b.openBlobovnicza(p) blz, err := b.openBlobovnicza(p)
if err != nil { if err != nil {
return false, errors.Wrapf(err, "could not open blobovnicza %s", p) return false, fmt.Errorf("could not open blobovnicza %s: %w", p, err)
} else if err := blz.Init(); err != nil { } else if err := blz.Init(); err != nil {
return false, errors.Wrapf(err, "could not initialize blobovnicza structure %s", p) return false, fmt.Errorf("could not initialize blobovnicza structure %s: %w", p, err)
} }
log := b.log.With(zap.String("id", p)) log := b.log.With(zap.String("id", p))
@ -831,7 +831,7 @@ func (b *blobovniczas) openBlobovnicza(p string) (*blobovnicza.Blobovnicza, erro
)...) )...)
if err := blz.Open(); err != nil { if err := blz.Open(); err != nil {
return nil, errors.Wrapf(err, "could not open blobovnicza %s", p) return nil, fmt.Errorf("could not open blobovnicza %s: %w", p, err)
} }
b.activeMtx.Lock() b.activeMtx.Lock()

View file

@ -1,9 +1,10 @@
package blobstor package blobstor
import ( import (
"errors"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
"github.com/pkg/errors"
) )
// DeleteBigPrm groups the parameters of DeleteBig operation. // DeleteBigPrm groups the parameters of DeleteBig operation.

View file

@ -1,9 +1,10 @@
package blobstor package blobstor
import ( import (
"errors"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
"github.com/pkg/errors"
) )
// ExistsPrm groups the parameters of Exists operation. // ExistsPrm groups the parameters of Exists operation.

View file

@ -1,9 +1,11 @@
package blobstor package blobstor
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
"github.com/pkg/errors"
) )
// GetBigPrm groups the parameters of GetBig operation. // GetBigPrm groups the parameters of GetBig operation.
@ -31,18 +33,18 @@ func (b *BlobStor) GetBig(prm *GetBigPrm) (*GetBigRes, error) {
return nil, object.ErrNotFound return nil, object.ErrNotFound
} }
return nil, errors.Wrap(err, "could not read object from fs tree") return nil, fmt.Errorf("could not read object from fs tree: %w", err)
} }
data, err = b.decompressor(data) data, err = b.decompressor(data)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not decompress object data") return nil, fmt.Errorf("could not decompress object data: %w", err)
} }
// unmarshal the object // unmarshal the object
obj := object.New() obj := object.New()
if err := obj.Unmarshal(data); err != nil { if err := obj.Unmarshal(data); err != nil {
return nil, errors.Wrap(err, "could not unmarshal the object") return nil, fmt.Errorf("could not unmarshal the object: %w", err)
} }
return &GetBigRes{ return &GetBigRes{

View file

@ -1,8 +1,9 @@
package blobstor package blobstor
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/pkg/errors"
) )
// GetRangeBigPrm groups the parameters of GetRangeBig operation. // GetRangeBigPrm groups the parameters of GetRangeBig operation.
@ -26,18 +27,18 @@ func (b *BlobStor) GetRangeBig(prm *GetRangeBigPrm) (*GetRangeBigRes, error) {
// get compressed object data // get compressed object data
data, err := b.fsTree.Get(prm.addr) data, err := b.fsTree.Get(prm.addr)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not read object from fs tree") return nil, fmt.Errorf("could not read object from fs tree: %w", err)
} }
data, err = b.decompressor(data) data, err = b.decompressor(data)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not decompress object data") return nil, fmt.Errorf("could not decompress object data: %w", err)
} }
// unmarshal the object // unmarshal the object
obj := object.New() obj := object.New()
if err := obj.Unmarshal(data); err != nil { if err := obj.Unmarshal(data); err != nil {
return nil, errors.Wrap(err, "could not unmarshal the object") return nil, fmt.Errorf("could not unmarshal the object: %w", err)
} }
payload := obj.Payload() payload := obj.Payload()

View file

@ -1,8 +1,9 @@
package blobstor package blobstor
import ( import (
"fmt"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/pkg/errors"
) )
// PutPrm groups the parameters of Put operation. // PutPrm groups the parameters of Put operation.
@ -27,7 +28,7 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
// marshal object // marshal object
data, err := prm.obj.Marshal() data, err := prm.obj.Marshal()
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not marshal the object") return nil, fmt.Errorf("could not marshal the object: %w", err)
} }
return b.PutRaw(prm.obj.Address(), data) return b.PutRaw(prm.obj.Address(), data)

View file

@ -1,7 +1,8 @@
package engine package engine
import ( import (
"github.com/pkg/errors" "fmt"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -12,7 +13,7 @@ func (e *StorageEngine) Open() error {
for id, sh := range e.shards { for id, sh := range e.shards {
if err := sh.Open(); err != nil { if err := sh.Open(); err != nil {
return errors.Wrapf(err, "could not open shard %s", id) return fmt.Errorf("could not open shard %s: %w", id, err)
} }
} }
@ -26,7 +27,7 @@ func (e *StorageEngine) Init() error {
for id, sh := range e.shards { for id, sh := range e.shards {
if err := sh.Init(); err != nil { if err := sh.Init(); err != nil {
return errors.Wrapf(err, "could not initialize shard %s", id) return fmt.Errorf("could not initialize shard %s: %w", id, err)
} }
} }

View file

@ -1,11 +1,12 @@
package engine package engine
import ( import (
"errors"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )

View file

@ -1,13 +1,13 @@
package engine package engine
import ( import (
"errors"
"fmt" "fmt"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/nspcc-dev/hrw" "github.com/nspcc-dev/hrw"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/pkg/errors"
) )
var errShardNotFound = errors.New("shard not found") var errShardNotFound = errors.New("shard not found")
@ -26,7 +26,7 @@ func (e *StorageEngine) AddShard(opts ...shard.Option) (*shard.ID, error) {
id, err := generateShardID() id, err := generateShardID()
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not generate shard ID") return nil, fmt.Errorf("could not generate shard ID: %w", err)
} }
e.shards[id.String()] = shard.New(append(opts, e.shards[id.String()] = shard.New(append(opts,

View file

@ -2,11 +2,11 @@ package meta
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/pkg/errors"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
@ -80,7 +80,7 @@ func (db *DB) delete(tx *bbolt.Tx, addr *objectSDK.Address, refCounter reference
if graveyard != nil { if graveyard != nil {
err := graveyard.Delete(addressKey(addr)) err := graveyard.Delete(addressKey(addr))
if err != nil { if err != nil {
return errors.Wrap(err, "could not remove from graveyard") return fmt.Errorf("could not remove from graveyard: %w", err)
} }
} }

View file

@ -1,11 +1,11 @@
package meta_test package meta_test
import ( import (
"errors"
"testing" "testing"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/pkg/errors"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View file

@ -2,9 +2,10 @@ package meta
import ( import (
"bytes" "bytes"
"errors"
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/pkg/errors"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
@ -50,7 +51,7 @@ func (db *DB) iterateOverGraveyard(tx *bbolt.Tx, h GraveHandler) error {
// parse Grave // parse Grave
g, err := graveFromKV(k, v) g, err := graveFromKV(k, v)
if err != nil { if err != nil {
return errors.Wrap(err, "could not parse Grave") return fmt.Errorf("could not parse Grave: %w", err)
} }
// handler Grave // handler Grave
@ -67,7 +68,7 @@ func (db *DB) iterateOverGraveyard(tx *bbolt.Tx, h GraveHandler) error {
func graveFromKV(k, v []byte) (*Grave, error) { func graveFromKV(k, v []byte) (*Grave, error) {
addr, err := addressFromKey(k) addr, err := addressFromKey(k)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not parse address") return nil, fmt.Errorf("could not parse address: %w", err)
} }
return &Grave{ return &Grave{

View file

@ -2,9 +2,10 @@ package meta
import ( import (
"bytes" "bytes"
"errors"
"fmt"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/pkg/errors"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
@ -86,7 +87,7 @@ func (db *DB) Inhume(prm *InhumePrm) (res *InhumeRes, err error) {
if data != nil && !bytes.Equal(data, []byte(inhumeGCMarkValue)) { if data != nil && !bytes.Equal(data, []byte(inhumeGCMarkValue)) {
err := graveyard.Delete(tombKey) err := graveyard.Delete(tombKey)
if err != nil { if err != nil {
return errors.Wrap(err, "could not remove grave with tombstone key") return fmt.Errorf("could not remove grave with tombstone key: %w", err)
} }
} }
} else { } else {

View file

@ -1,11 +1,11 @@
package meta_test package meta_test
import ( import (
"errors"
"testing" "testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/pkg/errors"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View file

@ -1,12 +1,13 @@
package meta package meta
import ( import (
"errors"
"fmt"
"strconv" "strconv"
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/pkg/errors"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
@ -60,7 +61,7 @@ func (db *DB) iterateExpired(tx *bbolt.Tx, epoch uint64, h ExpiredObjectHandler)
expiresAt, err := strconv.ParseUint(string(expKey), 10, 64) expiresAt, err := strconv.ParseUint(string(expKey), 10, 64)
if err != nil { if err != nil {
return errors.Wrap(err, "could not parse expiration epoch") return fmt.Errorf("could not parse expiration epoch: %w", err)
} else if expiresAt >= epoch { } else if expiresAt >= epoch {
return nil return nil
} }
@ -70,14 +71,14 @@ func (db *DB) iterateExpired(tx *bbolt.Tx, epoch uint64, h ExpiredObjectHandler)
err = id.Parse(string(idKey)) err = id.Parse(string(idKey))
if err != nil { if err != nil {
return errors.Wrap(err, "could not parse ID of expired object") return fmt.Errorf("could not parse ID of expired object: %w", err)
} }
cid := container.NewID() cid := container.NewID()
err = cid.Parse(string(cidBytes)) err = cid.Parse(string(cidBytes))
if err != nil { if err != nil {
return errors.Wrap(err, "could not parse container ID of expired bucket") return fmt.Errorf("could not parse container ID of expired bucket: %w", err)
} }
addr := object.NewAddress() addr := object.NewAddress()
@ -133,7 +134,7 @@ func (db *DB) iterateCoveredByTombstones(tx *bbolt.Tx, tss map[string]struct{},
if _, ok := tss[string(v)]; ok { if _, ok := tss[string(v)]; ok {
addr, err := addressFromKey(k) addr, err := addressFromKey(k)
if err != nil { if err != nil {
return errors.Wrap(err, "could not parse address of the object under tombstone") return fmt.Errorf("could not parse address of the object under tombstone: %w", err)
} }
return h(addr) return h(addr)

View file

@ -2,13 +2,13 @@ package meta
import ( import (
"encoding/binary" "encoding/binary"
"errors"
"fmt" "fmt"
"strings" "strings"
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
v2object "github.com/nspcc-dev/neofs-api-go/v2/object" v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/pkg/errors"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
"go.uber.org/zap" "go.uber.org/zap"
) )

View file

@ -1,8 +1,9 @@
package shard package shard
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/pkg/errors"
) )
type ContainerSizePrm struct { type ContainerSizePrm struct {
@ -28,7 +29,7 @@ func (r *ContainerSizeRes) Size() uint64 {
func (s *Shard) ContainerSize(prm *ContainerSizePrm) (*ContainerSizeRes, error) { func (s *Shard) ContainerSize(prm *ContainerSizePrm) (*ContainerSizeRes, error) {
size, err := s.metaBase.ContainerSize(prm.cid) size, err := s.metaBase.ContainerSize(prm.cid)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not get container size") return nil, fmt.Errorf("could not get container size: %w", err)
} }
return &ContainerSizeRes{ return &ContainerSizeRes{

View file

@ -1,7 +1,7 @@
package shard package shard
import ( import (
"github.com/pkg/errors" "fmt"
) )
// Open opens all Shard's components. // Open opens all Shard's components.
@ -16,7 +16,7 @@ func (s *Shard) Open() error {
for _, component := range components { for _, component := range components {
if err := component.Open(); err != nil { if err := component.Open(); err != nil {
return errors.Wrapf(err, "could not open %T", component) return fmt.Errorf("could not open %T: %w", component, err)
} }
} }
@ -35,7 +35,7 @@ func (s *Shard) Init() error {
for _, component := range components { for _, component := range components {
if err := component.Init(); err != nil { if err := component.Init(); err != nil {
return errors.Wrapf(err, "could not initialize %T", component) return fmt.Errorf("could not initialize %T: %w", component, err)
} }
} }
@ -70,7 +70,7 @@ func (s *Shard) Close() error {
for _, component := range components { for _, component := range components {
if err := component.Close(); err != nil { if err := component.Close(); err != nil {
return errors.Wrapf(err, "could not close %s", component) return fmt.Errorf("could not close %s: %w", component, err)
} }
} }

View file

@ -1,12 +1,13 @@
package shard package shard
import ( import (
"errors"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )

View file

@ -1,6 +1,7 @@
package shard package shard
import ( import (
"errors"
"fmt" "fmt"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
@ -8,7 +9,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )

View file

@ -6,7 +6,6 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -48,7 +47,7 @@ func (s *Shard) List() (*SelectRes, error) {
func (s *Shard) ListContainers(_ *ListContainersPrm) (*ListContainersRes, error) { func (s *Shard) ListContainers(_ *ListContainersPrm) (*ListContainersRes, error) {
containers, err := s.metaBase.Containers() containers, err := s.metaBase.Containers()
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not get list of containers") return nil, fmt.Errorf("could not get list of containers: %w", err)
} }
return &ListContainersRes{ return &ListContainersRes{

View file

@ -1,10 +1,11 @@
package shard package shard
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -52,14 +53,14 @@ func (s *Shard) Put(prm *PutPrm) (*PutRes, error) {
// res == nil if there is no writeCache or writeCache.Put has been failed // res == nil if there is no writeCache or writeCache.Put has been failed
if res, err = s.blobStor.Put(putPrm); err != nil { if res, err = s.blobStor.Put(putPrm); err != nil {
return nil, errors.Wrap(err, "could not put object to BLOB storage") return nil, fmt.Errorf("could not put object to BLOB storage: %w", err)
} }
// put to metabase // put to metabase
if err := meta.Put(s.metaBase, prm.obj, res.BlobovniczaID()); err != nil { if err := meta.Put(s.metaBase, prm.obj, res.BlobovniczaID()); err != nil {
// may we need to handle this case in a special way // may we need to handle this case in a special way
// since the object has been successfully written to BlobStor // since the object has been successfully written to BlobStor
return nil, errors.Wrap(err, "could not put object to metabase") return nil, fmt.Errorf("could not put object to metabase: %w", err)
} }
return nil, nil return nil, nil

View file

@ -1,10 +1,11 @@
package shard package shard
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/pkg/errors"
) )
// SelectPrm groups the parameters of Select operation. // SelectPrm groups the parameters of Select operation.
@ -48,7 +49,7 @@ func (r *SelectRes) AddressList() []*objectSDK.Address {
func (s *Shard) Select(prm *SelectPrm) (*SelectRes, error) { func (s *Shard) Select(prm *SelectPrm) (*SelectRes, error) {
addrList, err := meta.Select(s.metaBase, prm.cid, prm.filters) addrList, err := meta.Select(s.metaBase, prm.cid, prm.filters)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not select objects from metabase") return nil, fmt.Errorf("could not select objects from metabase: %w", err)
} }
return &SelectRes{ return &SelectRes{

View file

@ -1,8 +1,9 @@
package audit package audit
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// GetAuditResultArgs groups the arguments // GetAuditResultArgs groups the arguments
@ -35,14 +36,14 @@ func (c *Client) GetAuditResult(args GetAuditResultArgs) (*GetAuditResultValue,
args.id, args.id,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getResultMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getResultMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.getResultMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.getResultMethod, ln)
} }
resultBytes, err := client.BytesFromStackItem(prms[0]) resultBytes, err := client.BytesFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", c.getResultMethod) return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.getResultMethod, err)
} }
return &GetAuditResultValue{ return &GetAuditResultValue{

View file

@ -1,9 +1,10 @@
package audit package audit
import ( import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// ListResultsArgs groups the arguments // ListResultsArgs groups the arguments
@ -66,7 +67,7 @@ func (c *Client) ListAuditResults(args ListResultsArgs) (*ListResultsValues, err
c.listResultsMethod, c.listResultsMethod,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listResultsMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listResultsMethod, err)
} }
return parseAuditResults(items, c.listResultsMethod) return parseAuditResults(items, c.listResultsMethod)
@ -80,7 +81,7 @@ func (c *Client) ListAuditResultsByEpoch(args ListResultsByEpochArgs) (*ListResu
args.epoch, args.epoch,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listByEpochResultsMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listByEpochResultsMethod, err)
} }
return parseAuditResults(items, c.listByEpochResultsMethod) return parseAuditResults(items, c.listByEpochResultsMethod)
@ -95,7 +96,7 @@ func (c *Client) ListAuditResultsByCID(args ListResultsByCIDArgs) (*ListResultsV
args.cid, args.cid,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listByCIDResultsMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listByCIDResultsMethod, err)
} }
return parseAuditResults(items, c.listByCIDResultsMethod) return parseAuditResults(items, c.listByCIDResultsMethod)
@ -111,7 +112,7 @@ func (c *Client) ListAuditResultsByNode(args ListResultsByNodeArgs) (*ListResult
args.nodeKey, args.nodeKey,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listByNodeResultsMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listByNodeResultsMethod, err)
} }
return parseAuditResults(items, c.listByNodeResultsMethod) return parseAuditResults(items, c.listByNodeResultsMethod)
@ -119,12 +120,12 @@ func (c *Client) ListAuditResultsByNode(args ListResultsByNodeArgs) (*ListResult
func parseAuditResults(items []stackitem.Item, method string) (*ListResultsValues, error) { func parseAuditResults(items []stackitem.Item, method string) (*ListResultsValues, error) {
if ln := len(items); ln != 1 { if ln := len(items); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", method, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", method, ln)
} }
items, err := client.ArrayFromStackItem(items[0]) items, err := client.ArrayFromStackItem(items[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", method) return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", method, err)
} }
res := &ListResultsValues{ res := &ListResultsValues{
@ -134,7 +135,7 @@ func parseAuditResults(items []stackitem.Item, method string) (*ListResultsValue
for i := range items { for i := range items {
rawRes, err := client.BytesFromStackItem(items[i]) rawRes, err := client.BytesFromStackItem(items[i])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", method) return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", method, err)
} }
res.rawResults = append(res.rawResults, rawRes) res.rawResults = append(res.rawResults, rawRes)

View file

@ -1,7 +1,7 @@
package audit package audit
import ( import (
"github.com/pkg/errors" "fmt"
) )
// PutAuditResultArgs groups the arguments // PutAuditResultArgs groups the arguments
@ -19,8 +19,13 @@ func (g *PutAuditResultArgs) SetRawResult(v []byte) {
// PutAuditResult invokes the call of "put audit result" method // PutAuditResult invokes the call of "put audit result" method
// of NeoFS Audit contract. // of NeoFS Audit contract.
func (c *Client) PutAuditResult(args PutAuditResultArgs) error { func (c *Client) PutAuditResult(args PutAuditResultArgs) error {
return errors.Wrapf(c.client.Invoke( err := c.client.Invoke(
c.putResultMethod, c.putResultMethod,
args.rawResult, args.rawResult,
), "could not invoke method (%s)", c.putResultMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.putResultMethod, err)
}
return nil
} }

View file

@ -1,10 +1,12 @@
package audit package audit
import ( import (
"errors"
"fmt"
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit" auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/audit" "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
"github.com/pkg/errors"
) )
// ResultID is an identity of audit result inside audit contract. // ResultID is an identity of audit result inside audit contract.
@ -19,7 +21,7 @@ var errUnsupported = errors.New("unsupported structure version")
func (w *ClientWrapper) PutAuditResult(result *auditAPI.Result) error { func (w *ClientWrapper) PutAuditResult(result *auditAPI.Result) error {
rawResult, err := result.Marshal() rawResult, err := result.Marshal()
if err != nil { if err != nil {
return errors.Wrap(err, "could not marshal audit result") return fmt.Errorf("could not marshal audit result: %w", err)
} }
args := audit.PutAuditResultArgs{} args := audit.PutAuditResultArgs{}
@ -121,7 +123,7 @@ func (w *ClientWrapper) GetAuditResult(id ResultID) (*auditAPI.Result, error) {
auditRes := auditAPI.NewResult() auditRes := auditAPI.NewResult()
if err := auditRes.Unmarshal(value.Result()); err != nil { if err := auditRes.Unmarshal(value.Result()); err != nil {
return nil, errors.Wrap(err, "could not unmarshal audit result structure") return nil, fmt.Errorf("could not unmarshal audit result structure: %w", err)
} }
return auditRes, nil return auditRes, nil

View file

@ -1,10 +1,10 @@
package balance package balance
import ( import (
"fmt"
"math/big" "math/big"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// GetBalanceOfArgs groups the arguments // GetBalanceOfArgs groups the arguments
@ -38,14 +38,14 @@ func (c *Client) BalanceOf(args GetBalanceOfArgs) (*GetBalanceOfValues, error) {
args.wallet, args.wallet,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.balanceOfMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.balanceOfMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.balanceOfMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.balanceOfMethod, ln)
} }
amount, err := client.BigIntFromStackItem(prms[0]) amount, err := client.BigIntFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get integer stack item from stack item (%s)", c.balanceOfMethod) return nil, fmt.Errorf("could not get integer stack item from stack item (%s): %w", c.balanceOfMethod, err)
} }
return &GetBalanceOfValues{ return &GetBalanceOfValues{

View file

@ -1,8 +1,9 @@
package balance package balance
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// DecimalsArgs groups the arguments // DecimalsArgs groups the arguments
@ -28,14 +29,14 @@ func (c *Client) Decimals(args DecimalsArgs) (*DecimalsValues, error) {
c.decimalsMethod, c.decimalsMethod,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.decimalsMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.decimalsMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.decimalsMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.decimalsMethod, ln)
} }
decimals, err := client.IntFromStackItem(prms[0]) decimals, err := client.IntFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get integer stack item from stack item (%s)", c.decimalsMethod) return nil, fmt.Errorf("could not get integer stack item from stack item (%s): %w", c.decimalsMethod, err)
} }
return &DecimalsValues{ return &DecimalsValues{

View file

@ -1,7 +1,7 @@
package balance package balance
import ( import (
"github.com/pkg/errors" "fmt"
) )
// TransferXArgs groups the arguments // TransferXArgs groups the arguments
@ -58,11 +58,16 @@ func (c *Client) transferX(notary bool, args TransferXArgs) error {
f = c.client.NotaryInvoke f = c.client.NotaryInvoke
} }
return errors.Wrapf(f( err := f(
c.transferXMethod, c.transferXMethod,
args.sender, args.sender,
args.recipient, args.recipient,
args.amount, args.amount,
args.details, args.details,
), "could not invoke method (%s)", c.transferXMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.transferXMethod, err)
}
return nil
} }

View file

@ -1,8 +1,9 @@
package wrapper package wrapper
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance" "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
"github.com/pkg/errors"
) )
// Decimals decimal precision of currency transactions // Decimals decimal precision of currency transactions
@ -14,7 +15,7 @@ func (w *Wrapper) Decimals() (uint32, error) {
// invoke smart contract call // invoke smart contract call
values, err := w.client.Decimals(args) values, err := w.client.Decimals(args)
if err != nil { if err != nil {
return 0, errors.Wrap(err, "could not invoke smart contract") return 0, fmt.Errorf("could not invoke smart contract: %w", err)
} }
return uint32(values.Decimals()), nil return uint32(values.Decimals()), nil

View file

@ -1,9 +1,10 @@
package wrapper package wrapper
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance" "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
"github.com/pkg/errors"
) )
// TransferPrm groups parameters of TransferX method. // TransferPrm groups parameters of TransferX method.
@ -30,12 +31,12 @@ func (w *Wrapper) TransferXNotary(p TransferPrm) error {
func (w *Wrapper) transferX(notary bool, p TransferPrm) error { func (w *Wrapper) transferX(notary bool, p TransferPrm) error {
from, err := owner.ScriptHashBE(p.From) from, err := owner.ScriptHashBE(p.From)
if err != nil { if err != nil {
return errors.Wrap(err, "invalid sender") return fmt.Errorf("invalid sender: %w", err)
} }
to, err := owner.ScriptHashBE(p.To) to, err := owner.ScriptHashBE(p.To)
if err != nil { if err != nil {
return errors.Wrap(err, "invalid recipient") return fmt.Errorf("invalid recipient: %w", err)
} }
// prepare invocation arguments // prepare invocation arguments

View file

@ -2,6 +2,7 @@ package client
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"time" "time"
@ -17,7 +18,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -230,7 +230,7 @@ func (c *Client) TxHalt(h util.Uint256) (bool, error) {
func (c *Client) NeoFSAlphabetList() (keys.PublicKeys, error) { func (c *Client) NeoFSAlphabetList() (keys.PublicKeys, error) {
list, err := c.roleList(noderoles.NeoFSAlphabet) list, err := c.roleList(noderoles.NeoFSAlphabet)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't get alphabet nodes role list") return nil, fmt.Errorf("can't get alphabet nodes role list: %w", err)
} }
return list, nil return list, nil
@ -239,7 +239,7 @@ func (c *Client) NeoFSAlphabetList() (keys.PublicKeys, error) {
func (c *Client) roleList(r noderoles.Role) (keys.PublicKeys, error) { func (c *Client) roleList(r noderoles.Role) (keys.PublicKeys, error) {
height, err := c.client.GetBlockCount() height, err := c.client.GetBlockCount()
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't get chain height") return nil, fmt.Errorf("can't get chain height: %w", err)
} }
return c.client.GetDesignatedByRole(r, height) return c.client.GetDesignatedByRole(r, height)
@ -285,7 +285,7 @@ func toStackParameter(value interface{}) (sc.Parameter, error) {
return toStackParameter(arr) return toStackParameter(arr)
default: default:
return result, errors.Errorf("chain/client: unsupported parameter %v", value) return result, fmt.Errorf("chain/client: unsupported parameter %v", value)
} }
return result, nil return result, nil

View file

@ -1,6 +1,8 @@
package container package container
import "github.com/pkg/errors" import (
"fmt"
)
// DeleteArgs groups the arguments // DeleteArgs groups the arguments
// of delete container invocation call. // of delete container invocation call.
@ -25,9 +27,14 @@ func (p *DeleteArgs) SetSignature(v []byte) {
// Delete invokes the call of delete container // Delete invokes the call of delete container
// method of NeoFS Container contract. // method of NeoFS Container contract.
func (c *Client) Delete(args DeleteArgs) error { func (c *Client) Delete(args DeleteArgs) error {
return errors.Wrapf(c.client.Invoke( err := c.client.Invoke(
c.deleteMethod, c.deleteMethod,
args.cid, args.cid,
args.sig, args.sig,
), "could not invoke method (%s)", c.deleteMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.deleteMethod, err)
}
return nil
} }

View file

@ -1,8 +1,9 @@
package container package container
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// EACLArgs groups the arguments // EACLArgs groups the arguments
@ -51,33 +52,33 @@ func (c *Client) EACL(args EACLArgs) (*EACLValues, error) {
args.cid, args.cid,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.eaclMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.eaclMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.eaclMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.eaclMethod, ln)
} }
arr, err := client.ArrayFromStackItem(prms[0]) arr, err := client.ArrayFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get item array of eACL (%s)", c.eaclMethod) return nil, fmt.Errorf("could not get item array of eACL (%s): %w", c.eaclMethod, err)
} }
if len(arr) != 3 { if len(arr) != 3 {
return nil, errors.Errorf("unexpected eacl stack item count (%s): %d", c.eaclMethod, len(arr)) return nil, fmt.Errorf("unexpected eacl stack item count (%s): %d", c.eaclMethod, len(arr))
} }
eacl, err := client.BytesFromStackItem(arr[0]) eacl, err := client.BytesFromStackItem(arr[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array of eACL (%s)", c.eaclMethod) return nil, fmt.Errorf("could not get byte array of eACL (%s): %w", c.eaclMethod, err)
} }
sig, err := client.BytesFromStackItem(arr[1]) sig, err := client.BytesFromStackItem(arr[1])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array of eACL signature (%s)", c.eaclMethod) return nil, fmt.Errorf("could not get byte array of eACL signature (%s): %w", c.eaclMethod, err)
} }
pub, err := client.BytesFromStackItem(arr[2]) pub, err := client.BytesFromStackItem(arr[2])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array of eACL public key (%s)", c.eaclMethod) return nil, fmt.Errorf("could not get byte array of eACL public key (%s): %w", c.eaclMethod, err)
} }
return &EACLValues{ return &EACLValues{

View file

@ -1,6 +1,8 @@
package container package container
import "github.com/pkg/errors" import (
"fmt"
)
// SetEACLArgs groups the arguments // SetEACLArgs groups the arguments
// of set eACL invocation call. // of set eACL invocation call.
@ -25,9 +27,14 @@ func (p *SetEACLArgs) SetSignature(v []byte) {
// SetEACL invokes the call of set eACL method // SetEACL invokes the call of set eACL method
// of NeoFS Container contract. // of NeoFS Container contract.
func (c *Client) SetEACL(args SetEACLArgs) error { func (c *Client) SetEACL(args SetEACLArgs) error {
return errors.Wrapf(c.client.Invoke( err := c.client.Invoke(
c.setEACLMethod, c.setEACLMethod,
args.eacl, args.eacl,
args.sig, args.sig,
), "could not invoke method (%s)", c.setEACLMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.setEACLMethod, err)
}
return nil
} }

View file

@ -1,7 +1,7 @@
package container package container
import ( import (
"github.com/pkg/errors" "fmt"
) )
type StartEstimation struct { type StartEstimation struct {
@ -21,29 +21,29 @@ func (e *StopEstimation) SetEpoch(v int64) {
} }
func (c *Client) StartEstimation(args StartEstimation) error { func (c *Client) StartEstimation(args StartEstimation) error {
return errors.Wrapf(c.client.Invoke( if err := c.client.Invoke(c.startEstimation, args.epoch); err != nil {
c.startEstimation, return fmt.Errorf("could not invoke method (%s): %w", c.startEstimation, err)
args.epoch, }
), "could not invoke method (%s)", c.startEstimation) return nil
} }
func (c *Client) StartEstimationNotary(args StartEstimation) error { func (c *Client) StartEstimationNotary(args StartEstimation) error {
return errors.Wrapf(c.client.NotaryInvoke( if err := c.client.NotaryInvoke(c.startEstimation, args.epoch); err != nil {
c.startEstimation, return fmt.Errorf("could not invoke method (%s): %w", c.startEstimation, err)
args.epoch, }
), "could not invoke method (%s)", c.startEstimation) return nil
} }
func (c *Client) StopEstimation(args StopEstimation) error { func (c *Client) StopEstimation(args StopEstimation) error {
return errors.Wrapf(c.client.Invoke( if err := c.client.Invoke(c.stopEstimation, args.epoch); err != nil {
c.stopEstimation, return fmt.Errorf("could not invoke method (%s): %w", c.stopEstimation, err)
args.epoch, }
), "could not invoke method (%s)", c.stopEstimation) return nil
} }
func (c *Client) StopEstimationNotary(args StopEstimation) error { func (c *Client) StopEstimationNotary(args StopEstimation) error {
return errors.Wrapf(c.client.NotaryInvoke( if err := c.client.NotaryInvoke(c.stopEstimation, args.epoch); err != nil {
c.stopEstimation, return fmt.Errorf("could not invoke method (%s): %w", c.stopEstimation, err)
args.epoch, }
), "could not invoke method (%s)", c.stopEstimation) return nil
} }

View file

@ -1,8 +1,9 @@
package container package container
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// GetArgs groups the arguments // GetArgs groups the arguments
@ -37,14 +38,14 @@ func (c *Client) Get(args GetArgs) (*GetValues, error) {
args.cid, args.cid,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.getMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.getMethod, ln)
} }
cnrBytes, err := client.BytesFromStackItem(prms[0]) cnrBytes, err := client.BytesFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", c.getMethod) return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.getMethod, err)
} }
return &GetValues{ return &GetValues{

View file

@ -1,8 +1,9 @@
package container package container
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// ListArgs groups the arguments // ListArgs groups the arguments
@ -41,14 +42,14 @@ func (c *Client) List(args ListArgs) (*ListValues, error) {
invokeArgs..., invokeArgs...,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.listMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.listMethod, ln)
} }
prms, err = client.ArrayFromStackItem(prms[0]) prms, err = client.ArrayFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", c.listMethod) return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", c.listMethod, err)
} }
res := &ListValues{ res := &ListValues{
@ -58,7 +59,7 @@ func (c *Client) List(args ListArgs) (*ListValues, error) {
for i := range prms { for i := range prms {
cid, err := client.BytesFromStackItem(prms[i]) cid, err := client.BytesFromStackItem(prms[i])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", c.listMethod) return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.listMethod, err)
} }
res.cidList = append(res.cidList, cid) res.cidList = append(res.cidList, cid)

View file

@ -1,8 +1,9 @@
package container package container
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// PutSizeArgs groups the arguments // PutSizeArgs groups the arguments
@ -43,13 +44,18 @@ func (p *PutSizeArgs) SetReporterKey(v []byte) {
// Put invokes the call of put container method // Put invokes the call of put container method
// of NeoFS Container contract. // of NeoFS Container contract.
func (c *Client) PutSize(args PutSizeArgs) error { func (c *Client) PutSize(args PutSizeArgs) error {
return errors.Wrapf(c.client.Invoke( err := c.client.Invoke(
c.putSizeMethod, c.putSizeMethod,
args.epoch, args.epoch,
args.cid, args.cid,
args.size, args.size,
args.reporterKey, args.reporterKey,
), "could not invoke method (%s)", c.putSizeMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.putSizeMethod, err)
}
return nil
} }
// ListSizesArgs groups the arguments // ListSizesArgs groups the arguments
@ -84,14 +90,14 @@ func (c *Client) ListSizes(args ListSizesArgs) (*ListSizesValues, error) {
args.epoch, args.epoch,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listSizesMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listSizesMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.listSizesMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.listSizesMethod, ln)
} }
prms, err = client.ArrayFromStackItem(prms[0]) prms, err = client.ArrayFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", c.listSizesMethod) return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", c.listSizesMethod, err)
} }
res := &ListSizesValues{ res := &ListSizesValues{
@ -101,7 +107,7 @@ func (c *Client) ListSizes(args ListSizesArgs) (*ListSizesValues, error) {
for i := range prms { for i := range prms {
id, err := client.BytesFromStackItem(prms[i]) id, err := client.BytesFromStackItem(prms[i])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get ID byte array from stack item (%s)", c.listSizesMethod) return nil, fmt.Errorf("could not get ID byte array from stack item (%s): %w", c.listSizesMethod, err)
} }
res.ids = append(res.ids, id) res.ids = append(res.ids, id)
@ -152,28 +158,28 @@ func (c *Client) GetContainerSize(args GetSizeArgs) (*GetSizeValues, error) {
args.id, args.id,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getSizeMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getSizeMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.getSizeMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.getSizeMethod, ln)
} }
prms, err = client.ArrayFromStackItem(prms[0]) prms, err = client.ArrayFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get stack items of estimation fields from stack item (%s)", c.getSizeMethod) return nil, fmt.Errorf("could not get stack items of estimation fields from stack item (%s): %w", c.getSizeMethod, err)
} else if ln := len(prms); ln != 2 { } else if ln := len(prms); ln != 2 {
return nil, errors.Errorf("unexpected stack item count of estimations fields (%s)", c.getSizeMethod) return nil, fmt.Errorf("unexpected stack item count of estimations fields (%s)", c.getSizeMethod)
} }
es := Estimations{} es := Estimations{}
es.ContainerID, err = client.BytesFromStackItem(prms[0]) es.ContainerID, err = client.BytesFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get container ID byte array from stack item (%s)", c.getSizeMethod) return nil, fmt.Errorf("could not get container ID byte array from stack item (%s): %w", c.getSizeMethod, err)
} }
prms, err = client.ArrayFromStackItem(prms[1]) prms, err = client.ArrayFromStackItem(prms[1])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get estimation list array from stack item (%s)", c.getSizeMethod) return nil, fmt.Errorf("could not get estimation list array from stack item (%s): %w", c.getSizeMethod, err)
} }
es.Estimations = make([]Estimation, 0, len(prms)) es.Estimations = make([]Estimation, 0, len(prms))
@ -181,21 +187,21 @@ func (c *Client) GetContainerSize(args GetSizeArgs) (*GetSizeValues, error) {
for i := range prms { for i := range prms {
arr, err := client.ArrayFromStackItem(prms[i]) arr, err := client.ArrayFromStackItem(prms[i])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get estimation struct from stack item (%s)", c.getSizeMethod) return nil, fmt.Errorf("could not get estimation struct from stack item (%s): %w", c.getSizeMethod, err)
} else if ln := len(arr); ln != 2 { } else if ln := len(arr); ln != 2 {
return nil, errors.Errorf("unexpected stack item count of estimation fields (%s)", c.getSizeMethod) return nil, fmt.Errorf("unexpected stack item count of estimation fields (%s)", c.getSizeMethod)
} }
e := Estimation{} e := Estimation{}
e.Reporter, err = client.BytesFromStackItem(arr[0]) e.Reporter, err = client.BytesFromStackItem(arr[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get reporter byte array from stack item (%s)", c.getSizeMethod) return nil, fmt.Errorf("could not get reporter byte array from stack item (%s): %w", c.getSizeMethod, err)
} }
e.Size, err = client.IntFromStackItem(arr[1]) e.Size, err = client.IntFromStackItem(arr[1])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get estimation size from stack item (%s)", c.getSizeMethod) return nil, fmt.Errorf("could not get estimation size from stack item (%s): %w", c.getSizeMethod, err)
} }
es.Estimations = append(es.Estimations, e) es.Estimations = append(es.Estimations, e)

View file

@ -1,7 +1,7 @@
package container package container
import ( import (
"github.com/pkg/errors" "fmt"
) )
// PutArgs groups the arguments // PutArgs groups the arguments
@ -35,10 +35,15 @@ func (p *PutArgs) SetSignature(v []byte) {
// Put invokes the call of put container method // Put invokes the call of put container method
// of NeoFS Container contract. // of NeoFS Container contract.
func (c *Client) Put(args PutArgs) error { func (c *Client) Put(args PutArgs) error {
return errors.Wrapf(c.client.Invoke( err := c.client.Invoke(
c.putMethod, c.putMethod,
args.cnr, args.cnr,
args.sig, args.sig,
args.publicKey, args.publicKey,
), "could not invoke method (%s)", c.putMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.putMethod, err)
}
return nil
} }

View file

@ -2,13 +2,14 @@ package wrapper
import ( import (
"crypto/sha256" "crypto/sha256"
"errors"
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/pkg/owner"
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs" v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
core "github.com/nspcc-dev/neofs-node/pkg/core/container" core "github.com/nspcc-dev/neofs-node/pkg/core/container"
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/pkg/errors"
) )
var ( var (
@ -34,7 +35,7 @@ func (w *Wrapper) Put(cnr *container.Container, pubKey, signature []byte) (*cont
data, err := cnr.Marshal() data, err := cnr.Marshal()
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't marshal container") return nil, fmt.Errorf("can't marshal container: %w", err)
} }
id.SetSHA256(sha256.Sum256(data)) id.SetSHA256(sha256.Sum256(data))
@ -79,7 +80,7 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) {
cnr := container.New() cnr := container.New()
if err := cnr.Unmarshal(rpcAnswer.Container()); err != nil { if err := cnr.Unmarshal(rpcAnswer.Container()); err != nil {
// use other major version if there any // use other major version if there any
return nil, errors.Wrap(err, "can't unmarshal container") return nil, fmt.Errorf("can't unmarshal container: %w", err)
} }
return cnr, nil return cnr, nil

View file

@ -1,12 +1,13 @@
package wrapper package wrapper
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container" containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/container"
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/pkg/errors"
) )
// GetEACL reads the extended ACL table from NeoFS system // GetEACL reads the extended ACL table from NeoFS system
@ -65,7 +66,7 @@ func (w *Wrapper) PutEACL(table *eacl.Table, signature []byte) error {
data, err := table.Marshal() data, err := table.Marshal()
if err != nil { if err != nil {
return errors.Wrap(err, "can't marshal eacl table") return fmt.Errorf("can't marshal eacl table: %w", err)
} }
args.SetEACL(data) args.SetEACL(data)

View file

@ -1,7 +1,7 @@
package netmap package netmap
import ( import (
"github.com/pkg/errors" "fmt"
) )
// AddPeerArgs groups the arguments // AddPeerArgs groups the arguments
@ -18,10 +18,8 @@ func (a *AddPeerArgs) SetInfo(v []byte) {
// AddPeer invokes the call of add peer method // AddPeer invokes the call of add peer method
// of NeoFS Netmap contract. // of NeoFS Netmap contract.
func (c *Client) AddPeer(args AddPeerArgs) error { func (c *Client) AddPeer(args AddPeerArgs) error {
info := args.info if err := c.client.Invoke(c.addPeerMethod, args.info); err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.addPeerMethod, err)
return errors.Wrapf(c.client.Invoke( }
c.addPeerMethod, return nil
info,
), "could not invoke method (%s)", c.addPeerMethod)
} }

View file

@ -1,9 +1,10 @@
package netmap package netmap
import ( import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// ConfigArgs groups the arguments // ConfigArgs groups the arguments
@ -36,19 +37,18 @@ func (c *Client) Config(args ConfigArgs, assert func(stackitem.Item) (interface{
args.key, args.key,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, return nil, fmt.Errorf("could not perform test invocation (%s): %w",
"could not perform test invocation (%s)", c.configMethod, err)
c.configMethod)
} }
if ln := len(items); ln != 1 { if ln := len(items); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", return nil, fmt.Errorf("unexpected stack item count (%s): %d",
c.configMethod, ln) c.configMethod, ln)
} }
val, err := assert(items[0]) val, err := assert(items[0])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "value type assertion failed") return nil, fmt.Errorf("value type assertion failed: %w", err)
} }
return &ConfigValues{ return &ConfigValues{

View file

@ -1,8 +1,9 @@
package netmap package netmap
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// EpochArgs groups the arguments // EpochArgs groups the arguments
@ -28,19 +29,18 @@ func (c *Client) Epoch(_ EpochArgs) (*EpochValues, error) {
c.epochMethod, c.epochMethod,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, return nil, fmt.Errorf("could not perform test invocation (%s): %w",
"could not perform test invocation (%s)", c.epochMethod, err)
c.epochMethod)
} }
if ln := len(items); ln != 1 { if ln := len(items); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", return nil, fmt.Errorf("unexpected stack item count (%s): %d",
c.epochMethod, ln) c.epochMethod, ln)
} }
num, err := client.IntFromStackItem(items[0]) num, err := client.IntFromStackItem(items[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get number from stack item (%s)", c.epochMethod) return nil, fmt.Errorf("could not get number from stack item (%s): %w", c.epochMethod, err)
} }
return &EpochValues{ return &EpochValues{

View file

@ -1,9 +1,10 @@
package netmap package netmap
import ( import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// GetNetMapArgs groups the arguments // GetNetMapArgs groups the arguments
@ -61,9 +62,8 @@ func (c *Client) NetMap(_ GetNetMapArgs) (*GetNetMapValues, error) {
c.netMapMethod, c.netMapMethod,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, return nil, fmt.Errorf("could not perform test invocation (%s): %w",
"could not perform test invocation (%s)", c.netMapMethod, err)
c.netMapMethod)
} }
return peersFromStackItems(prms, c.netMapMethod) return peersFromStackItems(prms, c.netMapMethod)
@ -78,9 +78,8 @@ func (c *Client) Snapshot(a GetSnapshotArgs) (*GetNetMapValues, error) {
int64(a.diff), int64(a.diff),
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, return nil, fmt.Errorf("could not perform test invocation (%s): %w",
"could not perform test invocation (%s)", c.netMapMethod, err)
c.netMapMethod)
} }
return peersFromStackItems(prms, c.snapshotMethod) return peersFromStackItems(prms, c.snapshotMethod)
@ -94,9 +93,8 @@ func (c *Client) EpochSnapshot(args EpochSnapshotArgs) (*EpochSnapshotValues, er
int64(args.epoch), int64(args.epoch),
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, return nil, fmt.Errorf("could not perform test invocation (%s): %w",
"could not perform test invocation (%s)", c.epochSnapshotMethod, err)
c.epochSnapshotMethod)
} }
nmVals, err := peersFromStackItems(prms, c.epochSnapshotMethod) nmVals, err := peersFromStackItems(prms, c.epochSnapshotMethod)
@ -111,15 +109,14 @@ func (c *Client) EpochSnapshot(args EpochSnapshotArgs) (*EpochSnapshotValues, er
func peersFromStackItems(stack []stackitem.Item, method string) (*GetNetMapValues, error) { func peersFromStackItems(stack []stackitem.Item, method string) (*GetNetMapValues, error) {
if ln := len(stack); ln != 1 { if ln := len(stack); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", return nil, fmt.Errorf("unexpected stack item count (%s): %d",
method, ln) method, ln)
} }
peers, err := client.ArrayFromStackItem(stack[0]) peers, err := client.ArrayFromStackItem(stack[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w",
"could not get stack item array from stack item (%s)", method, err)
method)
} }
res := &GetNetMapValues{ res := &GetNetMapValues{
@ -129,8 +126,7 @@ func peersFromStackItems(stack []stackitem.Item, method string) (*GetNetMapValue
for i := range peers { for i := range peers {
peer, err := peerInfoFromStackItem(peers[i]) peer, err := peerInfoFromStackItem(peers[i])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, return nil, fmt.Errorf("could not parse stack item (Peer #%d): %w", i, err)
"could not parse stack item (Peer #%d)", i)
} }
res.peers = append(res.peers, peer) res.peers = append(res.peers, peer)
@ -142,9 +138,9 @@ func peersFromStackItems(stack []stackitem.Item, method string) (*GetNetMapValue
func peerInfoFromStackItem(prm stackitem.Item) ([]byte, error) { func peerInfoFromStackItem(prm stackitem.Item) ([]byte, error) {
prms, err := client.ArrayFromStackItem(prm) prms, err := client.ArrayFromStackItem(prm)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get stack item array (PeerInfo)") return nil, fmt.Errorf("could not get stack item array (PeerInfo): %w", err)
} else if ln := len(prms); ln != nodeInfoFixedPrmNumber { } else if ln := len(prms); ln != nodeInfoFixedPrmNumber {
return nil, errors.Errorf("unexpected stack item count (PeerInfo): expected %d, has %d", 1, ln) return nil, fmt.Errorf("unexpected stack item count (PeerInfo): expected %d, has %d", 1, ln)
} }
return client.BytesFromStackItem(prms[0]) return client.BytesFromStackItem(prms[0])

View file

@ -1,6 +1,8 @@
package netmap package netmap
import "github.com/pkg/errors" import (
"fmt"
)
// NewEpochArgs groups the arguments // NewEpochArgs groups the arguments
// of new epoch invocation call. // of new epoch invocation call.
@ -16,8 +18,8 @@ func (a *NewEpochArgs) SetEpochNumber(v int64) {
// NewEpoch invokes the call of new epoch method // NewEpoch invokes the call of new epoch method
// of NeoFS Netmap contract. // of NeoFS Netmap contract.
func (c *Client) NewEpoch(args NewEpochArgs) error { func (c *Client) NewEpoch(args NewEpochArgs) error {
return errors.Wrapf(c.client.Invoke( if err := c.client.Invoke(c.addPeerMethod, args.number); err != nil {
c.addPeerMethod, return fmt.Errorf("could not invoke method (%s): %w", c.newEpochMethod, err)
args.number, }
), "could not invoke method (%s)", c.newEpochMethod) return nil
} }

View file

@ -1,7 +1,7 @@
package netmap package netmap
import ( import (
"github.com/pkg/errors" "fmt"
) )
// UpdateStateArgs groups the arguments // UpdateStateArgs groups the arguments
@ -26,9 +26,15 @@ func (u *UpdateStateArgs) SetState(v int64) {
// UpdateState invokes the call of update state method // UpdateState invokes the call of update state method
// of NeoFS Netmap contract. // of NeoFS Netmap contract.
func (c *Client) UpdateState(args UpdateStateArgs) error { func (c *Client) UpdateState(args UpdateStateArgs) error {
return errors.Wrapf(c.client.Invoke( err := c.client.Invoke(
c.updateStateMethod, c.updateStateMethod,
args.state, args.state,
args.key, args.key,
), "could not invoke method (%s)", c.updateStateMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.updateStateMethod, err)
}
return nil
} }

View file

@ -1,8 +1,10 @@
package wrapper package wrapper
import ( import (
"errors"
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors"
) )
// AddPeer registers peer in NeoFS network through // AddPeer registers peer in NeoFS network through
@ -20,8 +22,8 @@ func (w *Wrapper) AddPeer(nodeInfo *netmap.NodeInfo) error {
args := netmap.AddPeerArgs{} args := netmap.AddPeerArgs{}
args.SetInfo(rawNodeInfo) args.SetInfo(rawNodeInfo)
return errors.Wrap( if err := w.client.AddPeer(args); err != nil {
w.client.AddPeer(args), return fmt.Errorf("could not invoke smart contract: %w", err)
"could not invoke smart contract", }
) return nil
} }

View file

@ -1,10 +1,10 @@
package wrapper package wrapper
import ( import (
"fmt"
"strconv" "strconv"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors"
) )
const ( const (
@ -24,7 +24,7 @@ const (
func (w *Wrapper) MaxObjectSize() (uint64, error) { func (w *Wrapper) MaxObjectSize() (uint64, error) {
objectSize, err := w.readUInt64Config(maxObjectSizeConfig) objectSize, err := w.readUInt64Config(maxObjectSizeConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get epoch number", w) return 0, fmt.Errorf("(%T) could not get epoch number: %w", w, err)
} }
return objectSize, nil return objectSize, nil
@ -35,7 +35,7 @@ func (w *Wrapper) MaxObjectSize() (uint64, error) {
func (w *Wrapper) BasicIncomeRate() (uint64, error) { func (w *Wrapper) BasicIncomeRate() (uint64, error) {
rate, err := w.readUInt64Config(basicIncomeRateConfig) rate, err := w.readUInt64Config(basicIncomeRateConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get basic income rate", w) return 0, fmt.Errorf("(%T) could not get basic income rate: %w", w, err)
} }
return rate, nil return rate, nil
@ -46,7 +46,7 @@ func (w *Wrapper) BasicIncomeRate() (uint64, error) {
func (w *Wrapper) AuditFee() (uint64, error) { func (w *Wrapper) AuditFee() (uint64, error) {
fee, err := w.readUInt64Config(auditFeeConfig) fee, err := w.readUInt64Config(auditFeeConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get audit fee", w) return 0, fmt.Errorf("(%T) could not get audit fee: %w", w, err)
} }
return fee, nil return fee, nil
@ -56,7 +56,7 @@ func (w *Wrapper) AuditFee() (uint64, error) {
func (w *Wrapper) EpochDuration() (uint64, error) { func (w *Wrapper) EpochDuration() (uint64, error) {
epochDuration, err := w.readUInt64Config(epochDurationConfig) epochDuration, err := w.readUInt64Config(epochDurationConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get epoch duration", w) return 0, fmt.Errorf("(%T) could not get epoch duration: %w", w, err)
} }
return epochDuration, nil return epochDuration, nil
@ -67,7 +67,7 @@ func (w *Wrapper) EpochDuration() (uint64, error) {
func (w *Wrapper) ContainerFee() (uint64, error) { func (w *Wrapper) ContainerFee() (uint64, error) {
fee, err := w.readUInt64Config(containerFeeConfig) fee, err := w.readUInt64Config(containerFeeConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get container fee", w) return 0, fmt.Errorf("(%T) could not get container fee: %w", w, err)
} }
return fee, nil return fee, nil
@ -78,7 +78,7 @@ func (w *Wrapper) ContainerFee() (uint64, error) {
func (w *Wrapper) EigenTrustIterations() (uint64, error) { func (w *Wrapper) EigenTrustIterations() (uint64, error) {
iterations, err := w.readUInt64Config(etIterationsConfig) iterations, err := w.readUInt64Config(etIterationsConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get eigen trust iterations", w) return 0, fmt.Errorf("(%T) could not get eigen trust iterations: %w", w, err)
} }
return iterations, nil return iterations, nil
@ -89,7 +89,7 @@ func (w *Wrapper) EigenTrustIterations() (uint64, error) {
func (w *Wrapper) EigenTrustAlpha() (float64, error) { func (w *Wrapper) EigenTrustAlpha() (float64, error) {
strAlpha, err := w.readStringConfig(etAlphaConfig) strAlpha, err := w.readStringConfig(etAlphaConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get eigen trust alpha", w) return 0, fmt.Errorf("(%T) could not get eigen trust alpha: %w", w, err)
} }
return strconv.ParseFloat(strAlpha, 64) return strconv.ParseFloat(strAlpha, 64)
@ -100,7 +100,7 @@ func (w *Wrapper) EigenTrustAlpha() (float64, error) {
func (w *Wrapper) InnerRingCandidateFee() (uint64, error) { func (w *Wrapper) InnerRingCandidateFee() (uint64, error) {
fee, err := w.readUInt64Config(irCandidateFeeConfig) fee, err := w.readUInt64Config(irCandidateFeeConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get inner ring candidate fee", w) return 0, fmt.Errorf("(%T) could not get inner ring candidate fee: %w", w, err)
} }
return fee, nil return fee, nil
@ -111,7 +111,7 @@ func (w *Wrapper) InnerRingCandidateFee() (uint64, error) {
func (w *Wrapper) WithdrawFee() (uint64, error) { func (w *Wrapper) WithdrawFee() (uint64, error) {
fee, err := w.readUInt64Config(withdrawFeeConfig) fee, err := w.readUInt64Config(withdrawFeeConfig)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get withdraw fee", w) return 0, fmt.Errorf("(%T) could not get withdraw fee: %w", w, err)
} }
return fee, nil return fee, nil
@ -130,7 +130,7 @@ func (w *Wrapper) readUInt64Config(key string) (uint64, error) {
numeric, ok := v.(int64) numeric, ok := v.(int64)
if !ok { if !ok {
return 0, errors.Errorf("(%T) invalid value type %T", w, v) return 0, fmt.Errorf("(%T) invalid value type %T", w, v)
} }
return uint64(numeric), nil return uint64(numeric), nil
@ -149,7 +149,7 @@ func (w *Wrapper) readStringConfig(key string) (string, error) {
str, ok := v.(string) str, ok := v.(string)
if !ok { if !ok {
return "", errors.Errorf("(%T) invalid value type %T", w, v) return "", fmt.Errorf("(%T) invalid value type %T", w, v)
} }
return str, nil return str, nil

View file

@ -1,8 +1,9 @@
package wrapper package wrapper
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors"
) )
// Epoch receives number of current NeoFS epoch // Epoch receives number of current NeoFS epoch
@ -12,7 +13,7 @@ func (w *Wrapper) Epoch() (uint64, error) {
vals, err := w.client.Epoch(args) vals, err := w.client.Epoch(args)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get epoch number", w) return 0, fmt.Errorf("(%T) could not get epoch number: %w", w, err)
} }
return uint64(vals.Number()), nil return uint64(vals.Number()), nil

View file

@ -1,9 +1,10 @@
package wrapper package wrapper
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" client "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors"
) )
// GetNetMap receives information list about storage nodes // GetNetMap receives information list about storage nodes
@ -43,7 +44,7 @@ func unmarshalNetmap(rawPeers [][]byte) (*netmap.Netmap, error) {
for _, peer := range rawPeers { for _, peer := range rawPeers {
nodeInfo := netmap.NewNodeInfo() nodeInfo := netmap.NewNodeInfo()
if err := nodeInfo.Unmarshal(peer); err != nil { if err := nodeInfo.Unmarshal(peer); err != nil {
return nil, errors.Wrap(err, "can't unmarshal peer info") return nil, fmt.Errorf("can't unmarshal peer info: %w", err)
} }
infos = append(infos, *nodeInfo) infos = append(infos, *nodeInfo)

View file

@ -1,9 +1,10 @@
package wrapper package wrapper
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors"
) )
// UpdatePeerState changes peer status through Netmap contract // UpdatePeerState changes peer status through Netmap contract
@ -14,10 +15,8 @@ func (w *Wrapper) UpdatePeerState(key []byte, state netmap.NodeState) error {
args.SetState(int64(state.ToV2())) args.SetState(int64(state.ToV2()))
// invoke smart contract call // invoke smart contract call
// if err := w.client.UpdateState(args); err != nil {
// Note: errors.Wrap returns nil on nil error arg. return fmt.Errorf("could not invoke smart contract: %w", err)
return errors.Wrap( }
w.client.UpdateState(args), return nil
"could not invoke smart contract",
)
} }

View file

@ -1,6 +1,8 @@
package client package client
import ( import (
"errors"
"fmt"
"strings" "strings"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
@ -13,7 +15,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -74,7 +75,7 @@ func (c *Client) EnableNotarySupport(proxy util.Uint160, opts ...NotaryOption) e
notaryContract, err := c.client.GetNativeContractHash(nativenames.Notary) notaryContract, err := c.client.GetNativeContractHash(nativenames.Notary)
if err != nil { if err != nil {
return errors.Wrap(err, "can't get notary contract script hash") return fmt.Errorf("can't get notary contract script hash: %w", err)
} }
c.notary = &notary{ c.notary = &notary{
@ -110,7 +111,7 @@ func (c *Client) DepositNotary(amount fixedn.Fixed8, delta uint32) (util.Uint256
bc, err := c.client.GetBlockCount() bc, err := c.client.GetBlockCount()
if err != nil { if err != nil {
return util.Uint256{}, errors.Wrap(err, "can't get blockchain height") return util.Uint256{}, fmt.Errorf("can't get blockchain height: %w", err)
} }
txHash, err := c.client.TransferNEP17( txHash, err := c.client.TransferNEP17(
@ -123,7 +124,7 @@ func (c *Client) DepositNotary(amount fixedn.Fixed8, delta uint32) (util.Uint256
nil, nil,
) )
if err != nil { if err != nil {
return util.Uint256{}, errors.Wrap(err, "can't make notary deposit") return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err)
} }
c.logger.Debug("notary deposit invoke", c.logger.Debug("notary deposit invoke",
@ -148,16 +149,16 @@ func (c *Client) GetNotaryDeposit() (int64, error) {
items, err := c.TestInvoke(c.notary.notary, notaryBalanceOfMethod, sh) items, err := c.TestInvoke(c.notary.notary, notaryBalanceOfMethod, sh)
if err != nil { if err != nil {
return 0, errors.Wrap(err, notaryBalanceErrMsg) return 0, fmt.Errorf("%v: %w", notaryBalanceErrMsg, err)
} }
if len(items) != 1 { if len(items) != 1 {
return 0, errors.Wrap(errUnexpectedItems, notaryBalanceErrMsg) return 0, fmt.Errorf("%v: %w", notaryBalanceErrMsg, errUnexpectedItems)
} }
bigIntDeposit, err := items[0].TryInteger() bigIntDeposit, err := items[0].TryInteger()
if err != nil { if err != nil {
return 0, errors.Wrap(err, notaryBalanceErrMsg) return 0, fmt.Errorf("%v: %w", notaryBalanceErrMsg, err)
} }
return bigIntDeposit.Int64(), nil return bigIntDeposit.Int64(), nil
@ -328,7 +329,7 @@ func (c *Client) notaryCosigners(ir []*keys.PublicKey, committee bool) ([]transa
multisigScript, err := sc.CreateMultiSigRedeemScript(m, ir) multisigScript, err := sc.CreateMultiSigRedeemScript(m, ir)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't create ir multisig redeem script") return nil, fmt.Errorf("can't create ir multisig redeem script: %w", err)
} }
s = append(s, transaction.Signer{ s = append(s, transaction.Signer{
@ -412,7 +413,7 @@ func (c *Client) notaryMultisigAccount(ir []*keys.PublicKey, committee bool) (*w
err := multisigAccount.ConvertMultisig(m, ir) err := multisigAccount.ConvertMultisig(m, ir)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't make inner ring multisig wallet") return nil, fmt.Errorf("can't make inner ring multisig wallet: %w", err)
} }
return multisigAccount, nil return multisigAccount, nil
@ -421,7 +422,7 @@ func (c *Client) notaryMultisigAccount(ir []*keys.PublicKey, committee bool) (*w
func (c *Client) notaryTxValidationLimit() (uint32, error) { func (c *Client) notaryTxValidationLimit() (uint32, error) {
bc, err := c.client.GetBlockCount() bc, err := c.client.GetBlockCount()
if err != nil { if err != nil {
return 0, errors.Wrap(err, "can't get current blockchain height") return 0, fmt.Errorf("can't get current blockchain height: %w", err)
} }
min := bc + c.notary.txValidTime min := bc + c.notary.txValidTime

View file

@ -1,9 +1,10 @@
package reputation package reputation
import ( import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// GetArgs groups the arguments of "get reputation value" test invocation. // GetArgs groups the arguments of "get reputation value" test invocation.
@ -52,7 +53,7 @@ func (c *Client) Get(args GetArgs) (*GetResult, error) {
args.peerID, args.peerID,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getMethod, err)
} }
return parseReputations(prms, c.getMethod) return parseReputations(prms, c.getMethod)
@ -66,7 +67,7 @@ func (c *Client) GetByID(args GetByIDArgs) (*GetResult, error) {
args.id, args.id,
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getByIDMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getByIDMethod, err)
} }
return parseReputations(prms, c.getByIDMethod) return parseReputations(prms, c.getByIDMethod)
@ -74,12 +75,12 @@ func (c *Client) GetByID(args GetByIDArgs) (*GetResult, error) {
func parseReputations(items []stackitem.Item, method string) (*GetResult, error) { func parseReputations(items []stackitem.Item, method string) (*GetResult, error) {
if ln := len(items); ln != 1 { if ln := len(items); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", method, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", method, ln)
} }
items, err := client.ArrayFromStackItem(items[0]) items, err := client.ArrayFromStackItem(items[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", method) return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", method, err)
} }
res := &GetResult{ res := &GetResult{
@ -89,7 +90,7 @@ func parseReputations(items []stackitem.Item, method string) (*GetResult, error)
for i := range items { for i := range items {
rawReputation, err := client.BytesFromStackItem(items[i]) rawReputation, err := client.BytesFromStackItem(items[i])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", method) return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", method, err)
} }
res.reputations = append(res.reputations, rawReputation) res.reputations = append(res.reputations, rawReputation)

View file

@ -1,8 +1,9 @@
package reputation package reputation
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
) )
// ListByEpochArgs groups the arguments of // ListByEpochArgs groups the arguments of
@ -35,14 +36,14 @@ func (c *Client) ListByEpoch(args ListByEpochArgs) (*ListByEpochResult, error) {
int64(args.epoch), int64(args.epoch),
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listByEpochMethod) return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listByEpochMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.listByEpochMethod, ln) return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.listByEpochMethod, ln)
} }
items, err := client.ArrayFromStackItem(prms[0]) items, err := client.ArrayFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", c.listByEpochMethod) return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", c.listByEpochMethod, err)
} }
res := &ListByEpochResult{ res := &ListByEpochResult{
@ -52,7 +53,7 @@ func (c *Client) ListByEpoch(args ListByEpochArgs) (*ListByEpochResult, error) {
for i := range items { for i := range items {
rawReputation, err := client.BytesFromStackItem(items[i]) rawReputation, err := client.BytesFromStackItem(items[i])
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", c.listByEpochMethod) return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.listByEpochMethod, err)
} }
res.ids = append(res.ids, rawReputation) res.ids = append(res.ids, rawReputation)

View file

@ -1,7 +1,7 @@
package reputation package reputation
import ( import (
"github.com/pkg/errors" "fmt"
) )
// PutArgs groups the arguments of "put reputation value" invocation call. // PutArgs groups the arguments of "put reputation value" invocation call.
@ -28,21 +28,31 @@ func (p *PutArgs) SetValue(v []byte) {
// Put invokes direct call of "put reputation value" method of reputation contract. // Put invokes direct call of "put reputation value" method of reputation contract.
func (c *Client) Put(args PutArgs) error { func (c *Client) Put(args PutArgs) error {
return errors.Wrapf(c.client.Invoke( err := c.client.Invoke(
c.putMethod, c.putMethod,
int64(args.epoch), int64(args.epoch),
args.peerID, args.peerID,
args.value, args.value,
), "could not invoke method (%s)", c.putMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.putMethod, err)
}
return nil
} }
// PutViaNotary invokes notary call of "put reputation value" method of // PutViaNotary invokes notary call of "put reputation value" method of
// reputation contract. // reputation contract.
func (c *Client) PutViaNotary(args PutArgs) error { func (c *Client) PutViaNotary(args PutArgs) error {
return errors.Wrapf(c.client.NotaryInvoke( err := c.client.NotaryInvoke(
c.putMethod, c.putMethod,
int64(args.epoch), int64(args.epoch),
args.peerID, args.peerID,
args.value, args.value,
), "could not invoke method (%s)", c.putMethod) )
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.putMethod, err)
}
return err
} }

View file

@ -1,9 +1,10 @@
package wrapper package wrapper
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/reputation" "github.com/nspcc-dev/neofs-api-go/pkg/reputation"
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation" reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
"github.com/pkg/errors"
) )
type ( type (
@ -83,7 +84,7 @@ func parseGetResult(data *reputationClient.GetResult) (*GetResult, error) {
err := r.Unmarshal(rawReputations[i]) err := r.Unmarshal(rawReputations[i])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "can't unmarshal global trust value") return nil, fmt.Errorf("can't unmarshal global trust value: %w", err)
} }
reputations = append(reputations, r) reputations = append(reputations, r)

View file

@ -1,9 +1,10 @@
package wrapper package wrapper
import ( import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/reputation" "github.com/nspcc-dev/neofs-api-go/pkg/reputation"
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation" reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
"github.com/pkg/errors"
) )
type ( type (
@ -56,7 +57,7 @@ func preparePutArgs(v PutArgs) (reputationClient.PutArgs, error) {
data, err := v.value.Marshal() data, err := v.value.Marshal()
if err != nil { if err != nil {
return args, errors.Wrap(err, "can't marshal global trust value") return args, fmt.Errorf("can't marshal global trust value: %w", err)
} }
args.SetEpoch(v.epoch) args.SetEpoch(v.epoch)

Some files were not shown because too many files have changed in this diff Show more