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

[EVM] Add logging for expiration #198

Merged
merged 2 commits into from
Jan 29, 2024
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
32 changes: 28 additions & 4 deletions internal/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,32 @@ func (txmp *TxMempool) removeTx(wtx *WrappedTx, removeFromCache bool) {
wtx.removeHandler(removeFromCache)
}

func (txmp *TxMempool) expire(blockHeight int64, wtx *WrappedTx) {
txmp.metrics.ExpiredTxs.Add(1)
txmp.logExpiredTx(blockHeight, wtx)
wtx.removeHandler(!txmp.config.KeepInvalidTxsInCache)
}

func (txmp *TxMempool) logExpiredTx(blockHeight int64, wtx *WrappedTx) {
// defensive check
if wtx == nil {
return
}

txmp.logger.Info(
"transaction expired",
"priority", wtx.priority,
"tx", fmt.Sprintf("%X", wtx.tx.Hash()),
"address", wtx.evmAddress,
"evm", wtx.isEVM,
"nonce", wtx.evmNonce,
"height", blockHeight,
"tx_height", wtx.height,
"tx_timestamp", wtx.timestamp,
"age", time.Since(wtx.timestamp),
)
}

// purgeExpiredTxs removes all transactions that have exceeded their respective
// height- and/or time-based TTLs from their respective indexes. Every expired
// transaction will be removed from the mempool, but preserved in the cache (except for pending txs).
Expand Down Expand Up @@ -902,14 +928,12 @@ func (txmp *TxMempool) purgeExpiredTxs(blockHeight int64) {
}

for _, wtx := range expiredTxs {
txmp.metrics.ExpiredTxs.Add(1)
txmp.removeTx(wtx, !txmp.config.KeepInvalidTxsInCache)
txmp.expire(blockHeight, wtx)
}

// remove pending txs that have expired
txmp.pendingTxs.PurgeExpired(txmp.config.TTLNumBlocks, blockHeight, txmp.config.TTLDuration, now, func(wtx *WrappedTx) {
txmp.metrics.ExpiredTxs.Add(1)
wtx.removeHandler(!txmp.config.KeepInvalidTxsInCache)
txmp.expire(blockHeight, wtx)
})
}

Expand Down
Loading