-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
watchtower: support taproot channel commitments #7733
watchtower: support taproot channel commitments #7733
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.
Concept ACK
e83d218
to
9dfbdfd
Compare
3540cb0
to
ebef7dc
Compare
ea83003
to
af36303
Compare
e885b37
to
128fec5
Compare
128fec5
to
dab0404
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.
Nice work! Dig the prepatory refactors to smooth out the integration of this channel type to the tower, as well as others.
No major comments, but still need to get more up to speed with the latest state of the codebase, as has been a while since I've reviewed anything here.
One thing I think we'll want to do to is have any instances of a new taproot
blob or commitment type instead be taprootStaging
. That final script change may not actually go through, but we should make sure to hedge things out a bit.
// In case of a taproot output any signature is always a Schnorr | ||
// signature, based on the new tapscript sighash algorithm. | ||
if txscript.IsPayToTaproot(signDesc.Output.PkScript) { | ||
sigHashes := txscript.NewTxSigHashes( |
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've copied this over in a few places in the codebase, perhaps we can try to unify with an internal/mock
package?
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.
do you mean the entire mock signer? dont think we can do that since it would cause an import package between input
and internal/mock
.
I guess another option is just to extend input.MockSigner
so that we can re-use it here?
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.
Ahh true re import cycle, I think I ran into the same thing when adding musig2 awareness in the first place...
Perhaps we can just make a new issue here to attempt to conslidate the mock signers in a single place. We don't update it all that often, but it can def burn some dev time when something small changes, and one mock signer works, but not the other.
dab0404
to
f34a718
Compare
f34a718
to
04c245c
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 🐟
Reviewable status: 0 of 33 files reviewed, 24 unresolved discussions (waiting on @ellemouton and @yyforyongyu)
watchtower/wtpolicy/policy.go
line 127 at r4 (raw file):
// FeatureBits returns the watchtower feature bits required for the given // policy. func (p *Policy) FeatureBits() []lnwire.FeatureBit {
👍
@yyforyongyu: 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 🎉 Left a few nits and questions, my main comment is there seems to be some test cases that won't be hit because how we check channel types.
@@ -400,3 +415,222 @@ func (b *justiceKitPacketV0) decode(r io.Reader) error { | |||
|
|||
return nil | |||
} | |||
|
|||
// justiceKitPacketV1 is lé Blob of Justice for taproot channels. |
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.
what is lé
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.
it's a fancy-shamnsy way of saying "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.
left this in cause that's the original way that Connor wrote it and I thought it was funny :) but it's already in the interface comment so will remove it here 😉
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.
lol TIL
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.
my two sats here: "le" is the French masculine word for "the". But because just "le" doesn't look very French, I assume the acute accent was added (and I believe all of this is from Sponge Bob if I'm not mistaken).
watchtower/blob/justice_kit.go
Outdated
// JusticeKit interface. | ||
var _ JusticeKit = (*taprootJusticeKit)(nil) | ||
|
||
// newTaprootJusticeKit constructs a new anchorJusticeKit. |
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.
// newTaprootJusticeKit constructs a new anchorJusticeKit. | |
// newTaprootJusticeKit constructs a new taprootJusticeKit. |
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.
oops!
watchtower/wtpolicy/policy.go
Outdated
@@ -114,26 +116,44 @@ type Policy struct { | |||
} | |||
|
|||
// String returns a human-readable description of the current policy. | |||
func (p Policy) String() string { | |||
func (p *Policy) String() string { |
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.
why this change?
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.
was just to make my IDE happy 😝 in general seems to be better to have pointer receivers to avoid some unexpected behaviour
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.
turns out this actually does need to stay like this or else the log line doesnt print properly 🙃 so changed it back
// IsAnchorChannel returns true if the session policy requires anchor channels. | ||
func (p Policy) IsAnchorChannel() bool { | ||
func (p *Policy) IsAnchorChannel() bool { |
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.
wondering whether we should restrict the method IsAnchorChannel
, and all its occurrence, to only return true if this channel is anchor type, and not taproot type - should help to avoid misusing as we now have to always keep in mind to check IsTaproot
first before check IsAnchor
in a switch statement, maybe we should do this on ChannelType
- future PRs tho.
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.
so for this instance (ie, in towers alone) it does actually just mean anchors. So this will return false for a taproot blob type.
but agreed that the we should make this the standard everywhere :)
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.
so for this instance (ie, in towers alone) it does actually just mean anchors. So this will return false for a taproot blob type.
Yeah I do notice that the feature bit is 101
and 11
, tho not sure about how to properly define a feature bit, as it seems that technically if anchor is a feature, then taproot chan should be 111
since it has this feature - unknown implications here, but I prefer the end result here as we can clearly distinguish the two channels. Meanwhile this shouldn't be an issue for feature negotiation since both are lnd
? I think if both sides understand and use the same defined feature bits we are fine, eg, they won't send us a 111
.
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 guess it's slightly different in this tower protocol cause the tower only cares about commit types as a whole since this completely changes the justice kit etc.
Meanwhile this shouldn't be an issue for feature negotiation since both are lnd?
yeah - currently the code for this is the spec. So this is fine for 2 lnd nodes, yeah 👍
Factor out the building of the delay and revoke scripts from NewLocalCommitScriptTree so that they can be re-used later on.
This commit adds a new FlagTaprootChannel Flag which is then used to construct a new blob Type: TypeAltruistTaprootCommit. New watchtower feature bits are also added (4/5).
In preparation for the new Taproot commitment type being supported by watchtowers, we add a new justice packet type.
04c245c
to
9f45c4b
Compare
Important Auto Review SkippedAuto reviews are limited to the following labels: llm-review. Please add one of these labels to enable auto reviews. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Thanks @yyforyongyu!! 🚀
Updated!
@@ -400,3 +415,222 @@ func (b *justiceKitPacketV0) decode(r io.Reader) error { | |||
|
|||
return nil | |||
} | |||
|
|||
// justiceKitPacketV1 is lé Blob of Justice for taproot channels. |
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.
it's a fancy-shamnsy way of saying "the" 😂
@@ -400,3 +415,222 @@ func (b *justiceKitPacketV0) decode(r io.Reader) error { | |||
|
|||
return nil | |||
} | |||
|
|||
// justiceKitPacketV1 is lé Blob of Justice for taproot channels. |
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.
left this in cause that's the original way that Connor wrote it and I thought it was funny :) but it's already in the interface comment so will remove it here 😉
watchtower/blob/justice_kit.go
Outdated
// JusticeKit interface. | ||
var _ JusticeKit = (*taprootJusticeKit)(nil) | ||
|
||
// newTaprootJusticeKit constructs a new anchorJusticeKit. |
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.
oops!
watchtower/wtpolicy/policy.go
Outdated
@@ -114,26 +116,44 @@ type Policy struct { | |||
} | |||
|
|||
// String returns a human-readable description of the current policy. | |||
func (p Policy) String() string { | |||
func (p *Policy) String() string { |
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.
was just to make my IDE happy 😝 in general seems to be better to have pointer receivers to avoid some unexpected behaviour
// IsAnchorChannel returns true if the session policy requires anchor channels. | ||
func (p Policy) IsAnchorChannel() bool { | ||
func (p *Policy) IsAnchorChannel() bool { |
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.
so for this instance (ie, in towers alone) it does actually just mean anchors. So this will return false for a taproot blob type.
but agreed that the we should make this the standard everywhere :)
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! Welcome towers to the taproot gang 😎
// IsAnchorChannel returns true if the session policy requires anchor channels. | ||
func (p Policy) IsAnchorChannel() bool { | ||
func (p *Policy) IsAnchorChannel() bool { |
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.
so for this instance (ie, in towers alone) it does actually just mean anchors. So this will return false for a taproot blob type.
Yeah I do notice that the feature bit is 101
and 11
, tho not sure about how to properly define a feature bit, as it seems that technically if anchor is a feature, then taproot chan should be 111
since it has this feature - unknown implications here, but I prefer the end result here as we can clearly distinguish the two channels. Meanwhile this shouldn't be an issue for feature negotiation since both are lnd
? I think if both sides understand and use the same defined feature bits we are fine, eg, they won't send us a 111
.
9f45c4b
to
2a61c91
Compare
In this PR, the watchtower server and client are updated to support backing up taproot channels.
This change is