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 | Bin 116706 -> 116706 bytes pkg/innerring/processors/audit/process.go | 3 +-- .../processors/netmap/cleanup_table.go | 3 +-- .../processors/netmap/cleanup_table_test.go | 11 +++++------ .../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, 19 insertions(+), 25 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 57de2360961c14ccf5e00bfc99ad10f96af8d902..d3e1a1d3e362265093d17afb6ba08bb60f93dd6f 100644 GIT binary patch delta 286 zcmaFV&;F>NeS`5DXHx@9V^b4jUE@ScLt_i$G$WHlON9(Wt7OakvH}zD(tt`&rwWsl zFn5!r-0akVoZM1BgTzu3C#MoO_XtOya5pF4$%3o36^-?bbPe>342+Bn4Ggduy7|zW zxhyV*#s=m_=7tu!Muw@WX@-fZ=4s|BVEeL+D{~WF(v5?SjmpDZGD`#U{6q4KvW$$v z3%m^iazhiH3@y?^UEBgAf%eHxKCn^R8>?aZ>G^uO`Cv1HeB294!jrO#ogMvMax9X( swT&WOEM1)ns$9H^(!7H7Q+*9`oV+c}3$rITZc=LY*tFea6XPsV0Qf0cbN~PV delta 286 zcmaFV&;F>NeS`5DXA?scBTG|rUDLE=BQq0|WHSqc6om{!EB|CeQ%8$*m;3342+Bn4Ggduy7|zW zxhyUQrUsVAmZpZfhQ>ywNhWDV=0=7VAp0UpoSnTw!aRd2!;Q^N0xHU#QvAy-a(o?2 zN_^AI^1O`PGQ$FjO581r1A+F*PCl?v+8e83`sw+4x%pr}czA}ICl~t#7gk25nHv_R t7nyjN7G{?CM)_8R737yW1>~6L8kkm^gjuFfZrr5Q?6GOP$0o*Eq5$$oSY`kK 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), )