lnd
lnd copied to clipboard
bumpforceclosefee rpc
Fixes https://github.com/lightningnetwork/lnd/issues/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 🙏
[!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 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
- lightningnetwork/lnd#8680: The changes enhance the sweeper's functionality, addressing the need for properly managing anchor outputs and fees.
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?
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.
@coderabbitai review
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.
[!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 68494fd91d69ccdd3e72a5eaca593b6e42babe23 and 219764f418dac9f25fd0f64a50559d5c4fa652cd.
Files ignored due to path filters (5)
lnrpc/walletrpc/walletkit.pb.gois excluded by!**/*.pb.go,!**/*.pb.golnrpc/walletrpc/walletkit.pb.gw.gois excluded by!**/*.pb.gw.go,!**/*.pb.gw.golnrpc/walletrpc/walletkit.swagger.jsonis excluded by!**/*.jsonlnrpc/walletrpc/walletkit.yamlis excluded by!**/*.yamllnrpc/walletrpc/walletkit_grpc.pb.gois excluded by!**/*.pb.go,!**/*.pb.goFiles 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?
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 Configration 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.
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 ...
waiting for https://github.com/lightningnetwork/lnd/pull/8717, so that itests are not updated twice.
I think this should be moved to 0.19 since we are adding an RPC?
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
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.
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.
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 :)
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.
@ProofOfKeags this is the main question I have not sure if you saw it ?
Ok will split into 2 PR's.
Regarding the parent fee rate I am still undecided especially considering the above mentioned flow.
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.
I will for now remove my addition of the parent weight consideration, so we can move on and merge this PR, however we might run into unpleasant behaviour when our commitment transaction is always broadcasted underestimating the fees.
Addressed all the comments, splitted the PR into two, first 3 commits of this PR belong to the other PR but we need this change so that the new itest will pass. Otherwise removed all the parent fee rate considerations which had the positive side effect of not breaking all the itests 😄.
@coderabbitai review
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.
@yyforyongyu: review reminder @ziggie1984, remember to re-request review from reviewers when ready
0.18.3 is on a side branch, there is no merge freeze in effect.