forked from TrueCloudLab/frostfs-node
[#1369] version: Upgrade SDK package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7a57d7b076
commit
088df0e2a9
13 changed files with 60 additions and 38 deletions
|
@ -171,8 +171,10 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
idOwner = owner.NewIDFromPublicKey(&key.PublicKey)
|
idOwner = owner.NewIDFromPublicKey(&key.PublicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ver := versionSDK.Current()
|
||||||
|
|
||||||
cnr := container.New()
|
cnr := container.New()
|
||||||
cnr.SetVersion(versionSDK.Current())
|
cnr.SetVersion(&ver)
|
||||||
cnr.SetPlacementPolicy(placementPolicy)
|
cnr.SetPlacementPolicy(placementPolicy)
|
||||||
cnr.SetBasicACL(basicACL)
|
cnr.SetBasicACL(basicACL)
|
||||||
cnr.SetAttributes(attributes)
|
cnr.SetAttributes(attributes)
|
||||||
|
@ -807,9 +809,8 @@ func parseEACL(eaclPath string) (*eacl.Table, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateAndFixEACLVersion(table *eacl.Table) {
|
func validateAndFixEACLVersion(table *eacl.Table) {
|
||||||
v := table.Version()
|
if !version.IsValid(table.Version()) {
|
||||||
if !version.IsValid(v) {
|
table.SetVersion(versionSDK.Current())
|
||||||
table.SetVersion(*versionSDK.Current())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/keyer"
|
"github.com/nspcc-dev/neofs-node/pkg/util/keyer"
|
||||||
locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db"
|
locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db"
|
||||||
airportsdb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db/airports"
|
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 {
|
if v2 := btok.ToV2(); v2 != nil {
|
||||||
// set eACL table version, because it usually omitted
|
// set eACL table version, because it usually omitted
|
||||||
table := v2.GetBody().GetEACL()
|
table := v2.GetBody().GetEACL()
|
||||||
table.SetVersion(version.Current().ToV2())
|
|
||||||
|
var ver refs.Version
|
||||||
|
version.Current().WriteToV2(&ver)
|
||||||
|
|
||||||
|
table.SetVersion(&ver)
|
||||||
} else {
|
} else {
|
||||||
return errors.New("unsupported bearer token version")
|
return errors.New("unsupported bearer token version")
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ type cfg struct {
|
||||||
|
|
||||||
ownerIDFromKey *owner.ID // owner ID calculated from key
|
ownerIDFromKey *owner.ID // owner ID calculated from key
|
||||||
|
|
||||||
apiVersion *version.Version
|
apiVersion version.Version
|
||||||
|
|
||||||
cfgGRPC cfgGRPC
|
cfgGRPC cfgGRPC
|
||||||
|
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -19,7 +19,7 @@ require (
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af // indirect
|
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-api-go/v2 v2.12.1
|
||||||
github.com/nspcc-dev/neofs-contract v0.14.2
|
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/nspcc-dev/tzhash v1.5.2
|
||||||
github.com/panjf2000/ants/v2 v2.4.0
|
github.com/panjf2000/ants/v2 v2.4.0
|
||||||
github.com/paulmach/orb v0.2.2
|
github.com/paulmach/orb v0.2.2
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -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-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-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 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.20220413072812-c961aea14446 h1:B8bTBqZvDJKKes+W3C/car7RARgAuvMZNx361zCXPDk=
|
||||||
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/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.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 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE=
|
||||||
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
|
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
|
||||||
|
|
|
@ -22,7 +22,8 @@ func TestCheckFormat(t *testing.T) {
|
||||||
|
|
||||||
require.Error(t, CheckFormat(c))
|
require.Error(t, CheckFormat(c))
|
||||||
|
|
||||||
c.SetVersion(version.Current())
|
ver := version.Current()
|
||||||
|
c.SetVersion(&ver)
|
||||||
|
|
||||||
require.Error(t, CheckFormat(c))
|
require.Error(t, CheckFormat(c))
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsValid(t *testing.T) {
|
func TestIsValid(t *testing.T) {
|
||||||
require.True(t, version.IsValid(*versionSDK.Current()))
|
require.True(t, version.IsValid(versionSDK.Current()))
|
||||||
|
|
||||||
var v versionSDK.Version
|
var v versionSDK.Version
|
||||||
|
|
||||||
|
|
|
@ -148,9 +148,9 @@ func testOID() *oidSDK.ID {
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
||||||
version := version.New()
|
var ver version.Version
|
||||||
version.SetMajor(2)
|
ver.SetMajor(2)
|
||||||
version.SetMinor(1)
|
ver.SetMinor(1)
|
||||||
|
|
||||||
csum := new(checksum.Checksum)
|
csum := new(checksum.Checksum)
|
||||||
csum.SetSHA256(sha256.Sum256(owner.PublicKeyToIDBytes(&test.DecodeKey(-1).PublicKey)))
|
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.SetID(testOID())
|
||||||
obj.SetOwnerID(ownertest.ID())
|
obj.SetOwnerID(ownertest.ID())
|
||||||
obj.SetContainerID(cid)
|
obj.SetContainerID(cid)
|
||||||
obj.SetVersion(version)
|
obj.SetVersion(&ver)
|
||||||
obj.SetPayloadChecksum(csum)
|
obj.SetPayloadChecksum(csum)
|
||||||
obj.SetPayloadHomomorphicHash(csumTZ)
|
obj.SetPayloadHomomorphicHash(csumTZ)
|
||||||
obj.SetPayload([]byte{1, 2, 3, 4, 5})
|
obj.SetPayload([]byte{1, 2, 3, 4, 5})
|
||||||
|
|
|
@ -68,9 +68,9 @@ func generateObject(t testing.TB) *object.Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
||||||
version := version.New()
|
var ver version.Version
|
||||||
version.SetMajor(2)
|
ver.SetMajor(2)
|
||||||
version.SetMinor(1)
|
ver.SetMinor(1)
|
||||||
|
|
||||||
csum := new(checksum.Checksum)
|
csum := new(checksum.Checksum)
|
||||||
csum.SetSHA256(sha256.Sum256(owner.PublicKeyToIDBytes(&test.DecodeKey(-1).PublicKey)))
|
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.SetID(testOID())
|
||||||
obj.SetOwnerID(ownertest.ID())
|
obj.SetOwnerID(ownertest.ID())
|
||||||
obj.SetContainerID(cid)
|
obj.SetContainerID(cid)
|
||||||
obj.SetVersion(version)
|
obj.SetVersion(&ver)
|
||||||
obj.SetPayloadChecksum(csum)
|
obj.SetPayloadChecksum(csum)
|
||||||
obj.SetPayloadHomomorphicHash(csumTZ)
|
obj.SetPayloadHomomorphicHash(csumTZ)
|
||||||
obj.SetPayload([]byte{1, 2, 3, 4, 5})
|
obj.SetPayload([]byte{1, 2, 3, 4, 5})
|
||||||
|
|
|
@ -82,9 +82,9 @@ func generateObjectWithCID(t *testing.T, cid *cid.ID) *object.Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
|
func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
|
||||||
version := version.New()
|
var ver version.Version
|
||||||
version.SetMajor(2)
|
ver.SetMajor(2)
|
||||||
version.SetMinor(1)
|
ver.SetMinor(1)
|
||||||
|
|
||||||
csum := new(checksum.Checksum)
|
csum := new(checksum.Checksum)
|
||||||
csum.SetSHA256(sha256.Sum256(data))
|
csum.SetSHA256(sha256.Sum256(data))
|
||||||
|
@ -96,7 +96,7 @@ func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
|
||||||
obj.SetID(generateOID())
|
obj.SetID(generateOID())
|
||||||
obj.SetOwnerID(ownertest.ID())
|
obj.SetOwnerID(ownertest.ID())
|
||||||
obj.SetContainerID(cid)
|
obj.SetContainerID(cid)
|
||||||
obj.SetVersion(version)
|
obj.SetVersion(&ver)
|
||||||
obj.SetPayload(data)
|
obj.SetPayload(data)
|
||||||
obj.SetPayloadChecksum(csum)
|
obj.SetPayloadChecksum(csum)
|
||||||
obj.SetPayloadHomomorphicHash(csumTZ)
|
obj.SetPayloadHomomorphicHash(csumTZ)
|
||||||
|
|
|
@ -2,14 +2,17 @@ package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
"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 {
|
type executorSvc struct {
|
||||||
version *version.Version
|
version refs.Version
|
||||||
|
|
||||||
state NodeState
|
state NodeState
|
||||||
|
|
||||||
netInfo NetworkInfo
|
netInfo NetworkInfo
|
||||||
|
@ -32,23 +35,32 @@ type NetworkInfo interface {
|
||||||
Dump(*refs.Version) (*netmap.NetworkInfo, error)
|
Dump(*refs.Version) (*netmap.NetworkInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewExecutionService(s NodeState, v *version.Version, netInfo NetworkInfo) Server {
|
func NewExecutionService(s NodeState, v versionsdk.Version, netInfo NetworkInfo) Server {
|
||||||
if s == nil || v == nil || netInfo == nil {
|
if s == nil || netInfo == nil || !version.IsValid(v) {
|
||||||
// this should never happen, otherwise it programmers bug
|
// this should never happen, otherwise it programmers bug
|
||||||
panic("can't create netmap execution service")
|
panic("can't create netmap execution service")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &executorSvc{
|
res := &executorSvc{
|
||||||
version: v,
|
|
||||||
state: s,
|
state: s,
|
||||||
netInfo: netInfo,
|
netInfo: netInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v.WriteToV2(&res.version)
|
||||||
|
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *executorSvc) LocalNodeInfo(
|
func (s *executorSvc) LocalNodeInfo(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
|
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()
|
ni, err := s.state.LocalNodeInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -69,7 +81,7 @@ func (s *executorSvc) LocalNodeInfo(
|
||||||
}
|
}
|
||||||
|
|
||||||
body := new(netmap.LocalNodeInfoResponseBody)
|
body := new(netmap.LocalNodeInfoResponseBody)
|
||||||
body.SetVersion(s.version.ToV2())
|
body.SetVersion(&s.version)
|
||||||
body.SetNodeInfo(ni)
|
body.SetNodeInfo(ni)
|
||||||
|
|
||||||
resp := new(netmap.LocalNodeInfoResponse)
|
resp := new(netmap.LocalNodeInfoResponse)
|
||||||
|
|
|
@ -63,8 +63,9 @@ func (f *formatter) Write(p []byte) (n int, err error) {
|
||||||
|
|
||||||
func (f *formatter) Close() (*AccessIdentifiers, error) {
|
func (f *formatter) Close() (*AccessIdentifiers, error) {
|
||||||
curEpoch := f.prm.NetworkState.CurrentEpoch()
|
curEpoch := f.prm.NetworkState.CurrentEpoch()
|
||||||
|
ver := version.Current()
|
||||||
|
|
||||||
f.obj.SetVersion(version.Current())
|
f.obj.SetVersion(&ver)
|
||||||
f.obj.SetPayloadSize(f.sz)
|
f.obj.SetPayloadSize(f.sz)
|
||||||
f.obj.SetSessionToken(f.prm.SessionToken)
|
f.obj.SetSessionToken(f.prm.SessionToken)
|
||||||
f.obj.SetCreationEpoch(curEpoch)
|
f.obj.SetCreationEpoch(curEpoch)
|
||||||
|
|
|
@ -18,15 +18,17 @@ type Service struct {
|
||||||
type Option func(*cfg)
|
type Option func(*cfg)
|
||||||
|
|
||||||
type cfg struct {
|
type cfg struct {
|
||||||
version *refs.Version
|
version refs.Version
|
||||||
|
|
||||||
state netmap.State
|
state netmap.State
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultCfg() *cfg {
|
func defaultCfg() *cfg {
|
||||||
return &cfg{
|
var c cfg
|
||||||
version: version.Current().ToV2(),
|
|
||||||
}
|
version.Current().WriteToV2(&c.version)
|
||||||
|
|
||||||
|
return &c
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewService creates, initializes and returns Service instance.
|
// NewService creates, initializes and returns Service instance.
|
||||||
|
@ -44,7 +46,7 @@ func NewService(opts ...Option) *Service {
|
||||||
|
|
||||||
func setMeta(resp util.ResponseMessage, cfg *cfg) {
|
func setMeta(resp util.ResponseMessage, cfg *cfg) {
|
||||||
meta := new(session.ResponseMetaHeader)
|
meta := new(session.ResponseMetaHeader)
|
||||||
meta.SetVersion(cfg.version)
|
meta.SetVersion(&cfg.version)
|
||||||
meta.SetTTL(1) // FIXME: #1160 TTL must be calculated
|
meta.SetTTL(1) // FIXME: #1160 TTL must be calculated
|
||||||
meta.SetEpoch(cfg.state.CurrentEpoch())
|
meta.SetEpoch(cfg.state.CurrentEpoch())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue