finished zerolog conversion

pull/1279/head
Priya Ganguly 5 years ago
parent 9c52d313fb
commit 36e9c11d6c
  1. 4
      node/contract.go
  2. 8
      node/node.go
  3. 21
      node/node_explorer.go
  4. 3
      node/node_genesis.go
  5. 20
      node/node_syncing.go
  6. 10
      node/staking.go

@ -178,7 +178,7 @@ func (node *Node) CallFaucetContract(address common.Address) common.Hash {
// Temporary code to workaround explorer issue for searching new addresses (https://github.com/harmony-one/harmony/issues/503)
nonce := atomic.AddUint64(&node.ContractDeployerCurrentNonce, 1)
tx, _ := types.SignTx(types.NewTransaction(nonce-1, address, node.Consensus.ShardID, big.NewInt(0), params.TxGasContractCreation*10, nil, nil), types.HomesteadSigner{}, node.ContractDeployerKey)
utils.Logger().Info().Str("Address", common2.MustAddressToBech32(address))("Sending placeholder token to ")
utils.Logger().Info().Str("Address", common2.MustAddressToBech32(address)).Msg("Sending placeholder token to ")
node.addPendingTransactions(types.Transactions{tx})
// END Temporary code
@ -228,6 +228,6 @@ func (node *Node) AddContractKeyAndAddress(t builtInSC) {
stakingPrivKey := genesis.GenesisBeaconAccountPriKey
node.StakingContractAddress = crypto.CreateAddress(crypto.PubkeyToAddress(stakingPrivKey.PublicKey), uint64(0))
default:
utils.Logger().Error().Err(err).Str("unknown SC", t)("AddContractKeyAndAddress")
utils.Logger().Error().Interface("unknown SC", t).Msg("AddContractKeyAndAddress")
}
}

