-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[bug]: routerClient.BuildRoute does not consider inbound fees #8814
Comments
While writing this issue I actually found out that this is a known "issue": #7060 Decided to submit it anyway because it might result in unexpected behaviour while using BuildRoute to rebalance. |
I looked into the problem and checked how The minimal amount approach currently requires:
Inbound fees complicate this in the second step, because inbound fees are not (easily?) invertible because they depend recursively on all remaining hops (due to the capping by outbound fees). I haven't found a way to compute an outgoing amount from an incoming amount yet. My current attempt (draft) is to do the first pass, followed by a brute force search within some bounds to determine the receiver amount by incrementally checking if the receiver amount is compatible with the sender amount. This may add lot of iterations compared to the original approach because the search space may be large. The current approach tries to fulfill min HTLC constraints while maximizing the amount a receiver receives. If we would drop that maximizing requirement, we could express the min HTLC amount bumps in the first pass as hop fees and be done after the first pass, by not using A longer term solution could be to let pathfinding itself do the route building, as suggested in #6920, by using hop constraints for the input route. This would require updates to the pathfinding algo to not use I think the choice boils down to whether we want to drop the requirement of the receiver receiving the max it could when building a route for the minimal amount. The amount to send would stay the same, the receiver would just receive less while the difference goes to fees at the hop where a min HTLC constraint was met. |
I felt challenged. The problem seems to be quite easy to invert, but obviously it is not. Created a small doc and a python prototype. Feel free to check this out and implement in lnd. https://github.com/feelancer21/lnd/tree/proto-inverse-outbound/prototype |
Great work and nice presentation @feelancer21, thank you for the thoughtful input 🔥! This would indeed work if policies could be assumed constant, but due possible parallel channels, we need to "synthesize" a unified policy that respects min/max HTLC bounds, which makes the unified policy dependent on the amount that is forwarded. You can see that step in the backward direction here. |
Thank you for the explanations. I had that in mind with the unfied edges, but only now realized how strongly the selections of the unfied edges influence each other. I also believe that you don't need the 100% optimal solution for the case. Noderunners should also stop having different feestrategies on channels with the same peer. So far I have only noticed negative effects in this regard. |
Background
Using
routerClient.BuildRoute
to create a route does not produce routes that use any fee discounts.Your environment
Steps to reproduce
Find a route via
lnClient.QueryRoutes
until one is found with a hop that has negative inbound fees. Reconstruct same route using the pubkeys from the original route thatQueryRoutes
returned:Expected behaviour
routerClient.BuildRoute
should return the same route as thelnClient.QueryRoutes
one with the same discounted fees.Actual behaviour
Code:
Debug output:
The text was updated successfully, but these errors were encountered: