Commit Graph

126 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
cc3b32c0d4
routing: extend TestFindRoutesFeeSorting to assert proper fee attributes 2017-12-06 18:39:56 -08:00
Olaoluwa Osuntokun
5bc9f07d12
routing: validate incoming announcements in parallel 2017-11-29 16:44:14 -08:00
Olaoluwa Osuntokun
5dbf5084e7
routing: fix linter error 2017-11-06 16:49:36 -08:00
Olaoluwa Osuntokun
ccf94e9457
routing: add new TestRouterChansClosedOfflinePruneGraph test
In this commit we add a new test to the set of unit tests for the
ChannelRouter: TestRouterChansClosedOfflinePruneGraph. This tests that
if channels are closed while the ChannelRouter is down, then upon
restart the channels are properly recognized as being closed.
2017-11-06 16:06:15 -08:00
Olaoluwa Osuntokun
2824f45aad
routing: update tests to adhere to new newMockChainView API 2017-11-06 16:00:57 -08:00
Olaoluwa Osuntokun
3be905109c
routing: add RestartRouter method to testCtx 2017-11-06 16:00:22 -08:00
Johan T. Halseth
256db86b02
routing: make channel router aware of stale blocks
This commit make the channel router handle the case where
it wakes up on a stale branch, and also the case where a
reorg happens while it is active.
2017-11-03 00:05:32 +01:00
Olaoluwa Osuntokun
6e00abf3f1
routing: update tests in router_test.go to pass in new param to FindRoutes 2017-10-22 18:36:52 -07:00
Olaoluwa Osuntokun
bbb34cebe0
routing: modify the TestSendPaymentRouteFailureFallback to clear missionControl between attempts
In order to maintain the original essence of the test, we need to clear
the state of missionControl with each attempt, essentially advancing
time between each payment attempt.
2017-10-16 19:07:40 -07:00
Olaoluwa Osuntokun
eb7b5b342e
routing: add a basic test to exercise route pruning in response to errors 2017-10-10 22:19:25 -07:00
Olaoluwa Osuntokun
3b7855e449
routing: implement 2-week zombie channel pruning
This commit implements 2-week zombie channel pruning. This means that
every GraphPruneInterval (currently set to one hour), we’ll scan the
channel graph, marking any channels which haven’t had *both* edges
updated in 2 weeks as a “zombie”. During the second pass, all “zombie”
channel are removed from the channel graph all together.

Adding this functionality means we’ll ensure that we maintain a
“healthy” network view, which will cut down on the number of failed
HTLC routing attempts, and also reflect an active portion of the graph.
2017-10-04 20:46:09 -07:00
Olaoluwa Osuntokun
7eb0e56406
routing: modify TestSendPaymentRouteFailureFallback to use non-critical error
In this commit we modify the existing
TestSendPaymentRouteFailureFallback to use a non-critical error aside
from FailChannelDisabled. This is necessary as the behavior of the
current error handling can fail due to us sending in a nil error.
2017-10-02 22:14:14 -07:00
John Griffith
1057a1a7c3 routing: handle onion errors in ChannelRouter 2017-10-02 22:13:05 -07:00
Olaoluwa Osuntokun
6467fdd829
routing: update path finding and notifications to use mSAT 2017-08-22 00:53:12 -07:00
Johan T. Halseth
39a59bbe6f routing: Require adding edge to node before adding node.
This commit introduces the requirement specified in BOLT#7,
where we ignore any node announcements for a specific node
if we yet haven't seen any channel announcements where this
node takes part. This is to prevent someone DoS-ing the
network with cheap node announcements. In the router this
is enforced by requiring a call to AddNode(node_id) to
be preceded by an AddEdge(edge_id) call, where node_id is
one of the nodes in edge_id.
2017-08-02 15:58:58 -07:00
Andrey Samokhvalov
2d378b3280 htlcswitch+router: add onion error obfuscation
Within the network, it's important that when an HTLC forwarding failure
occurs, the recipient is notified in a timely manner in order to ensure
that errors are graceful and not unknown. For that reason with
accordance to BOLT №4 onion failure obfuscation have been added.
2017-07-14 19:08:04 -07:00
Olaoluwa Osuntokun
1be4d67ce4
multi: run all test instances in parallel 2017-06-17 01:00:07 +02:00
Olaoluwa Osuntokun
bfc869739d
routing: fix linter error 2017-05-15 18:21:13 -07:00
Olaoluwa Osuntokun
cc19695dad
routing: reject channel announcement if connected vertexes are unknown
This commit modifies the processing in the routing package eo new
announcements. Previously,  if we cgot a cnew channel announcement but
didn’t yet know of the verses that the chanell connected, the
cnnounacment would be accepted. This behavior was eronoues as if the
channel were to be queried for, the DB query would fail as we would be
unable to retrieve the two nodes involved int he channel.

