Recovering from a restart/crash where an onchain transaction is in the mempool but not yet mined #2933
Labels
Severity / Medium
State / Investigating
For issues that are currently being looked into before labeling further
Milestone
Problem Definition
We have seen many cases lately where people's nodes get a
TransactionUnderpriced
error or similar at restart. This can probably happen when we have an on-chain transaction having been sent, added to the mempool but not yet mined and then we restart or the node crashes and we restart.It does not seem that we are able to recover from this at the moment as at recovering from a restart we will process all pending transactions which will essentially re-process the pending
ContractSendXXX
event and resend the on-chain transaction leading to the nonce reuse or transaction underpriced error.Task
We need to be able to handle this scenario as with the mainnet transactions taking too long to get mined this is really easy to hit.
How can we achieve this?
We should keep the transaction hash of all in flight chain transactions somewhere. Probably either in or close to the pending transactions of the ChainState. So whenever we send a transaction to the proxy the chainstate should already have it inside the pending transactions and we can add the pending transaction hash there.
Then at restarting of the node when we process the pending
transactions we can actually get the transaction hash of each pending transaction. Then for each of them call getTransactionByHash() and if this returns
None
continue by forwarding it to the raiden event handler for processing. But if on the other hand it returns a transaction then we know that the transaction is still pending to be mined so we don't do anything.Notes:
It will take a bit of work to make the chainstate accessible from inside the proxy. Maybe a better/cleaner approach exists to achieve the same results. Open to suggestions.
Another facet of this issue can also be seen at Overwrite in-flight transactions #2801 where the same idea is taken even further by also thinking on canceling or replacing pending on-chain transactions.
The text was updated successfully, but these errors were encountered: