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

lnwallet: properly set aux HTLC blob on retransmission #9032

Merged
merged 10 commits into from
Sep 13, 2024

Conversation

Roasbeef
Copy link
Member

Before this commit, we weren't properly setting the aux HTLC blob when we went to retransmit a signature. We fix this by setting the ExtraData field as expected in the CommitSig message.

Fixes #9031

Copy link
Contributor

coderabbitai bot commented Aug 24, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

Labels to auto review (1)
  • llm-review

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

Copy link

Pull reviewers stats

Stats of the last 30 days for lnd:

User Total reviews Time to review Total comments
yyforyongyu
🥇
28
▀▀▀
19h 34m
100
▀▀
guggero
🥈
19
▀▀
13h 47m
47
Roasbeef
🥉
14
14d 6h 59m
▀▀▀
56
carlaKC
10
1d 14h 32m
46
bhandras
9
2h 38m
5
ProofOfKeags
5
16d 4h 24m
▀▀▀▀
87
▀▀
ziggie1984
5
1d 4h 20m
17
Crypt-iQ
4
1d 20h 44m
11
bitromortac
4
2d 3h 3m
29
morehouse
3
1h 5m
1
ellemouton
3
1h 30m
11
hieblmi
2
5d 23h 6m
5
GeorgeTsagk
1
20h 3m
1

@Roasbeef
Copy link
Member Author

Before merging I want to cover this with a unit test, we have the existing retransmission test, and we can mock the aux sigs to specify a value.

@guggero guggero linked an issue Aug 26, 2024 that may be closed by this pull request
1 task
@Roasbeef
Copy link
Member Author

This builds on #9046.

@guggero guggero self-requested a review August 30, 2024 06:57
@GeorgeTsagk GeorgeTsagk self-requested a review August 30, 2024 15:48
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.

LGTM 🎉

lnwire/extra_bytes.go Show resolved Hide resolved
lnwallet/mock.go Show resolved Hide resolved
htlcswitch/link.go Show resolved Hide resolved
lnwallet/channel_test.go Show resolved Hide resolved
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.

lnwallet/channel.go Show resolved Hide resolved
lnwire/commit_sig.go Show resolved Hide resolved
lnwire/extra_bytes.go Outdated Show resolved Hide resolved
@saubyk saubyk added this to the v0.18.4 milestone Sep 5, 2024
Before this commit, we weren't properly setting the aux HTLC blob when
we went to retransmit a signature. We fix this by setting the
`ExtraData` field as expected in the `CommitSig` message.
In this commit, we fix an existing bug with the taproot channel type that can cause force closes if a peer disconnects while attempting to send the commitment signature.

Before this commit, since the `PartialSig` we send is never committed to disk, the version read wouldn't contain the musig2 partial sig. We never write these signatures to disk, as each time we make a new session, we need to generate fresh nonces to avoid nonce-reuse.

Due to the above interaction, if we went to re-send a signature after a disconnection, the `CommitSig` message we sent wouldn't actualy contain a `PartialSigWithNonce`, causing a protocol error.
This'll be useful later to make some enhancements to the existing unit tests.
In this commit, we expand some of the existing chan sync tests to cover
taproot channels (the others already did). Along the way, we always
assert that the `PartialSig` is populated on retransmission. In
addition, we now send the new commit sig rather than the existing
in-memory one to test the new logic that re-signs the commitment.
We'll use this to update CommitSig in the next commit.
This way, it's possible to run induvidual tests to target failures.
In a future commit, we'll use the new field to ensure that if we add any additional records, they aren't over written by the TLV records that would be encoded.
In this commit, we start to use the set of CustomRecords instead of ExtraData for the aux sig blobs.
This test ensures that when we go to retransmit a signature, we also include the set of CustomRecords.
@Roasbeef Roasbeef force-pushed the htlc-aux-sig-retransmission branch from 975af9d to 5058432 Compare September 13, 2024 00:57
@Roasbeef Roasbeef merged commit fb66bd2 into 0-19-staging Sep 13, 2024
22 of 27 checks passed
@guggero guggero deleted the htlc-aux-sig-retransmission branch September 13, 2024 06:25
@Roasbeef Roasbeef mentioned this pull request Sep 16, 2024
8 tasks
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.

[bug]: CommitSig deficiency causes HTLCs insufficiently populated on node restart
4 participants