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

Allow for user-specified error message during force close channel #2889

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

Sharmalm
Copy link
Contributor

This Pr solves issue #2840

Copy link

coderabbitai bot commented Feb 11, 2024

Important

Auto Review Skipped

Draft detected.

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.

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-tests 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 tests 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 tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Thanks!

lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2024

Codecov Report

Attention: Patch coverage is 98.24561% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 90.21%. Comparing base (ac9a2c8) to head (d17e759).
Report is 41 commits behind head on main.

Files Patch % Lines
lightning/src/ln/channelmanager.rs 94.44% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2889      +/-   ##
==========================================
+ Coverage   89.42%   90.21%   +0.78%     
==========================================
  Files         117      118       +1     
  Lines       96290   104723    +8433     
  Branches    96290   104723    +8433     
==========================================
+ Hits        86109    94475    +8366     
- Misses       7962     8097     +135     
+ Partials     2219     2151      -68     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sharmalm
Copy link
Contributor Author

I have updated the PR, Please review. :)

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Feel free to squash the fixup commits as you go. Please write a much more detailed commit message describing what was changed and why.

lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
fuzz/src/full_stack.rs Outdated Show resolved Hide resolved
@Sharmalm
Copy link
Contributor Author

I have updated the above changes in my Pr.

@Sharmalm
Copy link
Contributor Author

Gentle reminder for the review.

@Sharmalm
Copy link
Contributor Author

Sharmalm commented Mar 4, 2024

If every thing looks good, I will squash it.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Please proofread your commit before you push, don't rely on reviewers.

lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
@Sharmalm
Copy link
Contributor Author

Please proofread your commit before you push, don't rely on reviewers.

Understood, I'll keep in mind in future.

@Sharmalm
Copy link
Contributor Author

I have Proofread my commits, and i think it is fulfilling the objectives of issue, if not I'll update the PR accordingly :)

@TheBlueMatt
Copy link
Collaborator

Basically LGTM! Please squash the commit history so that each commit stands on its own and compiles+passes tests and no later commits are fixing/cleaning up things from previous commits (in this PR I think that probably means just one commit). Also please line-wrap the commit message(s) to 70 chars. Finally, note that your diff has some end-of-line whitespace in a few places. A local git show should highlight them for you so you can remove them.

@Sharmalm
Copy link
Contributor Author

Ok,
Thankyou @TheBlueMatt for the guidance to complete this PR.

@TheBlueMatt
Copy link
Collaborator

Please line-wrap your commit message text.

@Sharmalm Sharmalm marked this pull request as ready for review March 21, 2024 09:11
@Sharmalm
Copy link
Contributor Author

Sharmalm commented Apr 2, 2024

Please line-wrap your commit message text.

Is it fine now?

@TheBlueMatt
Copy link
Collaborator

No? The lines are still longer than 70 chars?

@Sharmalm
Copy link
Contributor Author

Sharmalm commented Apr 9, 2024

Done.

@TheBlueMatt
Copy link
Collaborator

CI thinks there's still places that need updating to the new API (possibly needs rebase), other than that this LGTM.

@Sharmalm Sharmalm force-pushed the 2840 branch 2 times, most recently from d20bb25 to fd1f2dc Compare April 17, 2024 06:59
@Sharmalm
Copy link
Contributor Author

CI is also done.
Thanks :)

@TheBlueMatt
Copy link
Collaborator

CI is still failing, see the check_commits and fuzz jobs.

@Sharmalm
Copy link
Contributor Author

Sorry about that, I missed it.

In this commit i added additional parameter `error_message` to
`force_close_sending_error`. This parameter will allow users to
configure error message and send to peers during the force closing
of channel.I have also updated the tests for this updated function.
@TheBlueMatt
Copy link
Collaborator

LGTM, but will need to wait for the next release.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Test changes could be cleaned up, but its fine enough.

@@ -3592,6 +3593,7 @@ fn do_claim_from_closed_chan(fail_payment: bool) {
// height.
connect_blocks(&nodes[3], final_cltv - HTLC_FAIL_BACK_BUFFER - nodes[3].best_block_info().1
- if fail_payment { 0 } else { 2 });
let error_message = "Channel force-closed";
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to keep the variable creation close to the place they're used.

@@ -3601,7 +3603,7 @@ fn do_claim_from_closed_chan(fail_payment: bool) {
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(&nodes[3], [reason]);
pass_failed_payment_back(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_hash, PaymentFailureReason::RecipientRejected);
} else {
nodes[1].node.force_close_broadcasting_latest_txn(&chan_bd, &nodes[3].node.get_our_node_id()).unwrap();
nodes[1].node.force_close_broadcasting_latest_txn(&chan_bd, &nodes[3].node.get_our_node_id(), error_message.to_string()).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It woudl be nice to move the .to_string() to the error_message declaration, reducing the amount of text on the force_close lines.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess alternatively, the force_close method could be made to accept &str, or both &str and String?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It could, but inside it needs a String anyway, so we really want that to be the API. Otherwise, eg, the user might do &format!(..), resulting in an allocation of a string, then a reference to it passed to LDK, which then unnecessarily clones.

@arik-so arik-so merged commit 993cd1e into lightningdevkit:main Jun 3, 2024
16 checks passed
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