-
Notifications
You must be signed in to change notification settings - Fork 117
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
[custom channels]: enforce minimum amounts #1252
Conversation
Pull Request Test Coverage Report for Build 12377264530Details
💛 - Coveralls |
4a8c953
to
e4d5219
Compare
Taking this out of draft, since |
1b74e37
to
ea99e95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Don't we also want to enforce a min-amt when creating an invoice?
Current commits seem to only protect the payer, would be useful to know that my invoice is uneconomical when I create it too
Thanks for the review. Isn't that what 9abedab does? |
|
Oh, probs missed it. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏌️ ⛳
Generally, I'm wondering if the root cause of this should be fixed instead. Pretty soon, 354 sat is going to buy a soda or candy bar. How can we not make small payments? Seems like a real limitation. There is discussion of symmetric/bidirectional HTLC in #888 . Why introduce this this additional code complexity when it isn't going to even be needed when #888 is fixed? |
@ZZiigguurraatt From what I understand, I think the idea is to work on both solutions? So that we can get RC3 out and then a long term solution also. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far. I still have a little more to review...
Nice work tracking down this issue! Thought about it a bit, and one issue I see with this solution is that even once we remove the behavior where we push the 354 sat HTLC across each time, this issue (trying to pay an invoice < 354 sats) still exists. Due to the NgU technology, 354 sats == ~35 cents, meaning that users won't be able to send amounts below that value with this change. Assuming NgU continues, the smallest invoice a user can pay will only grow. I think an alternative way to resolve this, would be to modify the This fails as we're still expecting the normal BTC routing fee to be paid on the last hop. If we relax this for HTLCs w/ the proper set of custom records (adding stricter checks/parsing), then we'd enable smaller invoices to be paid. This isn't without a tradeoff though, as naively the last hop will still lose money (eg: 1 sat incoming, but send 354 out, a loss of 353 sats). One way to side step this would be to also pay that last forwarding node a portion of the routing fee in the asset unit. Unfortunately, this doesn't work when the receiver doesn't yet have any asset units to give to the other side. TL;DR: NgU makes dust actually worth something, which hinders the smallest invoice that can be paid until the dust policy is abolished... |
// We now calculate the minimum amount of asset units that can be | ||
// transported within a single HTLC for this asset at the given rate. | ||
// This corresponds to the 354 satoshi minimum non-dust HTLC value. | ||
minTransportableUnits := rfqmath.MinTransportableUnits( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we actually need this value in the sell quote? In that we shouldn't even attempt to send if based on the rate returned by the outgoing edge peer, the transit HTLC amt would be below dust
Thought we needed this instead on the sell side, but once we remove the need to push 354 sats each time, users will be able to pay sat amts smaller than the dust limit since there'll be no HTLC amt swapping at the last hop.
rate BigIntFixedPoint) lnwire.MilliSatoshi { | ||
|
||
// We can only transport at least one asset unit in an HTLC. And we | ||
// always have to send out an HTLC with a BTC amount of 354 satoshi. So |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to send out 354 sats? Or does this only apply while we push 354 sats each time?
Assuming that's lifted, then we only push an asset value, allowing the routing node to send any amount outgoing, since we don't need to anchor any assets to that outgoing HTLC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this calculation only applies until we add the symmetric HTLC trick. Then we can delete both of these functions (I think).
Because without #888 things will fail in unexpected ways that are hard to understand for the user when small amounts are involved. So instead of running into weird timeouts or Waiting for #888 isn't really an option for RC3 since that is quite complicated and involved to implement. |
Since the field was renamed internally in the RFQ messages, we also update the RPC fields to better reflect the meaning of the field.
We'll want to be able to parse the amount and expiry of an invoice in other places, so we extract that into its own method.
ea99e95
to
967d866
Compare
With this commit we reject the payment of small invoices by using assets, if the total amount of sending 1 asset unit plus the protocol-dictated 354 satoshi for a non-dust HTLC is higher than the total invoice amount attempting to be paid. The user can override this decision with a new flag if they wish to proceed with the uneconomical payment.
967d866
to
5fcff90
Compare
Fixes #1240.
This PR introduces new minimum transportable amounts (asset units for invoice creation/buy quotes and milli-satoshi for sending payments/sell quotes) and then enforces them in the corresponding Taproot Asset Channel RPCs.
Because attempting to create an invoice for a too low amount would result in a payment that cannot be forwarded by the edge node (
FeeInsufficient
error on forwarding, see Godoc comment onrfqmath.MinTransportableUnits
function), creating such invoices is prevented.On the other side, when attempting to pay a small invoice with assets, the payment is rejected. But because it can succeed, the user has the option to override and send the payment anyway, even if that would be uneconomical.
For reference, here's the Godoc (and code) of
rfqmath.MinTransportableUnits
that explains theFeeInsufficient
problem:Just for clarity: This enforcement will no longer be necessary once we address #888 with the symmetric HTLC construction.