From e558cdd9dd503b4e09bdd4afba1752e8ea2dcb3b Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 29 Sep 2021 19:54:49 +0300 Subject: [PATCH] [#867] governance: Add more logs of the alphabet and inner ring lists Signed-off-by: Alex Vanin --- .../processors/governance/process_update.go | 25 ++++++++++++++++++- pkg/innerring/state.go | 3 ++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pkg/innerring/processors/governance/process_update.go b/pkg/innerring/processors/governance/process_update.go index 7d54a642c..a3de8ecb4 100644 --- a/pkg/innerring/processors/governance/process_update.go +++ b/pkg/innerring/processors/governance/process_update.go @@ -2,8 +2,11 @@ package governance import ( "encoding/binary" + "encoding/hex" "sort" + "strings" + "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "go.uber.org/zap" ) @@ -43,7 +46,10 @@ func (gp *Processor) processAlphabetSync() { return } - gp.log.Info("alphabet list has been changed, starting update") + gp.log.Info("alphabet list has been changed, starting update", + zap.String("side_chain_alphabet", prettyKeys(sidechainAlphabet)), + zap.String("new_alphabet", prettyKeys(newAlphabet)), + ) // 1. Vote to side chain committee via alphabet contracts. err = gp.voter.VoteForSidechainValidator(newAlphabet) @@ -65,6 +71,11 @@ func (gp *Processor) processAlphabetSync() { } else { sort.Sort(newInnerRing) + gp.log.Info("update of the inner ring list", + zap.String("before", prettyKeys(innerRing)), + zap.String("after", prettyKeys(newInnerRing)), + ) + if gp.notaryDisabled { err = gp.netmapClient.UpdateInnerRing(newInnerRing) } else { @@ -103,3 +114,15 @@ func (gp *Processor) processAlphabetSync() { gp.log.Info("finished alphabet list update") } + +func prettyKeys(keys keys.PublicKeys) string { + const delimiter = "," + + sb := strings.Builder{} + for _, key := range keys { + sb.WriteString(hex.EncodeToString(key.Bytes())) + sb.WriteString(delimiter) + } + + return strings.TrimRight(sb.String(), delimiter) +} diff --git a/pkg/innerring/state.go b/pkg/innerring/state.go index b0e014a36..e0750f032 100644 --- a/pkg/innerring/state.go +++ b/pkg/innerring/state.go @@ -99,7 +99,8 @@ func (s *Server) voteForSidechainValidator(validators keys.PublicKeys) error { if err != nil { s.log.Warn("can't invoke vote method in alphabet contract", zap.Int8("alphabet_index", int8(letter)), - zap.Uint64("epoch", epoch)) + zap.Uint64("epoch", epoch), + zap.String("error", err.Error())) } })