Skip to content

Commit de115ad

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 e41a4b2 commit de115ad

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
@@ -16,6 +16,9 @@ import (
1616
"github.com/spf13/viper"
1717
)
1818

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

@@ -49,7 +52,13 @@ func verifiedNodesDomainAccessList(cmd *cobra.Command, _ []string) error {
4952
}
5053

5154
for i := range records {
52-
cmd.Println(records[i])
55+
neoAddr := strings.TrimPrefix(records[i], nnsNeoAddressTextRecordPrefix)
56+
if len(neoAddr) == len(records[i]) {
57+
cmd.Printf("%s (not a Neo address)\n", records[i])
58+
continue
59+
}
60+
61+
cmd.Println(neoAddr)
5362
}
5463

5564
return nil
@@ -85,9 +94,9 @@ func verifiedNodesDomainSetAccessList(cmd *cobra.Command, _ []string) error {
8594
if err != nil {
8695
return fmt.Errorf("address #%d is invalid: %w", i, err)
8796
}
88-
}
8997

90-
additionalRecords = strNeoAddresses
98+
additionalRecords = append(additionalRecords, nnsNeoAddressTextRecordPrefix+strNeoAddresses[i])
99+
}
91100
} else {
92101
additionalRecords = make([]string, len(strPublicKeys))
93102

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

106-
additionalRecords[i] = address.Uint160ToString(pubKey.GetScriptHash())
115+
additionalRecords[i] = nnsNeoAddressTextRecordPrefix + address.Uint160ToString(pubKey.GetScriptHash())
107116
}
108117
}
109118

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)