lnd icon indicating copy to clipboard operation
lnd copied to clipboard

DynComms [1/n]: Implement Quiescence Protocol

Open ProofOfKeags opened this issue 1 year ago • 9 comments

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

📝 Please see our Contribution Guidelines for further guidance.

ProofOfKeags avatar Dec 12 '23 05:12 ProofOfKeags

[!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.

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.
With stfu in 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?

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 as 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.

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

coderabbitai[bot] avatar Jan 24 '24 00:01 coderabbitai[bot]

@roasbeef: review reminder @proofofkeags, remember to re-request review from reviewers when ready

lightninglabs-deploy avatar May 20 '24 01:05 lightninglabs-deploy

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?

ProofOfKeags avatar Jun 12 '24 23:06 ProofOfKeags

@roasbeef: review reminder @proofofkeags, remember to re-request review from reviewers when ready

lightninglabs-deploy avatar Jul 18 '24 02:07 lightninglabs-deploy

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?

carlaKC avatar Jul 31 '24 12:07 carlaKC

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. 👨🏻‍🍳🔪🥘

ProofOfKeags avatar Jul 31 '24 20:07 ProofOfKeags

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.

ProofOfKeags avatar Aug 10 '24 03:08 ProofOfKeags