[#867] governance: Add more logs of the alphabet and inner ring lists

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-09-29 19:54:49 +03:00 committed by Leonard Lyubich
parent be05bed0b3
commit e558cdd9dd
2 changed files with 26 additions and 2 deletions

View file

@ -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)
}

View file

@ -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()))
}
})