diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index c4adeff2b5..e33b8b3856 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -13,6 +13,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg" apiclient "github.com/nspcc-dev/neofs-api-go/pkg/client" "github.com/nspcc-dev/neofs-api-go/pkg/netmap" + "github.com/nspcc-dev/neofs-api-go/pkg/owner" netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" apiclientconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/apiclient" @@ -77,6 +78,8 @@ type cfg struct { key *keys.PrivateKey + ownerIDFromKey *owner.ID // owner ID calculated from key + apiVersion *pkg.Version cfgGRPC cfgGRPC @@ -221,9 +224,15 @@ func initCfg(path string) *cfg { key := nodeconfig.Key(appCfg) + neo3Wallet, err := owner.NEO3WalletFromPublicKey(&key.PrivateKey.PublicKey) + fatalOnErr(err) + + ownerIDFromKey := owner.NewID() + ownerIDFromKey.SetNeo3Wallet(neo3Wallet) + var logPrm logger.Prm - err := logPrm.SetLevelString( + err = logPrm.SetLevelString( loggerconfig.Level(appCfg), ) fatalOnErr(err) @@ -297,6 +306,8 @@ func initCfg(path string) *cfg { apiclient.WithDialTimeout(apiclientconfig.DialTimeout(appCfg)), ), persistate: persistate, + + ownerIDFromKey: ownerIDFromKey, } if metricsconfig.Address(c.appCfg) != "" { diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index c27f666a46..91f4821f31 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -120,14 +120,22 @@ func (r *localObjectInhumer) DeleteObjects(ts *objectSDK.Address, addr ...*objec type delNetInfo struct { netmap.State - tsLifetime uint64 + + cfg *cfg } func (i *delNetInfo) TombstoneLifetime() (uint64, error) { return i.tsLifetime, nil } +// returns node owner ID calculated from configured private key. +// +// Implements method needed for Object.Delete service. +func (i *delNetInfo) LocalNodeID() *owner.ID { + return i.cfg.ownerIDFromKey +} + type innerRingFetcherWithNotary struct { sidechain *morphClient.Client } @@ -334,6 +342,8 @@ func initObjectService(c *cfg) { deletesvc.WithNetworkInfo(&delNetInfo{ State: c.cfgNetmap.state, tsLifetime: 5, + + cfg: c, }), ) diff --git a/pkg/services/object/delete/exec.go b/pkg/services/object/delete/exec.go index 07bea71233..094e81b2b5 100644 --- a/pkg/services/object/delete/exec.go +++ b/pkg/services/object/delete/exec.go @@ -232,9 +232,15 @@ func (exec *execCtx) initTombstoneObject() bool { return false } + tombOwnerID := exec.commonParameters().SessionToken().OwnerID() + if tombOwnerID == nil { + // make local node a tombstone object owner + tombOwnerID = exec.svc.netInfo.LocalNodeID() + } + exec.tombstoneObj = object.NewRaw() exec.tombstoneObj.SetContainerID(exec.containerID()) - exec.tombstoneObj.SetOwnerID(exec.commonParameters().SessionToken().OwnerID()) + exec.tombstoneObj.SetOwnerID(tombOwnerID) exec.tombstoneObj.SetType(objectSDK.TypeTombstone) exec.tombstoneObj.SetPayload(payload) diff --git a/pkg/services/object/delete/service.go b/pkg/services/object/delete/service.go index bb10179724..81f943ea6e 100644 --- a/pkg/services/object/delete/service.go +++ b/pkg/services/object/delete/service.go @@ -2,6 +2,7 @@ package deletesvc import ( objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" + "github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-node/pkg/core/netmap" getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get" putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put" @@ -25,6 +26,10 @@ type NetworkInfo interface { // Must return the lifespan of the tombstones // in the NeoFS epochs. TombstoneLifetime() (uint64, error) + + // Returns user ID of the local storage node. Result must not be nil. + // New tombstone objects will have the result as an owner ID if removal is executed w/o a session. + LocalNodeID() *owner.ID } type cfg struct {