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

[2/?]: lnwallet+channeldb: add new AuxLeafStore for dynamic aux leaves #8684

Merged
merged 14 commits into from
May 1, 2024

Conversation

guggero
Copy link
Collaborator

@guggero guggero commented Apr 24, 2024

Depends/bases on #8683.

Replaces #8562 (with correct base branch and upstream feature branch).

In this commit, we add a new abstraction, the AuxLeafStore that's capable of dynamically deriving hte aux leaves for a new commitment state given the channel point and custom blob stored. The custom blob can be used by external programers to store custom information for a channel which can then be used to derive the aux leaves for each new state. All added features in this PR as optional, and if not set, don't alter the normal channel flow.

NOTE: In this PR, I've started to also commit my local go.work files, as I have some submodules change, and committing the go.work file allows the PR to build w/o any temporary commits or PRs.

TODO

  • Add custom blob to commit diff
  • Use leaf store to refresh blob for each new state
  • Thread through to the remaining resolvers

Summary by CodeRabbit

  • New Features
    • Introduced customizable script paths for channel and commitment transactions, enhancing flexibility and potential for future upgrades.
    • Added support for auxiliary tapscript leaves in commitment transactions, allowing for extended functionality.
  • Enhancements
    • Extended the wallet's capability to create commitment transactions with customizable options.
  • Refactor
    • Improved code structure related to script generation and handling of custom data blobs within channel data structures.
  • Tests
    • Expanded test coverage to include new features and enhancements, ensuring robustness and reliability.

Link to all PRs in the saga:

Copy link

Pull reviewers stats

Stats of the last 30 days for lnd:

User Total reviews Time to review Total comments
guggero
🥇
21
▀▀▀
12h 42m
25
Roasbeef
🥈
13
▀▀
7d 8h 43m
76
▀▀▀
ellemouton
🥉
7
5h 10m
7
bhandras
6
13h 56m
1
ziggie1984
6
8d 18h 41m
45
▀▀
morehouse
4
7d 11h 12m
19
ProofOfKeags
3
7d 8h 56m
40
▀▀
yyforyongyu
2
12h 24m
1
Crypt-iQ
2
7d 5h 38m
8
saubyk
2
3d 17h 37m
0
ffranr
1
3d 16h 49m
5
dstadulis
1
14d 35m
▀▀
1
bitromortac
1
14d 3h 18m
▀▀
3
Chinwendu20
1
23h 27m
1

Copy link

coderabbitai bot commented Apr 24, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

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.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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 testing code 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 testing code 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 testing code.
    • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@guggero
Copy link
Collaborator Author

guggero commented Apr 25, 2024

I can't approve the PR because I re-opened it. But I reviewed it and worked my feedback directly into the commits.
So I'm approving it with this comment: LGTM 🎉

Perhaps we'll want to wait for #8692 to be merged to fix the linter issue. But can also address that once we merge the 0-19-staging branch into master.

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 🪁

@Roasbeef
Copy link
Member

I think it's missing a commit somewhere?

Error: lnwallet/commitment.go:632:27: undefined: input.AuxTapLeaves

@Roasbeef
Copy link
Member

@guggero
Copy link
Collaborator Author

guggero commented Apr 26, 2024

Oops, will fix.

@guggero
Copy link
Collaborator Author

guggero commented Apr 29, 2024

Bumped go.mod to use tlv/v1.2.5 and with that also removed the go.work file (as that caused some issues with the linter). Also fixed the commit order, should be good to go now.

Copy link
Collaborator

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

Looks good 🍀

channeldb/channel.go Outdated Show resolved Hide resolved
channeldb/channel.go Outdated Show resolved Hide resolved
input/taproot.go Show resolved Hide resolved
lnwallet/commitment.go Outdated Show resolved Hide resolved
@@ -72,116 +148,60 @@ var (
// made into tlv records without further conversion.
type HTLCEntry struct {
// RHash is the payment hash of the HTLC.
RHash [32]byte
RHash tlv.RecordT[tlv.TlvType0, SparsePayHash]
Copy link
Collaborator

Choose a reason for hiding this comment

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

haven't fully wrapped my head around why we implemented sparse hash when we could have used fn.Option?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's to remain backward compatibility with existing data in the database. The sparse hash writes the TLV type and a length of 0 while an optional record would not be written at all (so neither type nor length). So the encoding on disk would be different.

Base automatically changed from funding-tapcript to 0-19-staging April 30, 2024 16:12
Roasbeef and others added 7 commits May 1, 2024 10:13
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.
In this commit, for each channel, we'll now start to store an optional custom blob. This can be used to store extra information for custom channels in an opauqe manner.
We'll need this later on to ensure we can always interact with the new aux blobs at all stages of commitment transaction construction.
In this commit, we also add the custom TLV blob to the internal commitment struct that we use within the in-memory commitment linked list.

This'll be useful to ensure that we're tracking the current blob for our in memory commitment for when we need to write it to disk.
In this commit, we add some useful type definitions for the aux leaf.
In this commit, we add a new AuxLeafStore which can be used to dynamically fetch the latest aux leaves for a given state. This is useful for custom channel types that will store some extra information in the form of a custom blob, then will use that information to derive the new leaf tapscript leaves that may be attached to reach state.
Roasbeef and others added 7 commits May 1, 2024 11:19
This'll be useful for custom channel types that want to store extra information that'll be useful to help handle channel revocation cases.
This may be useful for custom channel types that base everything off the index (a global value) rather than the output index (can change with each state).
In this commit, we add a TLV blob to the PaymentDescriptor struct. We also now thread through this value from the UpdateAddHTLC message to the PaymentDescriptor mapping, and the other way around.
In this commit, we start to thread thru the new aux tap leaf structures to all relevant areas. This includes: commitment outputs, resolution creation, breach handling, and also HTLC scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants