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

[preparation 1/2]: refactor to simplify send logic, prepare for new RPCs #799

Merged
merged 13 commits into from
Feb 21, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented Feb 13, 2024

This is a preparatory PR that does some of the refactoring required for #787. We also add two new fields to the vPSBT outputs: ProofSuffix and ProofDeliveryAddress which will be required to ship this missing information between different participants in a fully RPC driven send.

@dstadulis dstadulis mentioned this pull request Feb 13, 2024
@guggero guggero changed the title [preparation]: refactor to simplify send logic, prepare for new RPCs [preparation 1/2]: refactor to simplify send logic, prepare for new RPCs Feb 19, 2024
@guggero guggero force-pushed the prepare-refactor branch 2 times, most recently from 911ca66 to 89a88f5 Compare February 19, 2024 18:02
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🦄

tappsbt/testdata/psbt_encoding_generated.json Outdated Show resolved Hide resolved
tapfreighter/parcel.go Show resolved Hide resolved
tappsbt/testdata/psbt_encoding_generated.json Show resolved Hide resolved
We have the following weird package dependency chain:
proof -> vm -> tapscript -> tappsbt

This makes things weird and cumbersome. The only parts in tapscript that
actually use the tappsbt stuff is send related.
So to break that dependency chain between the vm and tappsbt, we split
off all the send functionality into a new tapsend package.
We don't want to have a dependency from the proof package to the tappsbt
package as that makes it impossible for us to have a proof within a
virtual package. To resolve that potential circular dependency, we split
the code of the ownership proving code into two pieces.
Now that we've resolved the circular package dependency between the
proof and tappsbt packages, we can finally use the *proof.Proof type
directly for the packet's input proof (and later the output's proof
suffix).
We rename the variable to match the naming style of the other ones.
When interactively signing a transfer that goes to a TAP address, the
participants might want to be able to check the proof courier delivery
URL that will be used to transfer the proof.
This information currently gets lost when converting a TAP address into
a vPSBT and is transported in a different data structure inside of the
freighter. For a flow that doesn't use the freighter (or just in the
very end), there currently is no way to specify the proof courier
address, which this commit now changes.
A follow-up commit will refactor the freighter to use this new field.
We need a way to transport proofs that are complete in terms of MS-SMT
proofs committing to the correct asset but incomplete in terms of the
asset witness (in the ASSET_VERSION_V1 case).
The virtual transaction output is as good a place as any other. This
will also allow us to simplify some of the data structures around
passive assets, as currently we need to carry those proofs around in a
separate map.
In order to be able to pass the dummy outputs to the lnd FundPsbt call
we need to make them look more like actual P2TR outputs.
We'll want to create proof suffixes outside of the chain porter, so we
export the function and make it more generic so it can work with any
number of related virtual transactions.
Since we now have a field to store the proof courier delivery address
URL in within the VOutput, we no longer need to carry along extra state
in the freighter.
This commit refactors the freighter in that we use the VPacket struct
directly for the passive assets. We now have all information available
directly in that struct and no longer need another wrapper.
With that looking more similar to other code, we can then also re-use
the updateAssetProofFile method which gets rid of some duplicated code.
@dstadulis dstadulis added this to the v0.4 milestone Feb 20, 2024
Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM + tACK ⚡

@guggero guggero added this pull request to the merge queue Feb 21, 2024
Merged via the queue into main with commit d37b486 Feb 21, 2024
14 checks passed
@guggero guggero deleted the prepare-refactor branch February 21, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants