diff --git a/CHANGELOG.md b/CHANGELOG.md index ad0cd39963..65e22a00d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Changelog for NeoFS Node - Shard can now change mode when encountering background disk errors (#2035) - Background workers and object service now use separate client caches (#2048) - `replicator.pool_size` config field to tune replicator pool size (#2049) +- Fix NNS hash parsing in morph client (#2063) ### Changed - `object lock` command reads CID and OID the same way other commands do (#1971) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go index d5dee7d72f..980fc7b061 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go @@ -261,6 +261,8 @@ func parseNNSResolveResult(res stackitem.Item) (util.Uint160, error) { continue } + // We support several formats for hash encoding, this logic should be maintained in sync + // with nnsResolve from pkg/morph/client/nns.go h, err := util.Uint160DecodeStringLE(string(bs)) if err == nil { return h, nil diff --git a/pkg/morph/client/nns.go b/pkg/morph/client/nns.go index 46f7d717f4..d22faf08e7 100644 --- a/pkg/morph/client/nns.go +++ b/pkg/morph/client/nns.go @@ -8,6 +8,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" + "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/util" @@ -149,7 +150,20 @@ func nnsResolve(c *rpcclient.WSClient, nnsHash util.Uint160, domain string) (uti if err != nil { return util.Uint160{}, fmt.Errorf("malformed response: %w", err) } - return util.Uint160DecodeStringLE(string(bs)) + + // We support several formats for hash encoding, this logic should be maintained in sync + // with parseNNSResolveResult from cmd/neofs-adm/internal/modules/morph/initialize_nns.go + h, err := util.Uint160DecodeStringLE(string(bs)) + if err == nil { + return h, nil + } + + h, err = address.StringToUint160(string(bs)) + if err == nil { + return h, nil + } + + return util.Uint160{}, errors.New("no valid hashes are found") } func exists(c *rpcclient.WSClient, nnsHash util.Uint160, domain string) (bool, error) {