[#1369] version: Upgrade SDK package

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-05-11 17:58:52 +03:00 committed by LeL
parent 7a57d7b076
commit 088df0e2a9
13 changed files with 60 additions and 38 deletions

View file

@ -171,8 +171,10 @@ It will be stored in sidechain when inner ring will accepts it.`,
idOwner = owner.NewIDFromPublicKey(&key.PublicKey)
}
ver := versionSDK.Current()
cnr := container.New()
cnr.SetVersion(versionSDK.Current())
cnr.SetVersion(&ver)
cnr.SetPlacementPolicy(placementPolicy)
cnr.SetBasicACL(basicACL)
cnr.SetAttributes(attributes)
@ -807,9 +809,8 @@ func parseEACL(eaclPath string) (*eacl.Table, error) {
}
func validateAndFixEACLVersion(table *eacl.Table) {
v := table.Version()
if !version.IsValid(v) {
table.SetVersion(*versionSDK.Current())
if !version.IsValid(table.Version()) {
table.SetVersion(versionSDK.Current())
}
}

View file

@ -10,6 +10,7 @@ import (
"strconv"
"time"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-node/pkg/util/keyer"
locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db"
airportsdb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db/airports"
@ -427,7 +428,11 @@ func completeBearerToken(btok *token.BearerToken) error {
if v2 := btok.ToV2(); v2 != nil {
// set eACL table version, because it usually omitted
table := v2.GetBody().GetEACL()
table.SetVersion(version.Current().ToV2())
var ver refs.Version
version.Current().WriteToV2(&ver)
table.SetVersion(&ver)
} else {
return errors.New("unsupported bearer token version")
}

View file

@ -79,7 +79,7 @@ type cfg struct {
ownerIDFromKey *owner.ID // owner ID calculated from key
apiVersion *version.Version
apiVersion version.Version
cfgGRPC cfgGRPC

2
go.mod
View file

@ -19,7 +19,7 @@ require (
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af // indirect
github.com/nspcc-dev/neofs-api-go/v2 v2.12.1
github.com/nspcc-dev/neofs-contract v0.14.2
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220412151250-3e75660802ae
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220413072812-c961aea14446
github.com/nspcc-dev/tzhash v1.5.2
github.com/panjf2000/ants/v2 v2.4.0
github.com/paulmach/orb v0.2.2

4
go.sum
View file

@ -405,8 +405,8 @@ github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnB
github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659/go.mod h1:/jay1lr3w7NQd/VDBkEhkJmDmyPNsu4W+QV2obsUV40=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220412151250-3e75660802ae h1:xcoEwEwZXu784Re1PPE35vm1A4+sUCVgMuGFqQPnN1Q=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220412151250-3e75660802ae/go.mod h1:Hl7a1l0ntZ4b1ZABpGX6fuAuFS3c6+hyMCUNVvZv/w4=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220413072812-c961aea14446 h1:B8bTBqZvDJKKes+W3C/car7RARgAuvMZNx361zCXPDk=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220413072812-c961aea14446/go.mod h1:Hl7a1l0ntZ4b1ZABpGX6fuAuFS3c6+hyMCUNVvZv/w4=
github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE=
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=

View file

@ -22,7 +22,8 @@ func TestCheckFormat(t *testing.T) {
require.Error(t, CheckFormat(c))
c.SetVersion(version.Current())
ver := version.Current()
c.SetVersion(&ver)
require.Error(t, CheckFormat(c))

View file

@ -9,7 +9,7 @@ import (
)
func TestIsValid(t *testing.T) {
require.True(t, version.IsValid(*versionSDK.Current()))
require.True(t, version.IsValid(versionSDK.Current()))
var v versionSDK.Version

View file

@ -148,9 +148,9 @@ func testOID() *oidSDK.ID {
}
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
version := version.New()
version.SetMajor(2)
version.SetMinor(1)
var ver version.Version
ver.SetMajor(2)
ver.SetMinor(1)
csum := new(checksum.Checksum)
csum.SetSHA256(sha256.Sum256(owner.PublicKeyToIDBytes(&test.DecodeKey(-1).PublicKey)))
@ -162,7 +162,7 @@ func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
obj.SetID(testOID())
obj.SetOwnerID(ownertest.ID())
obj.SetContainerID(cid)
obj.SetVersion(version)
obj.SetVersion(&ver)
obj.SetPayloadChecksum(csum)
obj.SetPayloadHomomorphicHash(csumTZ)
obj.SetPayload([]byte{1, 2, 3, 4, 5})

View file

@ -68,9 +68,9 @@ func generateObject(t testing.TB) *object.Object {
}
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
version := version.New()
version.SetMajor(2)
version.SetMinor(1)
var ver version.Version
ver.SetMajor(2)
ver.SetMinor(1)
csum := new(checksum.Checksum)
csum.SetSHA256(sha256.Sum256(owner.PublicKeyToIDBytes(&test.DecodeKey(-1).PublicKey)))
@ -82,7 +82,7 @@ func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
obj.SetID(testOID())
obj.SetOwnerID(ownertest.ID())
obj.SetContainerID(cid)
obj.SetVersion(version)
obj.SetVersion(&ver)
obj.SetPayloadChecksum(csum)
obj.SetPayloadHomomorphicHash(csumTZ)
obj.SetPayload([]byte{1, 2, 3, 4, 5})

View file

@ -82,9 +82,9 @@ func generateObjectWithCID(t *testing.T, cid *cid.ID) *object.Object {
}
func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
version := version.New()
version.SetMajor(2)
version.SetMinor(1)
var ver version.Version
ver.SetMajor(2)
ver.SetMinor(1)
csum := new(checksum.Checksum)
csum.SetSHA256(sha256.Sum256(data))
@ -96,7 +96,7 @@ func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
obj.SetID(generateOID())
obj.SetOwnerID(ownertest.ID())
obj.SetContainerID(cid)
obj.SetVersion(version)
obj.SetVersion(&ver)
obj.SetPayload(data)
obj.SetPayloadChecksum(csum)
obj.SetPayloadHomomorphicHash(csumTZ)

View file

@ -2,14 +2,17 @@ package netmap
import (
"context"
"errors"
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-sdk-go/version"
"github.com/nspcc-dev/neofs-node/pkg/core/version"
versionsdk "github.com/nspcc-dev/neofs-sdk-go/version"
)
type executorSvc struct {
version *version.Version
version refs.Version
state NodeState
netInfo NetworkInfo
@ -32,23 +35,32 @@ type NetworkInfo interface {
Dump(*refs.Version) (*netmap.NetworkInfo, error)
}
func NewExecutionService(s NodeState, v *version.Version, netInfo NetworkInfo) Server {
if s == nil || v == nil || netInfo == nil {
func NewExecutionService(s NodeState, v versionsdk.Version, netInfo NetworkInfo) Server {
if s == nil || netInfo == nil || !version.IsValid(v) {
// this should never happen, otherwise it programmers bug
panic("can't create netmap execution service")
}
return &executorSvc{
version: v,
res := &executorSvc{
state: s,
netInfo: netInfo,
}
v.WriteToV2(&res.version)
return res
}
func (s *executorSvc) LocalNodeInfo(
_ context.Context,
req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
ver := version.NewFromV2(req.GetMetaHeader().GetVersion())
verV2 := req.GetMetaHeader().GetVersion()
if verV2 == nil {
return nil, errors.New("missing version")
}
var ver versionsdk.Version
ver.ReadFromV2(*verV2)
ni, err := s.state.LocalNodeInfo()
if err != nil {
@ -69,7 +81,7 @@ func (s *executorSvc) LocalNodeInfo(
}
body := new(netmap.LocalNodeInfoResponseBody)
body.SetVersion(s.version.ToV2())
body.SetVersion(&s.version)
body.SetNodeInfo(ni)
resp := new(netmap.LocalNodeInfoResponse)

View file

@ -63,8 +63,9 @@ func (f *formatter) Write(p []byte) (n int, err error) {
func (f *formatter) Close() (*AccessIdentifiers, error) {
curEpoch := f.prm.NetworkState.CurrentEpoch()
ver := version.Current()
f.obj.SetVersion(version.Current())
f.obj.SetVersion(&ver)
f.obj.SetPayloadSize(f.sz)
f.obj.SetSessionToken(f.prm.SessionToken)
f.obj.SetCreationEpoch(curEpoch)

View file

@ -18,15 +18,17 @@ type Service struct {
type Option func(*cfg)
type cfg struct {
version *refs.Version
version refs.Version
state netmap.State
}
func defaultCfg() *cfg {
return &cfg{
version: version.Current().ToV2(),
}
var c cfg
version.Current().WriteToV2(&c.version)
return &c
}
// NewService creates, initializes and returns Service instance.
@ -44,7 +46,7 @@ func NewService(opts ...Option) *Service {
func setMeta(resp util.ResponseMessage, cfg *cfg) {
meta := new(session.ResponseMetaHeader)
meta.SetVersion(cfg.version)
meta.SetVersion(&cfg.version)
meta.SetTTL(1) // FIXME: #1160 TTL must be calculated
meta.SetEpoch(cfg.state.CurrentEpoch())