-
Notifications
You must be signed in to change notification settings - Fork 267
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
Additional parameters for findroute* API calls #1969
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1969 +/- ##
==========================================
- Coverage 87.77% 87.77% -0.01%
==========================================
Files 161 161
Lines 12526 12534 +8
Branches 539 535 -4
==========================================
+ Hits 10995 11002 +7
- Misses 1531 1532 +1
|
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.
Can you update the release notes as well since this PR updates some APIs?
And please post detailed results of how you manage to use this for rebalancing.
eclair-core/src/main/scala/fr/acinq/eclair/json/JsonSerializers.scala
Outdated
Show resolved
Hide resolved
eclair-node/src/main/scala/fr/acinq/eclair/api/directives/RouteFormat.scala
Outdated
Show resolved
Hide resolved
eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala
Outdated
Show resolved
Hide resolved
eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala
Outdated
Show resolved
Hide resolved
I don't know how to it |
ignore_node_ids = [self.get_own_pubkey()]
if isinstance(ignored_nodes, list):
ignore_node_ids = ignore_node_ids + ignored_nodes
params = {
'sourceNodeId': first_hop_pubkey,
'targetNodeId': last_hop_pubkey,
'amountMsat': int(amount * 1000),
'format': 'full',
'ignoreNodeIds': ignore_node_ids,
'ignoreChannelIds': ignore_channel_ids,
'maxFeeMsat': fee_limit,
}
found_routes = self.call_eclair("findroutebetweennodes", params)
if isinstance(found_routes, list):
routes = []
for found_route in found_routes:
amount_msat = found_route['amount']
hops = [self.route_to_hop(hop, amount_msat) for hop in found_route['hops']]
if first_hop_channel:
hops.insert(0, first_hop_channel.to_hop(amount_msat, 0, first=True))
if last_hop_channel:
hops.append(
last_hop_channel.to_hop(amount_msat, self.calc_fees_msat(amount_msat, last_hop_channel.chan_id),
first=False))
routes.append(Route(amount_msat, hops))
return routes |
Simply update this section: https://github.com/ACINQ/eclair/blob/master/docs/release-notes/eclair-vnext.md#api-changes |
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.
Concept ACK, we should integrate this soon (we're planning a release and it would be nice to have this PR be part of it).
Two things to consider:
- Json serializers refactoring #1979 will be merged soon and provides more flexibility for JSON serialization: I think you can leverage this to more cleanly apply the right serialization based on the requested route format
- Ignore redundant channels #1974 will change the internal logic of ignoring channels. When you ask to ignore a channel between Bob and Carol, we will ignore ALL channels between them (because non-strict forwarding means that if one channel cannot be used, none of them can unless the node is very buggy). The only exception is obviously for local channels. IIUC for rebalancing you only need to use this with local channels, right? If that's the case it should work properly.
Regarding release notes, it would be great if you could add a new "Circular rebalancing" section to https://github.com/ACINQ/eclair/blob/master/docs/release-notes/eclair-vnext.md where you explain how the eclair API can be used to rebalance your channels. You should describe the example of a triangular topology and show the concrete eclair-cli
commands that should be used.
eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala
Outdated
Show resolved
Hide resolved
I think it should be in a separate doc |
Good idea, a separate doc would be very useful. |
Is this ready to merge after review? It's desperately needed! My nodes routing activity and fee earnings have dropped more than 90% since LND started routing around nodes with unbalanced channels. |
FWIW, @Roasbeef confirmed that this behavior is a bug on their side, which is being fixed in their next release, so it is not a deliberate attempt at overly penalizing your node when you have unbalanced channels with one specific node. We are making progress on this PR and the other rebalancing-related PRs though, don't worry this will land soon. |
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.
Thanks @rorp!
I'd just like to see a parameter renamed and serialization re-worked, and we should be good to go.
eclair-node/src/main/scala/fr/acinq/eclair/api/directives/ExtraDirectives.scala
Outdated
Show resolved
Hide resolved
object RouteSerializer extends MinimalSerializer ({ | ||
case route: Route => | ||
Extraction.decompose(route)(DefaultFormats + | ||
ByteVector32Serializer + | ||
ByteVectorSerializer + | ||
PublicKeySerializer + | ||
ShortChannelIdSerializer + | ||
MilliSatoshiSerializer + | ||
CltvExpiryDeltaSerializer) |
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.
I think we should remove this entirely, and rely on the new mechanism with private case classes which gives you more flexibility.
You should define three private case classes:
private case class RouteNodeIdsJson(nodeIds: Seq[PublicKey])
private case class RouteShortChannelIdsJson(shortChannelIds: Seq[ShortChannelId])
private case class RouteFullJson(<whatever you need in the "full" format>)
And the serializers to convert from a Route
to these new private case classes. You should add only the RouteNodeIdsJson
serializer to the default formats
(to preserve as a default behavior listing the node ids only).
In RouteFormat.scala
, you should inject the route serializer you want to use based on what format was requested.
Does that make sense?
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.
No. :(
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.
Haha fair enough, I'll prototype it and send you the corresponding 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.
See #1969 (review)
eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala
Outdated
Show resolved
Hide resolved
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.
I reworked the route serializers in 6d40b0d, please apply that commit, test it with your rebalancing flow and rebase and we should be good to go.
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, just needs a last merge for the release notes conflict and we should be good to go.
That's good to know! And also thanks a lot to the both of you for finishing this so quickly! Very much appreciated! |
This PR adds new parameters for
findroute*
API calls useful automated route calculations for third-party applications:ignoreNodeIds
- specifies ignored nodesignoreChannelIds
- specifies ignored channelsmaxFeeMsat
- sets max fee for route calculationsAlso it adds
full
format that returns all information thatRouter
can provide about the found routes.