-
Notifications
You must be signed in to change notification settings - Fork 9
multi: implement missing vtxo db persistence, add refresh route via wallet #93
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cd7a0d2
round+vtxo: use *schnorr.Signature for forfeit signatures
Roasbeef 949c6a0
db: add VTXO lifecycle status schema and queries
Roasbeef b4572a1
db: implement VTXOPersistenceStore for lifecycle tracking
Roasbeef b9cd58c
wallet: add RefreshVTXOsRequest/Response messages
Roasbeef e2ac35c
wallet: add refresh request handler
Roasbeef 3dcc75f
round: use RoundID type in SubmitVTXOForfeitSigsToServer
Roasbeef 4d107bd
round+vtxo: add TriggerRefreshEvent for manual VTXO refresh
Roasbeef 4e3784f
actormsg: add TriggerVTXORefreshMsg for wallet-to-round refresh
Roasbeef 08b1318
round: handle wallet-initiated VTXO refresh via actor system
Roasbeef 639531e
round+vtxo: build VTXORequest for refresh, add debug logging
Roasbeef 117022e
round: fix linter issues
Roasbeef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| -- VTXO status and lifecycle queries. | ||
| -- These queries support the vtxo.VTXOStore interface for VTXO lifecycle | ||
| -- management, including status transitions and forfeit transaction tracking. | ||
|
|
||
| -- name: ListVTXOsByStatus :many | ||
| -- ListVTXOsByStatus returns all VTXOs with the specified status. | ||
| SELECT * FROM vtxos | ||
| WHERE status = $1 | ||
| ORDER BY creation_time DESC; | ||
|
|
||
| -- name: ListLiveVTXOs :many | ||
| -- ListLiveVTXOs returns all VTXOs that are not in a terminal state. | ||
| -- Terminal states are: Forfeited (3), Spent (4), Expiring (5), Failed (6). | ||
| -- This is used during startup to recover active VTXO actors. | ||
| -- Also filter on spent = FALSE to handle VTXOs marked spent via the legacy | ||
| -- flag before the status field was introduced. | ||
| SELECT * FROM vtxos | ||
| WHERE status < 3 AND spent = FALSE | ||
| ORDER BY creation_time DESC; | ||
|
|
||
| -- name: UpdateVTXOStatus :exec | ||
| -- UpdateVTXOStatus atomically updates a VTXO's status. This is the primary | ||
| -- method for state transitions that don't require additional data. | ||
| UPDATE vtxos | ||
| SET status = $3, last_update_time = $4 | ||
| WHERE outpoint_hash = $1 AND outpoint_index = $2; | ||
|
|
||
| -- name: MarkVTXOForfeiting :exec | ||
| -- MarkVTXOForfeiting transitions a VTXO to Forfeiting status and persists | ||
| -- the forfeit round ID and transaction for crash recovery. Called when | ||
| -- entering the forfeit flow. | ||
| UPDATE vtxos | ||
| SET status = 2, -- Forfeiting | ||
| forfeit_round_id = $3, | ||
| forfeit_tx = $4, | ||
| last_update_time = $5 | ||
| WHERE outpoint_hash = $1 AND outpoint_index = $2; | ||
|
|
||
| -- name: GetVTXOForfeitTx :one | ||
| -- GetVTXOForfeitTx retrieves the persisted forfeit transaction for a VTXO. | ||
| -- Used during recovery to restore the ForfeitingState with its tx. | ||
| SELECT forfeit_tx, forfeit_round_id FROM vtxos | ||
| WHERE outpoint_hash = $1 AND outpoint_index = $2; | ||
|
|
||
| -- name: MarkVTXOForfeited :exec | ||
| -- MarkVTXOForfeited marks a VTXO as forfeited and records the forfeit | ||
| -- transaction ID and replacement VTXO outpoint. Called when the new round's | ||
| -- commitment transaction confirms. | ||
| UPDATE vtxos | ||
| SET status = 3, -- Forfeited | ||
| forfeit_txid = $3, | ||
| replaced_by_hash = $4, | ||
| replaced_by_index = $5, | ||
| last_update_time = $6 | ||
| WHERE outpoint_hash = $1 AND outpoint_index = $2; | ||
|
|
||
| -- name: DeleteVTXO :exec | ||
| -- DeleteVTXO removes a VTXO from storage. Used for cleanup after terminal | ||
| -- states are reached and the VTXO is no longer needed. | ||
| DELETE FROM vtxos | ||
| WHERE outpoint_hash = $1 AND outpoint_index = $2; | ||
|
|
||
| -- name: GetVTXOReplacement :one | ||
| -- GetVTXOReplacement retrieves the replacement VTXO outpoint for a forfeited | ||
| -- VTXO. Returns NULL if not forfeited or no replacement recorded. | ||
| SELECT replaced_by_hash, replaced_by_index FROM vtxos | ||
| WHERE outpoint_hash = $1 AND outpoint_index = $2; | ||
|
|
||
| -- name: CountVTXOsByStatus :one | ||
| -- CountVTXOsByStatus returns the count of VTXOs with the specified status. | ||
| SELECT COUNT(*) FROM vtxos WHERE status = $1; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new
vtxoscolumns are introduced by editing migration 000003, but existing deployments that already ran 000003 will not re-run it, so their schema will still lackstatus/forfeit_* fields. All the new queries (e.g.,ListLiveVTXOs,UpdateVTXOStatus) referencestatusand will start failing at runtime after upgrade. Please add a new forward migration (ALTER TABLE + backfill spent→status) instead of modifying a historical migration.Useful? React with 👍 / 👎.