Timeout in mempool

I came across stuck TXs in mempool yesterday and today. What’s the reason or is it a bug? If not bug, what is the algorithm for Txs in mempool? For example,

1- Wait for execution (i.e. put into the block) for X minutes.
2- If not executed, drop it.

If the algorithm is correct, what is X? What’s the reason for stuck?

5 Likes

It can happen if a shard is stuck. Your transaction is in the shard pool but this shard doesn’t produce new blocks.

1 Like

Unfortunately, it isn’t. I checked it via incscan. The shard was working.In fact, I sent a few transactions (into the same shard) and they were executed. The stuck one was still stuck :slight_smile: Then, I suspected whether it was an incscan bug and I sent RPC to check whether it was really in mempool. Yes, it was.

3 Likes

as far as i know, it could be an issue with utxo. once a transaction gets into the network (often mempool) it’s verified on double-spending with both current transactions in mempool and blockchain data.

Let me give an example that a tx could be in mempool and got rejected to be picked into a block then removed from mempool by timeout:
2 txs A and B created from the same account X, tx A used an utxo O going to mempool then a shard for producing a new block but not confirmed yet, after that tx B used utxo O as well going to mempool, it’s also passed double-spending validation since O was not used in mempool and blockchain at that point because tx A left mempool but not got confirmed in a block yet. When tx A got confirmed in a block and O was stored into blockchain, tx B would be rejected from producing a new block due to utxo O double-spending in blockchain - it’s kept rejecting tx B until timeout.

The same situation could happen if you send multiple txs to different fullnode concurrently from the same account.

One solution for the issue is marking used/pending utxo at the client side so that txs are only created with “un-used” utxo.

6 Likes

I want to thank @abduraman for beginning this really excellent topic on a tech issue and furthermore thank @inccry and @duc for the further discussion that took place…the techie stuff could go over some of the community members for well not all will so well be versed in techie or programming or troubleshooting skills as you 3 members showed thru the discussion of the timeout in mempool…I thank you for the topic and the enlightenment given and hopefully, the cause for the issue and correction recommended is correct… :sunglasses:

Thanks for explanation. Do you remember how long the time duration is? @duc

2 Likes

The tx’s TTL is 15 min and the interval to run the check is 10 min so min and max durations for a tx being mempool are about 15 min and 25 min respectively.

5 Likes