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
lnrpc: deprecate QueryRoutes with more than one route #2497
lnrpc: deprecate QueryRoutes with more than one route #2497
Conversation
Is the workaround you mention (blacklisting edges) currently possible? Maybe we should provide that before deprecating this. |
No, not possible currently. But if we want to go this way, I thought it is better to signal it sooner rather than later. |
People can still use it while we mark it deprecated, before we remove it all together, we should have the replacement in place though. |
Change LGTM. Question is still whether we should wait to have a replacement before deprecating, but as you say maybe best to just start signaling right away. EDIT: Would be nice to be able to point to the "new way" of doing it when deprecating. |
As a user of the QueryRoutes rpc, our use case for multiple routes is to implement our own maximum time lock similar to the maximum fee that is already supported by the rpc. I suppose you could do this with edge blacklisting as well, but I'm not sure that's the right tool for the job. |
@treygriffith thanks for mentioning your use case. I don't think it works very well with black listing, but #1941 should do it. |
53d1b3f
to
cbb4344
Compare
070e5ad
to
9bca98a
Compare
This seems like a bad idea. "To keep facilitating those, a follow up PR will add any source to destination queries to QueryRoutes." |
9bca98a
to
bbf8f24
Compare
First thing to note is that returning multiple routes alleviates the problem you describe above somewhat, but it is still not a real solution. It could still be that all returned routes fail and that the route that would work is not in the set. You could ask for all existing routes, but that quickly becomes infeasible. The plan is that before we actually remove In addition to that, we are working towards returning structured errors from SendToRoute (#1662), which will allow a client to pinpoint the failing edge, update a (single use) black list and pass that into query routes. |
Thanks. |
bbf8f24
to
e9e83eb
Compare
0e723a6
to
643a7fd
Compare
7e1fbaa
to
d062139
Compare
@Roasbeef route cache restored |
3c7c456
to
44ffcd8
Compare
This check was a left over from when the fee limit wasn't checked yet in the path finding algorithm.
This allows removing a lot of empty map initialization code and makes the code more readable.
This commit allows the execution of QueryRoutes to be controlled using lists of black-listed edges and nodes. Any path returned will not pass through the edges and/or nodes on the list.
Currently public keys are represented either as a 33-byte array (Vertex) or as a btcec.PublicKey struct. The latter isn't useable as index into maps and cannot be used easily in compares. Therefore the 33-byte array representation is used predominantly throughout the code base. This commit converts the argument types of source and target nodes for path finding to Vertex. Path finding executes no crypto operations and using Vertex simplifies the code. Additionally, it prepares for the path finding source parameter to be exposed over rpc in a follow up commit without requiring conversion back and forth between Vertex and btcec.PublicKey.
This commit allows execution of QueryRoutes from any source node. Previously this was restricted to only the self node.
Now that QueryRoutes gained the ability to route from any source node and takes in edge and node black lists, all pieces are in place to have users implemented their own k-shortests path algorithm. Or any other algorithm they might wish to use and currently can't. This commit marks the num_routes field as deprecated as a preparation for removing k-shortest for lnd.
44ffcd8
to
6cc82b4
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.
The next chapter on the path to removing ksp! First pass review completed, pretty straight forward diffs with no major comments. The only thing I think we should do before merging this is to update the QueryRoutes
integration test to exercise this new behavior, and the new parsing logic along the way.
This commit moves the query routes backend logic from the main rpc server into the sub server. It is another step towards splitting up the main rpc server code. In addition to this, a unit test is added to verify rpc parameter parsing.
I think we should be careful with integration tests and only use them to test code that isn't testable otherwise. The queryroutes rpc behaviour can be tested in a unit test as well. I added this test in the last commit. |
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.
LGTM 💎
Does this mean that moving forward advanced routing functionality will be seen as something which should live outside lnd? Will this be extendable via plugins, or are we encouraged to build on top of the gRPC API? |
@wamde What do you mean exactly with 'advanced routing functionality'? KSP specifically has in our opinion not many good use cases, so that is why we decided to move it out of Can you tell me why you need ksp for rebalancing rather than trying the best route first and after processing the outcome of that, query again for the (then) best route? |
Let me explain (re-stating some obvious stuff for context):
All of this to say that I think that we are fine re-implementing all of that and adding flexibility to it on top of
|
Thanks for the clarification @wamde
In your experience, is calling I am sensitive to the performance argument in general. There are probably many ways to speed up path finding. One good candidate is keeping the graph in memory, but this is quite a refactor which we started but haven't completed yet.
These calls can be made concurrently, but ideally you only want to start the next path finding round when the previous probe has completed. To take into account the outcome of that probe.
Yes understood. On the
What do you mean with generic pathfinding exactly? We want to move the RPCs in a direction where they remain relatively simple, but still powerful enough to solve real world path finding problems. Any feedback on that is always welcome. A caller defined hop limit could also be an extension of the current api. Plugins are not on the roadmap atm. |
Hi @joostjager this is really nice, and I think it is the right way to go giving the difficulty in path-finding. |
@MrManPew As this is advanced functionality, we considered adding the flags to |
I can't answer this directly, but I can describe what we do:
Yes, that sounds like an obvious one, along with keeping heuristics from previous requests and
Yes, I probably worded that wrong. I mean one thread to find paths, passing them as it finds them to another thread trying them in a sequential manner.
The current KSP is a bit slow and could certainly use heuristics and caching, but my main pet peeve is around its lack of flexibility. A recent PR added the source pubkey parameter, which is great, but I still think that for rebalancing use cases we need more flexibility.
Hop limit is one way. To give you an example of what I am currently working on in a branch of rebalance-lnd, I compute the route's weight by using
Understood. |
If you would request the routes one at a time, I expect that it would in total not take significantly more time than requesting n routes at once. Assuming the performance is not degraded by the api change, do I understand it right that at the moment all the tools are there to implement KSP client side? With regards to further influencing path finding, I would suggest to open a new issue describing the use case and the extra levers that you'd need. Redefining the ignored edges and nodes list as more of a weight penalty which can be set to infinity could be a direction to take. |
This PR marks the num_routes argument of the query routes rpc as deprecated.
The use case for returning multiple routes is limited at best, but it does require maintaining a dedicated algorithm (k-shortest) in lnd.
It also encourages blindly attempting the second best route without interpreting the outcome of the best route, which is likely to result in less efficient payments.
The recommended approach is to request a single route, attempt payment, process the outcome if it failed (eg black list edges) and request another route, taking into account the outcome of the first attempt.
Currently QueryRoutes with multiple routes may have a use in special scripts (probing, rebalancing, ..). To keep facilitating those, a follow up PR will add any source to destination queries to QueryRoutes.