lnd icon indicating copy to clipboard operation
lnd copied to clipboard

invoice+rpc: add exit hop InvoiceAcceptor sub-systems and RPC calls

Open ffranr opened this issue 10 months ago • 9 comments

Change Description

Closes https://github.com/lightningnetwork/lnd/issues/8616

This pull request introduces the following components:

  1. An interceptor service for invoice settlements.
  2. An invoice acceptor RPC server and endpoint which makes use of the invoice settlement interceptor.
  3. An integration test demonstrating the settlement of an invoice through the invoice acceptor, using a HTLC with an amount smaller than the specified invoice amount.

Steps to Test

Steps for reviewers to follow to test the change.

Pull Request Checklist

Testing

  • [ ] Your PR passes all CI checks.
  • [ ] Tests covering the positive and negative (error paths) are included.
  • [ ] Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

ffranr avatar Apr 19 '24 14:04 ffranr

[!IMPORTANT]

Auto Review Skipped

Auto reviews are disabled on this repository.

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

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.
  • 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[bot] avatar Apr 19 '24 14:04 coderabbitai[bot]

@jharveyb and @GeorgeTsagk will review

dstadulis avatar Apr 23 '24 18:04 dstadulis

I think I also need to pass circuit key for latest HTLC along with invoice to settlement interceptor client. This way the client can inspect the correct HTLC.

ffranr avatar Apr 24 '24 15:04 ffranr

I think I also need to pass circuit key for latest HTLC along with invoice to settlement interceptor client. This way the client can inspect the correct HTLC.

This is included in the latest commits.

ffranr avatar Apr 25 '24 11:04 ffranr

I'm in the process of writing an itest for this PR. I noticed that providing the exit HTLC circuit key to the acceptor interceptor client is insufficient. The invoice will only include the exit HTLC if it is a replayed HTLC.

I will therefore need to provide fields from the invoice update context to the interceptor client. I will make changes to that effect.

ffranr avatar Apr 25 '24 14:04 ffranr

reviewed diff, left out the WIP commits also haven't locally tested anything

GeorgeTsagk avatar Apr 30 '24 12:04 GeorgeTsagk

Latest state:

  1. New integration test which shows that an invoice can be forced into the settled state (using the new interceptor) when the exit HTLC amount is less than the invoice amount.

  2. The latest modifications account for the MPP invoice settlement flow.

  3. I've simplified and reduced the necessary code changes.

Things to consider:

  1. The smallest exit HTLC payment amount I could send was 1000 msat. I'm not sure if we're hopping to send 0.

  2. We may need to add additional fields to the interceptor client request (provide more data to the interceptor client). In particular the custom records that are sent along with the p2p messages (UpdateAddHtlc etc.). That is not currently implemented.

ffranr avatar Apr 30 '24 17:04 ffranr

1. The smallest exit HTLC payment amount I could send was 1000 msat. I'm not sure if we're hopping to send 0.

IIRC the plan was for the HTLC to be >= dust threshold / 330ish sats, so that seems fine.

jharveyb avatar May 01 '24 16:05 jharveyb

@roasbeef: review reminder @jharveyb: review reminder @georgetsagk: review reminder

lightninglabs-deploy avatar May 15 '24 17:05 lightninglabs-deploy

I need to double check whether there are modifications in the PoC branch which relate to this PR.

ffranr avatar May 17 '24 16:05 ffranr

Replaced by https://github.com/lightningnetwork/lnd/pull/8771.

guggero avatar May 22 '24 16:05 guggero