improvement(log): Log duplicate cross link number (#4306)

* improvement(log): Log duplicate cross link number

improvement(log): log hash+key on verify failure

* more logs
pull/4296/head
Max 2 years ago committed by GitHub
parent 01a5b5fbb3
commit 4d1709b01d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      consensus/leader.go
  2. 2
      consensus/validator.go
  3. 15
      node/node_cross_link.go

@ -4,6 +4,7 @@ import (
"time"
"github.com/harmony-one/harmony/crypto/bls"
"github.com/harmony-one/harmony/internal/common"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/consensus/signature"
@ -156,7 +157,13 @@ func (consensus *Consensus) onPrepare(recvMsg *FBFTMessage) {
}
}
if !sign.VerifyHash(signerPubKey, blockHash) {
consensus.getLogger().Error().Msg("[OnPrepare] Received invalid BLS signature")
consensus.getLogger().
Error().
Msgf(
"[OnPrepare] Received invalid BLS signature: hash %s, key %s",
common.BytesToHash(blockHash).Hex(),
signerPubKey.SerializeToHexStr(),
)
return
}

@ -230,7 +230,7 @@ func (consensus *Consensus) onPrepared(recvMsg *FBFTMessage) {
var blockObj *types.Block
if blockObj, err = consensus.validateNewBlock(recvMsg); err != nil {
consensus.getLogger().Warn().
consensus.getLogger().Err(err).
Uint64("MsgBlockNum", recvMsg.BlockNum).
Uint64("MsgViewID", recvMsg.ViewID).
Msg("[OnPrepared] failed to verify new block")

@ -47,8 +47,19 @@ func (node *Node) VerifyBlockCrossLinks(block *types.Block) error {
// ReadCrossLink beacon chain usage.
cl, err := node.Blockchain().ReadCrossLink(crossLink.ShardID(), crossLink.BlockNum())
if err == nil && cl != nil {
// Add slash for exist same blocknum but different crosslink
return errAlreadyExist
utils.Logger().Err(errAlreadyExist).
Uint64("beacon-block-number", block.NumberU64()).
Interface("remote", crossLink).
Interface("local", cl).
Msg("[CrossLinkVerification]")
// TODO Add slash for exist same blocknum but different crosslink
return errors.Wrapf(
errAlreadyExist,
"[CrossLinkVerification] shard: %d block: %d on beacon block %d",
crossLink.ShardID(),
crossLink.BlockNum(),
block.NumberU64(),
)
}
if err := node.VerifyCrossLink(crossLink); err != nil {
return errors.Wrapf(err, "cannot VerifyBlockCrossLinks")

Loading…
Cancel
Save