Skip to content

Conversation

@majiayu000
Copy link

Fixes #8957

Changes

  • Changed the ErrBelowChanReserve error message from the terse "commitment transaction dips peer below chan reserve" to a more user-friendly message that explains what went wrong and why channel reserves exist
  • The new message helps developers and users understand the constraint and educates them about Lightning channel mechanics

This commit updates the ErrBelowChanReserve error message to be more
user-friendly and descriptive. The old message "commitment transaction
dips peer below chan reserve" was technical and confusing for users.

The new message clearly explains:
- What happened: "cannot complete request: insufficient funds"
- Why: "to maintain required channel reserve"
- What channel reserve is: ensures both parties have incentive to
  behave honestly

Fixes lightningnetwork#8957

Signed-off-by: majiayu000 <[email protected]>
@gemini-code-assist
Copy link

Summary of Changes

Hello @majiayu000, 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 focuses on enhancing the user experience by making a critical error message more informative. By clarifying the ErrBelowChanReserve message, it helps users and developers better understand the constraints of Lightning channels and the importance of maintaining reserves, thereby streamlining troubleshooting and promoting a deeper understanding of the network's operational principles.

Highlights

  • Improved Error Message: The ErrBelowChanReserve error message has been updated from a terse phrase to a more descriptive and user-friendly explanation, detailing why the error occurred and the purpose of channel reserves.
  • Enhanced User Experience: The new error message aims to improve the user experience by providing clearer guidance and educating developers and users about the underlying mechanics of Lightning channel reserves.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

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

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 improves the user experience by providing a more descriptive error message for ErrBelowChanReserve. The new message clarifies why the operation failed and explains the purpose of channel reserves. While the change is good, the formatting of the multi-line string can be improved to better align with the repository's style guide.

Comment on lines 67 to 70
ErrBelowChanReserve = fmt.Errorf("cannot complete request: " +
"insufficient funds available to maintain required channel " +
"reserve (this reserve ensures both parties have skin in " +
"the game to discourage cheating)")

Choose a reason for hiding this comment

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

medium

While the new error message is much more descriptive, the formatting can be made more compact to better align with the style guide's preference for minimizing lines in error messages. The current formatting uses four lines for the string concatenation, which could be reduced.

Suggested change
ErrBelowChanReserve = fmt.Errorf("cannot complete request: " +
"insufficient funds available to maintain required channel " +
"reserve (this reserve ensures both parties have skin in " +
"the game to discourage cheating)")
ErrBelowChanReserve = fmt.Errorf("cannot complete request: " +
"insufficient funds available to maintain required channel " +
"reserve (this reserve ensures both parties have skin in the game " +
"to discourage cheating)")
References
  1. The style guide at lines 210-211 states that lines for log and error messages should be minimized. The current implementation uses four lines for the error string, which can be made more compact. (link)

@lightninglabs-deploy
Copy link

@majiayu000, remember to re-request review from reviewers when ready

Refactor the error message to use 2 lines instead of 4, following review feedback.
@majiayu000
Copy link
Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 improves the error message for ErrBelowChanReserve to provide a better user experience. The change is a good improvement. I've suggested making the new message more concise for better readability, while retaining all the useful information.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@majiayu000
Copy link
Author

@Roasbeef I've updated the error message formatting as suggested. Ready for review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature]: More Descriptive Error on Attempted Spend from Reserve

2 participants