Skip to content

Conversation

@Roasbeef
Copy link
Member

In this commit, we update all the taproot scripts to also accept an optional aux leaf. This aux leaf can be used to add more redemption paths for advanced channels, or just as an extra commitment space. All the input/taproot_test.go have also been updated to ensure that the new slightly larger control blocks are always properly generated.

In this commit, we update all the taproot scripts to also accept an
optional aux leaf. This aux leaf can be used to add more redemption
paths for advanced channels, or just as an extra commitment space.
@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour wallet The wallet (lnwallet) which LND uses taproot labels Mar 15, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2024

Important

Auto Review Skipped

Auto 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 .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

// HTLC script tree with new spend paths, or just as extra commitment
// space. When present, this leaf will always be in the left-most or
// right-most area of the tapscript tree.
AuxLeaf fn.Option[txscript.TapLeaf]
Copy link
Collaborator

Choose a reason for hiding this comment

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

in order to be open-ended with regards to flexibility, couldn't we have multiple aux leaves here? something like fn.Slice

we could hide everything under a single AuxLeaf but I think just having multiple leaves will keep it simpler overall on the script level itself

@GeorgeTsagk GeorgeTsagk self-requested a review March 18, 2024 15:41
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Very nice, super small diff for what we get out of it. It's obvious a lot of thought already went into this while refactoring for the Simple Taproot Channels 💯

}

tapLeaves := []txscript.TapLeaf{successTapLeaf, timeoutTapLeaf}
auxLeaf.WhenSome(func(l txscript.TapLeaf) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth noting here that if there is an odd number of leaves, then the last one will always end up being a level higher than the other leaves. Which in our case works out to exactly what we want, with just three leaves. But the assumptions here (with using AssembleTaprootScriptTree) would break down for let's say 5 leaves.
Then again, we never have more than 3 leaves in any LN use cases, so maybe not worth spending more time on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this is a somewhat specific cut out that should work for our use case until there's some drastic overhaul of taproot chans.

func senderHtlcTapScriptTree(senderHtlcKey, receiverHtlcKey,
revokeKey *btcec.PublicKey, payHash []byte,
hType htlcType) (*HtlcScriptTree, error) {
hType htlcType,
Copy link
Collaborator

Choose a reason for hiding this comment

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

micro-nit: looks like hType could fit on previous line.

// commitment space. When present, this leaf will always be in the
// left-most or right-most area of the tapscript tree.
//
// TODO(roasbeeF): need to ensure commitment position...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this TODO related to my comment above? About relying on the logic in txscript.AssembleTaprootScriptTree?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, but as it it works since here we have it be that odd element out, which'll give it the top right position in the tree.


script, _ := input.NewLocalCommitScriptTree(
csvDelay, delay, rev,
csvDelay, delay, rev, fn.None[txscript.TapLeaf](),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need similar changes in other watchtower related code, see linter failures.

@dstadulis
Copy link

Fixes lightninglabs/taproot-assets#848

@lightninglabs-deploy
Copy link
Collaborator

@GeorgeTsagk: review reminder
@Roasbeef, remember to re-request review from reviewers when ready

@guggero
Copy link
Collaborator

guggero commented Apr 26, 2024

The single commit of this PR is included in #8684.

@guggero guggero closed this Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvements to existing features / behaviour taproot wallet The wallet (lnwallet) which LND uses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tracking]: enable lnd taproot scripts to accept optional aux leaf

5 participants