Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TX pool debug level logging optimizations #1609

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,14 @@ func (p *TxPool) Drop(tx *types.Transaction) {
clearAccountQueue(dropped)

p.eventManager.signalEvent(proto.EventType_DROPPED, tx.Hash)
p.logger.Debug("dropped account txs",
"num", droppedCount,
"next_nonce", nextNonce,
"address", tx.From.String(),
)

if p.logger.IsDebug() {
p.logger.Debug("dropped account txs",
"num", droppedCount,
"next_nonce", nextNonce,
"address", tx.From.String(),
igorcrevar marked this conversation as resolved.
Show resolved Hide resolved
)
}
}

// Demote excludes an account from being further processed during block building
Expand All @@ -440,10 +443,12 @@ func (p *TxPool) Drop(tx *types.Transaction) {
func (p *TxPool) Demote(tx *types.Transaction) {
account := p.accounts.get(tx.From)
if account.Demotions() >= maxAccountDemotions {
p.logger.Debug(
"Demote: threshold reached - dropping account",
"addr", tx.From.String(),
)
if p.logger.IsDebug() {
p.logger.Debug(
"Demote: threshold reached - dropping account",
"addr", tx.From.String(),
)
}

p.Drop(tx)

Expand Down Expand Up @@ -718,10 +723,12 @@ func (p *TxPool) pruneAccountsWithNonceHoles() {
// successful, an account is created for this address
// (only once) and an enqueueRequest is signaled.
func (p *TxPool) addTx(origin txOrigin, tx *types.Transaction) error {
p.logger.Debug("add tx",
"origin", origin.String(),
"hash", tx.Hash.String(),
)
if p.logger.IsDebug() {
p.logger.Debug("add tx",
"origin", origin.String(),
"hash", tx.Hash.String(),
)
}

// validate incoming tx
if err := p.validateTx(tx); err != nil {
Expand Down Expand Up @@ -786,7 +793,9 @@ func (p *TxPool) handleEnqueueRequest(req enqueueRequest) {
return
}

p.logger.Debug("enqueue request", "hash", tx.Hash.String())
if p.logger.IsDebug() {
p.logger.Debug("enqueue request", "hash", tx.Hash.String())
}

p.gauge.increase(slotsRequired(tx))

Expand All @@ -810,7 +819,9 @@ func (p *TxPool) handlePromoteRequest(req promoteRequest) {

// promote enqueued txs
promoted, pruned := account.promote()
p.logger.Debug("promote request", "promoted", promoted, "addr", addr.String())
if p.logger.IsDebug() {
p.logger.Debug("promote request", "promoted", promoted, "addr", addr.String())
}

p.index.remove(pruned...)
p.gauge.decrease(slotsRequired(pruned...))
Expand Down Expand Up @@ -854,7 +865,9 @@ func (p *TxPool) addGossipTx(obj interface{}, _ peer.ID) {
// add tx
if err := p.addTx(gossip, tx); err != nil {
if errors.Is(err, ErrAlreadyKnown) {
p.logger.Debug("rejecting known tx (gossip)", "hash", tx.Hash.String())
if p.logger.IsDebug() {
p.logger.Debug("rejecting known tx (gossip)", "hash", tx.Hash.String())
}

return
}
Expand Down