Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new hash format in morph nns client #2063

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions cmd/neofs-adm/internal/modules/morph/initialize_nns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion pkg/morph/client/nns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down