[#1765] Use hex format to print storage node ID

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2022-10-11 15:49:34 +03:00 committed by fyrchik
parent 5a2daadd37
commit 8714fc42b5
13 changed files with 23 additions and 29 deletions

View file

@ -29,6 +29,7 @@ Changelog for NeoFS Node
- Unify help messages in CLI (#1854) - Unify help messages in CLI (#1854)
- `evacuate`, `set-mode` and `flush-cache` control subcommands now accept a list of shard ids (#1867) - `evacuate`, `set-mode` and `flush-cache` control subcommands now accept a list of shard ids (#1867)
- Reading `object` commands of NeoFS CLI don't open remote sessions (#1865) - Reading `object` commands of NeoFS CLI don't open remote sessions (#1865)
- Use hex format to print storage node ID (#1765)
### Fixed ### Fixed
- Description of command `netmap nodeinfo` (#1821) - Description of command `netmap nodeinfo` (#1821)

View file

@ -1,9 +1,9 @@
package main package main
import ( import (
"encoding/hex"
"fmt" "fmt"
"github.com/mr-tron/base58"
nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node" nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
@ -110,7 +110,7 @@ func (n notificationWriter) Notify(topic string, address oid.Address) {
func initNotifications(c *cfg) { func initNotifications(c *cfg) {
if nodeconfig.Notification(c.appCfg).Enabled() { if nodeconfig.Notification(c.appCfg).Enabled() {
topic := nodeconfig.Notification(c.appCfg).DefaultTopic() topic := nodeconfig.Notification(c.appCfg).DefaultTopic()
pubKey := base58.Encode(c.cfgNodeInfo.localInfo.PublicKey()) pubKey := hex.EncodeToString(c.cfgNodeInfo.localInfo.PublicKey())
if topic == "" { if topic == "" {
topic = pubKey topic = pubKey

4
go.mod
View file

@ -17,9 +17,9 @@ require (
github.com/nspcc-dev/hrw v1.0.9 github.com/nspcc-dev/hrw v1.0.9
github.com/nspcc-dev/neo-go v0.99.2 github.com/nspcc-dev/neo-go v0.99.2
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b // indirect github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b // indirect
github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20221004142957-5fc2644c680d github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20221005093543-3a91383f24a9
github.com/nspcc-dev/neofs-contract v0.15.5-0.20220930133158-d95bc535894c github.com/nspcc-dev/neofs-contract v0.15.5-0.20220930133158-d95bc535894c
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20221005093951-1325b4f27218 github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20221013072718-21eef1ae7f7d
github.com/nspcc-dev/tzhash v1.6.1 github.com/nspcc-dev/tzhash v1.6.1
github.com/panjf2000/ants/v2 v2.4.0 github.com/panjf2000/ants/v2 v2.4.0
github.com/paulmach/orb v0.2.2 github.com/paulmach/orb v0.2.2

8
go.sum
View file

@ -453,8 +453,8 @@ github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b h1:J7
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20221004142957-5fc2644c680d h1:Oc15A8gDoP/TC5kdJi6TW9AnOp5dYiecZ0tJDRUV7vg= github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20221005093543-3a91383f24a9 h1:c9ovp4KuPyIBx4dVG4bmkePlmuN0au4BBtFGXALWFBM=
github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20221004142957-5fc2644c680d/go.mod h1:DRIr0Ic1s+6QgdqmNFNLIqMqd7lNMJfYwkczlm1hDtM= github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20221005093543-3a91383f24a9/go.mod h1:DRIr0Ic1s+6QgdqmNFNLIqMqd7lNMJfYwkczlm1hDtM=
github.com/nspcc-dev/neofs-contract v0.15.3/go.mod h1:BXVZUZUJxrmmDETglXHI8+5DSgn84B9y5DoSWqEjYCs= github.com/nspcc-dev/neofs-contract v0.15.3/go.mod h1:BXVZUZUJxrmmDETglXHI8+5DSgn84B9y5DoSWqEjYCs=
github.com/nspcc-dev/neofs-contract v0.15.5-0.20220930133158-d95bc535894c h1:jG8gu/qLprxjh99J7qGqGiPMJPXPQ5eM0el8Cb6o0Tc= github.com/nspcc-dev/neofs-contract v0.15.5-0.20220930133158-d95bc535894c h1:jG8gu/qLprxjh99J7qGqGiPMJPXPQ5eM0el8Cb6o0Tc=
github.com/nspcc-dev/neofs-contract v0.15.5-0.20220930133158-d95bc535894c/go.mod h1:gN5bo2TlMvLbySImmg76DVj3jVmYgti2VVlQ+h/tcr0= github.com/nspcc-dev/neofs-contract v0.15.5-0.20220930133158-d95bc535894c/go.mod h1:gN5bo2TlMvLbySImmg76DVj3jVmYgti2VVlQ+h/tcr0=
@ -465,8 +465,8 @@ github.com/nspcc-dev/neofs-crypto v0.4.0 h1:5LlrUAM5O0k1+sH/sktBtrgfWtq1pgpDs09f
github.com/nspcc-dev/neofs-crypto v0.4.0/go.mod h1:6XJ8kbXgOfevbI2WMruOtI+qUJXNwSGM/E9eClXxPHs= github.com/nspcc-dev/neofs-crypto v0.4.0/go.mod h1:6XJ8kbXgOfevbI2WMruOtI+qUJXNwSGM/E9eClXxPHs=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659/go.mod h1:/jay1lr3w7NQd/VDBkEhkJmDmyPNsu4W+QV2obsUV40= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659/go.mod h1:/jay1lr3w7NQd/VDBkEhkJmDmyPNsu4W+QV2obsUV40=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20221005093951-1325b4f27218 h1:XtCCJTVIRyW374PxwBdOv8lMAttMf6nJ2FiVPrtG9sQ= github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20221013072718-21eef1ae7f7d h1:cj3ymaDg3S32wVDiuPnOTorj22WpK0PmUaB18fUDFQY=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20221005093951-1325b4f27218/go.mod h1:HIU7csNSqyYf71rgr4H5qitMZMxVpovBPl7m05y4V9g= github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20221013072718-21eef1ae7f7d/go.mod h1:RLGptWbksCAODl8bK+2YD9EBpzDJrfJR/eM0lBK87qk=
github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE= github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE=
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=

View file

@ -3,7 +3,6 @@ package audit
import ( import (
"context" "context"
"crypto/sha256" "crypto/sha256"
"encoding/hex"
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client" clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
netmapcore "github.com/nspcc-dev/neofs-node/pkg/core/netmap" netmapcore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
@ -134,7 +133,7 @@ func (ap *Processor) findStorageGroups(cnr cid.ID, shuffled netmapcore.Nodes) []
for i := range shuffled { // consider iterating over some part of container for i := range shuffled { // consider iterating over some part of container
log := ap.log.With( log := ap.log.With(
zap.Stringer("cid", cnr), zap.Stringer("cid", cnr),
zap.String("key", hex.EncodeToString(shuffled[0].PublicKey())), zap.String("key", netmap.StringifyPublicKey(shuffled[0])),
zap.Int("try", i), zap.Int("try", i),
zap.Int("total_tries", ln), zap.Int("total_tries", ln),
) )

View file

@ -2,7 +2,6 @@ package netmap
import ( import (
"bytes" "bytes"
"encoding/hex"
"sync" "sync"
"github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/nspcc-dev/neofs-sdk-go/netmap"
@ -50,7 +49,7 @@ func (c *cleanupTable) update(snapshot netmap.NetMap, now uint64) {
for i := range nmNodes { for i := range nmNodes {
binNodeInfo := nmNodes[i].Marshal() binNodeInfo := nmNodes[i].Marshal()
keyString := hex.EncodeToString(nmNodes[i].PublicKey()) keyString := netmap.StringifyPublicKey(nmNodes[i])
access, ok := c.lastAccess[keyString] access, ok := c.lastAccess[keyString]
if ok { if ok {

View file

@ -1,7 +1,6 @@
package netmap package netmap
import ( import (
"encoding/hex"
"testing" "testing"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
@ -30,7 +29,7 @@ func TestCleanupTable(t *testing.T) {
for i := range infos { for i := range infos {
binNodeInfo := infos[i].Marshal() binNodeInfo := infos[i].Marshal()
mapInfos[hex.EncodeToString(infos[i].PublicKey())] = binNodeInfo mapInfos[netmap.StringifyPublicKey(infos[i])] = binNodeInfo
} }
t.Run("update", func(t *testing.T) { t.Run("update", func(t *testing.T) {
@ -47,7 +46,7 @@ func TestCleanupTable(t *testing.T) {
} }
t.Run("update with flagged", func(t *testing.T) { t.Run("update with flagged", func(t *testing.T) {
key := hex.EncodeToString(infos[0].PublicKey()) key := netmap.StringifyPublicKey(infos[0])
c.flag(key) c.flag(key)
c.update(networkMap, 2) c.update(networkMap, 2)
@ -60,7 +59,7 @@ func TestCleanupTable(t *testing.T) {
c := newCleanupTable(true, 1) c := newCleanupTable(true, 1)
c.update(networkMap, 1) c.update(networkMap, 1)
key := hex.EncodeToString(infos[1].PublicKey()) key := netmap.StringifyPublicKey(infos[1])
require.False(t, c.touch(key, 11, mapInfos[key])) require.False(t, c.touch(key, 11, mapInfos[key]))
require.EqualValues(t, 11, c.lastAccess[key].epoch) require.EqualValues(t, 11, c.lastAccess[key].epoch)
@ -77,7 +76,7 @@ func TestCleanupTable(t *testing.T) {
c := newCleanupTable(true, 1) c := newCleanupTable(true, 1)
c.update(networkMap, 1) c.update(networkMap, 1)
key := hex.EncodeToString(infos[1].PublicKey()) key := netmap.StringifyPublicKey(infos[1])
c.flag(key) c.flag(key)
require.True(t, c.lastAccess[key].removeFlag) require.True(t, c.lastAccess[key].removeFlag)
@ -113,7 +112,7 @@ func TestCleanupTable(t *testing.T) {
t.Run("some nodes to remove", func(t *testing.T) { t.Run("some nodes to remove", func(t *testing.T) {
cnt := 0 cnt := 0
key := hex.EncodeToString(infos[1].PublicKey()) key := netmap.StringifyPublicKey(infos[1])
require.True(t, c.touch(key, 4, mapInfos[key])) // one node was updated require.True(t, c.touch(key, 4, mapInfos[key])) // one node was updated

View file

@ -57,7 +57,7 @@ func (np *Processor) processAddPeer(ev netmapEvent.AddPeer) {
// marshal updated node info structure // marshal updated node info structure
nodeInfoBinary := nodeInfo.Marshal() nodeInfoBinary := nodeInfo.Marshal()
keyString := hex.EncodeToString(nodeInfo.PublicKey()) keyString := netmap.StringifyPublicKey(nodeInfo)
updated := np.netmapSnapshot.touch(keyString, np.epochState.EpochCounter(), nodeInfoBinary) updated := np.netmapSnapshot.touch(keyString, np.epochState.EpochCounter(), nodeInfoBinary)

View file

@ -3,7 +3,6 @@ package innerring
import ( import (
"crypto/ecdsa" "crypto/ecdsa"
"crypto/elliptic" "crypto/elliptic"
"encoding/hex"
"errors" "errors"
"fmt" "fmt"
@ -309,7 +308,7 @@ func (s *Server) handleSubnetRemoval(e event.Event) {
func (s *Server) processCandidate(txHash neogoutil.Uint256, removedID subnetid.ID, c netmap.NodeInfo) { func (s *Server) processCandidate(txHash neogoutil.Uint256, removedID subnetid.ID, c netmap.NodeInfo) {
removeSubnet := false removeSubnet := false
log := s.log.With( log := s.log.With(
zap.String("public_key", hex.EncodeToString(c.PublicKey())), zap.String("public_key", netmap.StringifyPublicKey(c)),
zap.String("removed_subnet", removedID.String()), zap.String("removed_subnet", removedID.String()),
) )

View file

@ -2,7 +2,6 @@ package auditor
import ( import (
"bytes" "bytes"
"encoding/hex"
"sync" "sync"
"time" "time"
@ -143,7 +142,7 @@ func (c *Context) collectHashes(p *gamePair) {
if err != nil { if err != nil {
c.log.Debug("could not get payload range hash", c.log.Debug("could not get payload range hash",
zap.Stringer("id", p.id), zap.Stringer("id", p.id),
zap.String("node", hex.EncodeToString(n.PublicKey())), zap.String("node", netmap.StringifyPublicKey(n)),
zap.String("error", err.Error()), zap.String("error", err.Error()),
) )
return res return res

View file

@ -2,12 +2,12 @@ package auditor
import ( import (
"bytes" "bytes"
"encoding/hex"
"sync" "sync"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/nspcc-dev/neofs-node/pkg/util/rand" "github.com/nspcc-dev/neofs-node/pkg/util/rand"
containerSDK "github.com/nspcc-dev/neofs-sdk-go/container" containerSDK "github.com/nspcc-dev/neofs-sdk-go/container"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
storagegroupSDK "github.com/nspcc-dev/neofs-sdk-go/storagegroup" storagegroupSDK "github.com/nspcc-dev/neofs-sdk-go/storagegroup"
"github.com/nspcc-dev/tzhash/tz" "github.com/nspcc-dev/tzhash/tz"
@ -83,7 +83,7 @@ func (c *Context) checkStorageGroupPoR(sgID oid.ID, sg storagegroupSDK.StorageGr
hdr, err := c.cnrCom.GetHeader(getHeaderPrm) hdr, err := c.cnrCom.GetHeader(getHeaderPrm)
if err != nil { if err != nil {
c.log.Debug("can't head object", c.log.Debug("can't head object",
zap.String("remote_node", hex.EncodeToString(flat[j].PublicKey())), zap.String("remote_node", netmap.StringifyPublicKey(flat[j])),
zap.Stringer("oid", members[i]), zap.Stringer("oid", members[i]),
) )

View file

@ -2,7 +2,6 @@ package policer
import ( import (
"context" "context"
"encoding/hex"
"errors" "errors"
"github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/container"
@ -153,7 +152,7 @@ func (p *Policer) processNodes(ctx *processPlacementContext, addr oid.Address,
shortage-- shortage--
p.log.Debug("consider node under maintenance as OK", p.log.Debug("consider node under maintenance as OK",
zap.String("node", hex.EncodeToString(node.PublicKey())), zap.String("node", netmap.StringifyPublicKey(node)),
) )
} }

View file

@ -2,7 +2,6 @@ package replicator
import ( import (
"context" "context"
"encoding/hex"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put" putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
@ -49,7 +48,7 @@ func (p *Replicator) HandleTask(ctx context.Context, task Task, res TaskResult)
} }
log := p.log.With( log := p.log.With(
zap.String("node", hex.EncodeToString(task.nodes[i].PublicKey())), zap.String("node", netmap.StringifyPublicKey(task.nodes[i])),
zap.Stringer("object", task.addr), zap.Stringer("object", task.addr),
) )