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] Fix expire metric to only count for expired txs #193

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions internal/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ func (txmp *TxMempool) CheckTx(
evmNonce: res.EVMNonce,
evmAddress: res.EVMSenderAddress,
isEVM: res.IsEVM,
expiredCallback: func(removeFromCache bool) {
txmp.metrics.ExpiredTxs.Add(1)
removeHandler: func(removeFromCache bool) {
if removeFromCache {
txmp.cache.Remove(tx)
}
Expand Down Expand Up @@ -856,7 +855,7 @@ func (txmp *TxMempool) removeTx(wtx *WrappedTx, removeFromCache bool) {

atomic.AddInt64(&txmp.sizeBytes, int64(-wtx.Size()))

wtx.expiredCallback(removeFromCache)
wtx.removeHandler(removeFromCache)
}

// purgeExpiredTxs removes all transactions that have exceeded their respective
Expand Down Expand Up @@ -905,12 +904,14 @@ func (txmp *TxMempool) purgeExpiredTxs(blockHeight int64) {
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions internal/mempool/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ type WrappedTx struct {
// a reCheckTx callback executed.
removed bool

// this is the callback that can be called when a transaction expires
expiredCallback func(removeFromCache bool)
// this is the callback that can be called when a transaction is removed
removeHandler func(removeFromCache bool)

// evm properties that aid in prioritization
evmAddress string
Expand Down
Loading