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

fix: Remove panic for unexpected tx response in resCbRecheck #394

Merged
merged 2 commits into from
Apr 7, 2022
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
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),
)
}
torao marked this conversation as resolved.
Show resolved Hide resolved
} else {
panic(fmt.Sprintf("unexpected tx response from proxy during recheck\ntxHash=%X, tx=%X", txHash, tx))
}
default:
// ignore other messages
Expand Down