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

Handle onion creation failure #314

Closed
wants to merge 1 commit into from
Closed

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Dec 10, 2021

If we have too much data to include in the onion, its creation will fail.
This wasn't handled explicitly before, as we thought there was no reason we would overflow the onion space.

However, it happened when invoices contained too many route hints, and it can now happen if invoices contain too much payment metadata (or too many features), so we need to handle it explicitly and provide a clear error to the user.

I'm not a huge fan of the complexity it brings to the OutgoingPaymentHandler, if you have suggestions on how we could improve it that would be great.

EDIT: once we move to variable-size trampoline onions, we probably don't need that change anymore and can instead set a hard-coded limit on invoice data before creating the onion.

@@ -14,6 +14,7 @@ sealed class FinalFailure {

// @formatter:off
object AlreadyPaid : FinalFailure() { override fun toString(): String = "this invoice has already been paid" }
object InvoiceTooBig : FinalFailure() { override fun toString(): String = "this invoice contains too much metadata to be paid" }
Copy link
Member Author

Choose a reason for hiding this comment

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

@dpad85 @robbiehanson what do you think of this error? I believe we need to surface to the user that this problem is caused by this specific invoice that they are trying to pay, and that some of the fields it contains force us to send too much data to the recipient, which we cannot do.

This shouldn't happen often, but when it does, it's good that it's explicitly handled. We currently use an inefficient trampoline scheme where the onion is capped at 400 bytes, we will change that to a variable-size onion which should improve the issue if we see it happening regularly once option_payment_metadata starts being deployed.

Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense. The error message would get surfaced to the user. On iOS, this info gets displayed in the payment details screen. For a developer, or anybody helping to debug, this would be very useful information.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, the UI needs as much info as it can get. We don't have to display everything right away, but this is a good thing to have and we can also reformat those messages easily if needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, then this should find its way into lightning-kmp soon (I've stacked a few PRs on top of each other)

If we have too much data to include in the onion, its creation will fail.
This wasn't handled explicitly before, as we thought there was no reason
we would overflow the onion space.

However, it happened when invoices contained too many route hints, and it
can now happen if invoices contain too much payment metadata, so we need
to handle it explicitly and provide a clear error to the user.
@t-bast t-bast force-pushed the handle-onion-creation-failure branch from 574df26 to 6bb2712 Compare February 8, 2022 14:09
@t-bast
Copy link
Member Author

t-bast commented Feb 19, 2024

Closing this PR, as we may be able to implement a final spec version of trampoline, which would make this easier to check before-hand that we won't overflow the onion and won't need that weird additional code.

@t-bast t-bast closed this Feb 19, 2024
@t-bast t-bast deleted the handle-onion-creation-failure branch February 19, 2024 10:33
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.

None yet

3 participants