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

Upgrade trader accounts to Taproot/MuSig2 #375

Merged
merged 18 commits into from
Sep 12, 2022
Merged

Conversation

guggero
Copy link
Member

@guggero guggero commented Jun 16, 2022

Depends on #370.

Pull Request Checklist

  • LndServices minimum version has been updated if new lnd apis/fields are
    used.

@guggero guggero requested a review from positiveblue June 17, 2022 10:01
Copy link
Contributor

@positiveblue positiveblue left a comment

Choose a reason for hiding this comment

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

First pass done, this looks really good @guggero 👏

poolscript/script.go Show resolved Hide resolved
account/interfaces.go Show resolved Hide resolved
account/manager.go Outdated Show resolved Hide resolved
account/manager.go Outdated Show resolved Hide resolved
server.go Show resolved Hide resolved
rpcserver.go Show resolved Hide resolved
@guggero guggero force-pushed the trader-account-taproot branch 3 times, most recently from dfe03c1 to cb22c9d Compare July 1, 2022 19:11
@guggero
Copy link
Member Author

guggero commented Jul 1, 2022

I addressed all comments and got almost all itests working on the server side.
This is now officially not WIP anymore 🎉

@guggero guggero marked this pull request as ready for review July 1, 2022 19:13
@guggero guggero requested a review from Roasbeef July 1, 2022 19:13
@positiveblue positiveblue self-requested a review July 4, 2022 03:00
@guggero guggero force-pushed the trader-account-taproot branch 2 times, most recently from 68374a5 to 76acc47 Compare July 5, 2022 20:03
@dstadulis dstadulis added the taro Taro Readiness label Jul 25, 2022
@lightninglabs-deploy
Copy link
Collaborator

@positiveblue: review reminder

Copy link
Contributor

@positiveblue positiveblue left a comment

Choose a reason for hiding this comment

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

LGTM 🌮

There is a small comment about how we are storing the new field but nothing blocking.

I would add the version field in multiple rpc calls, like ListAccounts. Also it could be useful to add it to the terminal confirmation message before creating an account. However, I can add those two things later 👍

clientdb/account.go Show resolved Hide resolved
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.

Amazing PR!!

Love how we're able to handle all the upgrade logic behind the scenes, hidden away from the user. This change will also make it even cheaper (on chain) to buy/sell leases as well, since the account witness is much smaller.

Completed an initial pass, with the most major comments being some wanted fuzzing/testing of the new witness parsing logic as well as all the new scripts added for taproot.

clientdb/account.go Outdated Show resolved Hide resolved
clientdb/account.go Show resolved Hide resolved
clientdb/account.go Show resolved Hide resolved
poolscript/log.go Show resolved Hide resolved
poolscript/script.go Outdated Show resolved Hide resolved
account/manager.go Show resolved Hide resolved
account/manager.go Show resolved Hide resolved
order/batch.go Show resolved Hide resolved
order/batch_storer.go Show resolved Hide resolved
order/batch.go Outdated Show resolved Hide resolved
@guggero guggero force-pushed the trader-account-taproot branch 6 times, most recently from dccf0a0 to 007610d Compare July 29, 2022 14:04
@guggero
Copy link
Member Author

guggero commented Jul 29, 2022

I addressed all comments except for the additional unit tests. I agree they should be added, but I'm going to work on them next week.

@dstadulis
Copy link
Contributor

dstadulis commented Aug 2, 2022

might need to extend unit test frame work

@guggero guggero force-pushed the trader-account-taproot branch 4 times, most recently from 07acb3d to 543f17d Compare August 3, 2022 15:31
@guggero guggero requested a review from Roasbeef August 3, 2022 16:10
@guggero
Copy link
Member Author

guggero commented Aug 3, 2022

I added a set of unit tests for the new spend paths. And I also ran the fuzzer locally for almost 2 hours and didn't find anything so far.

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 🐞

poolscript/script_test.go Show resolved Hide resolved
@positiveblue positiveblue force-pushed the trader-account-taproot branch 2 times, most recently from 665aeca to be2b1a8 Compare August 23, 2022 07:15
@guggero guggero force-pushed the trader-account-taproot branch from be2b1a8 to 0f37262 Compare August 23, 2022 11:54
@dstadulis
Copy link
Contributor

⚠️ PR will need to go back to sprint as changes have been made to MuSig2 spec regarding x-only keys

Deliverable outcome:

  • Modify the implemented MuSig2 spec to incoporate recent changes which will promote ISP

@guggero
Copy link
Member Author

guggero commented Aug 29, 2022

warning PR will need to go back to sprint as changes have been made to MuSig2 spec regarding x-only keys

Deliverable outcome:

* [ ]  Modify the implemented MuSig2 spec to incoporate recent changes which will promote ISP

Are we sure we want to wait for that? Updating to the latest spec means:

  • Implement new API in btcd, merge.
  • Implement changes to MuSig2 API in lnd, merge, release
  • Use new API in Pool.

I think it would make more sense to instead add a version parameter to the MuSig2 API when we implement this, so we can upgrade later.

@Roasbeef
Copy link
Member

Roasbeef commented Aug 29, 2022

PR will need to go back to sprint as changes have been made to MuSig2 spec regarding x-only keys

No, it can proceed as defined. As mentioned, those changes themselves are still in a draft state, with no other implementations currently tracking the change (other than the python ref implementation used to generate the test vectors). Correctness is still retained without the changes. It would matter more in a p2p setting as you need cross implementation compatibility.

Ofc, we could delay things, but then what if we hit another change in serialization somewhere that is "better" but doesn't affect correctness. Would we then do the same and pause to target the newer change? The tradeoff of being one of the first in the ecosystem to utilize these new features is that we sort of need to commit to having the proper versioning to handle future updates.

@Roasbeef
Copy link
Member

@guggero agreed, iiuc we already have the versioning in the proper places as well. An account version is the most apt, since the serialization changes will change the actual aggregate key, so making the jump a future version would be an actual account version bump.

@dstadulis
Copy link
Contributor

Agree that versioning should be incorporated here to facilitate it being upgraded. Appears there was some misinterpretation about the code etc constrained/delayed by MuSig2 spec, which won't be the plan.

guggero and others added 18 commits September 12, 2022 17:20
With this commit we streamline the signing code somewhat to make it
easier to understand. With the new flow the spendPkg struct is no longer
needed as we directly pass back the (partially) signed TX.
During the integration tests we might want to shut down a trader client
through the admin RPC. If that closes the shutdown channel on a package
global interceptor, that means we can't start another trader client
during that test. We need to make sure we can pass in an interceptor for
each trader instance.
The `.UnsignedTx` of a psbt does not include the related
SignatureScripts. Because SignatureScripts are not part of the signed
data, the partial signature for a psbt that does not include them is a
valid signature. However, the `TxHash` will change between a tx that has
SignatureScripts set and one that does not.

This behaviour led the auctioneer and the client to record the wrong
outpoint when using np2wkh.
@guggero guggero force-pushed the trader-account-taproot branch from e333a17 to a1dab84 Compare September 12, 2022 15:20
@guggero guggero merged commit a12246c into master Sep 12, 2022
@guggero guggero deleted the trader-account-taproot branch September 12, 2022 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
taro Taro Readiness
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants