Skip to content

Commit

Permalink
fix: Remove panic for unexpected tx response in resCbRecheck (#394)
Browse files Browse the repository at this point in the history
* fix: Remove panic for unexpected tx response in `resCbRecheck`

* fix: Add a log when tx could not be loaded and changed the level to `Debug` level
  • Loading branch information
Kynea0b authored Apr 7, 2022
1 parent d5bf6f6 commit 9615276
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions mempool/clist_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,20 +537,23 @@ func (mem *CListMempool) resCbFirstTime(
func (mem *CListMempool) resCbRecheck(req *abci.Request, res *abci.Response) {
switch r := res.Value.(type) {
case *abci.Response_CheckTx:
tx := req.GetCheckTx().Tx
txHash := TxKey(tx)
if e, ok := mem.txsMap.Load(txHash); ok {
celem := e.(*clist.CElement)
if r.CheckTx.Code == abci.CodeTypeOK {
// Good, nothing to do.
} else {
if r.CheckTx.Code == abci.CodeTypeOK {
// Good, nothing to do.
} else {
tx := req.GetCheckTx().Tx
txHash := TxKey(tx)
if e, ok := mem.txsMap.Load(txHash); ok {
celem := e.(*clist.CElement)
// Tx became invalidated due to newly committed block.
mem.logger.Debug("tx is no longer valid", "tx", txID(tx), "res", r)
// NOTE: we remove tx from the cache because it might be good later
mem.removeTx(tx, celem, true)
} else {
mem.logger.Debug(
"re-CheckTx transaction does not exist",
"expected", types.Tx(tx),
)
}
} else {
panic(fmt.Sprintf("unexpected tx response from proxy during recheck\ntxHash=%X, tx=%X", txHash, tx))
}
default:
// ignore other messages
Expand Down

0 comments on commit 9615276

Please sign in to comment.