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

Make BumpFee RPC user inputs more stricter. #9470

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Feb 1, 2025

The BumpFee RPC input parameters are changed with this PR.

For the lncli we do not allow to change the width of the fee-function. The conf_target which is specified changes the starting fee rate of the fee function. Which means the initial broadcasting fee if it's an CPFP transaction.

Copy link
Contributor

coderabbitai bot commented Feb 1, 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. (Beta)
  • @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.

@Roasbeef
Copy link
Member

Roasbeef commented Feb 4, 2025

If we want to get this into a minor release, I think it makes sense to add the new checks at the CLI level first. Then for 0.19, for bump fee that isn't coming from an internal sub-system (we can add some internal attribute to track this), we'll enforce a multiplier check to prevent excessive fees. The multiplier can either be based on the total amount of the output being spent (to set a new default budget), or it can keep the old default budget, then enforce a multiplier based on what the actual conf target is.

// are only able to be swept once the deadline is already
// passed we precautiously fetch our chainbackend and make sure
// we limit the fee rate to the current conditions.
fee := FeeEstimateInfo{
Copy link
Member

Choose a reason for hiding this comment

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

i don't think we need to change the fee function - also this means we can never reach the budget?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes it will be reached for all sweep sets which are swept (published) before the deadline of 1. Here we will create the fee-function with the maxBudget as the value for the dealine of 1. However also here I would argue before just taking the feeRate according to the fee-function which we defined at the beginning of the sweep, it acutally makes sense to always query the blockchain for the particular conf-target.

Copy link
Member

Choose a reason for hiding this comment

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

With the internal vs external split, for the external we sort of just use a one-shot fee function, one that starts at it's terminal rate. This is intended to match the user's expectation that we do a one time bump with a CPFP transaction that has a fee rate that's exactly either the conf target or fee sat/vb.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should touch the sweep, instead, everything can already be handled via tuning the params used in making the sweep request. For instance, if we want to provide the functionality that allow user to do one-shot fee function, with the fee rate derived from a fee estimation, we can craft a request such as,

  • the user specify a conf target, which is used to perform the fee estimate
  • the budget is the estimated fee
  • the starting fee rate is the estimated fee rate
  • the deadline is 1

And send this request to the sweeper, which I believe is the idea of internal vs external split. The sweeper is already abstracted in a way such that any communication is done via the request, and by changing the fee function here, it gives extra behavior that's not contained in the interface, which is an abstraction violation. This can also be viewed as overexposure,

Overexposure: An API forces callers to be aware of rarely used features in order to use commonly used features.

So if we want to provide the feature, we should do the "internal vs external" split on the RPC layer, though I don't think we even need this feature as the original issue is, the user misunderstood the target-conf param, and what @guggero suggested should be enough to fix the issue.

Copy link
Member

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

I still think we want the internal vs external split here.

@yyforyongyu
Copy link
Member

I'm also not convinced this should be put in 0.18.5, as minor release should include important bug fixes only?

@guggero
Copy link
Collaborator

guggero commented Feb 6, 2025

I'm also not convinced this should be put in 0.18.5, as minor release should include important bug fixes only?

Agree. IMO we can do a more in-depth update to the sweeper mechanism in 0.19. But for 0.18.5 I'd suggest only doing CLI level validation (and/or confirmation from user) for potentially dangerous combinations of parameter values.

That can IMO be as simple as:

lncli bumpfee --conf-target 1
Warning: No budget defined. A block deadline of 1 block will instruct the sweeper to use up to 50% of the
transaction's input as fees to get into the next block. Please provide either a fee rate in sat/vByte or a
budget limit to avoid paying high fees.
Continue? y/n

@ziggie1984 ziggie1984 force-pushed the fix-sweepInput-bug branch 2 times, most recently from 99b9cf5 to de62b21 Compare February 6, 2025 11:33
@ziggie1984
Copy link
Collaborator Author

ziggie1984 commented Feb 6, 2025

What's your opinion about this new approach:

We interpret the conf_target as the starting fee estimation, and introduce a new parameter called deadline-delta as proposed by yy ? I think that's the cleanest fix we can do for now ? It does not touch the sweeper logic, but makes sure a budget is supplied in case the new parameter is used ?

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! I think this approach is good for 0.18.5.

This shouldn't really break anyone, as I don't expect the --conf-target was actually understood as deadline delta by any users. And lndclient only uses a sat/vByte fee rate, so our applications should just work as before.

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Almost there!

@ziggie1984 ziggie1984 force-pushed the fix-sweepInput-bug branch 2 times, most recently from e49cae3 to 69e1ee6 Compare February 6, 2025 13:54
@ziggie1984
Copy link
Collaborator Author

Fixing itests now.

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.

Approach ack, thanks!

@ziggie1984 ziggie1984 changed the title Make sure we fail the bump fee request as long as no budget is specified Make BumpFee RPC user inputs more stricter. Feb 6, 2025
@ziggie1984
Copy link
Collaborator Author

follow-up: #9487

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the fixes!

@ziggie1984 ziggie1984 force-pushed the fix-sweepInput-bug branch 2 times, most recently from fbf7d66 to 46555eb Compare February 6, 2025 22:28
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.

The cli needs to be updated, and a few typos, otherwise it's good to go.

The deadline in number of blocks that the input should be spent within.
When not set, for new inputs, the default value (1008) is used; for
exiting inputs, their current values will be retained.`,
The conf target is the starting fee rate of the fee function expressed
Copy link
Member

Choose a reason for hiding this comment

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

We should also update the docs for bumpclosefee. In addition, we should add the new param deadline_delta in the cli too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

very good point, updated the bumpclosefee and bumpforceclose RPCs as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

also added the conf_target (target_conf) to the bumpforceclose RPC

@yyforyongyu
Copy link
Member

Pending CI and a final squash, other LGTM🙏

Add new parameter deadline-delta to the bumpfee request and only
allow it to be used when the budget value is used as well.
@ziggie1984 ziggie1984 self-assigned this Feb 7, 2025
@ziggie1984
Copy link
Collaborator Author

Just Release docs. changed with the final push.

@yyforyongyu
Copy link
Member

looking good - can squash the fixup commit now

Copy link
Member

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

LGTM 🥇

@Roasbeef Roasbeef merged commit ce8cde6 into lightningnetwork:master Feb 7, 2025
30 of 34 checks passed
starius added a commit to starius/lndclient that referenced this pull request Feb 15, 2025
The conf-target only reflects this behaviour for the 0.18.5 release, before
the conf target had a different meaning:
lightningnetwork/lnd#9470

This commit can be undone after minimalCompatibleVersion is bumbed to 0.18.5.
starius added a commit to starius/lndclient that referenced this pull request Feb 15, 2025
The conf-target only reflects this behaviour for the 0.18.5 release, before
the conf target had a different meaning:
lightningnetwork/lnd#9470

This commit can be undone after minimalCompatibleVersion is bumbed to 0.18.5.
starius added a commit to starius/lndclient that referenced this pull request Feb 16, 2025
The conf-target only reflects this behaviour for the 0.18.5 release, before
the conf target had a different meaning:
lightningnetwork/lnd#9470

This commit can be undone after minimalCompatibleVersion is bumbed to 0.18.5.
starius added a commit to starius/lndclient that referenced this pull request Feb 16, 2025
The conf-target only reflects this behaviour for the 0.18.5 release, before
the conf target had a different meaning:
lightningnetwork/lnd#9470

This commit can be undone after minimalCompatibleVersion is bumbed to 0.18.5.
guggero pushed a commit to lightninglabs/lndclient that referenced this pull request Feb 19, 2025
The conf-target only reflects this behaviour for the 0.18.5 release, before
the conf target had a different meaning:
lightningnetwork/lnd#9470

This commit can be undone after minimalCompatibleVersion is bumbed to 0.18.5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants