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

Renepay patch htlc_max=0 cases #7159

Merged

Conversation

Lagrang3
Copy link
Collaborator

@Lagrang3 Lagrang3 commented Mar 18, 2024

This solves issue #7150.

Renepay does not handle properly the case in which htlcmax=0 in the gossmap channels.
There are two cases that are to be considered separately: local channels and remote channels.

Local channels

When a local channel has htlcmax=0 the sender should ignore this value because the htlcmin/htlcmax constraints only apply to forwarded HTLCs, see setchannel documentation. We handle this case by setting a gossmap modifier (gossmap_localmods) in which htlc constraints are lifted from local channels, i.e. htlcmin=0 and htlcmax=spendable.

For reviewers: renepay creates the localmods by parsing a call to listpeerchannels, but recently it has been changed to use the gossmods_from_listpeerchannels API. The current implementation of that API would automatically forward to the user's callback function a unified value max = min(htlmax, spendable).
I've changed that, so now instead of the unified max value the callback function receives separate htlcmax and spendable amounts, so than I can use this functionality to ignore the htlcmax limit on local channels.

Remote channels

Not just htlc_max=0 is a problem but also small values of it. I think the best option here is to limit the arcs' capacities
in the Min. Cost Flow solver---as suggested by @renepickhardt in #6905 (comment) ---such that the maximum allowed flow in a channel does not exceed htlc_max.

To-do list:

  • local channels
  • remote channels

@Lagrang3 Lagrang3 marked this pull request as ready for review March 27, 2024 12:06
@Lagrang3 Lagrang3 changed the title [WIP] Renepay patch htlc_max=0 cases Renepay patch htlc_max=0 cases Mar 27, 2024
Add spendable/receivable and is_local fields to the callback function
used in gossmods_from_listpeerchannels. This allows to do more fine
grained use of the listpeerchannels call.
The first use case is renepay, for which we need to ignore the htlc_max
of the local channels only.
In the Min. Cost Flow solver we put a constraint on arcs capacities,
such that the total flow that can be allocated through a channel does
not exceed htlc_max. This solves two previous problem of the htlc_max
constraint at the MCF level.
@Lagrang3 Lagrang3 mentioned this pull request Mar 28, 2024
Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Concept ACK d94d15d

I am still digesting the match around raypay and the logic, so I can not of for an ACK, but code LGMT :)

Added a small comment inside the test that it is more an idea

Comment on lines +680 to +683
l1.rpc.call("renepay", {"invstring": inv["bolt11"]})
l1.wait_for_htlcs()
invoice = only_one(l6.rpc.listinvoices("inv")["invoices"])
assert invoice["amount_received_msat"] >= Millisatoshi("600000sat")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not relevant to this PR, but I think that maybe would be good for this kind of testing to know what is the path that the payment is taking.

Maybe we can add this as a pay result?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Neither pay does this, we get this kind of information from logs alone.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Neither pay does this, we get this kind of information from logs alone.

My idea was also to implement it inside vanilla pay

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if renepay gave the successful paths in the response, though that's pretty verbose!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What if the response from waitsendpay (as well as the payment success/failure notification) had a field with the route?
In renepay there is an internal database of these routes pushed to sendpay so that the plugin knows when a specific (groupid, partid) fail or succeeds it can recover which route was that and act accordingly, for example by updating the uncertainty/knowledge. If the route was already provided through the result of waitsendpay it would be easier and less fragile on renepay's side.

common/gossmods_listpeerchannels.h Outdated Show resolved Hide resolved
plugins/renepay/pay.c Show resolved Hide resolved
Comment on lines +680 to +683
l1.rpc.call("renepay", {"invstring": inv["bolt11"]})
l1.wait_for_htlcs()
invoice = only_one(l6.rpc.listinvoices("inv")["invoices"])
assert invoice["amount_received_msat"] >= Millisatoshi("600000sat")
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if renepay gave the successful paths in the response, though that's pretty verbose!

is_local, ie. "is this side of the channel ours?" is not needed since we
can determine that predicate by evaluating
`scidd->dir == node_id_idx(self, peer)`
Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

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

Ack e5c705f

@rustyrussell rustyrussell merged commit bb31856 into ElementsProject:master Apr 2, 2024
35 checks passed
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.

3 participants