From 8714fc42b5cef128cb717ff8f3390dae6019511f Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Tue, 11 Oct 2022 15:49:34 +0300 Subject: [PATCH] [#1765] Use hex format to print storage node ID Signed-off-by: Anton Nikiforov --- CHANGELOG.md | 1 + cmd/neofs-node/notificator.go | 4 ++-- go.mod | 4 ++-- go.sum | 8 ++++---- pkg/innerring/processors/audit/process.go | 3 +-- pkg/innerring/processors/netmap/cleanup_table.go | 3 +-- pkg/innerring/processors/netmap/cleanup_table_test.go | 11 +++++------ pkg/innerring/processors/netmap/process_peers.go | 2 +- pkg/innerring/subnet.go | 3 +-- pkg/services/audit/auditor/pdp.go | 3 +-- pkg/services/audit/auditor/por.go | 4 ++-- pkg/services/policer/check.go | 3 +-- pkg/services/replicator/process.go | 3 +-- 13 files changed, 23 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d0c0cce4..e3e609bdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Changelog for NeoFS Node - Unify help messages in CLI (#1854) - `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) +- Use hex format to print storage node ID (#1765) ### Fixed - Description of command `netmap nodeinfo` (#1821) diff --git a/cmd/neofs-node/notificator.go b/cmd/neofs-node/notificator.go index 4f9401876..7409d73b3 100644 --- a/cmd/neofs-node/notificator.go +++ b/cmd/neofs-node/notificator.go @@ -1,9 +1,9 @@ package main import ( + "encoding/hex" "fmt" - "github.com/mr-tron/base58" 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/morph/event" @@ -110,7 +110,7 @@ func (n notificationWriter) Notify(topic string, address oid.Address) { func initNotifications(c *cfg) { if nodeconfig.Notification(c.appCfg).Enabled() { topic := nodeconfig.Notification(c.appCfg).DefaultTopic() - pubKey := base58.Encode(c.cfgNodeInfo.localInfo.PublicKey()) + pubKey := hex.EncodeToString(c.cfgNodeInfo.localInfo.PublicKey()) if topic == "" { topic = pubKey diff --git a/go.mod b/go.mod index b7a78da71..531bb2195 100644 --- a/go.mod +++ b/go.mod @@ -17,9 +17,9 @@ require ( github.com/nspcc-dev/hrw v1.0.9 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/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-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/panjf2000/ants/v2 v2.4.0 github.com/paulmach/orb v0.2.2 diff --git a/go.sum b/go.sum index 57de23609..d3e1a1d3e 100644 --- a/go.sum +++ b/go.sum @@ -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/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.13.2-0.20221004142957-5fc2644c680d h1:Oc15A8gDoP/TC5kdJi6TW9AnOp5dYiecZ0tJDRUV7vg= -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 h1:c9ovp4KuPyIBx4dVG4bmkePlmuN0au4BBtFGXALWFBM= +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.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= @@ -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-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 v1.0.0-rc.6.0.20221005093951-1325b4f27218 h1:XtCCJTVIRyW374PxwBdOv8lMAttMf6nJ2FiVPrtG9sQ= -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 h1:cj3ymaDg3S32wVDiuPnOTorj22WpK0PmUaB18fUDFQY= +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.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE= github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= diff --git a/pkg/innerring/processors/audit/process.go b/pkg/innerring/processors/audit/process.go index e64d56354..2489ded9d 100644 --- a/pkg/innerring/processors/audit/process.go +++ b/pkg/innerring/processors/audit/process.go @@ -3,7 +3,6 @@ package audit import ( "context" "crypto/sha256" - "encoding/hex" clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client" 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 log := ap.log.With( 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("total_tries", ln), ) diff --git a/pkg/innerring/processors/netmap/cleanup_table.go b/pkg/innerring/processors/netmap/cleanup_table.go index 7bcd821f3..226a7d447 100644 --- a/pkg/innerring/processors/netmap/cleanup_table.go +++ b/pkg/innerring/processors/netmap/cleanup_table.go @@ -2,7 +2,6 @@ package netmap import ( "bytes" - "encoding/hex" "sync" "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 { binNodeInfo := nmNodes[i].Marshal() - keyString := hex.EncodeToString(nmNodes[i].PublicKey()) + keyString := netmap.StringifyPublicKey(nmNodes[i]) access, ok := c.lastAccess[keyString] if ok { diff --git a/pkg/innerring/processors/netmap/cleanup_table_test.go b/pkg/innerring/processors/netmap/cleanup_table_test.go index a3f5062e5..1c1433d0c 100644 --- a/pkg/innerring/processors/netmap/cleanup_table_test.go +++ b/pkg/innerring/processors/netmap/cleanup_table_test.go @@ -1,7 +1,6 @@ package netmap import ( - "encoding/hex" "testing" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" @@ -30,7 +29,7 @@ func TestCleanupTable(t *testing.T) { for i := range infos { binNodeInfo := infos[i].Marshal() - mapInfos[hex.EncodeToString(infos[i].PublicKey())] = binNodeInfo + mapInfos[netmap.StringifyPublicKey(infos[i])] = binNodeInfo } 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) { - key := hex.EncodeToString(infos[0].PublicKey()) + key := netmap.StringifyPublicKey(infos[0]) c.flag(key) c.update(networkMap, 2) @@ -60,7 +59,7 @@ func TestCleanupTable(t *testing.T) { c := newCleanupTable(true, 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.EqualValues(t, 11, c.lastAccess[key].epoch) @@ -77,7 +76,7 @@ func TestCleanupTable(t *testing.T) { c := newCleanupTable(true, 1) c.update(networkMap, 1) - key := hex.EncodeToString(infos[1].PublicKey()) + key := netmap.StringifyPublicKey(infos[1]) c.flag(key) 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) { 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 diff --git a/pkg/innerring/processors/netmap/process_peers.go b/pkg/innerring/processors/netmap/process_peers.go index 9b21a004f..f5f79fa13 100644 --- a/pkg/innerring/processors/netmap/process_peers.go +++ b/pkg/innerring/processors/netmap/process_peers.go @@ -57,7 +57,7 @@ func (np *Processor) processAddPeer(ev netmapEvent.AddPeer) { // marshal updated node info structure nodeInfoBinary := nodeInfo.Marshal() - keyString := hex.EncodeToString(nodeInfo.PublicKey()) + keyString := netmap.StringifyPublicKey(nodeInfo) updated := np.netmapSnapshot.touch(keyString, np.epochState.EpochCounter(), nodeInfoBinary) diff --git a/pkg/innerring/subnet.go b/pkg/innerring/subnet.go index 86350b4b9..7d8fcc391 100644 --- a/pkg/innerring/subnet.go +++ b/pkg/innerring/subnet.go @@ -3,7 +3,6 @@ package innerring import ( "crypto/ecdsa" "crypto/elliptic" - "encoding/hex" "errors" "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) { removeSubnet := false 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()), ) diff --git a/pkg/services/audit/auditor/pdp.go b/pkg/services/audit/auditor/pdp.go index d3d88b758..04b996f45 100644 --- a/pkg/services/audit/auditor/pdp.go +++ b/pkg/services/audit/auditor/pdp.go @@ -2,7 +2,6 @@ package auditor import ( "bytes" - "encoding/hex" "sync" "time" @@ -143,7 +142,7 @@ func (c *Context) collectHashes(p *gamePair) { if err != nil { c.log.Debug("could not get payload range hash", zap.Stringer("id", p.id), - zap.String("node", hex.EncodeToString(n.PublicKey())), + zap.String("node", netmap.StringifyPublicKey(n)), zap.String("error", err.Error()), ) return res diff --git a/pkg/services/audit/auditor/por.go b/pkg/services/audit/auditor/por.go index be7d3b87e..cdde8cd78 100644 --- a/pkg/services/audit/auditor/por.go +++ b/pkg/services/audit/auditor/por.go @@ -2,12 +2,12 @@ package auditor import ( "bytes" - "encoding/hex" "sync" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/util/rand" 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" storagegroupSDK "github.com/nspcc-dev/neofs-sdk-go/storagegroup" "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) if err != nil { 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]), ) diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index a06f8f0d9..c1b663caf 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -2,7 +2,6 @@ package policer import ( "context" - "encoding/hex" "errors" "github.com/nspcc-dev/neofs-node/pkg/core/container" @@ -153,7 +152,7 @@ func (p *Policer) processNodes(ctx *processPlacementContext, addr oid.Address, shortage-- p.log.Debug("consider node under maintenance as OK", - zap.String("node", hex.EncodeToString(node.PublicKey())), + zap.String("node", netmap.StringifyPublicKey(node)), ) } diff --git a/pkg/services/replicator/process.go b/pkg/services/replicator/process.go index 9b4ad8f12..96606070d 100644 --- a/pkg/services/replicator/process.go +++ b/pkg/services/replicator/process.go @@ -2,7 +2,6 @@ package replicator import ( "context" - "encoding/hex" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" 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( - zap.String("node", hex.EncodeToString(task.nodes[i].PublicKey())), + zap.String("node", netmap.StringifyPublicKey(task.nodes[i])), zap.Stringer("object", task.addr), )