-
Notifications
You must be signed in to change notification settings - Fork 2.2k
lncli: validate negative sat_per_vbyte in closechannel #10208
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @Suvrat1629, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request enhances the robustness of the lncli closechannel command by implementing client-side validation for the --sat_per_vbyte parameter. This change prevents the acceptance of negative fee rate inputs, which previously caused incorrect fee calculations due to integer wrapping, thereby improving the reliability of channel closure operations.
Highlights
- lncli closechannel Bug Fix: Resolves a bug where negative --sat_per_vbyte values were incorrectly processed, leading to large uint64 values and invalid fee rates.
- Negative Fee Rate Validation: Introduces explicit validation to reject negative inputs for the sat_per_vbyte flag in lncli closechannel, aligning behavior with gRPC and preventing unexpected fee calculations.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly adds validation to prevent negative values for sat_per_vbyte
in lncli closechannel
, which previously caused an integer overflow. The implementation is sound. My review includes a suggestion to make the comments more concise and aligned with the project's style guide, which prefers explaining the 'why' over the 'what'.
I managed to reproduce the original bug in regtest (LND 0.19.0). In LNG log I see the following:
From this I conclude that the sent value was 0, not -1. |
Other commands may be also affected by this: cmd/commands/cmd_open_channel.go: cmd/commands/commands.go: All of them have flag I propose to apply the fix to all of them. |
Please also change it for this command: cmd/commands/cmd_open_channel.go: |
@starius That should wrap it I guess. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure to follow the Pull Request Checklist
.
@yyforyongyu Sorry could you be a bit more specific this is my first time contributing to lnd. You need me to add test cases for the changes I have made I presume? |
@starius I was taking a look to add the test case for the |
@Suvrat1629 please make sure that you've gone through these docs: |
@Suvrat1629 I'm not aware about a method this fix can be tested automatically. It is a fix of lncli, not lnd, so it can't be tested in itests IIUC. |
@starius Sorry I don't know exactly what is expected of me here but I have added a test please take a look. I you find it unnecessary I will remove it. |
@Suvrat1629 I reworked the test and pushed the patch to this PR. If you like the approach, please squash all the commits and extend the test with other affected commands. |
1711175
to
d434631
Compare
@starius Well I have never squashed commits before but I have given it a shot and also extended the test cases please take a look. If there is any problem in the squashed commits I will close this pr and reopen it. |
@Suvrat1629 Check this how to squash multiple commits into one: https://stackoverflow.com/a/5189600 |
@starius Instead of working on squashing all commits I found an easier work around for this issue😅.Please take a look and tell me if it works for you. I apologize for the inconvenience I am causing over this pr. |
@Suvrat1629 The commit structure should be clear. There should not be merge commits in the PR.
This will rebase your changes on top of the master branch in the repo. Then squash everything left into a single commit using this instruction: https://stackoverflow.com/a/5189600 Then you can do |
3390258
to
031c69f
Compare
@starius Well I guess that should do it then. Once again thanks for your patience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left few comments.
Please change commit description to "lncli: validate negative sat_per_vbyte in closechannel".
031c69f
to
7c9c0b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the patch!
I checked the test - it captures the fix.
Please squash commits again into one commit.
27f3072
to
4bebbbc
Compare
@starius I have squashed the commits into one. Thanks for your patience and guidance learned quite a few things and also got started with contributing in lnd :) |
@yyforyongyu: review reminder |
@yyforyongyu @saubyk Gentle ping please take a look. |
Change Description
This PR fixes a bug in
lncli closechannel
(Issue #9834) where a negative--sat_per_vbyte
(e.g., -1) was accepted and wrapped to a largeuint64
, causing invalid fee rates. It adds validation to reject negative values, aligning with gRPC behavior.Steps to Test
Steps for reviewers to follow to test the change.
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]
in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.