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

bumpforceclosefee rpc #8843

Merged
merged 6 commits into from
Aug 12, 2024

Conversation

ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Jun 15, 2024

Fixes #8837

For reviewers please also focus on the following questions I included into the code starting with

// Question: 

Should we add an Integration Test for this new RPC call? => Yes I will

Thank you in advance 🙏

EDIT: Depends on #8946

Copy link
Contributor

coderabbitai bot commented Jun 15, 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.

Walkthrough

The recent update enhances the fee-bumping mechanism for force close operations in Lightning Network channels, particularly when no HTLCs are involved. It introduces the BumpForceCloseFee functionality, refines anchor handling, and ensures reliable fee adjustments for unconfirmed anchor channels. Users can now effectively increase force close fees, resolving previous limitations and improving overall usability.

Changes

Files/Directories Change Summary
cmd/lncli/walletrpc_active.go Refactored bump force close fee logic, removed deprecated flags, and clarified budget usage for force closes without HTLCs.
contractcourt/channel_arbitrator.go Modified anchor sweeping logic to register anchor outputs even when no HTLCs are present, enhancing fee adjustment capabilities.
docs/release-notes/release-notes-0.18.1.md Documented the fix for bumping anchor channel fees when no HTLCs are present and added the new BumpForceCloseFee walletrpc endpoint.
docs/release-notes/release-notes-0.18.3.md Detailed functional improvements and bug fixes related to the BumpForceCloseFee functionality.
lnrpc/walletrpc/config_active.go Introduced a new field, ChanStateDB, in the Config struct for better state management in wallet RPC.
lnrpc/walletrpc/walletkit.pb.json.go Added a JSON callback function for handling BumpForceCloseFee requests in the WalletKit service.
lnrpc/walletrpc/walletkit.proto Introduced the BumpForceCloseFee RPC method for adjusting fees on anchor channel closures.
lnrpc/walletrpc/walletkit_server.go Expanded the BumpForceCloseFee method to accommodate unconfirmed anchor channels and improve fee adjustment efficiency.
itest/lnd_sweep_test.go Added tests for the new fee bumping functionality to validate behavior when handling force close transactions without HTLCs.
lntest/rpc/wallet_kit.go Implemented a new method for invoking the BumpForceCloseFee RPC call within the HarnessRPC struct, enhancing testing capabilities.

Assessment against linked issues

