forked from TrueCloudLab/frostfs-node
[#1365] ir: Check homomorphic hash flexibly in audit
Do not perform that check if it was turned off for the container being checked. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
455096ab53
commit
e9c534b0a0
1 changed files with 19 additions and 12 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
|
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/rand"
|
"github.com/nspcc-dev/neofs-node/pkg/util/rand"
|
||||||
|
containerSDK "github.com/nspcc-dev/neofs-sdk-go/container"
|
||||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||||
storagegroupSDK "github.com/nspcc-dev/neofs-sdk-go/storagegroup"
|
storagegroupSDK "github.com/nspcc-dev/neofs-sdk-go/storagegroup"
|
||||||
"github.com/nspcc-dev/tzhash/tz"
|
"github.com/nspcc-dev/tzhash/tz"
|
||||||
|
@ -50,6 +51,8 @@ func (c *Context) checkStorageGroupPoR(sgID oid.ID, sg storagegroupSDK.StorageGr
|
||||||
getHeaderPrm.CID = c.task.ContainerID()
|
getHeaderPrm.CID = c.task.ContainerID()
|
||||||
getHeaderPrm.NodeIsRelay = true
|
getHeaderPrm.NodeIsRelay = true
|
||||||
|
|
||||||
|
homomorphicHashingEnabled := !containerSDK.IsHomomorphicHashingDisabled(c.task.ContainerStructure())
|
||||||
|
|
||||||
for i := range members {
|
for i := range members {
|
||||||
objectPlacement, err := c.buildPlacement(members[i])
|
objectPlacement, err := c.buildPlacement(members[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -90,18 +93,22 @@ func (c *Context) checkStorageGroupPoR(sgID oid.ID, sg storagegroupSDK.StorageGr
|
||||||
// update cache for PoR and PDP audit checks
|
// update cache for PoR and PDP audit checks
|
||||||
c.updateHeadResponses(hdr)
|
c.updateHeadResponses(hdr)
|
||||||
|
|
||||||
cs, _ := hdr.PayloadHomomorphicHash()
|
if homomorphicHashingEnabled {
|
||||||
|
cs, _ := hdr.PayloadHomomorphicHash()
|
||||||
|
if len(tzHash) == 0 {
|
||||||
|
tzHash = cs.Value()
|
||||||
|
} else {
|
||||||
|
tzHash, err = tz.Concat([][]byte{
|
||||||
|
tzHash,
|
||||||
|
cs.Value(),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
c.log.Debug("can't concatenate tz hash",
|
||||||
|
zap.String("oid", members[i].String()),
|
||||||
|
zap.String("error", err.Error()))
|
||||||
|
|
||||||
if len(tzHash) == 0 {
|
break
|
||||||
tzHash = cs.Value()
|
}
|
||||||
} else {
|
|
||||||
tzHash, err = tz.Concat([][]byte{tzHash, cs.Value()})
|
|
||||||
if err != nil {
|
|
||||||
c.log.Debug("can't concatenate tz hash",
|
|
||||||
zap.Stringer("oid", members[i]),
|
|
||||||
zap.String("error", err.Error()))
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +123,7 @@ func (c *Context) checkStorageGroupPoR(sgID oid.ID, sg storagegroupSDK.StorageGr
|
||||||
|
|
||||||
sizeCheck := sg.ValidationDataSize() == totalSize
|
sizeCheck := sg.ValidationDataSize() == totalSize
|
||||||
cs, _ := sg.ValidationDataHash()
|
cs, _ := sg.ValidationDataHash()
|
||||||
tzCheck := bytes.Equal(tzHash, cs.Value())
|
tzCheck := !homomorphicHashingEnabled || bytes.Equal(tzHash, cs.Value())
|
||||||
|
|
||||||
if sizeCheck && tzCheck {
|
if sizeCheck && tzCheck {
|
||||||
c.report.PassedPoR(sgID) // write report
|
c.report.PassedPoR(sgID) // write report
|
||||||
|
|
Loading…
Reference in a new issue