Skip to content

Commit cc4add1

Browse files
committed
nns: Use format of Neo address records specified in NEP-18 standard
From now verified nodes' domain records are prefixed with `address=` in order to comply the Neo specification. Signed-off-by: Leonard Lyubich <[email protected]>
1 parent 49c7996 commit cc4add1

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

cmd/neofs-adm/internal/modules/morph/verified_domains.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import (
1818
"github.com/spf13/viper"
1919
)
2020

21+
// as described in NEP-18 Specification https://github.com/neo-project/proposals/pull/133
22+
const nnsNeoAddressTextRecordPrefix = "address="
23+
2124
func verifiedNodesDomainAccessList(cmd *cobra.Command, _ []string) error {
2225
vpr := viper.GetViper()
2326

@@ -51,7 +54,13 @@ func verifiedNodesDomainAccessList(cmd *cobra.Command, _ []string) error {
5154
}
5255

5356
for i := range records {
54-
cmd.Println(records[i])
57+
neoAddr := strings.TrimPrefix(records[i], nnsNeoAddressTextRecordPrefix)
58+
if len(neoAddr) == len(records[i]) {
59+
cmd.Printf("%s (not a Neo address)\n", records[i])
60+
continue
61+
}
62+
63+
cmd.Println(neoAddr)
5564
}
5665

5766
return nil
@@ -87,9 +96,9 @@ func verifiedNodesDomainSetAccessList(cmd *cobra.Command, _ []string) error {
8796
if err != nil {
8897
return fmt.Errorf("address #%d is invalid: %w", i, err)
8998
}
90-
}
9199

92-
additionalRecords = strNeoAddresses
100+
additionalRecords = append(additionalRecords, nnsNeoAddressTextRecordPrefix+strNeoAddresses[i])
101+
}
93102
} else {
94103
additionalRecords = make([]string, len(strPublicKeys))
95104

@@ -105,7 +114,7 @@ func verifiedNodesDomainSetAccessList(cmd *cobra.Command, _ []string) error {
105114
return fmt.Errorf("public key #%d is not a HEX-encoded public key: %w", i, err)
106115
}
107116

108-
additionalRecords[i] = address.Uint160ToString(pubKey.GetScriptHash())
117+
additionalRecords[i] = nnsNeoAddressTextRecordPrefix + address.Uint160ToString(pubKey.GetScriptHash())
109118
}
110119
}
111120

docs/verified-node-domains.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ the network map.
2828
For each public key, a record is created - a structure with at least 3 fields:
2929
1. `ByteString` with name of the corresponding domain
3030
2. `Integer` that is `16` for TXT records (other record types are allowed but left unprocessed)
31-
3. `ByteString` with Neo address of the storage node's public key
31+
3. `ByteString` with `address=<Neo address>` value described in [NEP-18 Specification](https://github.com/neo-project/proposals/pull/133)
3232

3333
### Management
3434

pkg/innerring/processors/netmap/nodevalidation/privatedomains/validator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ func (x *Validator) VerifyAndUpdate(info *netmap.NodeInfo) error {
7777
emit.CheckSig(buf.BinWriter, bNodeKey)
7878
nodeNeoAddress := address.Uint160ToString(hash.Hash160(buf.Bytes()))
7979

80-
err := x.nns.CheckDomainRecord(verifiedNodesDomain, nodeNeoAddress)
80+
// record format is described in NEP-18 Specification https://github.com/neo-project/proposals/pull/133
81+
err := x.nns.CheckDomainRecord(verifiedNodesDomain, "address="+nodeNeoAddress)
8182
if err != nil {
8283
if errors.Is(err, ErrMissingDomainRecord) {
8384
return errAccessDenied

pkg/innerring/processors/netmap/nodevalidation/privatedomains/validator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ func (x *testNNS) CheckDomainRecord(domainName string, record string) error {
7575
func TestValidator_VerifyAndUpdate(t *testing.T) {
7676
const verifiedDomain = "nodes.some-org.neofs"
7777
const hNodeKey = "02a70577a832b338772c8cd07e7eaf526cae8d9b025a51b41671de5a4363eafe07"
78-
const nodeNeoAddress = "NZ1czz5gkEDamTg6Tiw6cxqp9Me1KLs8ae"
79-
const anyOtherNeoAddress = "NfMvD6WmBiCr4erfEnFFLs7jdj4Y5CM7nN"
78+
const nodeNeoAddress = "address=NZ1czz5gkEDamTg6Tiw6cxqp9Me1KLs8ae"
79+
const anyOtherNeoAddress = "address=NfMvD6WmBiCr4erfEnFFLs7jdj4Y5CM7nN"
8080

8181
bNodeKey, err := hex.DecodeString(hNodeKey)
8282
require.NoError(t, err)

0 commit comments

Comments
 (0)