routing+server: add new QueryBandwidth method to reduce outbound failures

In this commit, we introduce a new method to the channel router's config
struct: QueryBandwidth. This method allows the channel router to query
for the up-to-date available bandwidth of a particular link. In the case
that this link emanates from/to us, then we can query the switch to see
if the link is active (if not bandwidth is zero), and return the current
best estimate for the available bandwidth of the link. If the link,
isn't one of ours, then we can thread through the total maximal
capacity of the link.

In order to implement this, the missionControl struct will now query the
switch upon creation to obtain a fresh bandwidth snapshot. We take care
to do this in a distinct db transaction in order to now introduced a
circular waiting condition between the mutexes in bolt, and the channel
state machine.

The aim of this change is to reduce the number of unnecessary failures
during HTLC payment routing as we'll now skip any links that are
inactive, or just don't have enough bandwidth for the payment. Nodes
that have several hundred channels (all of which in various states of
activity and available bandwidth) should see a nice gain from this w.r.t
payment latency.
This commit is contained in:
Olaoluwa Osuntokun
2018-05-07 21:04:31 -07:00
parent c96d07c1ae
commit f494433cbf
6 changed files with 162 additions and 27 deletions

View File

@ -128,6 +128,9 @@ func createTestCtx(startingHeight uint32, testGraph ...string) (*testCtx, func()
},
ChannelPruneExpiry: time.Hour * 24,
GraphPruneInterval: time.Hour * 2,
QueryBandwidth: func(e *channeldb.ChannelEdgeInfo) lnwire.MilliSatoshi {
return lnwire.NewMSatFromSatoshis(e.Capacity)
},
})
if err != nil {
return nil, nil, fmt.Errorf("unable to create router %v", err)
@ -1617,7 +1620,7 @@ func TestFindPathFeeWeighting(t *testing.T) {
// path even though the direct path has a higher potential time lock.
path, err := findPath(
nil, ctx.graph, nil, sourceNode, target, ignoreVertex,
ignoreEdge, amt,
ignoreEdge, amt, nil,
)
if err != nil {
t.Fatalf("unable to find path: %v", err)