lnd
lnd copied to clipboard
DynComms [1/n]: Implement Quiescence Protocol
Rebased on #9097 now.
NOTE: This PR is part of a series implementing Dynamic Commitments. This PR does not directly implement any Dynamic Commitments specific logic but quiescence is a protocol gadget that is a prerequisite for Dynamic Commitments.
Change Description
This change implements the behavior described in the Quiescence Specification. It allows us to respond to our peer's request to quiesce the channel as well as implementing some ChannelUpdateHandler operations that allow us to initiate the process ourselves.
Some commits towards the end of the series have been included to allow us to initiate quiescence via RPC for the purposes of integration and interop testing. These commits should be removed before this PR is considered ready to merge. They will ultimately be replaced by RPCs that initiate the Dynamic Commitments protocol itself which will implicitly initiate quiescence as part of its process.
NOTE: This PR does NOT include a mechanism for timing out a quiescence session. This means that if we have an intentionally or unintentionally uncooperative peer, the channel will remain quiesced indefinitely. This is not desirable and will either be addressed in later commits in this PR or into a subsequent PR. However, this PR is submitted without it as it is "complete" in its own right.
Steps to Test
Steps for reviewers to follow to test the change.
Pull Request Checklist
Testing
- [ ] Your PR passes all CI checks.
- [x] Tests covering the positive and negative (error paths) are included.
- [x] Bug fixes contain tests triggering the bug to prevent regressions.
Code Style and Documentation
- [x] The change obeys the Code Documentation and Commenting guidelines, and lines wrap at 80.
- [x] Commits follow the Ideal Git Commit Structure.
- [x] Any new logging statements use an appropriate subsystem and logging level.
- [x] Any new lncli commands have appropriate tags in the comments for the rpc in the proto file.
- [ ] There is a change description in the release notes, or
[skip ci]in the commit message for small changes.
📝 Please see our Contribution Guidelines for further guidance.
[!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.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
The implementation of the Quiescence (stfu) protocol introduces a new mechanism for initiating quiescence on a link via RPC, enhancing channel synchronization, and error handling. It includes a state machine for managing the quiescence protocol, new RPC methods for testing purposes, and extends the functionality of existing structures to support these features. This change is pivotal for the advancement of Dynamic Commitments within the Lightning Network.
Changes
| File Pattern | Change Summary |
|---|---|
htlcswitch/... |
Introduced InitStfu() method, quiescence protocol logic, and related error handling. |
itest/... |
Added test cases for validating the quiescence protocol. |
lnrpc/... |
New RPC method Quiesce and related entities for quiescence protocol handling. |
lnwire/... |
Added MsgStfu message type and quiescence-related feature bits. |
peer/... |
Handling of lnwire.Stfu messages. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
Implement Quiescence (stfu) as a prerequisite for Dynamic Commitments (#8260) |
✅ | |
| Track state of Dynamic Commitments and upgrade channels to Taproot Channels (#7878) | ❌ | The PR focuses on the Quiescence protocol, not directly on Dynamic Commitments or Taproot Channels. |
Address retransmission of shutdown message upon reconnection (#8397) |
❌ | This PR does not address the retransmission issues described. |
| Improve handling of dust HTLCs in channel closure (#7969) | ❌ | The changes are unrelated to dust HTLCs handling. |
Possibly related issues
- #7878: While this PR doesn't directly implement Dynamic Commitments, the Quiescence protocol is a foundational step toward that goal.
- #8397: Though not directly addressed, improvements in channel synchronization and error handling could indirectly benefit the retransmission logic in future updates.
🐇✨
In the land of code and wire,
A rabbit hopped, with dreams so dire.
"Let's quiesce," it said, with glee,
For quieter channels, we all agree.
Withstfuin place, and tests to run,
Our Lightning paths are second to none.
🌩️🐰💻
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?
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
@coderabbitaiin 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
@coderabbitaiin 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 as PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
@roasbeef: review reminder @proofofkeags, remember to re-request review from reviewers when ready
Haven't reviewed the code, just wanna say maybe we could update the ruleset here so you can push branches and change the base branch so it's easier to review.
I'm not sure I understand what's being proposed here? Is this just so that I can have multi-stage branching in the LND main repo itself? If so, what does the ruleset do to support this?
@roasbeef: review reminder @proofofkeags, remember to re-request review from reviewers when ready
While we're in the business of pulling things out into prefactors, how about pulling out 3634cbafbc1d191a44ac4df2315cddad432ace0e and 8ccdbfd491f700c427376ba9df0bbfb33c6d2af9 into a trivial PR as suggested by @yyforyongyu?
While we're in the business of pulling things out into prefactors, how about pulling out https://github.com/lightningnetwork/lnd/commit/3634cbafbc1d191a44ac4df2315cddad432ace0e and https://github.com/lightningnetwork/lnd/commit/8ccdbfd491f700c427376ba9df0bbfb33c6d2af9 into a trivial PR as suggested by @yyforyongyu?
#8962 is served. 👨🏻🍳🔪🥘
All comments addressed. The code is substantially different. I recommend a full review. Only a handful of comments were contested as opposed to accepted. Feel free to consult those threads for the objection raised.