diff --git a/CHANGELOG.md b/CHANGELOG.md index 9018890dc6..acc659ee53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ a huge list of updates and fixes. - SN no longer accepts objects with invocation or verification script bigger than 1KiB (#3887) - Every object with non-zero payload is now paid, not only regular ones (#3856) - Separate policer placement state from replica shortage (#3901) +- Storage nodes do not calculate homomorphic hashes for objects (#3847) ### Removed - `node.persistent_sessions.path` config option from SN config (#3846) diff --git a/cmd/neofs-adm/internal/modules/config/config.go b/cmd/neofs-adm/internal/modules/config/config.go index be7a925664..2d42e0aa97 100644 --- a/cmd/neofs-adm/internal/modules/config/config.go +++ b/cmd/neofs-adm/internal/modules/config/config.go @@ -14,16 +14,15 @@ import ( ) type configTemplate struct { - Endpoint string - AlphabetDir string - MaxObjectSize int - EpochDuration int - BasicIncomeRate int - ContainerFee int - ContainerAliasFee int - WithdrawFee int - AlphabetNames []string - HomomorphicHashDisabled bool + Endpoint string + AlphabetDir string + MaxObjectSize int + EpochDuration int + BasicIncomeRate int + ContainerFee int + ContainerAliasFee int + WithdrawFee int + AlphabetNames []string } const configTxtTemplate = `rpc-endpoint: {{ .Endpoint}} @@ -32,7 +31,6 @@ network: max_object_size: {{ .MaxObjectSize}} epoch_duration: {{ .EpochDuration}} basic_income_rate: {{ .BasicIncomeRate}} - homomorphic_hash_disabled: {{ .HomomorphicHashDisabled}} fee: container: {{ .ContainerFee}} container_alias: {{ .ContainerAliasFee }} @@ -103,15 +101,14 @@ func defaultConfigPath() (string, error) { // some comments as well. func generateConfigExample(appDir string, credSize int) (string, error) { tmpl := configTemplate{ - Endpoint: "https://neo.rpc.node:30333", - MaxObjectSize: 67108864, // 64 MiB - EpochDuration: 240, // 1 hour with 15s per block - BasicIncomeRate: 1_0000_0000, // 0.0001 GAS per GiB (Fixed12) - HomomorphicHashDisabled: false, // object homomorphic hash is enabled - ContainerFee: 1000, // 0.000000001 * 7 GAS per container (Fixed12) - ContainerAliasFee: 500, // ContainerFee / 2 - WithdrawFee: 1_0000_0000, // 1.0 GAS (Fixed8) - AlphabetNames: make([]string, 0, credSize), + Endpoint: "https://neo.rpc.node:30333", + MaxObjectSize: 67108864, // 64 MiB + EpochDuration: 240, // 1 hour with 15s per block + BasicIncomeRate: 1_0000_0000, // 0.0001 GAS per GiB (Fixed12) + ContainerFee: 1000, // 0.000000001 * 7 GAS per container (Fixed12) + ContainerAliasFee: 500, // ContainerFee / 2 + WithdrawFee: 1_0000_0000, // 1.0 GAS (Fixed8) + AlphabetNames: make([]string, 0, credSize), } appDir, err := filepath.Abs(appDir) diff --git a/cmd/neofs-adm/internal/modules/fschain/config.go b/cmd/neofs-adm/internal/modules/fschain/config.go index fdc47c0839..dce9903aa6 100644 --- a/cmd/neofs-adm/internal/modules/fschain/config.go +++ b/cmd/neofs-adm/internal/modules/fschain/config.go @@ -76,13 +76,6 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error { _, _ = fmt.Fprintf(tw, "%s:\t%d (int)\n", k, n) case netmapEigenTrustAlphaKey: _, _ = fmt.Fprintf(tw, "%s:\t%s (str)\n", k, v) - case netmapHomomorphicHashDisabledKey: - vBool, err := tuple[1].TryBool() - if err != nil { - return invalidConfigValueErr(k) - } - - _, _ = fmt.Fprintf(tw, "%s:\t%t (bool)\n", k, vBool) default: _, _ = fmt.Fprintf(tw, "%s:\t%s (hex)\n", k, hex.EncodeToString(v)) } @@ -167,12 +160,6 @@ func parseConfigPair(kvStr string, force bool) (key string, val any, err error) } val = valRaw - case netmapHomomorphicHashDisabledKey: - val, err = strconv.ParseBool(valRaw) - if err != nil { - err = fmt.Errorf("invalid value for %s key, expected bool, got '%s'", key, valRaw) - } - default: if !force { return "", nil, fmt.Errorf( diff --git a/cmd/neofs-adm/internal/modules/fschain/initialize_deploy.go b/cmd/neofs-adm/internal/modules/fschain/initialize_deploy.go index cbf91aa386..aa4f9bb1a6 100644 --- a/cmd/neofs-adm/internal/modules/fschain/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/fschain/initialize_deploy.go @@ -43,15 +43,14 @@ const ( ) const ( - netmapEpochKey = "EpochDuration" - netmapMaxObjectSizeKey = "MaxObjectSize" - netmapContainerFeeKey = "ContainerFee" - netmapContainerAliasFeeKey = "ContainerAliasFee" - netmapEigenTrustIterationsKey = "EigenTrustIterations" - netmapEigenTrustAlphaKey = "EigenTrustAlpha" - netmapBasicIncomeRateKey = "BasicIncomeRate" - netmapWithdrawFeeKey = "WithdrawFee" - netmapHomomorphicHashDisabledKey = "HomomorphicHashingDisabled" + netmapEpochKey = "EpochDuration" + netmapMaxObjectSizeKey = "MaxObjectSize" + netmapContainerFeeKey = "ContainerFee" + netmapContainerAliasFeeKey = "ContainerAliasFee" + netmapEigenTrustIterationsKey = "EigenTrustIterations" + netmapEigenTrustAlphaKey = "EigenTrustAlpha" + netmapBasicIncomeRateKey = "BasicIncomeRate" + netmapWithdrawFeeKey = "WithdrawFee" defaultEigenTrustIterations = 4 defaultEigenTrustAlpha = "0.1" @@ -420,18 +419,6 @@ func (c *initializeContext) getContractDeployData(ctrHash util.Uint160, ctrName } configParam = append(configParam, kf.key, i64) } - for _, kf := range []struct { - key string - flag string - }{ - {netmapHomomorphicHashDisabledKey, homomorphicHashDisabledInitFlag}, - } { - bval, err := unwrap.Bool(c.ReadOnlyInvoker.Call(ctrHash, "config", kf.key)) - if err != nil { - bval = viper.GetBool(kf.flag) - } - configParam = append(configParam, kf.key, bval) - } configParam = append(configParam, netmapEigenTrustIterationsKey, int64(defaultEigenTrustIterations), netmapEigenTrustAlphaKey, defaultEigenTrustAlpha, ) diff --git a/cmd/neofs-adm/internal/modules/fschain/root.go b/cmd/neofs-adm/internal/modules/fschain/root.go index 51dfa5e396..830e5ee52c 100644 --- a/cmd/neofs-adm/internal/modules/fschain/root.go +++ b/cmd/neofs-adm/internal/modules/fschain/root.go @@ -13,37 +13,36 @@ import ( ) const ( - alphabetWalletsFlag = "alphabet-wallets" - alphabetSizeFlag = "size" - endpointFlag = "rpc-endpoint" - storageWalletFlag = "storage-wallet" - storageWalletLabelFlag = "label" - storageWalletsNumber = "wallets-number" - storageGasCLIFlag = "initial-gas" - storageGasConfigFlag = "storage.initial_gas" - contractsInitFlag = "contracts" - maxObjectSizeInitFlag = "network.max_object_size" - epochDurationInitFlag = "network.epoch_duration" - incomeRateInitFlag = "network.basic_income_rate" - containerFeeInitFlag = "network.fee.container" - containerAliasFeeInitFlag = "network.fee.container_alias" - homomorphicHashDisabledInitFlag = "network.homomorphic_hash_disabled" - withdrawFeeInitFlag = "network.fee.withdraw" - containerDumpFlag = "dump" - containerContractFlag = "container-contract" - containerIDsFlag = "cid" - refillGasAmountFlag = "gas" - walletAccountFlag = "account" - notaryDepositTillFlag = "till" - walletAddressFlag = "wallet-address" - domainFlag = "domain" - neoAddressesFlag = "neo-addresses" - publicKeysFlag = "public-keys" - walletFlag = "wallet" - containerIDFlag = "cid" - mintNeofsAmountFlag = "amount" - mintTxHashFlag = "deposit-tx" - quotasSoftLimitFlag = "soft" + alphabetWalletsFlag = "alphabet-wallets" + alphabetSizeFlag = "size" + endpointFlag = "rpc-endpoint" + storageWalletFlag = "storage-wallet" + storageWalletLabelFlag = "label" + storageWalletsNumber = "wallets-number" + storageGasCLIFlag = "initial-gas" + storageGasConfigFlag = "storage.initial_gas" + contractsInitFlag = "contracts" + maxObjectSizeInitFlag = "network.max_object_size" + epochDurationInitFlag = "network.epoch_duration" + incomeRateInitFlag = "network.basic_income_rate" + containerFeeInitFlag = "network.fee.container" + containerAliasFeeInitFlag = "network.fee.container_alias" + withdrawFeeInitFlag = "network.fee.withdraw" + containerDumpFlag = "dump" + containerContractFlag = "container-contract" + containerIDsFlag = "cid" + refillGasAmountFlag = "gas" + walletAccountFlag = "account" + notaryDepositTillFlag = "till" + walletAddressFlag = "wallet-address" + domainFlag = "domain" + neoAddressesFlag = "neo-addresses" + publicKeysFlag = "public-keys" + walletFlag = "wallet" + containerIDFlag = "cid" + mintNeofsAmountFlag = "amount" + mintTxHashFlag = "deposit-tx" + quotasSoftLimitFlag = "soft" ) var ( diff --git a/cmd/neofs-cli/modules/netmap/netinfo.go b/cmd/neofs-cli/modules/netmap/netinfo.go index c34d418faa..a84be0a276 100644 --- a/cmd/neofs-cli/modules/netmap/netinfo.go +++ b/cmd/neofs-cli/modules/netmap/netinfo.go @@ -51,7 +51,7 @@ var netInfoCmd = &cobra.Command{ cmd.Printf(format, "Epoch duration", netInfo.EpochDuration()) cmd.Printf(format, "Maximum object size", netInfo.MaxObjectSize()) cmd.Printf(format, "Withdrawal fee", netInfo.WithdrawalFee()) - cmd.Printf(format, "Homomorphic hashing disabled", netInfo.HomomorphicHashingDisabled()) + cmd.Printf(format, "Homomorphic hashing disabled", netInfo.HomomorphicHashingDisabled()) //nolint:staticcheck // networks may still have this setting cmd.Println("NeoFS network configuration (other)") for name, value := range netInfo.RawNetworkParameters() { diff --git a/cmd/neofs-cli/modules/object/hash.go b/cmd/neofs-cli/modules/object/hash.go index def93fca4a..8c11d643de 100644 --- a/cmd/neofs-cli/modules/object/hash.go +++ b/cmd/neofs-cli/modules/object/hash.go @@ -9,7 +9,6 @@ import ( "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common" "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags" "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key" - "github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/client" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" @@ -21,7 +20,6 @@ const getRangeHashSaltFlag = "salt" const ( hashSha256 = "sha256" - hashTz = "tz" rangeSep = ":" ) @@ -46,7 +44,7 @@ func initObjectHashCmd() { _ = objectHashCmd.MarkFlagRequired(commonflags.OIDFlag) flags.String("range", "", "Range to take hash from in the form offset1:length1,... Full object payload length if not specified") - flags.String("type", hashSha256, "Hash type. Either 'sha256' or 'tz'") + flags.String("type", hashSha256, "Hash type. Deprecated: can be omitted, only 'sha256' is currently supported") flags.String(getRangeHashSaltFlag, "", "Salt in hex format") } @@ -63,7 +61,8 @@ func getObjectHash(cmd *cobra.Command, _ []string) error { if err != nil { return err } - typ, err := getHashType(cmd) + // only validation of deprecated no-op flag + _, err = getHashType(cmd) if err != nil { return err } @@ -89,7 +88,6 @@ func getObjectHash(cmd *cobra.Command, _ []string) error { } defer cli.Close() - tz := typ == hashTz fullHash := len(ranges) == 0 if fullHash { common.PrintVerbose(cmd, "Get the hash of the full object payload.") @@ -105,15 +103,7 @@ func getObjectHash(cmd *cobra.Command, _ []string) error { return fmt.Errorf("rpc error: read object header via client: %w", err) } - var cs checksum.Checksum - var csSet bool - - if tz { - cs, csSet = hdr.PayloadHomomorphicHash() - } else { - cs, csSet = hdr.PayloadChecksum() - } - + cs, csSet := hdr.PayloadChecksum() if csSet { cmd.Println(hex.EncodeToString(cs.Value())) } else { @@ -141,10 +131,6 @@ func getObjectHash(cmd *cobra.Command, _ []string) error { } hashPrm.SetRangeList(rngs...) - if tz { - hashPrm.TillichZemorAlgo() - } - hs, err := cli.ObjectHash(ctx, cnr, obj, user.NewAutoIDSigner(*pk), hashPrm) if err != nil { return fmt.Errorf("rpc error: read payload hashes via client: %w", err) @@ -160,7 +146,7 @@ func getObjectHash(cmd *cobra.Command, _ []string) error { func getHashType(cmd *cobra.Command) (string, error) { rawType := cmd.Flag("type").Value.String() switch typ := strings.ToLower(rawType); typ { - case hashSha256, hashTz: + case hashSha256: return typ, nil default: return "", fmt.Errorf("invalid hash type: %s", typ) diff --git a/cmd/neofs-cli/modules/object/head.go b/cmd/neofs-cli/modules/object/head.go index e0a4aea398..bbc8adae73 100644 --- a/cmd/neofs-cli/modules/object/head.go +++ b/cmd/neofs-cli/modules/object/head.go @@ -167,7 +167,7 @@ func printHeader(cmd *cobra.Command, obj *object.Object) error { cmd.Printf("Owner: %s\n", obj.Owner()) cmd.Printf("CreatedAt: %d\n", obj.CreationEpoch()) cmd.Printf("Size: %d\n", obj.PayloadSize()) - common.PrintChecksum(cmd, "HomoHash", obj.PayloadHomomorphicHash) + common.PrintChecksum(cmd, "HomoHash", obj.PayloadHomomorphicHash) //nolint:staticcheck // old objects may still have it common.PrintChecksum(cmd, "Checksum", obj.PayloadChecksum) cmd.Printf("Type: %s\n", obj.Type()) diff --git a/cmd/neofs-cli/modules/object/search.go b/cmd/neofs-cli/modules/object/search.go index 65de0ac5c8..6485c586af 100644 --- a/cmd/neofs-cli/modules/object/search.go +++ b/cmd/neofs-cli/modules/object/search.go @@ -202,6 +202,13 @@ func parseSearchFilters(cmd *cobra.Command) (object.SearchFilters, error) { fs.AddPhyFilter() } + // nolint:staticcheck // deprecated but that is what is checked there + for _, f := range fs { + if f.Header() == object.FilterPayloadHomomorphicHash { + return nil, fmt.Errorf("%s filter target is prohibited starting from API 2.23", object.FilterPayloadHomomorphicHash) + } + } + return fs, nil } diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index b43d579d66..820957a8c8 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -484,10 +484,6 @@ func (c *cfg) GetNetworkInfo() (netmapSDK.NetworkInfo, error) { ni.SetEigenTrustAlpha(netInfoMorph.EigenTrustAlpha) ni.SetWithdrawalFee(netInfoMorph.WithdrawalFee) - if netInfoMorph.HomomorphicHashingDisabled { - ni.DisableHomomorphicHashing() - } - for i := range netInfoMorph.Raw { ni.SetRawNetworkParameter(netInfoMorph.Raw[i].Name, netInfoMorph.Raw[i].Value) } diff --git a/go.mod b/go.mod index 8be03878c9..f4460d974b 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/nspcc-dev/neofs-node go 1.25.0 +replace github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.17.0.20260325133051-c1dbddc28fdf => ../neofs-sdk-go + require ( github.com/cenkalti/backoff/v4 v4.3.0 github.com/cheggaaa/pb v1.0.29 @@ -21,7 +23,7 @@ require ( github.com/nspcc-dev/neo-go v0.118.0 github.com/nspcc-dev/neofs-api-go/v2 v2.14.1-0.20240827150555-5ce597aa14ea github.com/nspcc-dev/neofs-contract v0.26.1 - github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.18 + github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.17.0.20260327202214-2179ca1cb8d8 github.com/nspcc-dev/tzhash v1.8.4 github.com/panjf2000/ants/v2 v2.11.5 github.com/prometheus/client_golang v1.23.2 diff --git a/go.sum b/go.sum index 09766afbfa..ac6a412f29 100644 --- a/go.sum +++ b/go.sum @@ -191,8 +191,8 @@ github.com/nspcc-dev/neofs-api-go/v2 v2.14.1-0.20240827150555-5ce597aa14ea h1:mK github.com/nspcc-dev/neofs-api-go/v2 v2.14.1-0.20240827150555-5ce597aa14ea/go.mod h1:YzhD4EZmC9Z/PNyd7ysC7WXgIgURc9uCG1UWDeV027Y= github.com/nspcc-dev/neofs-contract v0.26.1 h1:7Ii7Q4L3au408LOsIWKiSgfnT1g8G9jo3W7381d41T8= github.com/nspcc-dev/neofs-contract v0.26.1/go.mod h1:pevVF9OWdEN5bweKxOu6ryZv9muCEtS1ppzYM4RfBIo= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.18 h1:2hsOgVEFCAT/vy+1WStNqk//XujMdHAtJ2n08vT+ITQ= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.18/go.mod h1:aUnzNCaipQZUQaai9lcapG90OwYx7g9s4UsrvcVkBoo= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.17.0.20260327202214-2179ca1cb8d8 h1:VhGG+9qrBaQ+tS3u+hmX5OjZTzEjAz2PU3rvMiEyK4g= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.17.0.20260327202214-2179ca1cb8d8/go.mod h1:aUnzNCaipQZUQaai9lcapG90OwYx7g9s4UsrvcVkBoo= github.com/nspcc-dev/rfc6979 v0.2.4 h1:NBgsdCjhLpEPJZqmC9rciMZDcSY297po2smeaRjw57k= github.com/nspcc-dev/rfc6979 v0.2.4/go.mod h1:86ylDw6Kss+P6v4QAJqo1Sp3mC0/Zr9G97xSjQ9TuFg= github.com/nspcc-dev/tzhash v1.8.4 h1:lvuPGWsqEo9dVEvo/kdNLKv/Cy0yxRs9z5hJp8VcBuo= diff --git a/internal/crypto/object_test.go b/internal/crypto/object_test.go index 2a83593e43..2bf0403c9b 100644 --- a/internal/crypto/object_test.go +++ b/internal/crypto/object_test.go @@ -226,7 +226,7 @@ func getUnsignedObject() object.Object { par.SetOwner(mainAcc) par.SetCreationEpoch(creationEpoch) par.SetType(typ) - par.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(payload))) + par.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(payload))) //nolint:staticcheck // this is a test and such objects are possible par.SetPayloadChecksum(checksum.NewSHA256(sha256.Sum256(payload))) par.SetAttributes(object.NewAttribute("690530953", "39483258"), object.NewAttribute("7208331", "31080424839")) par.SetID(oid.ID{156, 209, 245, 87, 177, 145, 183, 8, 181, 92, 171, 193, 58, 125, 77, 11, 28, 161, 217, 151, 17, 212, 232, 88, 6, @@ -240,7 +240,7 @@ func getUnsignedObject() object.Object { child.SetOwner(mainAcc) child.SetCreationEpoch(creationEpoch) child.SetType(typ) - child.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(childPayload))) + child.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(childPayload))) //nolint:staticcheck // this is a test and such objects are possible child.SetPayloadChecksum(checksum.NewSHA256(sha256.Sum256(childPayload))) child.SetAttributes(object.NewAttribute("31429585", "689450942"), object.NewAttribute("129849325", "859384298")) child.SetParent(&par) diff --git a/internal/ec/object_test.go b/internal/ec/object_test.go index 0b8f84072d..c71b5238f9 100644 --- a/internal/ec/object_test.go +++ b/internal/ec/object_test.go @@ -14,7 +14,6 @@ import ( sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test" usertest "github.com/nspcc-dev/neofs-sdk-go/user/test" "github.com/nspcc-dev/neofs-sdk-go/version" - "github.com/nspcc-dev/tzhash/tz" "github.com/stretchr/testify/require" ) @@ -151,7 +150,7 @@ func TestFormObjectForECPart(t *testing.T) { require.Equal(t, object.TypeRegular, obj.Type()) require.Zero(t, obj.SessionToken()) - _, ok = obj.PayloadHomomorphicHash() + _, ok = obj.PayloadHomomorphicHash() //nolint:staticcheck // this is a test require.False(t, ok) require.Len(t, obj.Attributes(), 2) @@ -159,18 +158,6 @@ func TestFormObjectForECPart(t *testing.T) { pi, err := iec.GetPartInfo(obj) require.NoError(t, err) require.Equal(t, partInfo, pi) - - t.Run("with homomorphic hash", func(t *testing.T) { - anyHash := checksum.NewTillichZemor([tz.Size]byte{1, 2, 3}) - parent.SetPayloadHomomorphicHash(anyHash) - - obj, err := iec.FormObjectForECPart(signer, parent, part, partInfo) - require.NoError(t, err) - - phh, ok := obj.PayloadHomomorphicHash() - require.True(t, ok) - require.Equal(t, checksum.NewTillichZemor(tz.Sum(part)), phh) - }) } func TestDecodePartInfoFromAttributes(t *testing.T) { diff --git a/internal/ec/objects.go b/internal/ec/objects.go index 620712fff6..f1705a0da9 100644 --- a/internal/ec/objects.go +++ b/internal/ec/objects.go @@ -8,10 +8,8 @@ import ( "strings" iobject "github.com/nspcc-dev/neofs-node/internal/object" - "github.com/nspcc-dev/neofs-sdk-go/checksum" neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto" "github.com/nspcc-dev/neofs-sdk-go/object" - "github.com/nspcc-dev/tzhash/tz" ) // PartInfo groups information about single EC part produced according to some [Rule]. @@ -79,9 +77,6 @@ func FormObjectForECPart(signer neofscrypto.Signer, parent object.Object, part [ obj.SetPayload(part) obj.SetPayloadSize(uint64(len(part))) - if _, ok := parent.PayloadHomomorphicHash(); ok { - obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(part))) - } if err := obj.SetVerificationFields(signer); err != nil { return object.Object{}, fmt.Errorf("set verification fields: %w", err) diff --git a/internal/object/wire_test.go b/internal/object/wire_test.go index c1cca6d0e4..9c1f63e8fe 100644 --- a/internal/object/wire_test.go +++ b/internal/object/wire_test.go @@ -239,7 +239,7 @@ func BenchmarkGetParentNonPayloadFieldBounds(b *testing.B) { obj.SetPayloadSize(math.MaxUint64) obj.SetPayloadChecksum(pldHash) obj.SetType(math.MaxInt32) - obj.SetPayloadHomomorphicHash(pldHomoHash) + obj.SetPayloadHomomorphicHash(pldHomoHash) //nolint:staticcheck // this is a test and such objects are possible obj.SetAttributes( object.NewAttribute("key1", "val1"), object.NewAttribute("key2", "val2"), diff --git a/pkg/core/object/ec.go b/pkg/core/object/ec.go index cdd84bb3d0..03f655683f 100644 --- a/pkg/core/object/ec.go +++ b/pkg/core/object/ec.go @@ -98,12 +98,6 @@ func checkECPart(part object.Object, rules []netmap.ECRule) error { return fmt.Errorf("diff creation epoch in parent (%d) and part (%d)", parentVal, partVal) } - _, parentHH := parent.PayloadHomomorphicHash() - _, partHH := part.PayloadHomomorphicHash() - if parentHH != partHH { - return fmt.Errorf("diff homomorphic hash presence in parent (%t) and part (%t)", parentHH, partHH) - } - pi, err := iec.GetRequiredPartInfo(part) if err != nil { return fmt.Errorf("unavailable part info: %w", err) diff --git a/pkg/core/object/ec_test.go b/pkg/core/object/ec_test.go index 882908e086..731b9fc44b 100644 --- a/pkg/core/object/ec_test.go +++ b/pkg/core/object/ec_test.go @@ -149,7 +149,7 @@ func TestFormatValidator_Validate_EC(t *testing.T) { }}, {name: "homomorphic hash mismatch", err: fmt.Sprintf("invalid regular EC part object: diff homomorphic hash presence in parent (%t) and part (%t)", true, false), corruptParent: func(obj *object.Object) { - obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(obj.Payload()))) + obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(obj.Payload()))) //nolint:staticcheck // this is a test and such objects are possible }, corruptPart: func(obj *object.Object) {}}, {name: "missing EC attributes", err: "missing EC attributes in regular object", corruptPart: func(obj *object.Object) { obj.SetAttributes() diff --git a/pkg/core/object/fmt_test.go b/pkg/core/object/fmt_test.go index 4ab1a058d1..21c1f5a795 100644 --- a/pkg/core/object/fmt_test.go +++ b/pkg/core/object/fmt_test.go @@ -652,7 +652,7 @@ func getUnsignedObject() object.Object { obj.SetPayload(payload) obj.CalculateAndSetPayloadChecksum() - obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(payload))) + obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(payload))) //nolint:staticcheck // this is a test and such objects are possible obj.SetID(oid.ID{231, 249, 6, 213, 114, 154, 74, 74, 49, 179, 107, 109, 34, 56, 68, 54, 226, 226, 16, 54, 217, 41, 138, 188, 245, 97, 133, 227, 199, 159, 163, 21}) // header checksum diff --git a/pkg/core/object/metadata.go b/pkg/core/object/metadata.go index 92d968e38b..a71fd32cec 100644 --- a/pkg/core/object/metadata.go +++ b/pkg/core/object/metadata.go @@ -13,6 +13,7 @@ import ( "github.com/google/uuid" "github.com/mr-tron/base58" + "github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/client" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" "github.com/nspcc-dev/neofs-sdk-go/object" @@ -186,9 +187,13 @@ func VerifyHeaderForMetadata(hdr object.Object) error { if hdr.Owner().IsZero() { return fmt.Errorf("invalid owner: %w", user.ErrZeroID) } - if _, ok := hdr.PayloadChecksum(); !ok { + cs, ok := hdr.PayloadChecksum() + if !ok { return errors.New("missing payload checksum") } + if typ := cs.Type(); typ != checksum.SHA256 { + return fmt.Errorf("unsupported payload checksum type: %s", typ) + } attrs := hdr.Attributes() for i := range attrs { if strings.IndexByte(attrs[i].Key(), MetaAttributeDelimiter[0]) >= 0 { @@ -523,6 +528,7 @@ func combineValues(attr string, dbVal []byte, fltVal string) ([]byte, []byte, er return dbVal, b, nil } dbVal = []byte(hex.EncodeToString(dbVal)) + //nolint:staticcheck // this is not DB's responsibility to force API rules, DB still may have these values inside case object.FilterPayloadHomomorphicHash: if len(dbVal) != tz.Size { return nil, nil, fmt.Errorf("invalid payload homomorphic hash len %d != %d", len(dbVal), tz.Size) @@ -587,7 +593,10 @@ func restoreAttributeValue(attr string, stored []byte) (string, error) { switch attr { case object.FilterOwnerID, object.FilterFirstSplitObject, object.FilterParentID: return base58.Encode(stored), nil - case object.FilterPayloadChecksum, object.FilterPayloadHomomorphicHash: + //nolint:staticcheck // this is not DB's responsibility to force API rules, DB still may have these values inside + case object.FilterPayloadHomomorphicHash: + return hex.EncodeToString(stored), nil + case object.FilterPayloadChecksum: return hex.EncodeToString(stored), nil case object.FilterSplitID: uid, err := uuid.FromBytes(stored) @@ -642,6 +651,7 @@ func PreprocessSearchQuery(fs object.SearchFilters, attrs []string, cursor strin if primValDB, err = base58.Decode(primVal); err != nil { return nil, nil, fmt.Errorf("%w: decode %q attribute value from Base58: %w", errInvalidPrimaryFilter, attr, err) } + //nolint:staticcheck // this is not DB's responsibility to force API rules, DB still may have these values inside case object.FilterPayloadChecksum, object.FilterPayloadHomomorphicHash: var err error if primValDB, err = hex.DecodeString(primVal); err != nil { @@ -870,6 +880,7 @@ func CalculateCursor(filt *object.SearchFilter, lastItem client.SearchResultItem if val, err = base58.Decode(lastItemVal); err != nil { return nil, fmt.Errorf("decode %q attribute value from Base58: %w", attr, err) } + //nolint:staticcheck // this is not DB's responsibility to force API rules, DB still may have these values inside case object.FilterPayloadChecksum, object.FilterPayloadHomomorphicHash: ln := hex.DecodedLen(len(lastItemVal)) if attr == object.FilterPayloadChecksum && ln != sha256.Size || attr == object.FilterPayloadHomomorphicHash && ln != tz.Size { diff --git a/pkg/innerring/config.go b/pkg/innerring/config.go index 004f9acd9e..c775e7530f 100644 --- a/pkg/innerring/config.go +++ b/pkg/innerring/config.go @@ -211,7 +211,6 @@ func setNetworkSettingsDefaults(netCfg *deploy.NetworkConfiguration) { netCfg.WithdrawalFee = 0 // in GAS per withdrawal (Fixed8) netCfg.EigenTrustIterations = 4 netCfg.EigenTrustAlpha = 0.1 - netCfg.HomomorphicHashingDisabled = false } func checkDurationPositive(val time.Duration, key string) error { diff --git a/pkg/innerring/network.go b/pkg/innerring/network.go index 6d19ba0620..e2e85e72cb 100644 --- a/pkg/innerring/network.go +++ b/pkg/innerring/network.go @@ -177,11 +177,6 @@ func convertKnownConfigValues(k, v string) (any, error) { } val = v - case netmapcore.HomomorphicHashingDisabledKey: - val, err = strconv.ParseBool(v) - if err != nil { - err = fmt.Errorf("invalid value for %s key, expected bool, got '%s'", k, v) - } default: val = v diff --git a/pkg/innerring/processors/container/process_container.go b/pkg/innerring/processors/container/process_container.go index 13dc2a429e..249a6106f9 100644 --- a/pkg/innerring/processors/container/process_container.go +++ b/pkg/innerring/processors/container/process_container.go @@ -88,11 +88,10 @@ const ( ) var allowedSystemAttributes = map[string]struct{}{ - sysAttrPrefix + "NAME": {}, - sysAttrPrefix + "ZONE": {}, - sysAttrPrefix + "DISABLE_HOMOMORPHIC_HASHING": {}, - sysAttrPrefix + "LOCK_UNTIL": {}, - sysAttrChainMeta: {}, + sysAttrPrefix + "NAME": {}, + sysAttrPrefix + "ZONE": {}, + sysAttrPrefix + "LOCK_UNTIL": {}, + sysAttrChainMeta: {}, } func (cp *Processor) checkPutContainer(cnr containerSDK.Container, cnrBytes, sessionToken, invocScript, verifScript []byte, domainName, domainZone string) error { @@ -140,12 +139,6 @@ func (cp *Processor) checkPutContainer(cnr containerSDK.Container, cnrBytes, ses return fmt.Errorf("invalid storage policy: %w", err) } - // check homomorphic hashing setting - err = checkHomomorphicHashing(cp.netState, cnr) - if err != nil { - return fmt.Errorf("incorrect homomorphic hashing setting: %w", err) - } - if domainZone != "" { // if PutNamed event => check if values in-container domain name and zone correspond to args err = checkNNS(cnr, domainName, domainZone) if err != nil { @@ -421,16 +414,3 @@ func checkNNS(cnr containerSDK.Container, name, zone string) error { return nil } - -func checkHomomorphicHashing(ns NetworkState, cnr containerSDK.Container) error { - netSetting, err := ns.HomomorphicHashDisabled() - if err != nil { - return fmt.Errorf("could not get setting in contract: %w", err) - } - - if cnrSetting := cnr.IsHomomorphicHashingDisabled(); netSetting != cnrSetting { - return fmt.Errorf("network setting: %t, container setting: %t", netSetting, cnrSetting) - } - - return nil -} diff --git a/pkg/innerring/processors/container/processor.go b/pkg/innerring/processors/container/processor.go index 8c703133f3..39b4e81707 100644 --- a/pkg/innerring/processors/container/processor.go +++ b/pkg/innerring/processors/container/processor.go @@ -61,14 +61,6 @@ type NetworkState interface { // which did not allow reading the value. Epoch() (uint64, error) - // HomomorphicHashDisabled must return boolean that - // represents homomorphic network state: - // * true if hashing is disabled; - // * false if hashing is enabled. - // - // which did not allow reading the value. - HomomorphicHashDisabled() (bool, error) - // NetMap must return actual network map. NetMap() (*netmap.NetMap, error) diff --git a/pkg/local_object_storage/engine/engine_test.go b/pkg/local_object_storage/engine/engine_test.go index af85990e15..87e0613ca4 100644 --- a/pkg/local_object_storage/engine/engine_test.go +++ b/pkg/local_object_storage/engine/engine_test.go @@ -154,7 +154,7 @@ func generateObjectWithCID(cnr cid.ID) *object.Object { obj.SetID(oidtest.ID()) obj.SetPayload([]byte{1, 2, 3, 4, 5}) obj.SetPayloadChecksum(checksum.NewSHA256(sha256.Sum256(obj.Payload()))) - obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(obj.Payload()))) + obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(obj.Payload()))) //nolint:staticcheck // this is a test and such objects are possible return obj } diff --git a/pkg/local_object_storage/metabase/db_test.go b/pkg/local_object_storage/metabase/db_test.go index a7bf8fa351..cd46c01c1b 100644 --- a/pkg/local_object_storage/metabase/db_test.go +++ b/pkg/local_object_storage/metabase/db_test.go @@ -100,7 +100,7 @@ func generateObjectWithCID(t testing.TB, cnr cid.ID) *object.Object { obj := object.New(cnr, usertest.ID()) obj.SetID(oidtest.ID()) obj.SetPayloadChecksum(csum) - obj.SetPayloadHomomorphicHash(csumTZ) + obj.SetPayloadHomomorphicHash(csumTZ) //nolint:staticcheck // this is a test and such objects are possible obj.SetPayload(payload) obj.SetPayloadSize(uint64(len(payload))) diff --git a/pkg/local_object_storage/metabase/get.go b/pkg/local_object_storage/metabase/get.go index 4fb0431848..e2f31e5df4 100644 --- a/pkg/local_object_storage/metabase/get.go +++ b/pkg/local_object_storage/metabase/get.go @@ -139,6 +139,7 @@ func get(metaCursor *bbolt.Cursor, addr oid.Address, checkStatus, raw bool, curr } var ch = checksum.NewSHA256([sha256.Size]byte(attrVal)) obj.SetPayloadChecksum(ch) + //nolint:staticcheck // old objects may still have it case object.FilterPayloadHomomorphicHash: if len(attrVal) != tz.Size { return nil, fmt.Errorf("invalid homo checksum in meta of %s/%s: length %d", cnr, objID, len(attrVal)) diff --git a/pkg/local_object_storage/metabase/metadata.go b/pkg/local_object_storage/metabase/metadata.go index c2849cb3c8..b4806e3a4c 100644 --- a/pkg/local_object_storage/metabase/metadata.go +++ b/pkg/local_object_storage/metabase/metadata.go @@ -98,6 +98,7 @@ func PutMetadataForObject(tx *bbolt.Tx, hdr object.Object, phy bool) error { return err } } + //nolint:staticcheck // this is not DB's responsibility to force API rules, DB still may have these values inside if h, ok := hdr.PayloadHomomorphicHash(); ok { if err = putPlainAttribute(metaBkt, &keyBuf, id, object.FilterPayloadHomomorphicHash, string(h.Value())); err != nil { return err diff --git a/pkg/local_object_storage/metabase/metadata_test.go b/pkg/local_object_storage/metabase/metadata_test.go index 5632effeb3..166484aa8d 100644 --- a/pkg/local_object_storage/metabase/metadata_test.go +++ b/pkg/local_object_storage/metabase/metadata_test.go @@ -106,7 +106,7 @@ func TestPutMetadata(t *testing.T) { pldHmmHashBytes := [64]byte{124, 127, 67, 236, 186, 166, 150, 202, 4, 115, 163, 58, 242, 73, 149, 35, 153, 93, 4, 247, 62, 18, 13, 150, 53, 141, 131, 172, 207, 164, 187, 240, 16, 30, 18, 30, 136, 0, 197, 213, 185, 62, 153, 223, 42, 213, 207, 86, 131, 144, 121, 127, 251, 248, 253, 176, 145, 101, 69, 75, 12, 97, 27, 19} - pldHmmHash := checksum.NewTillichZemor(pldHmmHashBytes) + pldHmmHash := checksum.NewTillichZemor(pldHmmHashBytes) //nolint:staticcheck // this is a test and such objects are possible splitID := []byte{240, 204, 35, 185, 222, 70, 69, 124, 160, 224, 208, 185, 9, 114, 37, 109} var attrs []object.Attribute addAttr := func(k, v string) { attrs = append(attrs, object.NewAttribute(k, v)) } @@ -133,7 +133,7 @@ func TestPutMetadata(t *testing.T) { obj.SetParentID(parentID) obj.SetFirstID(firstID) obj.SetPayloadChecksum(pldHash) - obj.SetPayloadHomomorphicHash(pldHmmHash) + obj.SetPayloadHomomorphicHash(pldHmmHash) //nolint:staticcheck // this is a test and such objects are possible obj.SetSplitID(object.NewSplitIDFromV2(splitID)) obj.SetAttributes(attrs...) diff --git a/pkg/local_object_storage/metabase/select_test.go b/pkg/local_object_storage/metabase/select_test.go index 1cfb1ba6fe..824df277a4 100644 --- a/pkg/local_object_storage/metabase/select_test.go +++ b/pkg/local_object_storage/metabase/select_test.go @@ -414,6 +414,7 @@ func TestDB_SelectWithSlowFilters(t *testing.T) { err = putBig(db, raw2) require.NoError(t, err) + //nolint:staticcheck // this is a test and such objects are possible t.Run("object with TZHash", func(t *testing.T) { cs, _ := raw1.PayloadHomomorphicHash() homoHash := [tz.Size]byte(cs.Value()) diff --git a/pkg/local_object_storage/shard/reload_test.go b/pkg/local_object_storage/shard/reload_test.go index 8086597497..9876de7538 100644 --- a/pkg/local_object_storage/shard/reload_test.go +++ b/pkg/local_object_storage/shard/reload_test.go @@ -126,6 +126,6 @@ func newObject(t testing.TB) *object.Object { x.SetPayloadSize(3) x.SetType(object.TypeRegular) x.SetPayloadChecksum(checksum.NewSHA256(sha256.Sum256(x.Payload()))) - x.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(x.Payload()))) + x.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(x.Payload()))) //nolint:staticcheck // this is a test and such objects are possible return x } diff --git a/pkg/local_object_storage/shard/shard_test.go b/pkg/local_object_storage/shard/shard_test.go index 2ac47c7cb8..41253ca604 100644 --- a/pkg/local_object_storage/shard/shard_test.go +++ b/pkg/local_object_storage/shard/shard_test.go @@ -105,7 +105,7 @@ func generateObjectWithPayload(cnr cid.ID, data []byte) *object.Object { obj.SetID(oidtest.ID()) obj.SetPayload(data) obj.SetPayloadChecksum(csum) - obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(csum.Value()))) + obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(csum.Value()))) //nolint:staticcheck // this is a test and such objects are possible return obj } diff --git a/pkg/local_object_storage/writecache/flush_test.go b/pkg/local_object_storage/writecache/flush_test.go index c02bc9ccd2..66b311cb88 100644 --- a/pkg/local_object_storage/writecache/flush_test.go +++ b/pkg/local_object_storage/writecache/flush_test.go @@ -343,7 +343,7 @@ func newObject(t *testing.T, size int) (*object.Object, []byte) { obj.SetType(object.TypeRegular) obj.SetPayload(make([]byte, size)) obj.SetPayloadChecksum(checksum.NewSHA256(sha256.Sum256(obj.Payload()))) - obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(obj.Payload()))) + obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(tz.Sum(obj.Payload()))) //nolint:staticcheck // this is a test and such objects are possible return obj, obj.Marshal() } diff --git a/pkg/morph/client/netmap/config.go b/pkg/morph/client/netmap/config.go index 5cd8ce4dca..c6a939e1af 100644 --- a/pkg/morph/client/netmap/config.go +++ b/pkg/morph/client/netmap/config.go @@ -7,20 +7,18 @@ import ( "github.com/nspcc-dev/neo-go/pkg/encoding/bigint" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" - islices "github.com/nspcc-dev/neofs-node/internal/slices" "github.com/nspcc-dev/neofs-node/pkg/morph/client" ) const ( - MaxObjectSizeConfig = "MaxObjectSize" - BasicIncomeRateConfig = "BasicIncomeRate" - EpochDurationConfig = "EpochDuration" - ContainerFeeConfig = "ContainerFee" - ContainerAliasFeeConfig = "ContainerAliasFee" - EigenTrustIterationsConfig = "EigenTrustIterations" - EigenTrustAlphaConfig = "EigenTrustAlpha" - WithdrawFeeConfig = "WithdrawFee" - HomomorphicHashingDisabledKey = "HomomorphicHashingDisabled" + MaxObjectSizeConfig = "MaxObjectSize" + BasicIncomeRateConfig = "BasicIncomeRate" + EpochDurationConfig = "EpochDuration" + ContainerFeeConfig = "ContainerFee" + ContainerAliasFeeConfig = "ContainerAliasFee" + EigenTrustIterationsConfig = "EigenTrustIterations" + EigenTrustAlphaConfig = "EigenTrustAlpha" + WithdrawFeeConfig = "WithdrawFee" ) // MaxObjectSize receives max object size configuration @@ -99,14 +97,6 @@ func (c *Client) EigenTrustAlpha() (float64, error) { return strconv.ParseFloat(strAlpha, 64) } -// HomomorphicHashDisabled returns global configuration value of homomorphic hashing -// settings. -// -// Returns (false, nil) if config key is not found in the contract. -func (c *Client) HomomorphicHashDisabled() (bool, error) { - return c.readBoolConfig(HomomorphicHashingDisabledKey) -} - // WithdrawFee returns global configuration value of fee paid by user to // withdraw assets from NeoFS contract. func (c *Client) WithdrawFee() (uint64, error) { @@ -138,22 +128,6 @@ func (c *Client) readStringConfig(key string) (string, error) { return v.(string), nil } -// reads boolean value by the given key from the NeoFS network configuration -// stored in FS chain. Returns false if key is not presented. -func (c *Client) readBoolConfig(key string) (bool, error) { - v, err := c.config([]byte(key), BoolAssert) - if err != nil { - if errors.Is(err, ErrConfigNotFound) { - return false, nil - } - - return false, fmt.Errorf("read boolean configuration value %s from FS chain: %w", key, err) - } - - // BoolAssert is guaranteed to return bool if the error is nil. - return v.(bool), nil -} - // SetConfigPrm groups parameters of SetConfig operation. type SetConfigPrm struct { id []byte @@ -217,8 +191,6 @@ type NetworkConfiguration struct { WithdrawalFee uint64 - HomomorphicHashingDisabled bool - Raw []RawNetworkParameter } @@ -279,8 +251,6 @@ func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) { } case WithdrawFeeConfig: res.WithdrawalFee = bytesToUint64(value) - case HomomorphicHashingDisabledKey: - res.HomomorphicHashingDisabled = bytesToBool(value) } return nil @@ -296,10 +266,6 @@ func bytesToUint64(val []byte) uint64 { return bigint.FromBytes(val).Uint64() } -func bytesToBool(val []byte) bool { - return !islices.AllZeros(val) -} - // ErrConfigNotFound is returned when the requested key was not found // in the network config (returned value is `Null`). var ErrConfigNotFound = errors.New("config value not found") diff --git a/pkg/services/meta/containers.go b/pkg/services/meta/containers.go index bd7defa814..a83da719ef 100644 --- a/pkg/services/meta/containers.go +++ b/pkg/services/meta/containers.go @@ -253,7 +253,7 @@ func fillObjectIndex(batch map[string][]byte, h object.Object, isParent bool) { ver = *v } var pldHmmHash []byte - if hash, ok := h.PayloadHomomorphicHash(); ok { + if hash, ok := h.PayloadHomomorphicHash(); ok { //nolint:staticcheck // db still may store it pldHmmHash = hash.Value() } @@ -267,7 +267,7 @@ func fillObjectIndex(batch map[string][]byte, h object.Object, isParent bool) { putIntAttribute(batch, id, object.FilterCreationEpoch, strconv.FormatUint(creationEpoch, 10), new(big.Int).SetUint64(creationEpoch)) putIntAttribute(batch, id, object.FilterPayloadSize, strconv.FormatUint(pSize, 10), new(big.Int).SetUint64(pSize)) putPlainAttribute(batch, id, object.FilterPayloadChecksum, string(pldHash.Value())) - putPlainAttribute(batch, id, object.FilterPayloadHomomorphicHash, string(pldHmmHash)) + putPlainAttribute(batch, id, object.FilterPayloadHomomorphicHash, string(pldHmmHash)) //nolint:staticcheck // db still may store it if !fPart.IsZero() { putPlainAttribute(batch, id, object.FilterFirstSplitObject, string(fPart[:])) } diff --git a/pkg/services/object/acl/eacl/v2/eacl_test.go b/pkg/services/object/acl/eacl/v2/eacl_test.go index e2ed45cdae..6786b8583b 100644 --- a/pkg/services/object/acl/eacl/v2/eacl_test.go +++ b/pkg/services/object/acl/eacl/v2/eacl_test.go @@ -269,6 +269,7 @@ func TestObjectHeaders(t *testing.T) { const creationEpochStr = "11361641039719275900" payloadHash := checksum.NewSHA256([sha256.Size]byte{250, 136, 163, 172, 95, 206, 95, 222, 135, 183, 75, 254, 82, 63, 114, 86, 175, 234, 218, 126, 249, 126, 15, 93, 228, 69, 103, 226, 188, 20, 53, 15}) const payloadHashStr = "SHA256:fa88a3ac5fce5fde87b74bfe523f7256afeada7ef97e0f5de44567e2bc14350f" + //nolint:staticcheck // this is a test and such objects are possible homoHash := checksum.NewTillichZemor([tz.Size]byte{199, 94, 209, 171, 81, 255, 104, 105, 199, 78, 103, 145, 33, 82, 51, 104, 36, 71, 94, 186, 122, 163, 215, 213, 37, 126, 202, 109, 135, 119, 180, 166, 97, 152, 172, 81, 109, 199, 85, 214, 251, 33, 77, 105, 107, 117, 10, 177, 172, 16, 236, 68, 168, 250, 78, 238, 247, 11, 4, 175, 194, 125, 131, 30}) const homoHashStr = "TZ:c75ed1ab51ff6869c74e67912152336824475eba7aa3d7d5257eca6d8777b4a66198ac516dc755d6fb214d696b750ab1ac10ec44a8fa4eeef70b04afc27d831e" @@ -337,7 +338,7 @@ func TestObjectHeaders(t *testing.T) { obj.SetVersion(&ver) obj.SetOwner(owner) obj.SetPayloadChecksum(payloadHash) - obj.SetPayloadHomomorphicHash(homoHash) + obj.SetPayloadHomomorphicHash(homoHash) //nolint:staticcheck // this is a test and such objects are possible obj.SetAttributes( object.NewAttribute("foo", "bar"), object.NewAttribute("hello", "world"), @@ -352,6 +353,7 @@ func TestObjectHeaders(t *testing.T) { const childPayloadLenStr = "17034386584505117111" childPayloadHash := checksum.NewSHA256([sha256.Size]byte{70, 249, 108, 82, 211, 20, 129, 201, 177, 205, 253, 190, 156, 148, 7, 122, 165, 153, 54, 128, 96, 0, 246, 232, 5, 78, 111, 190, 68, 74, 167, 174}) const childPayloadHashStr = "SHA256:46f96c52d31481c9b1cdfdbe9c94077aa59936806000f6e8054e6fbe444aa7ae" + //nolint:staticcheck // this is a test and such objects are possible childHomoHash := checksum.NewTillichZemor([tz.Size]byte{191, 33, 176, 230, 72, 226, 40, 54, 248, 99, 98, 74, 97, 223, 128, 145, 184, 14, 124, 85, 113, 204, 145, 55, 214, 96, 210, 161, 27, 170, 203, 191, 246, 83, 173, 163, 112, 152, 185, 131, 251, 218, 64, 145, 78, 29, 203, 105, 12, 150, 123, 54, 109, 23, 29, 140, 87, 196, 70, 81, 88, 110, 152, 99}) const childHomoHashStr = "TZ:bf21b0e648e22836f863624a61df8091b80e7c5571cc9137d660d2a11baacbbff653ada37098b983fbda40914e1dcb690c967b366d171d8c57c44651586e9863" @@ -366,7 +368,7 @@ func TestObjectHeaders(t *testing.T) { child.SetVersion(&ver) child.SetType(object.TypeLock) child.SetPayloadChecksum(childPayloadHash) - child.SetPayloadHomomorphicHash(childHomoHash) + child.SetPayloadHomomorphicHash(childHomoHash) //nolint:staticcheck // this is a test and such objects are possible child.SetParent(&obj) testWithObject(t, &id, child, [][2]string{ diff --git a/pkg/services/object/acl/eacl/v2/object.go b/pkg/services/object/acl/eacl/v2/object.go index 167b3f944e..e53bd96c1c 100644 --- a/pkg/services/object/acl/eacl/v2/object.go +++ b/pkg/services/object/acl/eacl/v2/object.go @@ -83,6 +83,7 @@ func headersFromObject(obj *object.Object, cnr cid.ID, oid *oid.ID) []eaclSDK.He }) } + //nolint:staticcheck // if we store old objects with it, we should support old eACL rules cs, ok = obj.PayloadHomomorphicHash() if ok { res = append(res, sysObjHdr{ @@ -179,6 +180,7 @@ func headersFromBinaryObjectHeader(buf []byte, cnr cid.ID, id *oid.ID) ([]eaclSD } off += n + //nolint:staticcheck // if we store old objects with it, we should support old eACL rules res = append(res, sysObjHdr{k: eaclSDK.FilterObjectPayloadHomomorphicChecksum, v: cs.String()}) case protoobject.FieldHeaderSessionToken: ln, n, err := iprotobuf.ParseLENField(buf[off:], num, typ) diff --git a/pkg/services/object/put/local.go b/pkg/services/object/put/local.go index 1e0114c246..2a8ca09288 100644 --- a/pkg/services/object/put/local.go +++ b/pkg/services/object/put/local.go @@ -9,7 +9,6 @@ import ( "github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" - "github.com/nspcc-dev/tzhash/tz" ) // ObjectStorage is an object storage interface. @@ -54,10 +53,11 @@ func (p *Service) ValidateAndStoreObjectLocally(obj object.Object) error { csType := cs.Type() switch csType { default: - return errors.New("unsupported payload checksum type") + return errors.New("unknown payload checksum type") + case checksum.TillichZemor: + return errors.New("object has unsupported Tillich-Zémor checksum") case - checksum.SHA256, - checksum.TillichZemor: + checksum.SHA256: } maxPayloadSz := p.maxSizeSrc.MaxObjectSize() @@ -75,45 +75,19 @@ func (p *Service) ValidateAndStoreObjectLocally(obj object.Object) error { return ErrExceedingMaxSize } - cnr, err := p.cnrSrc.Get(cnrID) - if err != nil { - return fmt.Errorf("read container by ID: %w", err) - } - - if !cnr.IsHomomorphicHashingDisabled() { - csHomo, csHomoSet := obj.PayloadHomomorphicHash() - switch { - case !csHomoSet: - return errors.New("missing homomorphic payload checksum") - case csHomo.Type() != checksum.TillichZemor: - return fmt.Errorf("wrong/unsupported type of homomorphic payload checksum, expected %s", checksum.TillichZemor) - case len(csHomo.Value()) != tz.Size: - return fmt.Errorf("invalid/unsupported length of %s homomorphic payload checksum, expected %d", - csHomo.Type(), tz.Size) - } - } - if err := p.fmtValidator.Validate(&obj, false, true); err != nil { return fmt.Errorf("validate object format: %w", err) } - err = p.fmtValidator.ValidateContent(&obj) + err := p.fmtValidator.ValidateContent(&obj) if err != nil { return fmt.Errorf("validate payload content: %w", err) } - //nolint:exhaustive - switch csType { - case checksum.SHA256: - h := sha256.Sum256(payload) - if !bytes.Equal(h[:], cs.Value()) { - return errors.New("payload SHA-256 checksum mismatch") - } - case checksum.TillichZemor: - h := tz.Sum(payload) - if !bytes.Equal(h[:], cs.Value()) { - return errors.New("payload Tillich-Zemor checksum mismatch") - } + // checksum must be only SHA256, this was checked above + h := sha256.Sum256(payload) + if !bytes.Equal(h[:], cs.Value()) { + return errors.New("payload SHA-256 checksum mismatch") } return putObjectLocally(p.localStore, &obj, nil) diff --git a/pkg/services/object/put/service_test.go b/pkg/services/object/put/service_test.go index 2e4d936183..4b4c741070 100644 --- a/pkg/services/object/put/service_test.go +++ b/pkg/services/object/put/service_test.go @@ -1222,7 +1222,7 @@ func assertSplitChain(t *testing.T, limit, ln uint64, sessionToken *session.Obje require.Zero(t, firstParent.PayloadSize()) _, ok := firstParent.PayloadChecksum() require.False(t, ok) - _, ok = firstParent.PayloadHomomorphicHash() + _, ok = firstParent.PayloadHomomorphicHash() //nolint:staticcheck // this is a test require.False(t, ok) require.Zero(t, firstParent.GetID()) require.Zero(t, firstParent.Signature()) @@ -1241,6 +1241,7 @@ func assertSplitChain(t *testing.T, limit, ln uint64, sessionToken *session.Obje if cs, ok := lastParent.PayloadChecksum(); ok { firstParentCp.SetPayloadChecksum(cs) } + //nolint:staticcheck // this is a test and such objects are possible if cs, ok := lastParent.PayloadHomomorphicHash(); ok { firstParentCp.SetPayloadHomomorphicHash(cs) } @@ -1284,7 +1285,7 @@ func assertObjectIntegrity(t *testing.T, obj object.Object) { got := sha256.Sum256(payload) require.Equal(t, got[:], cs.Value()) - if cs, ok := obj.PayloadHomomorphicHash(); ok { + if cs, ok := obj.PayloadHomomorphicHash(); ok { //nolint:staticcheck // this is a test and such objects are possible require.Equal(t, checksum.TillichZemor, cs.Type()) got := tz.Sum(payload) require.Equal(t, got[:], cs.Value()) @@ -1587,7 +1588,7 @@ func testInitialPlacementREP(t *testing.T, repRules []uint, initialRules []uint3 obj := *object.New(cidtest.ID(), creator.ID) obj.SetPayload([]byte("Hello, world!")) obj.SetPayloadSize(uint64(len(obj.Payload()))) - obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor([tz.Size]byte(testutil.RandByteSlice(tz.Size)))) + obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor([tz.Size]byte(testutil.RandByteSlice(tz.Size)))) //nolint:staticcheck // this is a test and such objects are possible require.NoError(t, obj.SetVerificationFields(creator)) nodeCounts := make([]uint, len(repRules)) diff --git a/pkg/services/object/put/slice.go b/pkg/services/object/put/slice.go index 4d9776ba64..da750bcdd3 100644 --- a/pkg/services/object/put/slice.go +++ b/pkg/services/object/put/slice.go @@ -18,13 +18,12 @@ import ( ) type slicingTarget struct { - ctx context.Context - signer user.Signer - sessionToken *session.Object - sessionTokenV2 *sessionv2.Token - currentEpoch uint64 - maxObjSize uint64 - homoHashDisabled bool + ctx context.Context + signer user.Signer + sessionToken *session.Object + sessionTokenV2 *sessionv2.Token + currentEpoch uint64 + maxObjSize uint64 nextTarget internal.Target @@ -37,7 +36,6 @@ type slicingTarget struct { func newSlicingTarget( ctx context.Context, maxObjSize uint64, - homoHashDisabled bool, signer user.Signer, sessionToken *session.Object, sessionTokenV2 *sessionv2.Token, @@ -45,14 +43,13 @@ func newSlicingTarget( initNextTarget internal.Target, ) internal.Target { return &slicingTarget{ - ctx: ctx, - signer: signer, - sessionToken: sessionToken, - sessionTokenV2: sessionTokenV2, - currentEpoch: curEpoch, - maxObjSize: maxObjSize, - homoHashDisabled: homoHashDisabled, - nextTarget: initNextTarget, + ctx: ctx, + signer: signer, + sessionToken: sessionToken, + sessionTokenV2: sessionTokenV2, + currentEpoch: curEpoch, + maxObjSize: maxObjSize, + nextTarget: initNextTarget, } } @@ -65,9 +62,6 @@ func (x *slicingTarget) WriteHeader(hdr *object.Object) error { } else if x.sessionToken != nil { opts.SetSession(*x.sessionToken) } - if !x.homoHashDisabled { - opts.CalculateHomomorphicChecksum() - } if payloadSize := hdr.PayloadSize(); payloadSize != 0 && payloadSize != math.MaxUint64 { // https://github.com/nspcc-dev/neofs-api/blob/d95228c40283cf6e188073a87a802af7e5dc0a7d/object/types.proto#L93-L95 diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index c4cae1af7e..7d832af50a 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -71,8 +71,6 @@ func (p *Streamer) initTarget(prm *PutInitPrm) error { return fmt.Errorf("(%T) could not obtain max object size parameter", p) } - homomorphicChecksumRequired := !prm.cnr.IsHomomorphicHashingDisabled() - if prm.hdr.Signature() != nil { p.relay = prm.relay @@ -85,8 +83,6 @@ func (p *Streamer) initTarget(prm *PutInitPrm) error { cachedCnr: prm.cnr, isECPart: prm.ecPart.RuleIndex >= 0, maxPayloadSz: p.maxPayloadSz, - - homomorphicChecksumRequired: homomorphicChecksumRequired, } return nil @@ -158,14 +154,12 @@ func (p *Streamer) initTarget(prm *PutInitPrm) error { nextTarget: newSlicingTarget( p.ctx, p.maxPayloadSz, - !homomorphicChecksumRequired, sessionSigner, sToken, sTokenV2, p.networkState.CurrentEpoch(), p.newCommonTarget(prm), ), - homomorphicChecksumRequired: homomorphicChecksumRequired, } return nil diff --git a/pkg/services/object/put/validation.go b/pkg/services/object/put/validation.go index f5b491e830..9b7d2833a0 100644 --- a/pkg/services/object/put/validation.go +++ b/pkg/services/object/put/validation.go @@ -15,7 +15,6 @@ import ( "github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" - "github.com/nspcc-dev/tzhash/tz" "go.uber.org/zap" ) @@ -42,8 +41,6 @@ type validatingTarget struct { isECPart bool cachedRepNumber uint64 cachedECRules []netmap.ECRule - - homomorphicChecksumRequired bool } var ( @@ -78,20 +75,6 @@ func (t *validatingTarget) WriteHeader(obj *object.Object) error { return ErrExceedingMaxSize } - if t.homomorphicChecksumRequired { - cs, csSet := obj.PayloadHomomorphicHash() - switch { - case !csSet: - return errors.New("missing homomorphic payload checksum") - case cs.Type() != checksum.TillichZemor: - return fmt.Errorf("wrong/unsupported type of homomorphic payload checksum: %s instead of %s", - cs.Type(), checksum.TillichZemor) - case len(cs.Value()) != tz.Size: - return fmt.Errorf("invalid/unsupported length of %s homomorphic payload checksum: %d instead of %d", - cs.Type(), len(cs.Value()), tz.Size) - } - } - cs, csSet := obj.PayloadChecksum() if !csSet { return errors.New("missing payload checksum") @@ -99,11 +82,11 @@ func (t *validatingTarget) WriteHeader(obj *object.Object) error { switch typ := cs.Type(); typ { default: - return fmt.Errorf("(%T) unsupported payload checksum type %v", t, typ) + return fmt.Errorf("(%T) unknown payload checksum type %v", t, typ) case checksum.SHA256: t.hash = sha256.New() case checksum.TillichZemor: - t.hash = tz.New() + return errors.New("object has unsupported Tillich-Zémor checksum") } t.checksum = cs.Value() diff --git a/pkg/services/object/search/search.go b/pkg/services/object/search/search.go index 4b92430c3e..a1184a945b 100644 --- a/pkg/services/object/search/search.go +++ b/pkg/services/object/search/search.go @@ -65,6 +65,11 @@ func (exec *execCtx) analyzeStatus(ctx context.Context, execCnr bool) { func verifyQuery(prm Prm) error { for i := range prm.filters { + // nolint:staticcheck // deprecated but that is what is checked there + if prm.filters[i].Header() == object.FilterPayloadHomomorphicHash { + return fmt.Errorf("%s filter target is prohibited starting from API 2.23", object.FilterPayloadHomomorphicHash) + } + //nolint:exhaustive switch prm.filters[i].Operation() { case object.MatchNumGT, object.MatchNumGE, object.MatchNumLT, object.MatchNumLE: diff --git a/pkg/util/meta/test/metatest.go b/pkg/util/meta/test/metatest.go index 18eaffe506..36b53492d8 100644 --- a/pkg/util/meta/test/metatest.go +++ b/pkg/util/meta/test/metatest.go @@ -119,7 +119,7 @@ func TestSearchObjects(t *testing.T, db DB, testSplitID bool) { obj.SetCreationEpoch(10 + uint64(nGroup)) obj.SetPayloadSize(20 + uint64(nGroup)) obj.SetPayloadChecksum(checksum.NewSHA256(checksums[nGlobal])) - obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(hmmChecksums[nGlobal])) + obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor(hmmChecksums[nGlobal])) //nolint:staticcheck // db still may store it si := strconv.Itoa(nGlobal) obj.SetAttributes( object.NewAttribute("attr_common", "val_common"), @@ -935,6 +935,7 @@ func TestSearchObjects(t *testing.T, db DB, testSplitID bool) { obj.SetType(object.TypeTombstone) obj.SetPayloadChecksum(checksum.NewSHA256([sha256.Size]byte{105, 23, 175, 222, 242, 223, 82, 69, 207, 193, 106, 168, 9, 238, 85, 29, 34, 68, 233, 54, 143, 217, 223, 248, 236, 227, 121, 195, 155, 187, 37, 242})) + //nolint:staticcheck // db still may store it obj.SetPayloadHomomorphicHash(checksum.NewTillichZemor([tz.Size]byte{171, 152, 81, 127, 134, 240, 228, 236, 10, 131, 10, 114, 174, 138, 120, 108, 165, 104, 36, 100, 129, 235, 160, 213, 96, 230, 190, 15, 196, 5, 252, 194, 205, 48, 236, 57, 117, 238, 170, 36, 251, 104, 62, 124, 1, 206, 131, 226, 221, 111, 73, 54, 235, 100, 49, 32, 252, 255,