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

[6/5]: invoice+rpc: add exit hop InvoiceAcceptor sub-systems and RPC calls #8771

Merged
merged 12 commits into from
May 28, 2024

Conversation

guggero
Copy link
Collaborator

@guggero guggero commented May 22, 2024

Replaces #8669.

Closes #8616

This pull request introduces the following components:

  • An interceptor service for invoice settlements.
  • An invoice acceptor RPC server and endpoint which makes use of the invoice settlement interceptor.
  • 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.

Link to all PRs in the saga:

Copy link
Contributor

coderabbitai bot commented May 22, 2024

Important

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.
    • @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 as 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 full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.

@guggero
Copy link
Collaborator Author

guggero commented May 22, 2024

This isn't ready for review yet. And for some reason I can't put it back to draft anymore, sorry.

@guggero
Copy link
Collaborator Author

guggero commented May 24, 2024

PR is now ready to review.

invoices/invoiceregistry.go Outdated Show resolved Hide resolved
lnrpc/invoicesrpc/htlc_interceptor.go Outdated Show resolved Hide resolved
lnrpc/invoicesrpc/htlc_interceptor.go Outdated Show resolved Hide resolved
lnrpc/invoicesrpc/htlc_interceptor.go Outdated Show resolved Hide resolved
lnrpc/invoicesrpc/invoices.proto Show resolved Hide resolved
lnrpc/invoicesrpc/invoices_server.go Outdated Show resolved Hide resolved
lntest/harness.go Outdated Show resolved Hide resolved
@guggero guggero force-pushed the custom-channels-integration branch 2 times, most recently from c6b7ef7 to 13828b7 Compare May 27, 2024 11:47
@guggero guggero force-pushed the custom-channels-integration-invoice branch from 6c31983 to 7158c31 Compare May 27, 2024 13:35
@guggero guggero requested a review from ffranr May 27, 2024 13:36
@guggero guggero force-pushed the custom-channels-integration branch from 13828b7 to f2e71de Compare May 27, 2024 13:53
@guggero guggero force-pushed the custom-channels-integration-invoice branch from 7158c31 to 3d167f3 Compare May 27, 2024 13:53
Copy link
Collaborator

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

looking good
CI is unhappy


// MockHtlcModifier is a mock implementation of the HtlcModifier interface.
type MockHtlcModifier struct {
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't the mocks live under some test related pkg?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately in Go we can't import test code from one package into the other. And because we need the mock in multiple packages, it needs to be defined in non-test code.

@guggero guggero force-pushed the custom-channels-integration-invoice branch from 3d167f3 to f9d0aa1 Compare May 27, 2024 16:20
@guggero guggero force-pushed the custom-channels-integration branch from f2e71de to d2d5064 Compare May 27, 2024 16:20
Base automatically changed from custom-channels-integration to 0-19-staging May 27, 2024 18:22
guggero and others added 8 commits May 27, 2024 20:23
This commit introduces a new invoice htlc interceptor service
that intercepts invoice HTLCs during their settlement phase. It forwards
HTLCs to a subscribed client to determine their settlement outcomes.

This commit also introduces an interface to facilitate integrating the
interceptor with other packages.
This commit updates the invoice registry to utilize the settlement
interceptor during the invoice settlement routine. It allows the
interceptor to capture the invoice, providing interception clients an
opportunity to determine the settlement outcome.
This commit initiates the invoice settlement interceptor during the
main server startup, assigning it a handle within the server.
This commit integrates the HTLC modifier service into the
invoices RPC server.
@guggero guggero force-pushed the custom-channels-integration-invoice branch from f9d0aa1 to d593663 Compare May 27, 2024 18:23
@guggero guggero requested a review from GeorgeTsagk May 27, 2024 18:24
This commit introduces a singleton invoice HTLC modifier RPC server and
an endpoint to activate it. The server interfaces with the internal
invoice HTLC modifier interpreter, handling the marshalling between RPC
types and internal formats.
This commit enhances the itest LND node harness to include support for
the new `HtlcModifier` RPC endpoint.
At the same time we move another method to the correct file.
This commit introduces a basic integration test for the invoice
HTLC modifier. The test covers scenarios where an invoice is settled with a
payment that is less than the invoice amount, facilitated by the invoice
HTLC modifier.
@guggero guggero force-pushed the custom-channels-integration-invoice branch from d593663 to db61508 Compare May 27, 2024 18:35
@guggero guggero force-pushed the custom-channels-integration-invoice branch from db61508 to 197b291 Compare May 28, 2024 06:48
@guggero
Copy link
Collaborator Author

guggero commented May 28, 2024

Fixed the CI, ready for final look.

Copy link
Collaborator

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

Looks good!

map<uint64, bytes> exit_htlc_wire_custom_records = 6;
}

message HtlcModifyResponse {
Copy link
Collaborator

Choose a reason for hiding this comment

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

my only side note in this PR is that we may wanna add more stuff here in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I guess we might want to, but it's not clear right now if we actually need to. So leaving off a TODO for now to avoid needing to trigger another CI run. But added this comment to the tracking issue.

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.

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