@ -244,7 +244,7 @@ func (node *Node) addPendingTransactions(newTxs types.Transactions) {
func (node *Node) AddPendingTransaction(newTx *types.Transaction) {
if node.NodeConfig.GetNetworkType() != nodeconfig.Mainnet {
node.addPendingTransactions(types.Transactions{newTx})
utils.Logger().Error().Err(err).Int("totalPending", len(node.pendingTransactions)).Msg("Got ONE more transaction")
utils.Logger().Error().Int("totalPending", len(node.pendingTransactions)).Msg("Got ONE more transaction")
}
}
@ -259,7 +259,7 @@ func (node *Node) getTransactionsForNewBlock(maxNumTxs int, coinbase common.Addr
node.pendingTransactions = unselected
node.reducePendingTransactions()
utils.Logger().Error().Err(err).
utils.Logger().Error().
Int("remainPending", len(node.pendingTransactions)).
Int("selected", len(selected)).
Int("invalidDiscarded", len(invalid)).
@ -369,7 +369,9 @@ func New(host p2p.Host, consensusObj *consensus.Consensus, chainDBFactory shardc
}
}
utils.Logger().Info().Str("genesis block header", node.Blockchain().GetBlockByNumber(0).Header()).Msg("Genesis block hash")
utils.Logger().Info().
Interface("genesis block header", node.Blockchain().GetBlockByNumber(0).Header()).
Msg("Genesis block hash")
// start the goroutine to receive client message
// client messages are sent by clients, like txgen, wallet

@ -18,7 +18,7 @@ var once sync.Once
// ExplorerMessageHandler passes received message in node_handler to explorer service
func (node *Node) ExplorerMessageHandler(payload []byte) {
if len(payload) == 0 {
utils.Logger().Error().Err(err).Msg("Payload is empty")
utils.Logger().Error().Msg("Payload is empty")
return
}
msg := &msg_pb.Message{}
@ -43,7 +43,10 @@ func (node *Node) ExplorerMessageHandler(payload []byte) {
// check has 2f+1 signatures
if count := utils.CountOneBits(mask.Bitmap); count < node.Consensus.Quorum() {
utils.Logger().Error().Err(err).Str("need", node.Consensus.Quorum()).Str("have", count)("[Explorer] not have enough signature")
utils.Logger().Error().
Int("need", node.Consensus.Quorum()).
Int("have", count).
Msg("[Explorer] not have enough signature")
return
}
@ -51,14 +54,19 @@ func (node *Node) ExplorerMessageHandler(payload []byte) {
binary.LittleEndian.PutUint64(blockNumHash, recvMsg.BlockNum)
commitPayload := append(blockNumHash, recvMsg.BlockHash[:]...)
if !aggSig.VerifyHash(mask.AggregatePublic, commitPayload) {
utils.Logger().Error().Err(err).Str("msgBlock", recvMsg.BlockNum).Msg("[Explorer] Failed to verify the multi signature for commit phase")
utils.Logger().
Error().Err(err).
Uint64("msgBlock", recvMsg.BlockNum).
Msg("[Explorer] Failed to verify the multi signature for commit phase")
return
}
block := node.Consensus.PbftLog.GetBlockByHash(recvMsg.BlockHash)
if block == nil {
utils.Logger().Info().Str("msgBlock", recvMsg.BlockNum).Msg("[Explorer] Haven't received the block before the committed msg")
utils.Logger().Info().
Uint64("msgBlock", recvMsg.BlockNum).
Msg("[Explorer] Haven't received the block before the committed msg")
node.Consensus.PbftLog.AddMessage(recvMsg)
return
}
@ -99,7 +107,7 @@ func (node *Node) AddNewBlockForExplorer() {
break
} else {
if len(blocks) > 1 {
utils.Logger().Error().Err(err).Msg("[Explorer] We should have not received more than one block with the same block height.")
utils.Logger().Error().Msg("[Explorer] We should have not received more than one block with the same block height.")
}
utils.Logger().Info().Uint64("blockHeight", blocks[0].NumberU64()).Msg("Adding new block for explorer node")
if err := node.AddNewBlock(blocks[0]); err == nil {
@ -109,7 +117,8 @@ func (node *Node) AddNewBlockForExplorer() {
// TODO: some blocks can be dumped before state syncing finished.
// And they would be dumped again here. Please fix it.
once.Do(func() {
utils.Logger().Info().Uint64("starting height", int64(blocks[0].NumberU64())-1).Msg("[Explorer] Populating explorer data from state synced blocks")
utils.Logger().Info().Int64("starting height", int64(blocks[0].NumberU64())-1).
Msg("[Explorer] Populating explorer data from state synced blocks")
go func() {
for blockHeight := int64(blocks[0].NumberU64()) - 1; blockHeight >= 0; blockHeight-- {
explorer.GetStorageInstance(node.SelfPeer.IP, node.SelfPeer.Port, true).Dump(

@ -55,8 +55,7 @@ func (gi *genesisInitializer) InitChainDB(db ethdb.Database, shardID uint32) err
// SetupGenesisBlock sets up a genesis blockchain.
func (node *Node) SetupGenesisBlock(db ethdb.Database, shardID uint32, myShardState types.ShardState) {
utils.Logger().Info().Msg("setting up a brand new chain database",
"shardID", shardID)
utils.Logger().Info().Interface("shardID", shardID).Msg("setting up a brand new chain database")
if shardID == node.NodeConfig.ShardID {
node.isFirstTime = true
}

@ -7,7 +7,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/harmony/api/service/syncing"
@ -114,24 +114,22 @@ func (node *Node) DoBeaconSyncing() {
func (node *Node) DoSyncing(bc *core.BlockChain, worker *worker.Worker, getPeers func() []p2p.Peer, willJoinConsensus bool) {
ticker := time.NewTicker(SyncFrequency * time.Second)
logger := utils.Logger()
getLogger := func() log.Logger { return utils.WithCallerSkip(logger, 1) }
SyncingLoop:
for {
select {
case <-ticker.C:
if node.stateSync == nil {
node.stateSync = syncing.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, node.GetSyncID())
logger = logger.New("syncID", node.GetSyncID())
Logger().Debug().Msg("[SYNC] initialized state sync")
utils.Logger().Debug().Msg("[SYNC] initialized state sync")
}
if node.stateSync.GetActivePeerNumber() < MinConnectedPeers {
peers := getPeers()
if err := node.stateSync.CreateSyncConfig(peers, false); err != nil {
Logger().Debug().Msg("[SYNC] create peers error")
utils.Logger().Debug().Msg("[SYNC] create peers error")
continue SyncingLoop
}
Logger().Debug().Int("len", node.stateSync.GetActivePeerNumber()).Msg("[SYNC] Get Active Peers")
utils.Logger().Debug().Int("len", node.stateSync.GetActivePeerNumber()).Msg("[SYNC] Get Active Peers")
}
if node.stateSync.IsOutOfSync(bc) {
node.stateMutex.Lock()
@ -297,7 +295,7 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in
var blockObj types.Block
err := rlp.DecodeBytes(request.BlockHash, &blockObj)
if err != nil {
utils.Logger().Warn().Error().Err(err).Msg("[SYNC] unable to decode received new block")
utils.Logger().Warn().Msg("[SYNC] unable to decode received new block")
return response, err
}
node.stateSync.AddNewBlock(request.PeerHash, &blockObj)
@ -310,7 +308,7 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in
defer node.stateMutex.Unlock()
if _, ok := node.peerRegistrationRecord[peerID]; ok {
response.Type = downloader_pb.DownloaderResponse_FAIL
utils.Logger().Warn().Err(err).
utils.Logger().Warn().
Interface("ip", ip).
Interface("port", port).
Msg("[SYNC] peerRegistration record already exists")
@ -324,7 +322,7 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in
syncPort := syncing.GetSyncingPort(port)
client := downloader.ClientSetup(ip, syncPort)
if client == nil {
utils.Logger().Warn().Err(err).
utils.Logger().Warn().
Str("ip", ip).
Str("port", port).
Msg("[SYNC] unable to setup client for peerID")
@ -343,7 +341,7 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in
if node.State == NodeNotInSync {
count := node.stateSync.RegisterNodeInfo()
utils.Logger().Debug().
Str("number", count).
Int("number", count).
Msg("[SYNC] extra node registered")
}
}

@ -28,7 +28,7 @@ const (
// UpdateStakingList updates staking list from the given StakeInfo query result.
func (node *Node) UpdateStakingList(stakeInfoReturnValue *structs.StakeInfoReturnValue) {
utils.Logger().Str("contractState", stakeInfoReturnValue).Msg("Updating staking list")
utils.Logger().Info().Interface("contractState", stakeInfoReturnValue).Msg("Updating staking list")
if stakeInfoReturnValue == nil {
return
}
@ -64,11 +64,11 @@ func (node *Node) printStakingList() {
utils.Logger().Info().Msg("CURRENT STAKING INFO [START] ------------------------------------")
for addr, stakeInfo := range node.CurrentStakes {
utils.Logger().Info().
Str("Address", addr).
Str("Address", addr.String()).
Str("BlsPubKey", hex.EncodeToString(stakeInfo.BlsPublicKey[:])).
Uint64("BlockNum", stakeInfo.BlockNum).
Int("lockPeriodCount", stakeInfo.LockPeriodCount).
Int("amount", stakeInfo.Amount).
Interface("BlockNum", stakeInfo.BlockNum).
Interface("lockPeriodCount", stakeInfo.LockPeriodCount).
Interface("amount", stakeInfo.Amount).
Msg("")
}
utils.Logger().Info().Msg("CURRENT STAKING INFO [END} ------------------------------------")

Loading…
Cancel
Save