To avoid such an error case, we will now _reject_ any channel
announcements in which we don’t yet have a valid node announcement for
the connected nodes. This case has been inserted into the handling of
channel announcement, a new test has been added, and finally older
tests have also been updated to ensure that nodes are added to the
database _before_ the edge is.
2017-05-14 19:27:24 -07:00
Olaoluwa Osuntokun
828d28581a
routing: abandon ChainNotifier for FilteredChainView
This commit modifies the routing package to no longer use the
ChainNotifier for pruning the channel graph. Instead, we now use the
FilteredChainView interface to more (from the ChannelRouter’s PoV)
efficiently maintain the channel graph.

Rather than scanning the _entire_ block manually, we now rely on the
FilteredChainView to provide us with FilteredBlocks which include
_only_ the relevant transactions that we care about.
2017-05-11 15:20:48 -07:00
Olaoluwa Osuntokun
2d10d83f07
routing: assert that paths have same length in isSamePath 2017-04-13 14:42:35 -07:00
Andrey Samokhvalov
07076cce21 routing+channeldb: add AddProof method
Originally we adding the edge without proof in order to able to use it
for payments path constrcution. This method will allow us to populate
the announcement proof after the exchange of the half proofs and
constrcutrion of full proof finished.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
4bca54e30c routing: add validation of utxo
Add check that the edge that was received really exist in the blockchain
and that the announced funding keys and capcity corresponds to reality.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
b4ac7071ff discovery+routing: split 'routing' package on 'routing' and 'discovery'
In this commit the routing package was divided on two separete one,
this was done because 'routing' package start take too much responsibily
on themself, so with following commit:

Routing pacakge:
Enitites:
* channeldb.ChannelEdge
* channeldb.ChannelPolicy
* channeldb.NodeLightning

Responsibilities:
* send topology notification
* find payment paths
* send payment
* apply topology changes to the graph
* prune graph
* validate that funding point exist and corresponds to given one
* to be the source of topology data

Discovery package:
Entities:
* lnwire.AnnounceSignature
* lnwire.ChannelAnnouncement
* lnwire.NodeAnnouncement
* lnwire.ChannelUpdateAnnouncement

Responsibilities:
* validate announcement signatures
* sync topology with newly connected peers
* handle the premature annoucement
* redirect topology changes to the router susbsystem
* broadcast announcement to the rest of the network
* exchange channel announcement proofs

Before that moment all that was in the 'routing' which is quite big for
one subsystem.

split
2017-03-29 19:49:05 -07:00
Olaoluwa Osuntokun
b126298b2b
routing: implement route failure fallback in SendPayment
This commit adds payment route failure fallback to SendPayment. By
this, we mean that we now take all the possible routes found during
path finding and try them in series. Either a route fails and we move
onto the next one, or the route is successful and we terminate early.

With this commit, sending payments using lnd is now much more robust as
if there exists an eligible route with sufficient capacity, it will be
utilized.
2017-03-21 12:20:45 -07:00
Olaoluwa Osuntokun
1df5bece85
routing: FindRoute is now FindRoutes, uses our KSP algo, ranks by fee
This commit modifies the existing FindRoute method on the ChannelRouter
to now use the KSP implementation added in a prior commit.

This new method FindRoutes, is able to find all the possible paths
between a source and destination. The method takes all paths reported
by findPaths, and attempt to turn each of them into a route. A route
differs from a path in that is has complete time-lock and fee
information. Some paths may not be able to be turned into routes as
once fees are accounted for the have an insufficient flow. We then take
the routes, sort them by total fee (with time-lock being a
time-breaker), then return them in sorted order.
2017-03-21 12:20:40 -07:00