xaya / libxayagame

MIT License
21 stars 19 forks source link

Track pending resolutions / disputes through mempool #65

Closed domob1812 closed 5 years ago

domob1812 commented 5 years ago

Currently, the ChannelManager just has flags for when a resolution or dispute move has been sent. When a new block comes in, that flag is reset, and we assume there is no pending move anymore.

This presumably works well most of the time, but it can have bad side effects. For instance, when a block containing a resolution is detached again, the ChannelManager will resend another move resolving the dispute - which may be redundant if the previous resolution is still in the mempool.

More precise logic should track the txid of sent moves (for disputes and resolutions) instead of just flags, and sync that with Xaya Core's mempool (e.g. through name_pending) when processing on-chain updates. Then there may still be some discrepancy (because of delays between Xaya Core and the GSP, for instance), but it should be much better.

domob1812 commented 5 years ago

The first step for implementing this is returning a txid from MoveSender. Then, we should replace the boolean flags in ChannelManager by the txid (or null if no pending move is there). Finally, instead of clearing the flags on ProcessOnChain, we should query name_pending and only clear the flag if the txid is not in the mempool.

domob1812 commented 5 years ago

This was mostly fixed with #78. Note that the special case described in the original post of a detached resolution is not solved, but that is something we'll likely not "fix" at all. See #78 for a discussion.