lightning icon indicating copy to clipboard operation
lightning copied to clipboard

Renepay patch htlc_max=0 cases

Open Lagrang3 opened this issue 1 year ago • 0 comments

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 https://github.com/ElementsProject/lightning/pull/6905#issuecomment-1839183009 ---such that the maximum allowed flow in a channel does not exceed htlc_max.

To-do list:

  • [x] local channels
  • [x] remote channels

Lagrang3 avatar Mar 18 '24 08:03 Lagrang3