Submitted by berndartmueller, also found by oakcobalt
The outbound transaction queue is potentially blocked by such stuck transactions, preventing other pending cctxs from being sent out.
The AddToOutTxTracker function, handling the MsgAddToOutTxTracker message, adds a transaction hash associated with a pending cctx to the outbound transaction tracker, which is subsequently watched by observers to detect the transactions inclusion and confirmation in a block. As a result, the pending cctx is marked as CctxStatus_OutboundMined.
This MsgAddToOutTxTracker message is sent by observers as soon as the outbound transaction is broadcast. See zetaclient/evm_signer.go#L585 and zetaclient/btc_signer.go#L360.
However, the AddToOutTxTracker function only keeps track of a maximum of two different transaction hashes, as seen in line 100. Otherwise, the msg.TxHash is discarded.
This is problematic as an outbound cctx, uniquely identified by its nonce, can have multiple different transaction hashes caused by repeatedly increasing the gas price every epoch.
As soon as the gas price has been increased and observers broadcast the updated transaction (i.e., replace it in the mempool), the transaction hash will change. As a result, reporting the transaction hash to ZetaChain via the AddTxHashToOutTxTracker function call will not keep track of the new transaction hash.
Consequently, the EVM clients observeOutTx and the BTC clients observeOutTx function are not able to query the transaction by the available hashes found in the tracker HashList. This results in the outbound cctx being repeatedly processed by the observers, unnecessarily blocking other pending cctxs from being sent out (due to limiting the amount of sent outbound cctx per the 3-second ticker).
Only after such a stuck transaction is manually added to the outbound transaction tracker via the AddTxHashToOutTxTracker function by providing a block inclusion proof, the correct and up-to-date transaction hash is added to the tracker and the observers can finally confirm and conclude the cctx. However, this is a separate process and requires (manual) intervention, which might take some time until it is noticed.
Consider keeping track of all transaction hashes associated with a pending cctx instead of limiting it to two hashes.
lumtis (ZetaChain) acknowledged