Objective (Issue #8837) Addressed Explanation
Register the anchor with the sweeper for accurate data
Allow fee bumping without HTLCs
Move logic from lncli to rpc

Possibly related issues

Poem

In the code's deep lightning grasp,
Anchors steady, no longer clasp.
Fees now bump, in clean euphoria,
Channels close, sans-HTLC gloria.
Rabbit smiles, in bits and bytes,
Onward flows, the network's lights. ✨


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.

@ziggie1984 ziggie1984 force-pushed the bumpforceclosefee-rpc branch 3 times, most recently from 3946e44 to 219764f Compare June 15, 2024 13:28
@ziggie1984
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jun 15, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jun 15, 2024

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

Commits

Files that changed from the base of the PR and between 68494fd and 219764f418dac9f25fd0f64a50559d5c4fa652cd.

Files ignored due to path filters (5)
  • lnrpc/walletrpc/walletkit.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • lnrpc/walletrpc/walletkit.pb.gw.go is excluded by !**/*.pb.gw.go, !**/*.pb.gw.go
  • lnrpc/walletrpc/walletkit.swagger.json is excluded by !**/*.json
  • lnrpc/walletrpc/walletkit.yaml is excluded by !**/*.yaml
  • lnrpc/walletrpc/walletkit_grpc.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (9)
  • cmd/lncli/walletrpc_active.go (1 hunks)
  • contractcourt/channel_arbitrator.go (1 hunks)
  • docs/release-notes/release-notes-0.18.1.md (1 hunks)
  • lnrpc/walletrpc/config_active.go (2 hunks)
  • lnrpc/walletrpc/walletkit.pb.json.go (1 hunks)
  • lnrpc/walletrpc/walletkit.proto (1 hunks)
  • lnrpc/walletrpc/walletkit_server.go (3 hunks)
  • lnwallet/wallet.go (1 hunks)
  • subrpcserver_config.go (1 hunks)
 _________________________________________________________________________________________________________________
< Iterate the schedule with the code. Use experience you gain as you implement to refine the project time scales. >
 -----------------------------------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

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

@ziggie1984 ziggie1984 marked this pull request as ready for review June 15, 2024 13:33
@ziggie1984 ziggie1984 added this to the v0.18.1 milestone Jun 15, 2024
@ziggie1984 ziggie1984 self-assigned this Jun 15, 2024
@ziggie1984 ziggie1984 added rpc Related to the RPC interface channel closing Related to the closing of channels cooperatively and uncooperatively labels Jun 15, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Outside diff range and nitpick comments (3)
cmd/lncli/walletrpc_active.go (1)

Line range hint 528-528: Remove unused function getWaitingCloseCommitments.

The function getWaitingCloseCommitments is marked as unused by static analysis tools. If this function is indeed not required, consider removing it to clean up the codebase.

- func getWaitingCloseCommitments(ctxc context.Context,
-     client lnrpc.LightningClient, channelPoint string) (
-     *lnrpc.PendingChannelsResponse_Commitments, error) {
-     req := &lnrpc.PendingChannelsRequest{}
-     resp, err := client.PendingChannels(ctxc, req)
-     if err != nil {
-         return nil, err
-     }
-     for _, channel := range resp.WaitingCloseChannels {
-         if channel.Channel.ChannelPoint == channelPoint {
-             return channel.Commitments, nil
-         }
-     }
-     return nil, errors.New("channel not found")
- }
lnrpc/walletrpc/walletkit_server.go (1)

Line range hint 2406-2407: Potential security risk detected by Gitleaks.

The lines 2406-2407, 2412-2413, and 2416-2417 have been flagged by Gitleaks for containing a Generic API Key. This could potentially expose access to various services and sensitive operations. It's crucial to investigate these findings, remove any hardcoded secrets, and possibly use a secure vault or environment variables.

Also applies to: 2412-2413, 2416-2417

contractcourt/channel_arbitrator.go (1)

Line range hint 410-435: ### Review: Interaction with Blockchain State in sweepAnchors
The sweepAnchors function (lines 410-435) interacts directly with the blockchain to manage anchor outputs. It's crucial that this interaction is robust against blockchain reorgs and other anomalies. The current implementation assumes a stable chain state, which might not always be the case. Consider adding reorg-safe mechanisms or checks to ensure that the anchor handling remains consistent even when the blockchain state changes unexpectedly.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 68494fd and 219764f418dac9f25fd0f64a50559d5c4fa652cd.

Files ignored due to path filters (5)
  • lnrpc/walletrpc/walletkit.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • lnrpc/walletrpc/walletkit.pb.gw.go is excluded by !**/*.pb.gw.go, !**/*.pb.gw.go
  • lnrpc/walletrpc/walletkit.swagger.json is excluded by !**/*.json
  • lnrpc/walletrpc/walletkit.yaml is excluded by !**/*.yaml
  • lnrpc/walletrpc/walletkit_grpc.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (9)
  • cmd/lncli/walletrpc_active.go (1 hunks)
  • contractcourt/channel_arbitrator.go (1 hunks)
  • docs/release-notes/release-notes-0.18.1.md (1 hunks)
  • lnrpc/walletrpc/config_active.go (2 hunks)
  • lnrpc/walletrpc/walletkit.pb.json.go (1 hunks)
  • lnrpc/walletrpc/walletkit.proto (1 hunks)
  • lnrpc/walletrpc/walletkit_server.go (3 hunks)
  • lnwallet/wallet.go (1 hunks)
  • subrpcserver_config.go (1 hunks)
Additional context used
LanguageTool
docs/release-notes/release-notes-0.18.1.md

[uncategorized] ~28-~28: A comma may be missing after the conjunctive/linking adverb ‘Moreover’. (SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
Context: ...ment when the channel was force closed. Moreover a new walletrpc endpoint `BumpForceClos...

Markdownlint
docs/release-notes/release-notes-0.18.1.md

22-22: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


26-26: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


36-36: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


40-40: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


48-48: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


51-51: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


56-56: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


59-59: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


62-62: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


78-78: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


79-79: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


4-4: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


5-5: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


6-6: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


8-8: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


9-9: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


10-10: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


11-11: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


12-12: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


14-14: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


15-15: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


16-16: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


17-17: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


18-18: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


26-26: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


48-48: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


58-58: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1-1: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


31-31: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


32-32: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


32-32: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


33-33: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


33-33: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


34-34: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


44-44: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


45-45: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


45-45: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


46-46: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


65-65: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


66-66: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


66-66: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


67-67: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


69-69: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


70-70: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


70-70: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


71-71: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


71-71: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


72-72: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


72-72: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


73-73: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


73-73: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


74-74: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


20-20: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


31-31: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


44-44: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


69-69: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


76-76: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


2-2: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines

GitHub Check: lint code
cmd/lncli/walletrpc_active.go

[failure] 528-528:
func getWaitingCloseCommitments is unused (unused)

lnrpc/walletrpc/walletkit_server.go

[failure] 1136-1136:
unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)

Gitleaks
lnrpc/walletrpc/walletkit_server.go

2406-2407: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


2412-2413: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


2416-2417: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Additional comments not posted (9)
lnrpc/walletrpc/config_active.go (1)

82-85: The addition of GetWaitingCloseChannel to the Config struct aligns with the PR objectives to enable channel closure functionalities at the RPC level. Ensure that the function provided to this field is thoroughly tested for various scenarios to guarantee robustness.

subrpcserver_config.go (1)

205-207: Properly setting the GetWaitingCloseChannel in the WalletKitRPC configuration is essential for the new fee bump functionality. This change appears correctly implemented.

lnrpc/walletrpc/walletkit.pb.json.go (1)

575-598: The addition of the BumpForceCloseFee callback is crucial for the new RPC functionality to be accessible via JSON. The implementation appears correct, ensuring proper error handling and response marshaling. It's important to test this thoroughly to ensure it handles various edge cases correctly.

lnrpc/walletrpc/walletkit.proto (1)

276-282: The addition of BumpForceCloseFee RPC method is well-implemented and correctly documented. It specifically addresses the need to bump the fee for force-closed anchor channels, aligning with the PR objectives.

cmd/lncli/walletrpc_active.go (1)

511-518: Ensure proper error handling and context propagation.

Given the critical nature of the BumpForceCloseFee operation, it's essential to ensure that all errors are handled appropriately and that the context is correctly propagated. Please verify that all potential errors from downstream calls are managed effectively and that the operation's context is consistent with the expected behavior.

Verification successful

The new context provided by the shell script results shows that error handling around the BumpForceCloseFee operation is indeed present in multiple instances across the codebase. Specifically, there are checks for if err != nil after the BumpForceCloseFee calls, ensuring that errors are managed appropriately.

Additionally, context propagation appears to be handled correctly, as seen in the various usages of ctx and the creation of new contexts with context.WithCancel and runtime.AnnotateContext.

Given this information, it is clear that the concerns regarding error handling and context propagation are addressed.

  • Locations with proper error handling and context propagation:
    • lnrpc/walletrpc/walletkit.pb.json.go
    • lnrpc/walletrpc/walletkit.pb.gw.go
    • lnrpc/walletrpc/walletkit_grpc.pb.go
    • cmd/lncli/walletrpc_active.go
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify error handling in BumpForceCloseFee operation.

# Test: Search for error handling patterns around BumpForceCloseFee calls.
rg --type go 'BumpForceCloseFee' | grep 'if err != nil'

Length of output: 55



Script:

#!/bin/bash
# Description: Verify error handling and context propagation in BumpForceCloseFee operation.

# Search for the BumpForceCloseFee function calls in the codebase.
rg --type go 'BumpForceCloseFee' -A 5 -B 5

# Check for context propagation by searching for context usage around BumpForceCloseFee.
rg --type go 'BumpForceCloseFee' -A 5 -B 5 | rg 'ctx'

Length of output: 29091

lnwallet/wallet.go (1)

1160-1179: The implementation of GetWaitingCloseChannel appears functionally correct.

This method extends the LightningWallet struct to support fetching channels in a 'waiting close' state, which is relevant for the PR's objectives related to managing channel states more effectively. Good use of error handling and clear structure in the method.

lnrpc/walletrpc/walletkit_server.go (1)

110-113: Ensure correct permission settings for the new RPC method.

The permissions for the new RPC method BumpForceCloseFee are correctly set to "write" which aligns with its functionality of modifying the fee rate of unconfirmed anchor channels. This is crucial for maintaining security and appropriate access control.

contractcourt/channel_arbitrator.go (2)

1326-1333: ### Review: Logic to Handle Anchor Sweeping with No HTLCs at Stake
The logic for sweeping anchors when no HTLCs are at stake (lines 1326-1333) appears well-implemented. It correctly checks for the absence of a deadline and logs the sweeping operation, which is crucial for maintaining the state of the channel in scenarios where no immediate action is required on the HTLCs. This is aligned with the PR's objective of handling anchor channels more effectively, especially in edge cases like the absence of HTLCs.


Line range hint 288-308: ### Review: Error Handling in ForceCloseChan
The function ForceCloseChan in the ArbChannel interface (lines 288-308) is critical as it forces the closure of a channel and updates the state accordingly. The error handling here is crucial because any failures in this process can lead to inconsistent states or loss of funds. It's important to ensure that all possible errors are handled gracefully and that the channel's state is accurately updated in the database to reflect these changes.

Verification successful

The implementations of ForceCloseChan in contractcourt/chain_arbitrator.go and contractcourt/channel_arbitrator_test.go handle errors appropriately. The main implementation in contractcourt/chain_arbitrator.go includes error checks after each critical operation, ensuring that errors are returned immediately and handled gracefully. The mock implementation in contractcourt/channel_arbitrator_test.go also simulates error handling by returning predefined errors.

  • contractcourt/chain_arbitrator.go:319-356: Proper error handling is implemented at each step.
  • contractcourt/channel_arbitrator_test.go:2994-3004: Mock implementation simulates error handling.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that all implementations of ForceCloseChan handle errors correctly.
rg "ForceCloseChan" --type go

Length of output: 2141



Script:

#!/bin/bash
# Extract the implementation of ForceCloseChan in contractcourt/channel_arbitrator.go and contractcourt/chain_arbitrator.go
ast-grep --lang go --pattern 'func (a *arbChannel) ForceCloseChan() ($_, error) { $$$ }' contractcourt/chain_arbitrator.go
ast-grep --lang go --pattern 'func (m *mockChannel) ForceCloseChan() ($_, error) { $$$ }' contractcourt/channel_arbitrator_test.go
ast-grep --lang go --pattern 'ForceCloseChan() ($_, error)' contractcourt/channel_arbitrator.go

Length of output: 3771

cmd/lncli/walletrpc_active.go Outdated Show resolved Hide resolved
cmd/lncli/walletrpc_active.go Outdated Show resolved Hide resolved
lnrpc/walletrpc/walletkit_server.go Outdated Show resolved Hide resolved
docs/release-notes/release-notes-0.18.1.md Outdated Show resolved Hide resolved
@ziggie1984 ziggie1984 force-pushed the bumpforceclosefee-rpc branch 3 times, most recently from ae64e45 to b313721 Compare June 17, 2024 12:22
@ziggie1984 ziggie1984 force-pushed the bumpforceclosefee-rpc branch from b313721 to 0a11b8d Compare June 18, 2024 12:57
lntest/harness_miner.go Outdated Show resolved Hide resolved
itest/lnd_multi-hop_test.go Show resolved Hide resolved
itest/lnd_multi-hop_test.go Show resolved Hide resolved
@ziggie1984
Copy link
Collaborator Author

We definitely need to prioritize the flattening of the mulit_hop tests, fixing those takes super long because they include a lot of different special case for different channel types ...

@ziggie1984
Copy link
Collaborator Author

waiting for #8717, so that itests are not updated twice.

@saubyk saubyk added the P1 MUST be fixed or reviewed label Jun 25, 2024
@saubyk saubyk requested a review from yyforyongyu June 27, 2024 15:21
@yyforyongyu
Copy link
Member

I think this should be moved to 0.19 since we are adding an RPC?

@saubyk
Copy link
Collaborator

saubyk commented Jul 17, 2024

I think this should be moved to 0.19 since we are adding an RPC?

Need to understand this better. I thought rpc was already added in 0.18 but not doing its function of bumping up the fee

@ziggie1984
Copy link
Collaborator Author

This PR needs a final decision before I will proceed fixing the itests, basically the following:

Currently when creating the Force-Close transaction we will not account for the parent fee rate immediately but rely on the createRBFCompliantTx which will at least create a transaction which meets the current mempool conditions. This has in my view several downsides, that's why I think the new approach by accounting the feerate is better:

When force-closing a channel the conf target will never select the right fee-rate which was essentially required but will only reach this feerate several blocks down the road which can be a long time until the desired feerate is reached in case the commitment transaction (parent) is very big.

Moreover when trying to bump the feerate of a closing transaction with this newly introduced RPC we will not be able to specify the exact feerate and therefore this might be a bad user experience.

Based on the decision above when we account for the parent feerate we need to change some itests which are now failing, but if we decide against it those itests remain unchanged. That's why I am waiting for your feedback before proceeding.

Maybe @morehouse and @yyforyongyu and comment on this matter ?

Thank you in advance for your time.

@yyforyongyu
Copy link
Member

Moreover when trying to bump the feerate of a closing transaction with this newly introduced RPC we will not be able to specify the exact feerate and therefore this might be a bad user experience.

With the new sweeper I don't think it makes sense to specify a feerate anymore. Instead, users should seek to specify a budget, which is more accurate IMO, as in the end you wanna control the fees paid. Previously we achieved so by specifying a feerate, but it was not precise as it's mostly estimation.

@ziggie1984
Copy link
Collaborator Author

I think this should be moved to 0.19 since we are adding an RPC?

Although its a new RPC, the logic was mostly copied from the lncli side, and it fixes the bug of bumping force closes with no htlcs, so I think getting this in lnd 18.3 is a good choice :)

@saubyk saubyk requested a review from ProofOfKeags July 23, 2024 16:41
@ziggie1984 ziggie1984 force-pushed the bumpforceclosefee-rpc branch 2 times, most recently from ba02bd0 to 96f6a97 Compare July 30, 2024 23:02
@ziggie1984 ziggie1984 force-pushed the bumpforceclosefee-rpc branch from 96f6a97 to 773be0a Compare July 31, 2024 10:07
@saubyk saubyk modified the milestones: v0.18.3, v0.19.0 Aug 1, 2024
lntest/miner/miner.go Outdated Show resolved Hide resolved
@lightninglabs-deploy
Copy link

@yyforyongyu: review reminder
@ziggie1984, remember to re-request review from reviewers when ready

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.

Cool just need to remove the unused method and should be good to go. Will hold on merging it before 0.18.3 is cut later today.

@@ -71,6 +71,40 @@ func NoError(f func() error, timeout time.Duration) error {
return nil
}

// NoErrorWithValue runs the function f and returns its value if it succeeds
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this can be removed now.

chanPoint := chanPoints[0]
alice := nodes[0]

// We need to fund alice with 2 wallet inputs so that we can test to
Copy link
Member

Choose a reason for hiding this comment

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

This does remind me something - that we need to check how many UTXOs are there and return an error if it's below 2, otherwise we can only bump one of the anchors below, and the error will only be shown in the logs, which can be a bad UX. Not in this PR tho as we will soon merge it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahh ok so you mean we would need 3 wallet inputs in the above case, so that we can be sure that we have enough wallet inputs to at least try to publish the anchor transaction.

Hmm however I think one input for all the anchor sweeps is enough, because as soon as one succeeds we can be sure the others won't make it into the mempool anyways ?

I added a TODO to investigate it.

Copy link
Member

Choose a reason for hiding this comment

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

For full nodes yes, for neutrino nope - for instance when a local force close happens, and we only have one wallet utxo, that utxo could be used to bump the remote anchor, while an error won't be returned there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense, you mean we should generalize this behavior because this test for example skips the neutrino case, however you are right if we are not generalizing it we might run into this problem when all of a sudden we want to support the neutrino case here.

itest/lnd_sweep_test.go Show resolved Hide resolved
docs/release-notes/release-notes-0.18.3.md Outdated Show resolved Hide resolved
Add a new bumpforceclosefee rpc endpoint to the wallet server.
Move the logic from the lncli level to the wallet server rpc level.
This is more in line with a proper client-server design.

wallet lncli: use new bumpforceclosefee endpoint.

Besides using the new bumpforceclosefee rpc endpoint we also enable the
bumping of taproot anchor channels.
Legacy Channel types are not tested anymore via the multi-hop
test harness, therefore we can remove unused code.
@ziggie1984 ziggie1984 force-pushed the bumpforceclosefee-rpc branch 2 times, most recently from 780ced1 to 68781ca Compare August 9, 2024 17:39
return the transaction when found in the mempool.
Add an itest which will bump the close fee rate of an anchor
channel which is force closed without having any HTLCs at stake.
Make sure we only trigger the sweep of a specific input when
updating its fee parameters not the all the current pending
registered sweeps.
@ziggie1984 ziggie1984 force-pushed the bumpforceclosefee-rpc branch from 68781ca to 08aba8c Compare August 9, 2024 17:41
@ziggie1984 ziggie1984 requested a review from yyforyongyu August 9, 2024 18:36
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, will hold the merging until 0.18.3 is out so we don't need to cherry-pick on the master.

@@ -0,0 +1,56 @@
# Release Notes
Copy link
Member

Choose a reason for hiding this comment

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

🙏

@guggero
Copy link
Collaborator

guggero commented Aug 12, 2024

0.18.3 is on a side branch, there is no merge freeze in effect.

@guggero guggero merged commit 2f2efc7 into lightningnetwork:master Aug 12, 2024
23 of 34 checks passed
@ziggie1984 ziggie1984 deleted the bumpforceclosefee-rpc branch August 12, 2024 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channel closing Related to the closing of channels cooperatively and uncooperatively force closes P1 MUST be fixed or reviewed rpc Related to the RPC interface
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[bug]: Not able to bumpclosefee of an anchor channel in a special case (no HLTCs at stake).
7 participants