1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-03-13 11:35:47 +01:00

Merge branch 'master' into android

This commit is contained in:
pm47 2019-02-12 17:36:33 +01:00
commit a86da82bb6
No known key found for this signature in database
GPG key ID: E434ED292E85643A
5 changed files with 30 additions and 20 deletions

View file

@ -244,7 +244,7 @@ object NodeParams {
searchMaxRouteLength = config.getInt("router.path-finding.max-route-length"),
searchMaxCltv = config.getInt("router.path-finding.max-cltv"),
searchMaxFeeBaseSat = config.getLong("router.path-finding.fee-threshold-sat"),
searchMaxFeePct = config.getDouble("router.path-finding.route-max-fee-pct")
searchMaxFeePct = config.getDouble("router.path-finding.max-fee-pct")
),
socksProxy_opt = socksProxy_opt
)

View file

@ -87,7 +87,7 @@ object Graph {
// select the spur node as the i-th element of the k-th previous shortest path (k -1)
val spurEdge = prevShortestPath(i)
// select the subpath from the source to the spur node of the k-th previous shortest path
// select the sub-path from the source to the spur node of the k-th previous shortest path
val rootPathEdges = if (i == 0) prevShortestPath.head :: Nil else prevShortestPath.take(i)
val rootPathWeight = pathWeight(rootPathEdges, amountMsat, isPartial = true)
@ -100,8 +100,11 @@ object Graph {
}
}
// find the "spur" path, a subpath going from the spur edge to the target avoiding previously found subpaths
val spurPath = dijkstraShortestPath(graph, spurEdge.desc.a, targetNode, amountMsat, ignoredEdges ++ edgesToIgnore.toSet, extraEdges, rootPathWeight, boundaries)
// remove any link that can lead back to the previous vertex to avoid going back from where we arrived (previous iteration)
val returningEdges = rootPathEdges.lastOption.map(last => graph.getEdgesBetween(last.desc.b, last.desc.a)).toSeq.flatten.map(_.desc)
// find the "spur" path, a sub-path going from the spur edge to the target avoiding previously found sub-paths
val spurPath = dijkstraShortestPath(graph, spurEdge.desc.a, targetNode, amountMsat, ignoredEdges ++ edgesToIgnore.toSet ++ returningEdges, extraEdges, rootPathWeight, boundaries)
// if there wasn't a path the spur will be empty
if (spurPath.nonEmpty) {

View file

@ -112,7 +112,7 @@ class IntegrationSpec extends TestKit(ActorSystem("test")) with BitcoindService
test("starting eclair nodes") {
import collection.JavaConversions._
val commonConfig = ConfigFactory.parseMap(Map("eclair.chain" -> "regtest", "eclair.spv" -> false, "eclair.server.public-ips.1" -> "127.0.0.1", "eclair.bitcoind.port" -> 28333, "eclair.bitcoind.rpcport" -> 28332, "eclair.bitcoind.zmqblock" -> "tcp://127.0.0.1:28334", "eclair.bitcoind.zmqtx" -> "tcp://127.0.0.1:28335", "eclair.mindepth-blocks" -> 2, "eclair.max-htlc-value-in-flight-msat" -> 100000000000L, "eclair.router.broadcast-interval" -> "2 second", "eclair.auto-reconnect" -> false, "eclair.router.path-finding.route-max-fee-pct" -> 1))
val commonConfig = ConfigFactory.parseMap(Map("eclair.chain" -> "regtest", "eclair.spv" -> false, "eclair.server.public-ips.1" -> "127.0.0.1", "eclair.bitcoind.port" -> 28333, "eclair.bitcoind.rpcport" -> 28332, "eclair.bitcoind.zmqblock" -> "tcp://127.0.0.1:28334", "eclair.bitcoind.zmqtx" -> "tcp://127.0.0.1:28335", "eclair.mindepth-blocks" -> 2, "eclair.max-htlc-value-in-flight-msat" -> 100000000000L, "eclair.router.broadcast-interval" -> "2 second", "eclair.auto-reconnect" -> false))
instantiateEclairNode("A", ConfigFactory.parseMap(Map("eclair.node-alias" -> "A", "eclair.delay-blocks" -> 130, "eclair.server.port" -> 29730, "eclair.api.port" -> 28080, "eclair.channel-flags" -> 0)).withFallback(commonConfig)) // A's channels are private
instantiateEclairNode("B", ConfigFactory.parseMap(Map("eclair.node-alias" -> "B", "eclair.delay-blocks" -> 131, "eclair.server.port" -> 29731, "eclair.api.port" -> 28081)).withFallback(commonConfig))
instantiateEclairNode("C", ConfigFactory.parseMap(Map("eclair.node-alias" -> "C", "eclair.delay-blocks" -> 132, "eclair.server.port" -> 29732, "eclair.api.port" -> 28082, "eclair.payment-handler" -> "noop")).withFallback(commonConfig))

View file

@ -78,7 +78,7 @@ class RouteCalculationSpec extends FunSuite {
val updates = List(
makeUpdate(1L, a, b, feeBaseMsat = 1, feeProportionalMillionth = 200, minHtlcMsat = 0),
makeUpdate(4L, a, e, feeBaseMsat = 1, feeProportionalMillionth = 200, minHtlcMsat = 0),
makeUpdate(4L, a, e, feeBaseMsat = 1, feeProportionalMillionth = 200, minHtlcMsat = 0),
makeUpdate(2L, b, c, feeBaseMsat = 1, feeProportionalMillionth = 300, minHtlcMsat = 0),
makeUpdate(3L, c, d, feeBaseMsat = 1, feeProportionalMillionth = 400, minHtlcMsat = 0),
makeUpdate(5L, e, f, feeBaseMsat = 1, feeProportionalMillionth = 400, minHtlcMsat = 0),
@ -104,10 +104,10 @@ class RouteCalculationSpec extends FunSuite {
test("calculate route considering the direct channel pays no fees") {
val updates = List(
makeUpdate(1L, a, b, 5, 0), // a -> b
makeUpdate(2L, a, d, 15, 0),// a -> d this goes a bit closer to the target and asks for higher fees but is a direct channel
makeUpdate(2L, a, d, 15, 0), // a -> d this goes a bit closer to the target and asks for higher fees but is a direct channel
makeUpdate(3L, b, c, 5, 0), // b -> c
makeUpdate(4L, c, d, 5, 0), // c -> d
makeUpdate(5L, d, e, 5, 0) // d -> e
makeUpdate(5L, d, e, 5, 0) // d -> e
).toMap
val g = makeGraph(updates)
@ -441,7 +441,7 @@ class RouteCalculationSpec extends FunSuite {
val g = makeGraph(updates)
val route1 = Router.findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, numRoutes = 1 , ignoredEdges = Set(ChannelDesc(ShortChannelId(3L), c, d)), routeParams = DEFAULT_ROUTE_PARAMS)
val route1 = Router.findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, numRoutes = 1, ignoredEdges = Set(ChannelDesc(ShortChannelId(3L), c, d)), routeParams = DEFAULT_ROUTE_PARAMS)
assert(route1.map(hops2Ids) === Failure(RouteNotFound))
// verify that we left the graph untouched
@ -463,8 +463,8 @@ class RouteCalculationSpec extends FunSuite {
val g = makeGraph(updates)
// val route = Router.findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS)
// assert(route.map(hops2Ids) === Failure(RouteNotFound))
val route = Router.findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS)
assert(route.map(hops2Ids) === Failure(RouteNotFound))
// now we add the missing edge to reach the destination
val (extraDesc, extraUpdate) = makeUpdate(4L, d, e, 5, 5)
@ -546,7 +546,7 @@ class RouteCalculationSpec extends FunSuite {
val updates = nodes
.zip(nodes.drop(1)) // (0, 1) :: (1, 2) :: ...
.zipWithIndex // ((0, 1), 0) :: ((1, 2), 1) :: ...
.map {case ((na, nb), index) => makeUpdate(index, na, nb, 5, 0)}
.map { case ((na, nb), index) => makeUpdate(index, na, nb, 5, 0) }
.toMap
val g = makeGraph(updates)
@ -564,7 +564,7 @@ class RouteCalculationSpec extends FunSuite {
val updates = nodes
.zip(nodes.drop(1)) // (0, 1) :: (1, 2) :: ...
.zipWithIndex // ((0, 1), 0) :: ((1, 2), 1) :: ...
.map {case ((na, nb), index) => makeUpdate(index, na, nb, 1, 0)}
.map { case ((na, nb), index) => makeUpdate(index, na, nb, 1, 0) }
.toMap
val updates2 = updates + makeUpdate(99, nodes(2), nodes(48), 1000, 0) // expensive shorter route
@ -622,7 +622,7 @@ class RouteCalculationSpec extends FunSuite {
val g = makeGraph(updates)
val route1 = Router.findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS)
assert(route1.map(hops2Ids) === Success(1 :: 2 :: 4 :: 5 :: Nil))
assert(route1.map(hops2Ids) === Success(1 :: 2 :: 4 :: 5 :: Nil))
}
@ -647,7 +647,7 @@ class RouteCalculationSpec extends FunSuite {
PublicKey("0358e32d245ff5f5a3eb14c78c6f69c67cea7846bdf9aeeb7199e8f6fbb0306484"), //c
PublicKey("029e059b6780f155f38e83601969919aae631ddf6faed58fe860c72225eb327d7c"), //d
PublicKey("02f38f4e37142cc05df44683a83e22dea608cf4691492829ff4cf99888c5ec2d3a"), //e
PublicKey("03fc5b91ce2d857f146fd9b986363374ffe04dc143d8bcd6d7664c8873c463cdfc") //f
PublicKey("03fc5b91ce2d857f146fd9b986363374ffe04dc143d8bcd6d7664c8873c463cdfc") //f
)
@ -679,7 +679,7 @@ class RouteCalculationSpec extends FunSuite {
PublicKey("0358e32d245ff5f5a3eb14c78c6f69c67cea7846bdf9aeeb7199e8f6fbb0306484"), //e
PublicKey("029e059b6780f155f38e83601969919aae631ddf6faed58fe860c72225eb327d7c"), //f
PublicKey("02f38f4e37142cc05df44683a83e22dea608cf4691492829ff4cf99888c5ec2d3a"), //g
PublicKey("03fc5b91ce2d857f146fd9b986363374ffe04dc143d8bcd6d7664c8873c463cdfc") //h
PublicKey("03fc5b91ce2d857f146fd9b986363374ffe04dc143d8bcd6d7664c8873c463cdfc") //h
)
@ -707,18 +707,25 @@ class RouteCalculationSpec extends FunSuite {
assert(hops2Ids(secondShortest.path.map(graphEdgeToHop)) === 10 :: 60 :: 90 :: Nil) // C -> E -> G -> H
}
test("terminate looking for k-shortest path if there are no more alternative paths than k"){
test("terminate looking for k-shortest path if there are no more alternative paths than k, must not consider routes going back on their steps") {
val f = randomKey.publicKey
// simple graph with only 2 possible paths from A to F
val edges = Seq(
makeUpdate(1L, a, b, 1, 0),
makeUpdate(1L, b, a, 1, 0),
makeUpdate(2L, b, c, 1, 0),
makeUpdate(2L, c, b, 1, 0),
makeUpdate(3L, c, f, 1, 0),
makeUpdate(3L, f, c, 1, 0),
makeUpdate(4L, c, d, 1, 0),
makeUpdate(4L, d, c, 1, 0),
makeUpdate(41L, d, c, 1, 0), // there is more than one D -> C channel
makeUpdate(5L, d, e, 1, 0),
makeUpdate(6L, e, f, 1, 0)
makeUpdate(5L, e, d, 1, 0),
makeUpdate(6L, e, f, 1, 0),
makeUpdate(6L, f, e, 1, 0)
)
val graph = DirectedGraph().addEdges(edges)
@ -748,7 +755,7 @@ class RouteCalculationSpec extends FunSuite {
makeUpdate(7L, e, c, feeBaseMsat = 9, 0)
).toMap)
(for { _ <- 0 to 10 } yield Router.findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, numRoutes = 3, routeParams = DEFAULT_ROUTE_PARAMS.copy(maxFeeBaseMsat = 7, maxFeePct = 0))).map {
(for {_ <- 0 to 10} yield Router.findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, numRoutes = 3, routeParams = DEFAULT_ROUTE_PARAMS.copy(maxFeeBaseMsat = 7, maxFeePct = 0))).map {
case Failure(_) => assert(false)
case Success(someRoute) =>

View file

@ -66,7 +66,7 @@
<scala.version.short>2.11</scala.version.short>
<akka.version>2.3.14</akka.version>
<sttp.version>1.3.9</sttp.version>
<bitcoinlib.version>0.9.18</bitcoinlib.version>
<bitcoinlib.version>0.9.19</bitcoinlib.version>
<guava.version>24.0-android</guava.version>
</properties>