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
8a61d33c65
commit
ae4740f99f
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,20 +93,24 @@ 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)
|
||||||
|
|
||||||
|
if homomorphicHashingEnabled {
|
||||||
cs, _ := hdr.PayloadHomomorphicHash()
|
cs, _ := hdr.PayloadHomomorphicHash()
|
||||||
|
|
||||||
if len(tzHash) == 0 {
|
if len(tzHash) == 0 {
|
||||||
tzHash = cs.Value()
|
tzHash = cs.Value()
|
||||||
} else {
|
} else {
|
||||||
tzHash, err = tz.Concat([][]byte{tzHash, cs.Value()})
|
tzHash, err = tz.Concat([][]byte{
|
||||||
|
tzHash,
|
||||||
|
cs.Value(),
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Debug("can't concatenate tz hash",
|
c.log.Debug("can't concatenate tz hash",
|
||||||
zap.Stringer("oid", members[i]),
|
zap.String("oid", members[i].String()),
|
||||||
zap.String("error", err.Error()))
|
zap.String("error", err.Error()))
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
totalSize += hdr.PayloadSize()
|
totalSize += hdr.PayloadSize()
|
||||||
|
|
||||||
|
@ -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