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

trace removed txs #144

Closed
wants to merge 3 commits into from
Closed
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
42 changes: 37 additions & 5 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ func (pool *TxPool) loop() {
list := pool.queue[addr].Flatten()
for _, tx := range list {
pool.removeTx(tx.Hash(), true)

log.Info("[tx_pool_trace_txn]", "func", "loop", "remove by lifetime", fmt.Sprintf("%v", tx.Hash()))
}
queuedEvictionMeter.Mark(int64(len(list)))
}
Expand Down Expand Up @@ -480,6 +482,8 @@ func (pool *TxPool) SetGasPrice(price *big.Int) {
drop := pool.all.RemotesBelowTip(price)
for _, tx := range drop {
pool.removeTx(tx.Hash(), false)

log.Info("[tx_pool_trace_txn]", "func", "SetGasPrice", "remove by new gasPrice", fmt.Sprintf("%v", tx.Hash()))
}
pool.priced.Removed(len(drop))
}
Expand Down Expand Up @@ -753,9 +757,11 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
pool.changesSinceReorg += len(drop)
// Kick out the underpriced remote transactions.
for _, tx := range drop {
log.Trace("Discarding freshly underpriced transaction", "hash", tx.Hash(), "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap())
// log.Trace("Discarding freshly underpriced transaction", "hash", tx.Hash(), "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap())
underpricedTxMeter.Mark(1)
pool.removeTx(tx.Hash(), false)

log.Info("[tx_pool_trace_txn]", "func", "add", "discard by global slot", fmt.Sprintf("%v", tx.Hash()))
}
}
// Try to replace an existing transaction in the pending pool
Expand All @@ -772,6 +778,8 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
pool.all.Remove(old.Hash())
pool.priced.Removed(1)
pendingReplaceMeter.Mark(1)

