Skip to content
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

Routing heuristics #821

Merged
merged 86 commits into from
Feb 22, 2019
Merged

Routing heuristics #821

merged 86 commits into from
Feb 22, 2019

Conversation

araspitzu
Copy link
Contributor

@araspitzu araspitzu commented Jan 15, 2019

Add heuristics to the cost function of the path finding algorithm, and the ability to tune them by prioritizing for certain types. This enables the initiator of the payment (via SendPayment) to search for routes optimized for reliability or timeout where the reliability of a channel is obtained considering its age and capacity, with the assumption that older and larger channel are more reliable. Note that it is possible to specify the factor(s) by which we want consider each optimization, the ratios: WeightRatios parameter allows to specify a floating point value for each optimization heuristic, for example:

  • WeightRatios(cltvDeltaFactor = 0, ageFactor = 0.5, capacityFactor = 0.5) will consider equally the age and capacity of a channel but won't consider its CLTV delta.
  • WeightRatios(cltvDeltaFactor = 0, ageFactor = 0, capacityFactor = 0) will not consider heuristics optimization at all thus falling back to the previous behavior, cost optimized.
  • WeightRatios(cltvDeltaFactor = 1, ageFactor = 0, capacityFactor = 0) will find the route with the smallest possible cltv, thus minimizing the timeout in case of payment failure.

Optimization ratios can be specified at payment time or via the configuration file, by default they're all set to 0 in order to search for the route with the cheapest fees. Note that this can be combined with the existing bounded-search parameters such as the fee-threshold-sat to ask the router to find heuristics-optimized routes within the given constraints.

@araspitzu
Copy link
Contributor Author

This supersedes #792

# Conflicts:
#	eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala
#	eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala
#	eclair-core/src/test/scala/fr/acinq/eclair/router/RouteCalculationSpec.scala
# Conflicts:
#	eclair-core/src/main/resources/reference.conf
#	eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala
@araspitzu araspitzu changed the title [WIP] Routing heuristics Routing heuristics Jan 24, 2019
# Conflicts:
#	eclair-core/src/main/resources/reference.conf
#	eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala
#	eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala
# Conflicts:
#	eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala
#	eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala
# Conflicts:
#	eclair-core/src/main/resources/reference.conf
#	eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala
#	eclair-core/src/main/scala/fr/acinq/eclair/payment/PaymentLifecycle.scala
#	eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala
#	eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala
#	eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala
#	eclair-core/src/test/scala/fr/acinq/eclair/router/RouteCalculationSpec.scala
# Conflicts:
#	eclair-core/src/main/scala/fr/acinq/eclair/router/Graph.scala
#	eclair-core/src/test/scala/fr/acinq/eclair/router/RouteCalculationSpec.scala
@araspitzu
Copy link
Contributor Author

These changes have no significant performance impact, below a benchmark on a routing table from 29/01/2019 (~23k channels).

 Run complete. Total time: 00:07:24 (routing_heuristic: b1bf584) - Bounded search, no randomization, max-route-length=7, cost-optimized

Benchmark                                   Mode  Cnt  Score   Error  Units
GraphBenchmark.findPath                     avgt    2  0.001           s/op   
GraphBenchmark.findPathWithExtraChannels    avgt    2  0.004           s/op
GraphBenchmark.findPathWithIgnoredChannels  avgt    2  0.032           s/op
GraphBenchmark.routerLoadingTime            avgt    2  5.320           s/op

@araspitzu araspitzu requested review from sstone and pm47 February 21, 2019 10:28
@sstone sstone merged commit fe31f2d into master Feb 22, 2019
@sstone sstone deleted the routing_heuristics branch March 13, 2019 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants