[#1878] services/object: Fix child check in GET

In previous implementation `ObjectService.Get` RPC handler failed with
`parent address in child object differs` while assembling the "big"
object. This was caused by the child check which required parent
reference to be set in all child objects. The check was impracticable
because not all elements of the split-chain have a link to the parent.

Make `execCtx.isChild` to return `true` if parameterized object has no
parent header in its own header.

Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
This commit is contained in:
Leonard Lyubich 2022-10-11 14:08:43 +04:00 committed by fyrchik
parent 9a006ac14f
commit dde4d4df2a
2 changed files with 7 additions and 2 deletions

View file

@ -38,6 +38,7 @@ Changelog for NeoFS Node
- Do not increase error counter in `engine.Inhume` if shard is read-only (#1839)
- `control drop-objects` can remove split objects (#1830)
- Node's status in `neofs-cli netmap nodeinfo` command (#1833)
- Child check in object assembly process of `ObjectService.Get` handler (#1878)
### Removed
- Remove WIF and NEP2 support in `neofs-cli`'s --wallet flag (#1128)

View file

@ -99,9 +99,13 @@ func (exec execCtx) address() oid.Address {
return exec.prm.addr
}
// isChild checks if reading object is a parent of the given object.
// Object without reference to the parent (only children with the parent header
// have it) is automatically considered as child: this should be guaranteed by
// upper level logic.
func (exec execCtx) isChild(obj *objectSDK.Object) bool {
par := obj.Parent()
return par != nil && equalAddresses(exec.address(), object.AddressOf(par))
return par == nil || equalAddresses(exec.address(), object.AddressOf(par))
}
func (exec execCtx) key() (*ecdsa.PrivateKey, error) {
@ -244,7 +248,7 @@ func (exec *execCtx) headChild(id oid.ID) (*objectSDK.Object, bool) {
case err == nil:
child := w.Object()
if _, ok := child.ParentID(); ok && !exec.isChild(child) {
if !exec.isChild(child) {
exec.status = statusUndefined
exec.log.Debug("parent address in child object differs")