-
Notifications
You must be signed in to change notification settings - Fork 123
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
Store transfer output proof delivery status #1035
Store transfer output proof delivery status #1035
Conversation
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.
Looks good overall!
AFAICT this is missing the reordering of when proof delivery occurs mentioned here:
Is that intended for a follow-up PR?
@jharveyb Thanks for the review. Yes, will definitely get done. I was thinking in a follow up PR. |
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.
Nice approach!
Makes sense to me but I think the current implementation on the SQL level is a bit brittle and will likely lead to issues down the line.
Added a suggestion in there that should solve it in a nice way (and with probably a smaller diff too).
tapdb/sqlc/migrations/000022_transfer_outputs_proof_delivered.down.sql
Outdated
Show resolved
Hide resolved
f11dc88
to
696261d
Compare
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.
Very happy with the SQL part, should make things more reliable.
Almost there on the rest!
tapdb/sqlc/migrations/000022_transfer_outputs_proof_delivered.down.sql
Outdated
Show resolved
Hide resolved
Add the `proof_delivery_complete` and `position` columns to the `asset_transfer_outputs` table. The `position` column indicates the position of the output in the transfer output list. The position and anchor outpoint uniquely identify a transfer output. This change updates the row insertion and retrieval SQL statements for this table. Additionally, new SQL statements are included for modifying these new columns.
ShouldDeliverProof returns true if a proof corresponding to the subject transfer output should be delivered to a peer.
Set and retrieve the `proof_delivery_complete` and `position` columns from the `asset_transfer_outputs` table.
Refactors the `transferReceiverProof` method in `ChainPorter` by utilizing the new `ShouldDeliverProof` method for transfer output. This change simplifies the method's implementation. Note: This refactoring is not related to the primary objectives of this series of commits.
Add a `ConfirmProofDelivery` method to the export log. This function is called after a proof has been successfully delivered to a remote peer.
This commit introduces a unit test for the `SetTransferOutputProofDeliveryStatus` functionality to ensure proof delivery confirmation.
696261d
to
25f0aba
Compare
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.
Very nice, LGTM 🚀
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.
Looks good overall! The newer version is definitely a smaller / simpler diff. Just one note on the position type itself.
|
||
// Check if position value can be stored in a 32-bit integer. Type cast | ||
// if possible, otherwise return an error. | ||
if output.Position > math.MaxInt32 { |
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.
See note elsewhere re: switching to int64
.
ADD COLUMN proof_delivery_complete BOOL; | ||
|
||
-- Add column `position` which indicates the index of the output in the list of | ||
-- outputs for a given transfer. This index position in conjunction with the |
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.
Couldn't we just use the existing primary key for this?
|
||
// If this is an output that is going to our own node/wallet, we don't | ||
// need to deliver a proof. | ||
if out.ScriptKey.TweakedScriptKey != nil && out.ScriptKeyLocal { |
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.
We should double check this with some of the litd itests we have for channels. At times, we verify that a proof was uploaded even if it was a local script key.
|
||
// If the script key is a burn key, we don't need to deliver a proof. | ||
if len(out.WitnessData) > 0 && asset.IsBurnKey( | ||
out.ScriptKey.PubKey, out.WitnessData[0], |
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.
Aren't burns still relevant? So to proof to someone that you've burnt an asset.
|
||
// Burns are also always kept local and not sent to any | ||
// receiver. | ||
if len(out.WitnessData) > 0 && asset.IsBurnKey( |
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.
Ah I see this was also just existing behavior, feel free to ignore those other comments.
Summary
This PR is work towards fixing #1009 (making the proof transfer process more robust).
This pull request adds a new
proof_deliver_complete
column to theasset_transfer_outputs
table. It includes updates to the table schema, modifications to SQL statements, and adjustments to unit tests. Additionally, it integrates changes to thetapfreighter
component for logging proof delivery confirmations.Changes
Schema Update:
proof_deliver_complete
column to theasset_transfer_outputs
table.SQL Statement Modifications:
proof_deliver_complete
column.proof_deliver_complete
column.Field Population:
proof_deliver_complete
field for new transfer output rows.proof_deliver_complete
field is populated when reading from the database.Proof Delivery Logging:
ConfirmProofDelivery
method to thetapfreighter
export log.ConfirmProofDelivery
function is called after a proof has been successfully delivered to a remote peer.Unit Test Adjustment: