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

[Feature]: Write bitcoin block data in a SQL transaction #1194

Open
1 task
djordon opened this issue Jan 9, 2025 · 0 comments
Open
1 task

[Feature]: Write bitcoin block data in a SQL transaction #1194

djordon opened this issue Jan 9, 2025 · 0 comments
Labels
sbtc signer binary The sBTC Bootstrap Signer.

Comments

@djordon
Copy link
Contributor

djordon commented Jan 9, 2025

Feature - Write bitcoin block data in a SQL transaction

1. Description

We want to make sure that when we write bitcoin block data, either all of it gets written or none of it.

1.1 Context & Purpose

In the event of an error during processing of a bitcoin block, bailing leaves the database in a clean state and reprocessing can happen cleanly. So connectivity issues with bitcoin core or other temporary issues do not disturb the proper processing of the bitcoin block and the transactions within.

2. Technical Details:

This one has been known for some time, but it is quite tricky to tackle because all of our queries get executed atomically. But it's actually not too bad to change.

2.1 Acceptance Criteria:

  • Processing of a bitcoin block always leaves the database in a "clean" state. So either the entire block is successfully processed or none of it is.

3. Related Issues and Pull Requests (optional):

4. Appendix

I only see one way to make this a seamless update, and that is to make the following three changes:

  1. Change the PgStore type to be an enum, with a sqlx::PgPool variant and a sqlx::Transaction variant.
  2. Add a method to PgStore that returns a &dyn sqlx::Executor or something like that.
  3. Modify some of the functions in the BlockObserver to pass in the PgStore (the sqlx::Transaction variant) when writing to the database.
@djordon djordon added the sbtc signer binary The sBTC Bootstrap Signer. label Jan 9, 2025
@djordon djordon added this to the sBTC: Key rotation milestone Jan 9, 2025
@djordon djordon added this to sBTC Jan 9, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in sBTC Jan 9, 2025
@djordon djordon moved this from Needs Triage to Todo in sBTC Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sbtc signer binary The sBTC Bootstrap Signer.
Projects
Status: Todo
Development

No branches or pull requests

1 participant