[#1505] Log byte arrays as Hex Strings (#1506)

pull/1529/head
Nye Liu 5 years ago committed by Charles Wang
parent c3f4cb9135
commit 1499169d40
  1. 2
      api/proto/message/server.go
  2. 6
      api/service/syncing/syncing.go
  3. 16
      consensus/consensus_v2.go
  4. 2
      consensus/consensus_viewchange_msg.go
  5. 6
      consensus/view_change.go
  6. 2
      core/blockchain.go
  7. 2
      core/rawdb/accessors_indexes.go
  8. 2
      core/rawdb/accessors_metadata.go
  9. 6
      drand/drand_leader.go
  10. 4
      node/node_handler.go

@ -48,7 +48,7 @@ func (s *Server) Process(ctx context.Context, message *Message) (*Response, erro
}
address := crypto.PubkeyToAddress(key.PublicKey)
utils.Logger().Info().Int64("amount", amount).Bytes("address", address[:]).Msg("Enter")
utils.Logger().Info().Int64("amount", amount).Hex("address", address[:]).Msg("Enter")
if err := s.CreateTransactionForEnterMethod(amount, priKey); err != nil {
return nil, ErrEnterMethod
}

@ -506,8 +506,8 @@ func (ss *StateSync) getMaxConsensusBlockFromParentHash(parentHash common.Hash)
maxFirstID, maxCount := GetHowManyMaxConsensus(candidateBlocks)
hash := candidateBlocks[maxFirstID].Hash()
utils.Logger().Debug().
Bytes("parentHash", parentHash[:]).
Bytes("hash", hash[:]).
Hex("parentHash", parentHash[:]).
Hex("hash", hash[:]).
Int("maxCount", maxCount).
Msg("[SYNC] Find block with matching parenthash")
return candidateBlocks[maxFirstID]
@ -662,7 +662,7 @@ func (ss *StateSync) RegisterNodeInfo() int {
err := peerConfig.registerToBroadcast(ss.selfPeerHash[:], ss.selfip, ss.selfport)
if err != nil {
logger.Debug().
Bytes("selfPeerHash", ss.selfPeerHash[:]).
Hex("selfPeerHash", ss.selfPeerHash[:]).
Msg("[SYNC] register failed to peer")
return
}

@ -385,7 +385,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
consensus.getLogger().Warn().Msg("[OnPrepare] Cannot send prepared message")
} else {
consensus.getLogger().Debug().
Bytes("blockHash", consensus.blockHash[:]).
Hex("blockHash", consensus.blockHash[:]).
Uint64("blockNum", consensus.blockNum).
Msg("[OnPrepare] Sent Prepared Message!!")
}
@ -481,7 +481,7 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) {
if blockObj.Header().Hash() != recvMsg.BlockHash {
consensus.getLogger().Warn().
Uint64("MsgBlockNum", recvMsg.BlockNum).
Bytes("MsgBlockHash", recvMsg.BlockHash[:]).
Hex("MsgBlockHash", recvMsg.BlockHash[:]).
Str("blockObjHash", blockObj.Header().Hash().Hex()).
Msg("[OnPrepared] BlockHash not match")
return
@ -509,7 +509,7 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) {
consensus.getLogger().Debug().
Uint64("MsgViewID", recvMsg.ViewID).
Uint64("MsgBlockNum", recvMsg.BlockNum).
Bytes("blockHash", recvMsg.BlockHash[:]).
Hex("blockHash", recvMsg.BlockHash[:]).
Msg("[OnPrepared] Prepared message and block added")
consensus.mutex.Lock()
@ -569,7 +569,7 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) {
} else {
consensus.getLogger().Info().
Uint64("blockNum", consensus.blockNum).
Bytes("blockHash", consensus.blockHash[:]).
Hex("blockHash", consensus.blockHash[:]).
Msg("[OnPrepared] Sent Commit Message!!")
}
@ -616,7 +616,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
if !consensus.PbftLog.HasMatchingAnnounce(consensus.blockNum, recvMsg.BlockHash) {
consensus.getLogger().Debug().
Bytes("MsgBlockHash", recvMsg.BlockHash[:]).
Hex("MsgBlockHash", recvMsg.BlockHash[:]).
Uint64("MsgBlockNum", recvMsg.BlockNum).
Uint64("blockNum", consensus.blockNum).
Msg("[OnCommit] Cannot find matching blockhash")
@ -625,7 +625,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
if !consensus.PbftLog.HasMatchingPrepared(consensus.blockNum, recvMsg.BlockHash) {
consensus.getLogger().Debug().
Bytes("blockHash", recvMsg.BlockHash[:]).
Hex("blockHash", recvMsg.BlockHash[:]).
Uint64("blockNum", consensus.blockNum).
Msg("[OnCommit] Cannot find matching prepared message")
return
@ -746,7 +746,7 @@ func (consensus *Consensus) finalizeCommits() {
consensus.getLogger().Warn().Err(err).Msg("[Finalizing] Cannot send committed message")
} else {
consensus.getLogger().Info().
Bytes("blockHash", consensus.blockHash[:]).
Hex("blockHash", consensus.blockHash[:]).
Uint64("blockNum", consensus.blockNum).
Msg("[Finalizing] Sent Committed Message")
}
@ -1073,7 +1073,7 @@ func (consensus *Consensus) Start(blockChannel chan *types.Block, stopChan chan
// Verify the randomness
_ = blockHash
consensus.getLogger().Info().
Bytes("rnd", rnd[:]).
Hex("rnd", rnd[:]).
Msg("[ConsensusMainLoop] Adding randomness into new block")
// newBlock.AddVdf([258]byte{}) // TODO(HB): add real vdf
} else {

@ -43,7 +43,7 @@ func (consensus *Consensus) constructViewChangeMessage() []byte {
}
consensus.getLogger().Debug().
Bytes("m1Payload", vcMsg.Payload).
Hex("m1Payload", vcMsg.Payload).
Str("pubKey", consensus.PubKey.SerializeToHexStr()).
Msg("[constructViewChangeMessage]")

@ -338,7 +338,7 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
// Verify the multi-sig for prepare phase
if !aggSig.VerifyHash(mask.AggregatePublic, blockHash[:]) {
consensus.getLogger().Warn().
Bytes("blockHash", blockHash).
Hex("blockHash", blockHash).
Msg("[onViewChange] failed to verify multi signature for m1 prepared payload")
return
}
@ -430,7 +430,7 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
consensus.getLogger().Warn().
Int("payloadSize", len(consensus.m1Payload)).
Bytes("M1Payload", consensus.m1Payload).
Hex("M1Payload", consensus.m1Payload).
Msg("[onViewChange] Sent NewView Message")
consensus.msgSender.SendWithRetry(consensus.blockNum, msg_pb.MessageType_NEWVIEW, []p2p.GroupID{p2p.NewGroupIDByShardID(p2p.ShardID(consensus.ShardID))}, host.ConstructP2pMessage(byte(17), msgToSend))
@ -491,7 +491,7 @@ func (consensus *Consensus) onNewView(msg *msg_pb.Message) {
if !m3Sig.VerifyHash(m3Mask.AggregatePublic, viewIDBytes) {
consensus.getLogger().Warn().
Str("m3Sig", m3Sig.SerializeToHexStr()).
Bytes("m3Mask", m3Mask.Bitmap).
Hex("m3Mask", m3Mask.Bitmap).
Uint64("MsgViewID", recvMsg.ViewID).
Msg("[onNewView] Unable to Verify Aggregated Signature of M3 (ViewID) payload")
return

@ -266,7 +266,7 @@ func (bc *BlockChain) loadLastState() error {
currentBlock := bc.GetBlockByHash(head)
if currentBlock == nil {
// Corrupt or empty database, init from scratch
utils.Logger().Warn().Bytes("hash", head.Bytes()).Msg("Head block missing, resetting chain")
utils.Logger().Warn().Str("hash", head.Hex()).Msg("Head block missing, resetting chain")
return bc.Reset()
}
// Make sure the state associated with the block is available

@ -33,7 +33,7 @@ func ReadTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64
}
var entry TxLookupEntry
if err := rlp.DecodeBytes(data, &entry); err != nil {
utils.Logger().Error().Err(err).Bytes("hash", hash.Bytes()).Msg("Invalid transaction lookup entry RLP")
utils.Logger().Error().Err(err).Str("hash", hash.Hex()).Msg("Invalid transaction lookup entry RLP")
return common.Hash{}, 0, 0
}
return entry.BlockHash, entry.BlockIndex, entry.Index

@ -52,7 +52,7 @@ func ReadChainConfig(db DatabaseReader, hash common.Hash) *params.ChainConfig {
}
var config params.ChainConfig
if err := json.Unmarshal(data, &config); err != nil {
utils.Logger().Error().Err(err).Bytes("hash", hash.Bytes()).Msg("Invalid chain config JSON")
utils.Logger().Error().Err(err).Str("hash", hash.Hex()).Msg("Invalid chain config JSON")
return nil
}
return &config

@ -78,7 +78,7 @@ func (dRand *DRand) init(epochBlock *types.Block) {
(*dRand.vrfs)[dRand.SelfAddress] = append(rand[:], proof...)
utils.Logger().Info().
Bytes("msg", msgToSend).
Hex("msg", msgToSend).
Str("leader.PubKey", dRand.leader.ConsensusPubKey.SerializeToHexStr()).
Msg("[DRG] sent init")
dRand.host.SendMessageToGroups([]p2p.GroupID{p2p.NewGroupIDByShardID(p2p.ShardID(dRand.ShardID))}, host.ConstructP2pMessage(byte(17), msgToSend))
@ -167,8 +167,8 @@ func (dRand *DRand) processCommitMessage(message *msg_pb.Message) {
utils.Logger().Error().
Err(err).
Str("validatorAddress", validatorAddress).
Bytes("expectedRand", expectedRand[:]).
Bytes("receivedRand", rand[:]).
Hex("expectedRand", expectedRand[:]).
Hex("receivedRand", rand[:]).
Msg("[DRAND] Failed to verify the VRF")
return
}

@ -478,8 +478,8 @@ func (node *Node) AddNewBlock(newBlock *types.Block) error {
utils.Logger().Error().
Err(err).
Uint64("blockNum", newBlock.NumberU64()).
Bytes("parentHash", newBlock.Header().ParentHash.Bytes()[:]).
Bytes("hash", newBlock.Header().Hash().Bytes()[:]).
Str("parentHash", newBlock.Header().ParentHash.Hex()).
Str("hash", newBlock.Header().Hash().Hex()).
Msg("Error Adding new block to blockchain")
} else {
utils.Logger().Info().

Loading…
Cancel
Save