<oembed><type>rich</type><version>1.0</version><author_name>npub1zlxd3xlzjhq2ue03e5m5p2w6mp8v3dkhq5r39flsftjjsje04wvsdd2k4w</author_name><author_url>https://nostr.ae/npub1zlxd3xlzjhq2ue03e5m5p2w6mp8v3dkhq5r39flsftjjsje04wvsdd2k4w</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2022-03-11&#xA;📝 Original message:&#xA;Dear fellow Lightning Developers,&#xA;&#xA;I am pleased (and a bit proud) to be able to inform you that I finally&#xA;found a quick way to approximate the slow minimum convex cost flow&#xA;computation. This is necessary for optimally reliable and cheap payment&#xA;flows [0] to deliver large multi part payments over the Lightning Network.&#xA;The proposed solution happens via piecewise linearization [1] of the min&#xA;cost flow problem on the uncertainty network which we face in order to&#xA;compute the optimal split and planning of large amount multi part payments.&#xA;The notion of &#34;optimal&#34; is obviously subjective with respect to the chosen&#xA;cost function. As known we suggest to include the negative logarithm of&#xA;success probabilities based on the likelihood that enough liquidity is&#xA;available on a channel as a dominant feature of the used cost function. We&#xA;give the background for this in [2] which since then has already been&#xA;picked up by c-lightning and LDK. The c-lightning team even published&#xA;benchmarks showing significant improvement in payment speed over their&#xA;previously used cost function [2b].&#xA;&#xA;Let me recall that one of the largest criticisms and concerns of our&#xA;approach to use minimum cost flows for payment delivery back in July /&#xA;August last year (especially by the folks from lightning labs) was that the&#xA;min cost flow approach would be impractical due to run time constrains.&#xA;Thus I am delighted that with the now published code [3] (which has exactly&#xA;100 lines including data import and parsing and ignoring comments) we are&#xA;able to compute a reasonable looking approximation to the optimal solution&#xA;in a sub second run time on the complete public channel graph of the&#xA;Lightning Network. This is achieved via piecewise linearization of the&#xA;convex cost function and invoking of a standard linear min cost flow solver&#xA;[4] for the linearized problem. This works quickly despite the fact that&#xA;the piecewise linearization adds a significant higher amount of arcs to the&#xA;network and blows up the size of the network on which we solve the min cost&#xA;flow problem. This makes me fairly certain that with proper pruning of the&#xA;graph we might even reach the 100 millisecond runtime frontier, which would&#xA;be far faster than what I dreamed &amp; hoped to be possible.&#xA;&#xA;The currently widely deployed Dijkstra search to generate a single&#xA;candidate path takes roughly 100ms of runtime. It seems that with the&#xA;runtime of the piecewise linearized problem the min cost flow approach is&#xA;now competitive from a runtime perspective. The flow computation is still a&#xA;bit slower than Dijkstra in both theory and practice. However the piecewise&#xA;linearized min cost flow has the huge advantage that it generates several&#xA;candidate paths for a solid approximation of the optimal MPP split.&#xA;Remember the exact min cost flow corresponds to the optimal MPP split. The&#xA;later was not used so far as the min cost flow was considered to be too&#xA;slow. Yet the question how to split seems to be addressed as issues in&#xA;implementations [5][6][7] and acknowledged to be complicated (especially&#xA;with respect to fees) in [8]. This result is btw of particular interest for&#xA;LSPs. If an LSP has to schedule x payments per second it can just do one&#xA;flow computation with several sink nodes and plan all of those payments&#xA;with a single min cost flow computation. This globally optimizes the&#xA;potentially heavy load that LSPs might have even if all payments were so&#xA;small that no splitting was necessary.&#xA;&#xA;The iPython notebook which I shared contains about 1 page to explain how to&#xA;conduct a piecewise linear approximation. The quality of the approximation&#xA;is not the major goal here as I am just focused to demonstrate the run time&#xA;of the approach and the principle how to achieve this runtime. Thus I do&#xA;the piecewise linear approximation very roughly in the published code.&#xA;Selecting the optimal piecewise approximation [9] will not change the the&#xA;runtime of flow computation but only blows up the code to prepare the&#xA;solver. This is why I decided to keep the code as simple and short as&#xA;possible even if that means that the approximation will be not as close to&#xA;the optimum as it could be in practice. For the same reason I did not&#xA;include any code to update the uncertainty network from previously failed&#xA;or successful attempts by using conditional success probabilities P(X&gt;a |&#xA;min_liquidity &lt; X &lt; max_liquidity ). People who are interested might look&#xA;at my hands on instructions and explanations for coders in this&#xA;rust-lightning issue [10]. The folks from LDK have picked this up and&#xA;implemented this already for single path payments in [11] which might be&#xA;relevant for people who prefer code over math papers. An obvious&#xA;optimization of the piece wise linearization would be to chose the first&#xA;segment of the piecewise linear approximation with a capacity of the&#xA;certain liquidity and a unit cost of 0 for that piece.&#xA;&#xA;Our original papers describe everything only from a theoretical point of&#xA;view and with simulations. However our mainnet experiments from July last&#xA;year [12] indicated that we easily have been able to deliver for example&#xA;0.3679 BTC via a couple rounds of min cost flow computations through the&#xA;Lightning Network (given we accept the computational waiting time). This&#xA;experiment was too slow to be used in practice but confirmed our model and&#xA;approach to deliver such large amounts. Given that the min cost flow&#xA;computation is now significantly below the median onion round trip times it&#xA;is my understanding that with these newly introduced techniques we should&#xA;be able to deliver substantial monetary amounts over the Lightning Network&#xA;within a couple of seconds despite the uncertainty about the Liquidity in&#xA;remote channels. While I am very excited about the result I think some&#xA;principle roadblocks of the protocol are becoming more and more visible:&#xA;&#xA;1. The well known issue of hanging HTLCs. As of now I believe onion&#xA;messages would be great to acknowledge incoming HTLCs of multipart payments&#xA;but I certainly believe this will not be sufficient if we don&#39;t go for a&#xA;cancelable &amp; stuckless payment protocol as suggested in [13].&#xA;2. I believe the Lightning Network Protocol should be able to handle&#xA;redundant overpayments as suggested in [14] and [15] (The later paper&#xA;derives independently of us the same success probabilities and tries to&#xA;maximize them!). This would allow to transform the problem of finding a&#xA;flow that maximizes the success probability to a flow that expects to&#xA;deliver the amount of the invoice (when redundancy is applied) with a&#xA;single round of min cost flow computation on average.&#xA;&#xA;Last but not least, please allow me to make a short remark on the (still to&#xA;me very surprisingly controversial) base fee discussion: For simplicity I&#xA;did not include any fee considerations to the published code (besides a fee&#xA;report on how expensive the computed flow is). However in practice we wish&#xA;to optimize at least for high reliability (via neg log success&#xA;probabilities) and cheap fees which in particular with the ppm is very&#xA;easily possible to be included to the piece wise linearized cost function.&#xA;While for small base fees it seems possible to encode the base fee into the&#xA;first segment of the piecewise linearized approximation I think the base&#xA;fee will still be tricky to be handled in practice (even with this&#xA;approximation). For example if the base fee is too high the &#34;base fee&#xA;adjusted&#34; unit cost of the first segment of the piecewise linearized&#xA;problem might be higher than the unit cost of the second segment which&#xA;effectively would break the convexity. Thus I reiterate my earlier point&#xA;that from the perspective of the year long pursued goal of optimizing for&#xA;fees (which all Dijkstra based single path implementations do) it seems to&#xA;be best if the non linearity that is introduced by the base fee would be&#xA;removed at all. According to discussions with people who crate Lightning&#xA;Network explorer (and according to my last check of gossip) about 90% of&#xA;channels have a base fee of 1 sat or lower and ~38% of all channels already&#xA;set their base fee away from the default value to 0 [16].&#xA;&#xA;I hope this mail was useful for you. Feel free to ask me anything if there&#xA;should be questions or if you need help to integrate those results into&#xA;your software!&#xA;&#xA;With kind regards Rene Pickhardt&#xA;&#xA;[0]: https://arxiv.org/abs/2107.05322&#xA;[1]: https://en.wikipedia.org/wiki/Piecewise_linear_function&#xA;[2]: https://arxiv.org/abs/2103.08576&#xA;[2b]:&#xA;https://medium.com/blockstream/c-lightning-v0-10-2-bitcoin-dust-consensus-rule-33e777d58657&#xA;&#xA;[3]:&#xA;https://github.com/renepickhardt/mpp-splitter/blob/master/Minimal%20Linearized%20min%20cost%20flow%20example%20for%20MPP.ipynb&#xA;[4]: https://developers.google.com/optimization/flow/mincostflow&#xA;[5]: https://github.com/lightningnetwork/lnd/issues/4203&#xA;[6]: https://github.com/lightningdevkit/rust-lightning/issues/1276&#xA;[7]: https://github.com/ElementsProject/lightning/issues/4753&#xA;[8]: https://github.com/ACINQ/eclair/pull/1427&#xA;[9]: http://www.iaeng.org/publication/WCECS2008/WCECS2008_pp1191-1194.pdf&#xA;[10]:&#xA;https://github.com/lightningdevkit/rust-lightning/issues/1170#issuecomment-972396747&#xA;[11]: https://github.com/lightningdevkit/rust-lightning/pull/1227&#xA;[12]: https://twitter.com/renepickhardt/status/1418849788531990530&#xA;[13]:&#xA;https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-June/002029.html&#xA;[14]: https://berkeley-defi.github.io/assets/material/1910.01834.pdf&#xA;[15]: https://dl.acm.org/doi/10.1145/3479722.3480997&#xA;[16]: https://lnrouter.app/graph/zero-base-fee&#xA;&#xA;-- &#xA;https://ln.rene-pickhardt.de&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20220311/0ba5d2d0/attachment-0001.html&gt;</html></oembed>