routing: convert to node pair based

Previously mission control tracked failures on a per node, per channel basis.
This commit changes this to tracking on the level of directed node pairs. The goal
of moving to this coarser-grained level is to reduce the number of required
payment attempts without compromising payment reliability.
This commit is contained in:
Joost Jager committed 2019-08-13 19:21:37 +02:00
1 parent 6ee2c04190
commit f1769c8c8c
17 files changed
+1133 -995

No files matched your search

+30 -12
View File
@@ -23,6 +23,10 @@ const (
var (
sourceKey = route.Vertex{1, 2, 3}
node1 = route.Vertex{10}
node2 = route.Vertex{11}
)
// TestQueryRoutes asserts that query routes rpc parameters are properly parsed
@@ -50,11 +54,6 @@ func testQueryRoutes(t *testing.T, useMissionControl bool) {
t.Fatal(err)
}
ignoredEdge := routing.EdgeLocator{
ChannelID: 555,
Direction: 1,
}
request := &lnrpc.QueryRoutesRequest{
PubKey: destKey,
Amt: 100000,
@@ -69,6 +68,10 @@ func testQueryRoutes(t *testing.T, useMissionControl bool) {
ChannelId: 555,
DirectionReverse: true,
}},
IgnoredPairs: []*lnrpc.NodePair{{
From: node1[:],
To: node2[:],
}},
UseMissionControl: useMissionControl,
}
@@ -92,24 +95,28 @@ func testQueryRoutes(t *testing.T, useMissionControl bool) {
t.Fatal("unexpected fee limit")
}
if restrictions.ProbabilitySource(route.Vertex{},
ignoredEdge, 0,
if restrictions.ProbabilitySource(route.Vertex{2},
route.Vertex{1}, 0,
) != 0 {
t.Fatal("expecting 0% probability for ignored edge")
}
if restrictions.ProbabilitySource(ignoreNodeVertex,
routing.EdgeLocator{}, 0,
route.Vertex{6}, 0,
) != 0 {
t.Fatal("expecting 0% probability for ignored node")
}
if restrictions.ProbabilitySource(node1, node2, 0) != 0 {
t.Fatal("expecting 0% probability for ignored pair")
}
expectedProb := 1.0
if useMissionControl {
expectedProb = testMissionControlProb
}
if restrictions.ProbabilitySource(route.Vertex{},
routing.EdgeLocator{}, 0,
if restrictions.ProbabilitySource(route.Vertex{4},
route.Vertex{5}, 0,
) != expectedProb {
t.Fatal("expecting 100% probability")
}
@@ -128,6 +135,16 @@ func testQueryRoutes(t *testing.T, useMissionControl bool) {
return 1, nil
},
MissionControl: &mockMissionControl{},
FetchChannelEndpoints: func(chanID uint64) (route.Vertex,
route.Vertex, error) {
if chanID != 555 {
t.Fatal("expected endpoints to be fetched for "+
"channel 555, but got %v instead",
chanID)
}
return route.Vertex{1}, route.Vertex{2}, nil
},
}
resp, err := backend.QueryRoutes(context.Background(), request)
@@ -142,8 +159,9 @@ func testQueryRoutes(t *testing.T, useMissionControl bool) {
type mockMissionControl struct {
}
func (m *mockMissionControl) GetEdgeProbability(fromNode route.Vertex,
edge routing.EdgeLocator, amt lnwire.MilliSatoshi) float64 {
func (m *mockMissionControl) GetProbability(fromNode, toNode route.Vertex,
amt lnwire.MilliSatoshi) float64 {
return testMissionControlProb
}