log.Info("[tx_pool_trace_txn]", "func", "add", "replace old -> true, add new txn hash", fmt.Sprintf("%v", hash), "remove old txn hash", fmt.Sprintf("%v", old.Hash()))
}
pool.all.Add(tx, isLocal)
pool.priced.Put(tx, isLocal)
Expand Down Expand Up @@ -823,6 +831,8 @@ func (pool *TxPool) enqueueTx(hash common.Hash, tx *types.Transaction, local boo
pool.all.Remove(old.Hash())
pool.priced.Removed(1)
queuedReplaceMeter.Mark(1)

log.Info("[tx_pool_trace_txn]", "func", "enqueueTx", "replace old -> true, add new txn hash", fmt.Sprintf("%v", tx.Hash()), "remove old txn hash", fmt.Sprintf("%v", old.Hash()))
} else {
// Nothing was replaced, bump the queued counter
queuedGauge.Inc(1)
Expand Down Expand Up @@ -872,13 +882,17 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
pool.all.Remove(hash)
pool.priced.Removed(1)
pendingDiscardMeter.Mark(1)

log.Info("[tx_pool_trace_txn]", "func", "promoteTx", "replace old -> false, remove new txn hash", fmt.Sprintf("%v", hash))
return false
}
// Otherwise discard any previous transaction and mark this
if old != nil {
pool.all.Remove(old.Hash())
pool.priced.Removed(1)
pendingReplaceMeter.Mark(1)

log.Info("[tx_pool_trace_txn]", "func", "promoteTx", "replace old -> true, add new txn hash", fmt.Sprintf("%v", hash), "remove old txn hash", fmt.Sprintf("%v", old.Hash()))
} else {
// Nothing was replaced, bump the pending counter
pendingGauge.Inc(1)
Expand Down Expand Up @@ -1043,6 +1057,8 @@ func (pool *TxPool) RemoveTx(hash common.Hash, outofbound bool) {
pool.mu.Lock()
defer pool.mu.Unlock()

log.Info("[tx_pool_trace_txn]", "func", "RemoveTx", "remove by external calls", fmt.Sprintf("%v", hash))

pool.removeTx(hash, outofbound)
}

Expand All @@ -1058,6 +1074,8 @@ func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) {

// Remove it from the list of known transactions
pool.all.Remove(hash)
log.Info("[tx_pool_trace_txn]", "func", "removeTx", "txn hash", fmt.Sprintf("%v", hash))

if outofbound {
pool.priced.Removed(1)
}
Expand Down Expand Up @@ -1394,6 +1412,8 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans
for _, tx := range drops {
hash := tx.Hash()
pool.all.Remove(hash)

log.Info("[tx_pool_trace_txn]", "func", "promoteExecutables", "remove low balance or out of gas", fmt.Sprintf("%v", hash))
}
log.Trace("Removed unpayable queued transactions", "count", len(drops))
queuedNofundsMeter.Mark(int64(len(drops)))
Expand All @@ -1416,7 +1436,9 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans
for _, tx := range caps {
hash := tx.Hash()
pool.all.Remove(hash)
log.Trace("Removed cap-exceeding queued transaction", "hash", hash)
// log.Trace("Removed cap-exceeding queued transaction", "hash", hash)

log.Info("[tx_pool_trace_txn]", "func", "promoteExecutables", "remove by cap-exceeding AccountQueue", fmt.Sprintf("%v", hash))
}
queuedRateLimitMeter.Mark(int64(len(caps)))
}
Expand Down Expand Up @@ -1482,7 +1504,9 @@ func (pool *TxPool) truncatePending() {

// Update the account nonce to the dropped transaction
pool.pendingNonces.setIfLower(offenders[i], tx.Nonce())
log.Trace("Removed fairness-exceeding pending transaction", "hash", hash)
// log.Trace("Removed fairness-exceeding pending transaction", "hash", hash)

log.Info("[tx_pool_trace_txn]", "func", "truncatePending", "remove by GlobalSlots limit", fmt.Sprintf("%v", hash))
}
pool.priced.Removed(len(caps))
pendingGauge.Dec(int64(len(caps)))
Expand All @@ -1509,7 +1533,9 @@ func (pool *TxPool) truncatePending() {

// Update the account nonce to the dropped transaction
pool.pendingNonces.setIfLower(addr, tx.Nonce())
log.Trace("Removed fairness-exceeding pending transaction", "hash", hash)
// log.Trace("Removed fairness-exceeding pending transaction", "hash", hash)

log.Info("[tx_pool_trace_txn]", "func", "truncatePending", "remove by GlobalSlots limit & AccountSlots", fmt.Sprintf("%v", hash))
}
pool.priced.Removed(len(caps))
pendingGauge.Dec(int64(len(caps)))
Expand Down Expand Up @@ -1554,6 +1580,8 @@ func (pool *TxPool) truncateQueue() {
if size := uint64(list.Len()); size <= drop {
for _, tx := range list.Flatten() {
pool.removeTx(tx.Hash(), true)

log.Info("[tx_pool_trace_txn]", "func", "truncateQueue", "remove by GlobalQueue limit", fmt.Sprintf("%v", tx.Hash()))
}
drop -= size
queuedRateLimitMeter.Mark(int64(size))
Expand All @@ -1563,6 +1591,8 @@ func (pool *TxPool) truncateQueue() {
txs := list.Flatten()
for i := len(txs) - 1; i >= 0 && drop > 0; i-- {
pool.removeTx(txs[i].Hash(), true)

log.Info("[tx_pool_trace_txn]", "func", "truncateQueue", "remove by GlobalQueue limit again", fmt.Sprintf("%v", txs[i].Hash()))
drop--
queuedRateLimitMeter.Mark(1)
}
Expand Down Expand Up @@ -1592,8 +1622,10 @@ func (pool *TxPool) demoteUnexecutables() {
drops, invalids := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas)
for _, tx := range drops {
hash := tx.Hash()
log.Trace("Removed unpayable pending transaction", "hash", hash)
// log.Trace("Removed unpayable pending transaction", "hash", hash)
pool.all.Remove(hash)

log.Info("[tx_pool_trace_txn]", "func", "demoteUnexecutables", "remove by low balance or out of gas", fmt.Sprintf("%v", hash))
}
pendingNofundsMeter.Mark(int64(len(drops)))

Expand Down
Loading