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

multi: preliminary changes towards integrating the new RBF close protocol feature #9559

Merged
merged 14 commits into from
Feb 28, 2025

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Feb 27, 2025

This PR contains a set of preliminary changes towards integrating the RBF close state machine.

Spun off from: #8453

NOTE: the merge target here is a side feature branch: rbf-staging.


This change is Reviewable

Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this 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.

@saubyk saubyk added this to the v0.19.0 milestone Feb 27, 2025
Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Looking good! Since we are merging to a side branch, I think we can skip the itest CI as long as they are green in the final PR, as they are likely to only start working once all pieces are fit together. I think once the linter and check commits are fixed we are good to go - the unit tests are failed due to compile error so they are expected to pass once the linter is fixed.

Reviewed 1 of 1 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 3 of 3 files at r4, 1 of 1 files at r5, 1 of 1 files at r6, 1 of 1 files at r7, 1 of 1 files at r8, 2 of 2 files at r9, 5 of 5 files at r10, 4 of 4 files at r11, 3 of 3 files at r12, 2 of 2 files at r13, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @Crypt-iQ)


lnwire/features.go line 236 at r1 (raw file):

	KeysendOptional = 55

	// RbfCoopCloseRequired is an required feature bit that signals that

nit: an required -> a required


lnwire/features.go line 244 at r1 (raw file):

	RbfCoopCloseOptional = 61

	// RbfCoopCloseRequiredStaging is an required feature bit that signals

nit: an required -> a required


lnwire/features.go line 248 at r1 (raw file):

	RbfCoopCloseRequiredStaging = 160

	// RbfCoopCloseOptionalStaging is a optional feature bit that signals

nit: a optional feature bit -> an optional feature bit


peer/daemon_adapters.go line 79 at r6 (raw file):

// gossip network.
//
//nolint:iface

looks like we have two interfaces which are the same? There's already a linkNetworkController in chan_observer.go


peer/chan_observer.go line 98 at r5 (raw file):

	}

	_ = l.link.DisableAdds(htlcswitch.Incoming)

nit: add a debug/warning log so we know whether it's disabled or not?


peer/chan_observer.go line 151 at r5 (raw file):

		snapshot := l.chanView.StateSnapshot()

		return fn.Some[chancloser.ShutdownBalances](

nit: can remove chancloser.ShutdownBalances,

return fn.Some(chancloser.ShutdownBalances{
			LocalBalance:  snapshot.LocalBalance,
			RemoteBalance: snapshot.RemoteBalance,
            })

Copy link
Collaborator

@Crypt-iQ Crypt-iQ left a comment

Choose a reason for hiding this comment

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

The changes look good to me. Are the itests failing because of the different base-branch?

@Roasbeef
Copy link
Member Author

Are the itests failing because of the different base-branch?

Cherry-pick + rebase issue. Should be fixed in a push shortly.

@Roasbeef Roasbeef requested a review from yyforyongyu February 27, 2025 22:29
Copy link
Member Author

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @yyforyongyu)


peer/chan_observer.go line 151 at r5 (raw file):

Previously, yyforyongyu (Yong) wrote…

nit: can remove chancloser.ShutdownBalances,

return fn.Some(chancloser.ShutdownBalances{
			LocalBalance:  snapshot.LocalBalance,
			RemoteBalance: snapshot.RemoteBalance,
            })

Nice this PR was before they improved the type inferencing.


peer/daemon_adapters.go line 79 at r6 (raw file):

Previously, yyforyongyu (Yong) wrote…

looks like we have two interfaces which are the same? There's already a linkNetworkController in chan_observer.go

Removed this one.

In an earlier version the state machine executor also gained this ability as a daemon event, but reviewer feedback was that is less universal. So moved it into the env of the state machine instead.

Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

:lgtm: niiice!

Reviewed 7 of 7 files at r14, 1 of 1 files at r15, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @Roasbeef)


lnwire/features.go line 236 at r14 (raw file):

	KeysendOptional = 55

	// RbfCoopCloseRequired is n required feature bit that signals that

Suggestion:

a required

lnwire/features.go line 244 at r14 (raw file):

	RbfCoopCloseOptional = 61

	// RbfCoopCloseRequiredStaging is n required feature bit that signals

Suggestion:

a required

In this commit, we change LinkDirection to be a type alias. This makes
creating wrapper structs/interfaces easier, as we don't need to leak
htlcswitch.LinkDirection, instead we can accept a bool.
In this commit, we add an implementation of a new interface the rbf coop
state machine needs. We take care to accept interfaces everywhere, to
make this easier to test, and decouple from the concrete types we'll end
up using elsewhere.
Similar to the last commit, in this commit, we make a daemon adapter
impl for lnd. We'll use this for any future protofsm based state
machine.
We don't return an error on broadcast fail as the broadcast might have
failed due to insufficient fees, or inability to be replaced, which may
happen when one side attempts to unnecessarily bump their coop close
fee.
With this commit, we make sure we set the right height hint, even if the
channel is a zero conf channel.
In this commit, we update `chooseDeliveryScript` to generate a new
script if needed. This allows us to fold in a few other lines that
always followed this function into this expanded function.

The tests have been updated accordingly.
@Roasbeef Roasbeef requested a review from yyforyongyu February 28, 2025 23:36
Copy link
Member Author

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

Reviewed 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r6, 1 of 1 files at r8, 2 of 2 files at r9, 4 of 5 files at r10, 3 of 4 files at r11, 3 of 3 files at r12, 1 of 2 files at r13, 7 of 7 files at r14.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @yyforyongyu)


lnwire/features.go line 236 at r14 (raw file):

	KeysendOptional = 55

	// RbfCoopCloseRequired is n required feature bit that signals that

Done.


lnwire/features.go line 244 at r14 (raw file):

	RbfCoopCloseOptional = 61

	// RbfCoopCloseRequiredStaging is n required feature bit that signals

Done.

@Roasbeef
Copy link
Member Author

Merging into side feature branch.

@Roasbeef Roasbeef merged commit d109107 into lightningnetwork:rbf-staging Feb 28, 2025
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants