Skip to content

Commit

Permalink
enhancement(logging): leverage trace level (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain authored Nov 7, 2024
1 parent 7a89780 commit 8be8574
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cmd/thor/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (n *Node) txStashLoop(ctx context.Context) {
if err := stash.Save(txEv.Tx); err != nil {
logger.Warn("stash tx", "id", txEv.Tx.ID(), "err", err)
} else {
logger.Debug("stashed tx", "id", txEv.Tx.ID())
logger.Trace("stashed tx", "id", txEv.Tx.ID())
}
}
}
Expand Down Expand Up @@ -392,7 +392,7 @@ func (n *Node) processBlock(newBlock *block.Block, stats *blockStats) (bool, err
commitElapsed := mclock.Now() - startTime - execElapsed

if v, updated := n.bandwidth.Update(newBlock.Header(), time.Duration(realElapsed)); updated {
logger.Debug("bandwidth updated", "gps", v)
logger.Trace("bandwidth updated", "gps", v)
}
stats.UpdateProcessed(1, len(receipts), execElapsed, commitElapsed, realElapsed, newBlock.Header().GasUsed())

Expand Down
2 changes: 1 addition & 1 deletion cmd/thor/node/packer_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (n *Node) pack(flow *packer.Flow) (err error) {
)

if v, updated := n.bandwidth.Update(newBlock.Header(), time.Duration(realElapsed)); updated {
logger.Debug("bandwidth updated", "gps", v)
logger.Trace("bandwidth updated", "gps", v)
}

metricBlockProcessedTxs().SetWithLabel(int64(len(receipts)), map[string]string{"type": "proposed"})
Expand Down
2 changes: 1 addition & 1 deletion comm/handle_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// peer will be disconnected if error returned
func (c *Communicator) handleRPC(peer *Peer, msg *p2p.Msg, write func(interface{}), txsToSync *txsToSync) (err error) {
log := peer.logger.New("msg", proto.MsgName(msg.Code))
log.Debug("received RPC call")
log.Trace("received RPC call")
defer func() {
if err != nil {
log.Debug("failed to handle RPC call", "err", err)
Expand Down
2 changes: 1 addition & 1 deletion comm/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func findCommonAncestor(ctx context.Context, repo *chain.Repository, peer *Peer,

func (c *Communicator) syncTxs(peer *Peer) {
for i := 0; ; i++ {
peer.logger.Debug(fmt.Sprintf("sync txs loop %v", i))
peer.logger.Trace(fmt.Sprintf("sync txs loop %v", i))
result, err := proto.GetTxs(c.ctx, peer)
if err != nil {
peer.logger.Debug("failed to request txs", "err", err)
Expand Down
4 changes: 2 additions & 2 deletions p2psrv/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *Server) Start(protocols []*p2p.Protocol, topic discv5.Topic) error {
}
log := logger.New("peer", peer, "dir", dir)

log.Debug("peer connected")
log.Trace("peer connected")
metricConnectedPeers().Add(1)

startTime := mclock.Now()
Expand Down Expand Up @@ -252,7 +252,7 @@ func (s *Server) discoverLoop(topic discv5.Topic) {
if _, found := s.discoveredNodes.Get(node.ID); !found {
metricDiscoveredNodes().Add(1)
s.discoveredNodes.Set(node.ID, node)
logger.Debug("discovered node", "node", node)
logger.Trace("discovered node", "node", node)
}
case <-s.done:
close(setPeriod)
Expand Down
14 changes: 7 additions & 7 deletions txpool/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (p *TxPool) housekeeping() {
}

metricTxPoolGauge().AddWithLabel(0-int64(removed), map[string]string{"source": "washed", "total": "true"})
logger.Debug("wash done", ctx...)
logger.Trace("wash done", ctx...)
}
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@ func (p *TxPool) add(newTx *tx.Transaction, rejectNonExecutable bool, localSubmi
p.goes.Go(func() {
p.txFeed.Send(&TxEvent{newTx, &executable})
})
logger.Debug("tx added", "id", newTx.ID(), "executable", executable)
logger.Trace("tx added", "id", newTx.ID(), "executable", executable)
} else {
// we skip steps that rely on head block when chain is not synced,
// but check the pool's limit
Expand All @@ -287,7 +287,7 @@ func (p *TxPool) add(newTx *tx.Transaction, rejectNonExecutable bool, localSubmi
if err := p.all.Add(txObj, p.options.LimitPerAccount, func(_ thor.Address, _ *big.Int) error { return nil }); err != nil {
return txRejectedError{err.Error()}
}
logger.Debug("tx added", "id", newTx.ID())
logger.Trace("tx added", "id", newTx.ID())
p.goes.Go(func() {
p.txFeed.Send(&TxEvent{newTx, nil})
})
Expand Down Expand Up @@ -408,29 +408,29 @@ func (p *TxPool) wash(headSummary *chain.BlockSummary) (executables tx.Transacti
for _, txObj := range all {
if thor.IsOriginBlocked(txObj.Origin()) || p.blocklist.Contains(txObj.Origin()) {
toRemove = append(toRemove, txObj)
logger.Debug("tx washed out", "id", txObj.ID(), "err", "blocked")
logger.Trace("tx washed out", "id", txObj.ID(), "err", "blocked")
continue
}

// out of lifetime
if !txObj.localSubmitted && now > txObj.timeAdded+int64(p.options.MaxLifetime) {
toRemove = append(toRemove, txObj)
logger.Debug("tx washed out", "id", txObj.ID(), "err", "out of lifetime")
logger.Trace("tx washed out", "id", txObj.ID(), "err", "out of lifetime")
continue
}
// settled, out of energy or dep broken
executable, err := txObj.Executable(chain, newState(), headSummary.Header)
if err != nil {
toRemove = append(toRemove, txObj)
logger.Debug("tx washed out", "id", txObj.ID(), "err", err)
logger.Trace("tx washed out", "id", txObj.ID(), "err", err)
continue
}

if executable {
provedWork, err := txObj.ProvedWork(headSummary.Header.Number(), chain.GetBlockID)
if err != nil {
toRemove = append(toRemove, txObj)
logger.Debug("tx washed out", "id", txObj.ID(), "err", err)
logger.Trace("tx washed out", "id", txObj.ID(), "err", err)
continue
}
txObj.overallGasPrice = txObj.OverallGasPrice(baseGasPrice, provedWork)
Expand Down

0 comments on commit 8be8574

Please sign in to comment.