From 9c52d313fbba5b881eaf878eb00e10e4c002b828 Mon Sep 17 00:00:00 2001 From: Priya Ganguly Date: Thu, 1 Aug 2019 15:05:15 -0700 Subject: [PATCH 1/5] changed leftover files from log15 to zerolog --- node/contract.go | 28 ++++++++++++------------ node/node.go | 23 +++++++++++--------- node/node_explorer.go | 28 ++++++++++++------------ node/node_genesis.go | 2 +- node/node_syncing.go | 50 ++++++++++++++++++++++++++++++------------- node/rpc.go | 12 +++++++---- node/service_setup.go | 4 ++-- node/staking.go | 18 ++++++++++------ 8 files changed, 99 insertions(+), 66 deletions(-) diff --git a/node/contract.go b/node/contract.go index 3e92f108b..96c8f6445 100644 --- a/node/contract.go +++ b/node/contract.go @@ -74,12 +74,12 @@ func (node *Node) generateDeployedStakingContractAddress(contractAddress common. func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue { abi, err := abi.JSON(strings.NewReader(contracts.StakeLockContractABI)) if err != nil { - utils.GetLogInstance().Error("Failed to generate staking contract's ABI", "error", err) + utils.Logger().Error().Err(err).Msg("Failed to generate staking contract's ABI") return nil } bytesData, err := abi.Pack("listLockedAddresses") if err != nil { - utils.GetLogInstance().Error("Failed to generate ABI function bytes data", "error", err) + utils.Logger().Error().Err(err).Msg("Failed to generate ABI function bytes data") return nil } @@ -89,7 +89,7 @@ func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue { state, err := node.Blockchain().State() if err != nil { - utils.GetLogInstance().Error("Failed to get blockchain state", "error", err) + utils.Logger().Error().Err(err).Msg("Failed to get blockchain state") return nil } @@ -105,13 +105,13 @@ func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue { ) signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, priKey) if err != nil { - utils.GetLogInstance().Error("Failed to sign contract call tx", "error", err) + utils.Logger().Error().Err(err).Msg("Failed to sign contract call tx") return nil } output, err := node.ContractCaller.CallContract(signedTx) if err != nil { - utils.GetLogInstance().Error("Failed to call staking contract", "error", err) + utils.Logger().Error().Err(err).Msg("Failed to call staking contract") return nil } @@ -120,7 +120,7 @@ func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue { err = abi.Unpack(ret, "listLockedAddresses", output) if err != nil { - utils.GetLogInstance().Error("Failed to unpack stake info", "error", err) + utils.Logger().Error().Err(err).Msg("Failed to unpack stake info") return nil } return ret @@ -137,7 +137,7 @@ func (node *Node) getDeployedStakingContract() common.Address { func (node *Node) GetNonceOfAddress(address common.Address) uint64 { state, err := node.Blockchain().State() if err != nil { - utils.GetLogger().Error("Failed to get chain state", "Error", err) + utils.Logger().Error().Err(err).Msg("Failed to get chain state") return 0 } return state.GetNonce(address) @@ -147,7 +147,7 @@ func (node *Node) GetNonceOfAddress(address common.Address) uint64 { func (node *Node) GetBalanceOfAddress(address common.Address) (*big.Int, error) { state, err := node.Blockchain().State() if err != nil { - utils.GetLogger().Error("Failed to get chain state", "Error", err) + utils.Logger().Error().Err(err).Msg("Failed to get chain state") return nil, err } return state.GetBalance(address), nil @@ -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.GetLogInstance().Info("Sending placeholder token to ", "Address", common2.MustAddressToBech32(address)) + utils.Logger().Info().Str("Address", common2.MustAddressToBech32(address))("Sending placeholder token to ") node.addPendingTransactions(types.Transactions{tx}) // END Temporary code @@ -194,20 +194,20 @@ func (node *Node) callGetFreeToken(address common.Address) common.Hash { func (node *Node) callGetFreeTokenWithNonce(address common.Address, nonce uint64) common.Hash { abi, err := abi.JSON(strings.NewReader(contracts.FaucetABI)) if err != nil { - utils.GetLogInstance().Error("Failed to generate faucet contract's ABI", "error", err) + utils.Logger().Error().Err(err).Msg("Failed to generate faucet contract's ABI") return common.Hash{} } bytesData, err := abi.Pack("request", address) if err != nil { - utils.GetLogInstance().Error("Failed to generate ABI function bytes data", "error", err) + utils.Logger().Error().Err(err).Msg("Failed to generate ABI function bytes data") return common.Hash{} } if len(node.ContractAddresses) == 0 { - utils.GetLogInstance().Error("Failed to find the contract address") + utils.Logger().Error().Err(err).Msg("Failed to find the contract address") return common.Hash{} } tx, _ := types.SignTx(types.NewTransaction(nonce, node.ContractAddresses[0], node.Consensus.ShardID, big.NewInt(0), params.TxGasContractCreation*10, nil, bytesData), types.HomesteadSigner{}, node.ContractDeployerKey) - utils.GetLogInstance().Info("Sending Free Token to ", "Address", common2.MustAddressToBech32(address)) + utils.Logger().Info().Str("Address", common2.MustAddressToBech32(address)).Msg("Sending Free Token to ") node.addPendingTransactions(types.Transactions{tx}) return tx.Hash() @@ -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.GetLogInstance().Error("AddContractKeyAndAddress", "unknown SC", t) + utils.Logger().Error().Err(err).Str("unknown SC", t)("AddContractKeyAndAddress") } } diff --git a/node/node.go b/node/node.go index cba5c415c..b94430da2 100644 --- a/node/node.go +++ b/node/node.go @@ -236,7 +236,7 @@ func (node *Node) addPendingTransactions(newTxs types.Transactions) { node.pendingTransactions = append(node.pendingTransactions, newTxs...) node.reducePendingTransactions() node.pendingTxMutex.Unlock() - utils.GetLogInstance().Info("Got more transactions", "num", len(newTxs), "totalPending", len(node.pendingTransactions)) + utils.Logger().Info().Int("num", len(newTxs)).Int("totalPending", len(node.pendingTransactions)).Msg("Got more transactions") } } @@ -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.GetLogInstance().Debug("Got ONE more transaction", "totalPending", len(node.pendingTransactions)) + utils.Logger().Error().Err(err).Int("totalPending", len(node.pendingTransactions)).Msg("Got ONE more transaction") } } @@ -259,7 +259,11 @@ func (node *Node) getTransactionsForNewBlock(maxNumTxs int, coinbase common.Addr node.pendingTransactions = unselected node.reducePendingTransactions() - utils.GetLogInstance().Debug("Selecting Transactions", "remainPending", len(node.pendingTransactions), "selected", len(selected), "invalidDiscarded", len(invalid)) + utils.Logger().Error().Err(err). + Int("remainPending", len(node.pendingTransactions)). + Int("selected", len(selected)). + Int("invalidDiscarded", len(invalid)). + Msg("Selecting Transactions") node.pendingTxMutex.Unlock() return selected } @@ -360,13 +364,12 @@ func New(host p2p.Host, consensusObj *consensus.Consensus, chainDBFactory shardc var err error node.TestBankKeys, err = CreateTestBankKeys(TestAccountNumber) if err != nil { - utils.GetLogInstance().Crit("Error while creating test keys", - "error", err) + utils.Logger().Error().Err(err).Msg("Error while creating test keys") } } } - utils.GetLogInstance().Info("Genesis block hash", "genesis block header", node.Blockchain().GetBlockByNumber(0).Header()) + utils.Logger().Info().Str("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 @@ -481,17 +484,17 @@ func (node *Node) initNodeConfiguration() (service.NodeConfig, chan p2p.Peer) { var err error node.shardGroupReceiver, err = node.host.GroupReceiver(node.NodeConfig.GetShardGroupID()) if err != nil { - utils.GetLogInstance().Error("Failed to create shard receiver", "msg", err) + utils.Logger().Error().Err(err).Msg("Failed to create shard receiver") } node.globalGroupReceiver, err = node.host.GroupReceiver(p2p.GroupIDBeaconClient) if err != nil { - utils.GetLogInstance().Error("Failed to create global receiver", "msg", err) + utils.Logger().Error().Err(err).Msg("Failed to create global receiver") } node.clientReceiver, err = node.host.GroupReceiver(node.NodeConfig.GetClientGroupID()) if err != nil { - utils.GetLogInstance().Error("Failed to create client receiver", "msg", err) + utils.Logger().Error().Err(err).Msg("Failed to create client receiver") } return nodeConfig, chanPeer } @@ -503,6 +506,6 @@ func (node *Node) AccountManager() *accounts.Manager { // SetDNSZone sets the DNS zone to use to get peer info for node syncing func (node *Node) SetDNSZone(zone string) { - utils.GetLogger().Info("using DNS zone to get peers", "zone", zone) + utils.Logger().Info().Str("zone", zone).Msg("using DNS zone to get peers") node.dnsZone = zone } diff --git a/node/node_explorer.go b/node/node_explorer.go index 8a94727cf..b54278c28 100644 --- a/node/node_explorer.go +++ b/node/node_explorer.go @@ -18,32 +18,32 @@ 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.GetLogger().Debug("Payload is empty") + utils.Logger().Error().Err(err).Msg("Payload is empty") return } msg := &msg_pb.Message{} err := protobuf.Unmarshal(payload, msg) if err != nil { - utils.GetLogger().Error("Failed to unmarshal message payload.", "err", err) + utils.Logger().Error().Err(err).Msg("Failed to unmarshal message payload.") return } if msg.Type == msg_pb.MessageType_COMMITTED { recvMsg, err := consensus.ParsePbftMessage(msg) if err != nil { - utils.GetLogInstance().Debug("[Explorer] onCommitted unable to parse msg", "error", err) + utils.Logger().Error().Err(err).Msg("[Explorer] onCommitted unable to parse msg") return } aggSig, mask, err := node.Consensus.ReadSignatureBitmapPayload(recvMsg.Payload, 0) if err != nil { - utils.GetLogInstance().Debug("[Explorer] readSignatureBitmapPayload failed", "error", err) + utils.Logger().Error().Err(err).Msg("[Explorer] readSignatureBitmapPayload failed") return } // check has 2f+1 signatures if count := utils.CountOneBits(mask.Bitmap); count < node.Consensus.Quorum() { - utils.GetLogInstance().Debug("[Explorer] not have enough signature", "need", node.Consensus.Quorum(), "have", count) + utils.Logger().Error().Err(err).Str("need", node.Consensus.Quorum()).Str("have", count)("[Explorer] not have enough signature") return } @@ -51,14 +51,14 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { binary.LittleEndian.PutUint64(blockNumHash, recvMsg.BlockNum) commitPayload := append(blockNumHash, recvMsg.BlockHash[:]...) if !aggSig.VerifyHash(mask.AggregatePublic, commitPayload) { - utils.GetLogInstance().Debug("[Explorer] Failed to verify the multi signature for commit phase", "msgBlock", recvMsg.BlockNum) + utils.Logger().Error().Err(err).Str("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.GetLogInstance().Info("[Explorer] Haven't received the block before the committed msg", "msgBlock", recvMsg.BlockNum) + utils.Logger().Info().Str("msgBlock", recvMsg.BlockNum).Msg("[Explorer] Haven't received the block before the committed msg") node.Consensus.PbftLog.AddMessage(recvMsg) return } @@ -69,7 +69,7 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { recvMsg, err := consensus.ParsePbftMessage(msg) if err != nil { - utils.GetLogInstance().Debug("[Explorer] Unable to parse Prepared msg", "error", err) + utils.Logger().Error().Err(err).Msg("[Explorer] Unable to parse Prepared msg") return } block := recvMsg.Block @@ -91,7 +91,7 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { // AddNewBlockForExplorer add new block for explorer. func (node *Node) AddNewBlockForExplorer() { - utils.GetLogInstance().Info("[Explorer] Add new block for explorer") + utils.Logger().Info().Msg("[Explorer] Add new block for explorer") // Search for the next block in PbftLog and commit the block into blockchain for explorer node. for { blocks := node.Consensus.PbftLog.GetBlocksByNumber(node.Blockchain().CurrentBlock().NumberU64() + 1) @@ -99,9 +99,9 @@ func (node *Node) AddNewBlockForExplorer() { break } else { if len(blocks) > 1 { - utils.GetLogInstance().Error("[Explorer] We should have not received more than one block with the same block height.") + utils.Logger().Error().Err(err).Msg("[Explorer] We should have not received more than one block with the same block height.") } - utils.GetLogInstance().Info("Adding new block for explorer node", "blockHeight", blocks[0].NumberU64()) + utils.Logger().Info().Uint64("blockHeight", blocks[0].NumberU64()).Msg("Adding new block for explorer node") if err := node.AddNewBlock(blocks[0]); err == nil { // Clean up the blocks to avoid OOM. node.Consensus.PbftLog.DeleteBlockByNumber(blocks[0].NumberU64()) @@ -109,7 +109,7 @@ 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.GetLogInstance().Info("[Explorer] Populating explorer data from state synced blocks", "starting height", int64(blocks[0].NumberU64())-1) + utils.Logger().Info().Uint64("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( @@ -118,7 +118,7 @@ func (node *Node) AddNewBlockForExplorer() { }() }) } else { - utils.GetLogInstance().Error("[Explorer] Error when adding new block for explorer node", "error", err) + utils.Logger().Error().Err(err).Msg("[Explorer] Error when adding new block for explorer node") } } } @@ -130,7 +130,7 @@ func (node *Node) commitBlockForExplorer(block *types.Block) { return } // Dump new block into level db. - utils.GetLogInstance().Info("[Explorer] Committing block into explorer DB", "blockNum", block.NumberU64()) + utils.Logger().Info().Uint64("blockNum", block.NumberU64()).Msg("[Explorer] Committing block into explorer DB") explorer.GetStorageInstance(node.SelfPeer.IP, node.SelfPeer.Port, true).Dump(block, block.NumberU64()) curNum := block.NumberU64() diff --git a/node/node_genesis.go b/node/node_genesis.go index d06f2b8dd..363493350 100644 --- a/node/node_genesis.go +++ b/node/node_genesis.go @@ -55,7 +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.GetLogger().Info("setting up a brand new chain database", + utils.Logger().Info().Msg("setting up a brand new chain database", "shardID", shardID) if shardID == node.NodeConfig.ShardID { node.isFirstTime = true diff --git a/node/node_syncing.go b/node/node_syncing.go index 5ca9e318d..0baca76ab 100644 --- a/node/node_syncing.go +++ b/node/node_syncing.go @@ -78,7 +78,7 @@ func (node *Node) GetPeersFromDNS() []p2p.Peer { dns := fmt.Sprintf("s%d.%s", shardID, node.dnsZone) addrs, err := net.LookupHost(dns) if err != nil { - utils.GetLogInstance().Debug("[SYNC] GetPeersFromDNS cannot find peers", "error", err) + utils.Logger().Debug().Msg("[SYNC] GetPeersFromDNS cannot find peers") return nil } port := syncing.GetSyncingPort(node.SelfPeer.Port) @@ -114,7 +114,7 @@ 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.GetLogInstance() + logger := utils.Logger() getLogger := func() log.Logger { return utils.WithCallerSkip(logger, 1) } SyncingLoop: for { @@ -123,15 +123,15 @@ SyncingLoop: if node.stateSync == nil { node.stateSync = syncing.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, node.GetSyncID()) logger = logger.New("syncID", node.GetSyncID()) - getLogger().Debug("[SYNC] initialized state sync") + Logger().Debug().Msg("[SYNC] initialized state sync") } if node.stateSync.GetActivePeerNumber() < MinConnectedPeers { peers := getPeers() if err := node.stateSync.CreateSyncConfig(peers, false); err != nil { - getLogger().Debug("[SYNC] create peers error", "error", err) + Logger().Debug().Msg("[SYNC] create peers error") continue SyncingLoop } - getLogger().Debug("[SYNC] Get Active Peers", "len", node.stateSync.GetActivePeerNumber()) + Logger().Debug().Int("len", node.stateSync.GetActivePeerNumber()).Msg("[SYNC] Get Active Peers") } if node.stateSync.IsOutOfSync(bc) { node.stateMutex.Lock() @@ -192,7 +192,7 @@ func (node *Node) InitSyncingServer() { // StartSyncingServer starts syncing server. func (node *Node) StartSyncingServer() { - utils.GetLogInstance().Info("[SYNC] support_syncing: StartSyncingServer") + utils.Logger().Info().Msg("[SYNC] support_syncing: StartSyncingServer") if node.downloaderServer.GrpcServer == nil { node.downloaderServer.Start(node.SelfPeer.IP, syncing.GetSyncingPort(node.SelfPeer.Port)) } @@ -204,7 +204,7 @@ func (node *Node) SendNewBlockToUnsync() { block := <-node.Consensus.VerifiedNewBlock blockHash, err := rlp.EncodeToBytes(block) if err != nil { - utils.GetLogInstance().Warn("[SYNC] unable to encode block to hashes") + utils.Logger().Warn().Msg("[SYNC] unable to encode block to hashes") continue } @@ -212,7 +212,7 @@ func (node *Node) SendNewBlockToUnsync() { for peerID, config := range node.peerRegistrationRecord { elapseTime := time.Now().UnixNano() - config.timestamp if elapseTime > broadcastTimeout { - utils.GetLogInstance().Warn("[SYNC] SendNewBlockToUnsync to peer timeout", "peerID", peerID) + utils.Logger().Warn().Str("peerID", peerID).Msg("[SYNC] SendNewBlockToUnsync to peer timeout") node.peerRegistrationRecord[peerID].client.Close() delete(node.peerRegistrationRecord, peerID) continue @@ -248,7 +248,14 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in startHeight := startBlock.NumberU64() endHeight := node.Blockchain().CurrentBlock().NumberU64() if startHeight >= endHeight { - utils.GetLogInstance().Debug("[SYNC] GetBlockHashes Request: I am not higher than requested node", "myHeight", endHeight, "requestHeight", startHeight, "incomingIP", request.Ip, "incomingPort", request.Port, "incomingPeer", incomingPeer) + utils.Logger(). + Debug(). + Uint64("myHeight", endHeight). + Uint64("requestHeight", startHeight). + Str("incomingIP", request.Ip). + Str("incomingPort", request.Port). + Str("incomingPeer", incomingPeer). + Msg("[SYNC] GetBlockHashes Request: I am not higher than requested node") return response, nil } @@ -281,14 +288,16 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in // this is the out of sync node acts as grpc server side case downloader_pb.DownloaderRequest_NEWBLOCK: if node.State != NodeNotInSync { - utils.GetLogInstance().Debug("[SYNC] new block received, but state is", "state", node.State.String()) + utils.Logger().Debug(). + Str("state", node.State.String()). + Msg("[SYNC] new block received, but state is") response.Type = downloader_pb.DownloaderResponse_INSYNC return response, nil } var blockObj types.Block err := rlp.DecodeBytes(request.BlockHash, &blockObj) if err != nil { - utils.GetLogInstance().Warn("[SYNC] unable to decode received new block") + utils.Logger().Warn().Error().Err(err).Msg("[SYNC] unable to decode received new block") return response, err } node.stateSync.AddNewBlock(request.PeerHash, &blockObj) @@ -301,7 +310,10 @@ 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.GetLogInstance().Warn("[SYNC] peerRegistration record already exists", "ip", ip, "port", port) + utils.Logger().Warn().Err(err). + Interface("ip", ip). + Interface("port", port). + Msg("[SYNC] peerRegistration record already exists") return response, nil } else if len(node.peerRegistrationRecord) >= maxBroadcastNodes { response.Type = downloader_pb.DownloaderResponse_FAIL @@ -312,19 +324,27 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in syncPort := syncing.GetSyncingPort(port) client := downloader.ClientSetup(ip, syncPort) if client == nil { - utils.GetLogInstance().Warn("[SYNC] unable to setup client for peerID", "ip", ip, "port", port) + utils.Logger().Warn().Err(err). + Str("ip", ip). + Str("port", port). + Msg("[SYNC] unable to setup client for peerID") return response, nil } config := &syncConfig{timestamp: time.Now().UnixNano(), client: client} node.peerRegistrationRecord[peerID] = config - utils.GetLogInstance().Debug("[SYNC] register peerID success", "ip", ip, "port", port) + utils.Logger().Debug(). + Str("ip", ip). + Str("port", port). + Msg("[SYNC] register peerID success") response.Type = downloader_pb.DownloaderResponse_SUCCESS } case downloader_pb.DownloaderRequest_REGISTERTIMEOUT: if node.State == NodeNotInSync { count := node.stateSync.RegisterNodeInfo() - utils.GetLogInstance().Debug("[SYNC] extra node registered", "number", count) + utils.Logger().Debug(). + Str("number", count). + Msg("[SYNC] extra node registered") } } return response, nil diff --git a/node/rpc.go b/node/rpc.go index 8db4cd2f7..46b7ea0e8 100644 --- a/node/rpc.go +++ b/node/rpc.go @@ -83,7 +83,11 @@ func (node *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, c return err } - utils.GetLogger().Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%s", endpoint), "cors", strings.Join(cors, ","), "vhosts", strings.Join(vhosts, ",")) + utils.Logger().Info(). + Str("url", fmt.Sprintf("http://%s", endpoint)). + Str("cors", strings.Join(cors, ",")). + Str("vhosts", strings.Join(vhosts, ",")). + Msg("HTTP endpoint opened") // All listeners booted successfully httpListener = listener httpHandler = handler @@ -97,7 +101,7 @@ func (node *Node) stopHTTP() { httpListener.Close() httpListener = nil - utils.GetLogger().Info("HTTP endpoint closed", "url", fmt.Sprintf("http://%s", httpEndpoint)) + utils.Logger().Info().Str("url", fmt.Sprintf("http://%s", httpEndpoint)).Msg("HTTP endpoint closed") } if httpHandler != nil { httpHandler.Stop() @@ -115,7 +119,7 @@ func (node *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsO if err != nil { return err } - utils.GetLogger().Info("WebSocket endpoint opened", "url", fmt.Sprintf("ws://%s", listener.Addr())) + utils.Logger().Info().Str("url", fmt.Sprintf("ws://%s", listener.Addr())).Msg("WebSocket endpoint opened") // All listeners booted successfully wsListener = listener wsHandler = handler @@ -129,7 +133,7 @@ func (node *Node) stopWS() { wsListener.Close() wsListener = nil - utils.GetLogger().Info("WebSocket endpoint closed", "url", fmt.Sprintf("ws://%s", wsEndpoint)) + utils.Logger().Info().Str("url", fmt.Sprintf("ws://%s", wsEndpoint)).Msg("WebSocket endpoint closed") } if wsHandler != nil { wsHandler.Stop() diff --git a/node/service_setup.go b/node/service_setup.go index 763aa7ef6..afb9f0467 100644 --- a/node/service_setup.go +++ b/node/service_setup.go @@ -96,7 +96,7 @@ func (node *Node) ServiceManagerSetup() { // RunServices runs registered services. func (node *Node) RunServices() { if node.serviceManager == nil { - utils.GetLogInstance().Info("Service manager is not set up yet.") + utils.Logger().Info().Msg("Service manager is not set up yet.") return } node.serviceManager.RunServices() @@ -105,7 +105,7 @@ func (node *Node) RunServices() { // StopServices runs registered services. func (node *Node) StopServices() { if node.serviceManager == nil { - utils.GetLogInstance().Info("Service manager is not set up yet.") + utils.Logger().Info().Msg("Service manager is not set up yet.") return } node.serviceManager.StopServicesByRole([]service.Type{}) diff --git a/node/staking.go b/node/staking.go index af02bba28..468c93609 100644 --- a/node/staking.go +++ b/node/staking.go @@ -28,7 +28,7 @@ const ( // UpdateStakingList updates staking list from the given StakeInfo query result. func (node *Node) UpdateStakingList(stakeInfoReturnValue *structs.StakeInfoReturnValue) { - utils.GetLogInstance().Info("Updating staking list", "contractState", stakeInfoReturnValue) + utils.Logger().Str("contractState", stakeInfoReturnValue).Msg("Updating staking list") if stakeInfoReturnValue == nil { return } @@ -60,13 +60,19 @@ func (node *Node) UpdateStakingList(stakeInfoReturnValue *structs.StakeInfoRetur } func (node *Node) printStakingList() { - utils.GetLogInstance().Info("\n") - utils.GetLogInstance().Info("CURRENT STAKING INFO [START] ------------------------------------") + utils.Logger().Info().Msg("\n") + utils.Logger().Info().Msg("CURRENT STAKING INFO [START] ------------------------------------") for addr, stakeInfo := range node.CurrentStakes { - utils.GetLogInstance().Info("", "Address", addr, "BlsPubKey", hex.EncodeToString(stakeInfo.BlsPublicKey[:]), "BlockNum", stakeInfo.BlockNum, "lockPeriodCount", stakeInfo.LockPeriodCount, "amount", stakeInfo.Amount) + utils.Logger().Info(). + Str("Address", addr). + Str("BlsPubKey", hex.EncodeToString(stakeInfo.BlsPublicKey[:])). + Uint64("BlockNum", stakeInfo.BlockNum). + Int("lockPeriodCount", stakeInfo.LockPeriodCount). + Int("amount", stakeInfo.Amount). + Msg("") } - utils.GetLogInstance().Info("CURRENT STAKING INFO [END} ------------------------------------") - utils.GetLogInstance().Info("\n") + utils.Logger().Info().Msg("CURRENT STAKING INFO [END} ------------------------------------") + utils.Logger().Info().Msg("\n") } //The first four bytes of the call data for a function call specifies the function to be called. From 36e9c11d6cdc7ab46cff1d93a830834f284dae09 Mon Sep 17 00:00:00 2001 From: Priya Ganguly Date: Fri, 2 Aug 2019 11:35:18 -0700 Subject: [PATCH 2/5] finished zerolog conversion --- node/contract.go | 4 ++-- node/node.go | 8 +++++--- node/node_explorer.go | 21 +++++++++++++++------ node/node_genesis.go | 3 +-- node/node_syncing.go | 20 +++++++++----------- node/staking.go | 10 +++++----- 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/node/contract.go b/node/contract.go index 96c8f6445..a4ef00bed 100644 --- a/node/contract.go +++ b/node/contract.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") } } diff --git a/node/node.go b/node/node.go index b94430da2..2f51b2aa8 100644 --- a/node/node.go +++ b/node/node.go @@ -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 diff --git a/node/node_explorer.go b/node/node_explorer.go index b54278c28..6cd89ec9c 100644 --- a/node/node_explorer.go +++ b/node/node_explorer.go @@ -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( diff --git a/node/node_genesis.go b/node/node_genesis.go index 363493350..69f03f6f8 100644 --- a/node/node_genesis.go +++ b/node/node_genesis.go @@ -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 } diff --git a/node/node_syncing.go b/node/node_syncing.go index 0baca76ab..c27495424 100644 --- a/node/node_syncing.go +++ b/node/node_syncing.go @@ -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") } } diff --git a/node/staking.go b/node/staking.go index 468c93609..318312c11 100644 --- a/node/staking.go +++ b/node/staking.go @@ -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} ------------------------------------") From 70bca64b795220151cb1b989665fa302524ad1fb Mon Sep 17 00:00:00 2001 From: Priya Ganguly Date: Fri, 2 Aug 2019 16:22:50 -0700 Subject: [PATCH 3/5] fixed goimport format --- node/node.go | 12 ++++++------ node/node_explorer.go | 18 +++++++++--------- node/node_syncing.go | 44 +++++++++++++++++++++---------------------- node/rpc.go | 8 ++++---- node/staking.go | 12 ++++++------ 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/node/node.go b/node/node.go index 2f51b2aa8..779eb7b7b 100644 --- a/node/node.go +++ b/node/node.go @@ -260,10 +260,10 @@ func (node *Node) getTransactionsForNewBlock(maxNumTxs int, coinbase common.Addr node.pendingTransactions = unselected node.reducePendingTransactions() utils.Logger().Error(). - Int("remainPending", len(node.pendingTransactions)). - Int("selected", len(selected)). - Int("invalidDiscarded", len(invalid)). - Msg("Selecting Transactions") + Int("remainPending", len(node.pendingTransactions)). + Int("selected", len(selected)). + Int("invalidDiscarded", len(invalid)). + Msg("Selecting Transactions") node.pendingTxMutex.Unlock() return selected } @@ -370,8 +370,8 @@ func New(host p2p.Host, consensusObj *consensus.Consensus, chainDBFactory shardc } utils.Logger().Info(). - Interface("genesis block header", node.Blockchain().GetBlockByNumber(0).Header()). - Msg("Genesis block hash") + 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 diff --git a/node/node_explorer.go b/node/node_explorer.go index 6cd89ec9c..355d025b1 100644 --- a/node/node_explorer.go +++ b/node/node_explorer.go @@ -44,9 +44,9 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { // check has 2f+1 signatures if count := utils.CountOneBits(mask.Bitmap); count < node.Consensus.Quorum() { utils.Logger().Error(). - Int("need", node.Consensus.Quorum()). - Int("have", count). - Msg("[Explorer] not have enough signature") + Int("need", node.Consensus.Quorum()). + Int("have", count). + Msg("[Explorer] not have enough signature") return } @@ -55,9 +55,9 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { commitPayload := append(blockNumHash, recvMsg.BlockHash[:]...) if !aggSig.VerifyHash(mask.AggregatePublic, commitPayload) { utils.Logger(). - Error().Err(err). - Uint64("msgBlock", recvMsg.BlockNum). - Msg("[Explorer] Failed to verify the multi signature for commit phase") + Error().Err(err). + Uint64("msgBlock", recvMsg.BlockNum). + Msg("[Explorer] Failed to verify the multi signature for commit phase") return } @@ -65,8 +65,8 @@ func (node *Node) ExplorerMessageHandler(payload []byte) { if block == nil { utils.Logger().Info(). - Uint64("msgBlock", recvMsg.BlockNum). - Msg("[Explorer] Haven't received the block before the committed msg") + Uint64("msgBlock", recvMsg.BlockNum). + Msg("[Explorer] Haven't received the block before the committed msg") node.Consensus.PbftLog.AddMessage(recvMsg) return } @@ -118,7 +118,7 @@ func (node *Node) AddNewBlockForExplorer() { // And they would be dumped again here. Please fix it. once.Do(func() { utils.Logger().Info().Int64("starting height", int64(blocks[0].NumberU64())-1). - Msg("[Explorer] Populating explorer data from state synced blocks") + 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( diff --git a/node/node_syncing.go b/node/node_syncing.go index c27495424..fe1e91836 100644 --- a/node/node_syncing.go +++ b/node/node_syncing.go @@ -7,7 +7,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - + "github.com/ethereum/go-ethereum/rlp" "github.com/harmony-one/harmony/api/service/syncing" @@ -120,7 +120,7 @@ SyncingLoop: case <-ticker.C: if node.stateSync == nil { node.stateSync = syncing.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, node.GetSyncID()) - + utils.Logger().Debug().Msg("[SYNC] initialized state sync") } if node.stateSync.GetActivePeerNumber() < MinConnectedPeers { @@ -247,13 +247,13 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in endHeight := node.Blockchain().CurrentBlock().NumberU64() if startHeight >= endHeight { utils.Logger(). - Debug(). - Uint64("myHeight", endHeight). - Uint64("requestHeight", startHeight). - Str("incomingIP", request.Ip). - Str("incomingPort", request.Port). - Str("incomingPeer", incomingPeer). - Msg("[SYNC] GetBlockHashes Request: I am not higher than requested node") + Debug(). + Uint64("myHeight", endHeight). + Uint64("requestHeight", startHeight). + Str("incomingIP", request.Ip). + Str("incomingPort", request.Port). + Str("incomingPeer", incomingPeer). + Msg("[SYNC] GetBlockHashes Request: I am not higher than requested node") return response, nil } @@ -287,8 +287,8 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in case downloader_pb.DownloaderRequest_NEWBLOCK: if node.State != NodeNotInSync { utils.Logger().Debug(). - Str("state", node.State.String()). - Msg("[SYNC] new block received, but state is") + Str("state", node.State.String()). + Msg("[SYNC] new block received, but state is") response.Type = downloader_pb.DownloaderResponse_INSYNC return response, nil } @@ -309,9 +309,9 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in if _, ok := node.peerRegistrationRecord[peerID]; ok { response.Type = downloader_pb.DownloaderResponse_FAIL utils.Logger().Warn(). - Interface("ip", ip). - Interface("port", port). - Msg("[SYNC] peerRegistration record already exists") + Interface("ip", ip). + Interface("port", port). + Msg("[SYNC] peerRegistration record already exists") return response, nil } else if len(node.peerRegistrationRecord) >= maxBroadcastNodes { response.Type = downloader_pb.DownloaderResponse_FAIL @@ -323,17 +323,17 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in client := downloader.ClientSetup(ip, syncPort) if client == nil { utils.Logger().Warn(). - Str("ip", ip). - Str("port", port). - Msg("[SYNC] unable to setup client for peerID") + Str("ip", ip). + Str("port", port). + Msg("[SYNC] unable to setup client for peerID") return response, nil } config := &syncConfig{timestamp: time.Now().UnixNano(), client: client} node.peerRegistrationRecord[peerID] = config utils.Logger().Debug(). - Str("ip", ip). - Str("port", port). - Msg("[SYNC] register peerID success") + Str("ip", ip). + Str("port", port). + Msg("[SYNC] register peerID success") response.Type = downloader_pb.DownloaderResponse_SUCCESS } @@ -341,8 +341,8 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in if node.State == NodeNotInSync { count := node.stateSync.RegisterNodeInfo() utils.Logger().Debug(). - Int("number", count). - Msg("[SYNC] extra node registered") + Int("number", count). + Msg("[SYNC] extra node registered") } } return response, nil diff --git a/node/rpc.go b/node/rpc.go index 46b7ea0e8..5d3cf96e8 100644 --- a/node/rpc.go +++ b/node/rpc.go @@ -84,10 +84,10 @@ func (node *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, c } utils.Logger().Info(). - Str("url", fmt.Sprintf("http://%s", endpoint)). - Str("cors", strings.Join(cors, ",")). - Str("vhosts", strings.Join(vhosts, ",")). - Msg("HTTP endpoint opened") + Str("url", fmt.Sprintf("http://%s", endpoint)). + Str("cors", strings.Join(cors, ",")). + Str("vhosts", strings.Join(vhosts, ",")). + Msg("HTTP endpoint opened") // All listeners booted successfully httpListener = listener httpHandler = handler diff --git a/node/staking.go b/node/staking.go index 318312c11..57b984c9e 100644 --- a/node/staking.go +++ b/node/staking.go @@ -64,12 +64,12 @@ func (node *Node) printStakingList() { utils.Logger().Info().Msg("CURRENT STAKING INFO [START] ------------------------------------") for addr, stakeInfo := range node.CurrentStakes { utils.Logger().Info(). - Str("Address", addr.String()). - Str("BlsPubKey", hex.EncodeToString(stakeInfo.BlsPublicKey[:])). - Interface("BlockNum", stakeInfo.BlockNum). - Interface("lockPeriodCount", stakeInfo.LockPeriodCount). - Interface("amount", stakeInfo.Amount). - Msg("") + Str("Address", addr.String()). + Str("BlsPubKey", hex.EncodeToString(stakeInfo.BlsPublicKey[:])). + Interface("BlockNum", stakeInfo.BlockNum). + Interface("lockPeriodCount", stakeInfo.LockPeriodCount). + Interface("amount", stakeInfo.Amount). + Msg("") } utils.Logger().Info().Msg("CURRENT STAKING INFO [END} ------------------------------------") utils.Logger().Info().Msg("\n") From ac00a1092ece228dfb0bbfec4f6c3333db2afb1b Mon Sep 17 00:00:00 2001 From: Priya Ganguly Date: Sat, 3 Aug 2019 15:37:57 -0700 Subject: [PATCH 4/5] got rid of CURRENT STAKING INFO error message --- node/staking.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/node/staking.go b/node/staking.go index 57b984c9e..f1c24ebcb 100644 --- a/node/staking.go +++ b/node/staking.go @@ -71,8 +71,6 @@ func (node *Node) printStakingList() { Interface("amount", stakeInfo.Amount). Msg("") } - utils.Logger().Info().Msg("CURRENT STAKING INFO [END} ------------------------------------") - utils.Logger().Info().Msg("\n") } //The first four bytes of the call data for a function call specifies the function to be called. From e6246ed207dba45f1f3113035d16748a628a2d35 Mon Sep 17 00:00:00 2001 From: Priya Ganguly Date: Sat, 3 Aug 2019 15:40:12 -0700 Subject: [PATCH 5/5] got rid of CURRENT STAKING INFO error message --- node/staking.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/node/staking.go b/node/staking.go index f1c24ebcb..4d43297c9 100644 --- a/node/staking.go +++ b/node/staking.go @@ -60,8 +60,6 @@ func (node *Node) UpdateStakingList(stakeInfoReturnValue *structs.StakeInfoRetur } func (node *Node) printStakingList() { - utils.Logger().Info().Msg("\n") - utils.Logger().Info().Msg("CURRENT STAKING INFO [START] ------------------------------------") for addr, stakeInfo := range node.CurrentStakes { utils.Logger().Info(). Str("Address", addr.String()).