-
Notifications
You must be signed in to change notification settings - Fork 137
tapgarden: implement SealBatch #866
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
Conversation
3f53f04 to
a6fc23f
Compare
c2e1cfd to
42b7bde
Compare
a6fc23f to
c922d04
Compare
|
Have an external group witness working now in unit tests. Still looking at ways to prevent Right now IIUC we don't explicitly reject new seedling requests after a batch is frozen, so one option is to just freeze the batch at the end of |
42b7bde to
132a2d0
Compare
c922d04 to
cf332e1
Compare
cf332e1 to
78baa21
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.
Looks pretty good to me! Looking forward to seeing it in action with an itest 🎉
Main request is to potentially remove some code duplication by moving some of the complexity of the seedlings further down, instead of having two almost identical batch structs.
1f28703 to
434b33a
Compare
|
Looks like a possible new flake in custodian event handling? --- FAIL: TestTransactionConfirmedOnly (123.22s)
test_postgres.go:11: Creating new Postgres DB for testing
custodian_test.go:220:
Error Trace: /home/runner/work/taproot-assets/taproot-assets/tapgarden/custodian_test.go:220
/home/runner/work/taproot-assets/taproot-assets/tapgarden/custodian_test.go:740
/home/runner/work/taproot-assets/taproot-assets/tapgarden/custodian_test.go:669
Error: Received unexpected error:
method did not return within the timeout
Test: TestTransactionConfirmedOnly
FAIL
FAIL github.com/lightninglabs/taproot-assets/tapgarden 156.362s
FAIL |
3909a99 to
67ade9f
Compare
|
Posted some updates, mostly fixes where the group tapscript root wasn't being propogated correctly. Also some changes in the Still working out some marshalling issues when generating group witnesses. |
67ade9f to
761212d
Compare
|
Posted my latest state. The issue with the version of the test I was working on before was internal keys not derived from the backing tapd node. Example for derivation here:
The posted version generates a sig for a siglock external to the planter, but I could not get a similar witness working if that key was derived from the backing lnd node, for both the Taproot Assets key family, or a random key family. I'm at the last steps of the PSBT flow, which is very similar to the multisig test. |
fb3ce36 to
00530e2
Compare
|
Remaining tasks:
There's a path toward external key support in the itest via some changes in |
|
I have a branch that resolves #883 , but the better fix for that would be switching to From offline discussion, I think for this PR we'll continue to accept a non-local group internal key without any constraints on the |
00530e2 to
0dd4dd0
Compare
69b4b7e to
c74bf0b
Compare
|
CLI commands are added, but they omit the fields with non-trivial formatting like |
|
@GeorgeTsagk: review reminder |
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! tACK, LGTM 🎉
Mostly nits and nice-to-haves.
cmd/tapcli/assets.go
Outdated
| var sealBatchCommand = cli.Command{ | ||
| Name: "seal", | ||
| Usage: "seal a batch", | ||
| Description: "Attempt to seal the pending batch.", |
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.
Does this command really do anything on the command line other than sanity check that we can generate witnesses for all group keys in the batch? Not sure if we should hide (Hidden: true) the command and only keep it for debugging? Since it probably doesn't make sense to support submitting the actual witnesses through the CLI (only makes sense through RPC).
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.
Hmm, yeh seems odd given that it doesn't have any acutal args in the proto.
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.
Yeah I agree it doesn't have much use...
I suppose we want to still expose fund as we'll add other features to that 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.
Update: added more to the descriptions and hid this cmd. In practice you could do fund + finalize from the CLI if we don't accept witness in seal.
| // also want to reissue assets with a custom asset group witness, and spend | ||
| // an asset with a custom script key witness. An asset group with a tapscript | ||
| // root should also be imported into a new node correctly. | ||
| func testMintFundSealAssets(t *harnessTest) { |
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.
Great itest, but I think it would be easier to follow if some of the sub-components were split down into helper functions. So eg:
- Making the tapscript root for the group key.
- Making the root for the funding output tapscript leaf.
- Signing on both levels,
- The multi-sig sign and transfer at the end,
etc
cmd/tapcli/assets.go
Outdated
| var sealBatchCommand = cli.Command{ | ||
| Name: "seal", | ||
| Usage: "seal a batch", | ||
| Description: "Attempt to seal the pending batch.", |
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.
Hmm, yeh seems odd given that it doesn't have any acutal args in the proto.
|
|
||
| func (r *rpcServer) SealBatch(ctx context.Context, | ||
| req *mintrpc.SealBatchRequest) (*mintrpc.SealBatchResponse, error) { | ||
|
|
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.
Shouldn't this require that group witnesses re provided? Otherwise, how can you seal a batch w/o providing the witness?
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.
The check for all assets that need a witness, having a witness, is in the planter:
taproot-assets/tapgarden/planter.go
Line 1360 in 4b15443
| switch { |
For all assets without an external witness, we try to derive the default witness. If we are unable to, DeriveGroupKey fails and no groups would be saved to disk.
So this call would fail if at least one external witness is needed. From the RPC layer, we can't really know if any external witnesses are needed.
In this commit, we add a verbosity flag to ListBatches, which will show the group key request and virtual TX needed for a user to produce an asset group witness for a grouped seedling.
In this commit, we add an itest to exercise the FundBatch and SealBatch RPCs. Specifically, we use asset script and group internal keys derived outside of tapd, pass asset group witnesses via SealBatch, and use a tweaked asset script key set during minting to complete an asset transfer. We also use a tapscript sibling set during minting to provide a script witness for anchoring an asset transfer.
|
Updated to address all comments, itest should be more readable now + other small fixes. |
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 🍵
Addresses #722. Depends on #827.
Remaining TODOs:
tapdb/asset_mintingtests to cover new query params for script key, group key, etc.tapdb/asset_minting/CommitBatchTx,AddSeedlingGroups,FetchSeedlingGroups