-
Notifications
You must be signed in to change notification settings - Fork 122
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
tapgarden: tapscript tree support for minting anchor outputs #768
Conversation
itests are panicking as the DB-backed implementation of |
Next milestone for the PR: We will try to split up the PR. if the itest test be modified to be independent to the DB changes, PR would be possible to be split. |
026d404
to
77cf410
Compare
Proof generation during minting now includes the tapscript sibling, and this includes the fixes for tapscript preimage verification. The DB implementation will be a follow-on 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 work! This helps us cover the ability to use custom tapscript trees at the top-level Bitcoin output. Spotted a few areas we can use some new types to avoid nil
pointer checks when we want an arg to actually be optional w/o relying on any specific pointer semantics.
I think to round out this PR, we'll want to make a concrete implementation for the new tree store in the DB. We can denormalize a bit by having a table that refs an internal key and then build out the tree storage in another table to be ref'd as a foreign key. This'll let us de-dup a bit, as we can have the tree storage primary key be the root hash.
Then we can add an itest to ensure that we can spend from the output using normal keypend. From there we can opt to push out the final component of accepting a valid witness somehow (send call that uses a PSBT?) so we can make further progess on the group key component.
commitment/taproot.go
Outdated
// Enforce that it is not including another Taproot Asset commitment. | ||
if bytes.Contains(preimage, TaprootAssetsMarker[:]) { | ||
// Verify that the script is not including a Taproot Asset commitment. | ||
if IsTaprootAssetCommitmentScript(script) { |
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.
I think ok as is if we want to keep the exiting control flow, but in the future I'd like to re-work the control flow to assert all the preconditions up front, then have this just be a dumb method that computes the tap leaf hash.
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.
agree.. Dumb method "TapLeafHash" and smart method which checks whatever validity constraints on the leaf
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.
Went with always enforcing these checks before computing the TapHash, as sometimes we're initializing TapscriptPreimage
from a decoded Proof vs. using a safe constructor.
Expanding this PR to include the DB implementation and a itest that will cover a key-spend & script spend of the minting output. |
2f06c7c
to
fb4df87
Compare
268dd37
to
7b130ff
Compare
Latest push adds a DB implementation of Remaining TODOs, in descending priority order:
|
f17b2d7
to
cbac1e1
Compare
Rebased + test issues are resolved, ready for final review. |
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.
Awesome, LGTM 🎉
In this commit, we introduce the TapscriptTreeManager. This interface stores a tapscript tree associated with a root hash, which could be a stored alongside a batch key, asset script key, or group key.
This commit adds three new tables that enable us to store tapscript trees, with deduplication of tapscript leaves. A tree can also be stored as two TapHashes representing a TapBranch, allowing for externally managed tapscript trees. These tables are not intended to be modified with the basic queries added in this commit, but wrapper functions in the next commit.
In this commit, we expose helpers to upsert and delete tapscript trees. These are used to add support for tapscript trees during minting.
In this commit, we remove an overly strict version check when asserting that a Tapscript script is not a Taproot Asset Commitment. All versions, including unknown future versions, should be rejected in this context.
In this commit, we update how tapscript preimages are validated before use. We define safe constructors for tapscript preimages, and require their use by making the raw preimage bytes private. We also add checks when decoding a preimage to further prevent improper construction.
cbac1e1
to
35c8156
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.
LGTM 🦖
Fixes #343.
Adding support for a batch key tapscript sibling first (BTC anchor-level), which would be supplied during the
Finalize
call for the batch. This should be a smaller change than per-asset support, while still using similar interfaces and DB changes.TODOs:
I think given the related DB changes the per-asset sibling support should be in this PR (adding further TODOs) vs. a separate PR, but that may cause some commit reordering later on.
This change is