Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate rocksdb to persist btc payments #246

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

gregdhill
Copy link
Member

@gregdhill gregdhill commented Mar 8, 2022

Signed-off-by: Gregory Hill [email protected]

My reasoning is that we cannot trust that the BTC payment for a parachain request will definitely be in the mempool - if not already included in a block. We could use the listtransactions Bitcoin RPC to check what transactions our node has made but it is far easier to maintain a simple KV lookup for request ID to TxId.

TODO

  • Lock transaction on fetch from store
  • Migrate existing payments for backwards compatibility
  • Re-register change addresses at startup

@sander2
Copy link
Member

sander2 commented Mar 8, 2022

My reasoning is that we cannot trust that the BTC payment for a parachain request will definitely be in the mempool

I am not sure this is true, if we use the transaction creation mutex correctly.

Anyway, my main problem with this approach is atomicity - sending the transaction and writing to the database needs to be one atomic action, which it is not. If the program stops executing after submitting the transaction but before the database write, you will end up making the transaction again at startup.

@sander2
Copy link
Member

sander2 commented Mar 9, 2022

As discussed, the way forward here is probably to store the raw transaction in the database prior to sending them out. Then at startup, you can just resend any transactions still in the database.

With this approach we do need to be careful with our transaction creation mutex. If there is a raw transaction in the database at startup, we must send them to the bitcoin chain prior to creating new transactions, since otherwise bitcoin core can try to spend the same uxto twice.

@gregdhill gregdhill marked this pull request as ready for review May 11, 2022 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants