Skip to content

mempool: panic when app's CheckTx returns an error while rechecking #2225

@hvanz

Description

@hvanz

Thanks @p4u for reporting this bug!

Bug Report

Setup

CometBFT version: from v0.38 and up

What happened?

Comet panics with the message "recheck cursor is not nil before resCbFirstTime", which is found in this line:

panic("recheck cursor is not nil before resCbFirstTime")

Briefly, when we are using a local ABCI client and the app's CheckTx method returns a non-nil error, the rechecking process is broken at this line, leaving recheckCursor and recheckEnd in an inconsistent state.

These are the steps to reach the panic line:

  • Rechecking is started by recheckTxs, which:
    • sets recheckCursor to the first element of the transaction list txs
    • for every element in txs, it sends a CheckTx request to the app. We are using a local client, so the call to proxyAppConn.CheckTxAsync is synchronous, meaning that it will the CheckTx method on the app and immediately call the globalCb callback to process the response.
    • If the app's CheckTx returns an error, the function recheckTxs returns without finishing the rechecking process and leaving recheckCursor with a non-nil value. recheckCursor is set to nil again only in resCbRecheck, when it's equal to recheckEnd.
  • A CheckTx request of type CHECK_TX_TYPE_CHECK is sent to the app for a new tx; a response is handled by globalCb, which will panic because recheckCursor is not nil.

Notes

On previous versions of CometBFT, CheckTxAsync didn't return an error, so this problem didn't exist. And when this new behaviour was introduced, the documentation was not updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmempool

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions