Commit Graph

84 Commits

Author SHA1 Message Date
Johan T. Halseth
dbf7b380a9
autopilot/manager: only set m.pilot if started successfully
This commit fixes a subtle bug within the autopilot manager, that would
cause the active pilot to not be reset in case it wasn't started
successfully.

We also make sure the associated goroutines close over the started
pilot, and not the active pilot.
2018-12-19 19:48:44 +01:00
Johan T. Halseth
6310ed0f1c
autopilot: add autopilot.Manager
This commit adds a new type Manager responsible for managing an
autopilot agent, making it possible to start and stop it at runtime.
2018-12-13 12:26:29 +01:00
Olaoluwa Osuntokun
d24a6d2a3d
Merge pull request #2304 from halseth/weigthed-choice-errnopositive
[autopilot] Don't fail on no more positive nodes
2018-12-12 12:21:06 -08:00
Johan T. Halseth
8e57ed7025
autopilot/agent_test: let agent self-trigger retry
This ensures that it is done updating its pending connections map before
re-querying the heuristic.
2018-12-11 10:21:40 +01:00
Johan T. Halseth
dda7355ad6
autopilot/agent_test: ensure mochHeuristics exits cleanly 2018-12-11 10:20:38 +01:00
Johan T. Halseth
0255db5120
autopilot/prefattach_test: ensure non-connected nodes get 0-score
This addition to the unit tests makes sure nodes that have no channels
in the graph are left out od the scored nodes, implicitly giving them a
score of 0.
2018-12-10 15:05:24 +01:00
Johan T. Halseth
b9c33da3f8
autopilot/prefattach: skip nodes having no channels 2018-12-10 15:01:43 +01:00
Johan T. Halseth
aeeff4714d
autopilot/graph: define addRandNode 2018-12-10 15:01:43 +01:00
Johan T. Halseth
5224c94aaf
autopilot/prefattach_test: assert scored nodes having addresses
This addtion to the test makes sure the scored nodes have their
addresses populated. This would fail without the previous commit.
2018-12-10 15:01:05 +01:00
Johan T. Halseth
d9eef4625e
autopilot/prefattach: populate Addrs field 2018-12-10 15:00:41 +01:00
Johan T. Halseth
55ba5fe654
autopilot/graph: add addresses to memNode 2018-12-10 14:56:54 +01:00
Johan T. Halseth
40db2dd5a5
autopilot/choice: return ErrNoPositive in case no choice can be made 2018-12-10 13:53:36 +01:00
Johan T. Halseth
f1e8c8d5b5
autopilot/agent: move choice algorithms to new file choice.go 2018-12-10 13:53:31 +01:00
Johan T. Halseth
6130189d95
autopilot/interface+agent: remove Select 2018-12-06 14:26:28 +01:00
Johan T. Halseth
b3d315298c
autopilot/agent: use NodeScores to select channel candidates
This commit makes the autopilot agent use the new NodeScores heuristic
API to select channel candiates, instead of the Select API. The result
will be similar, but instead of selecting a set of nodes to open
channels to, we get a score based results which can later be used
together with other heuristics to choose nodes to open channels to.

This commit also makes the existing autopilot agent tests compatible
with the new NodeScores API.
2018-12-06 14:26:26 +01:00
Johan T. Halseth
e84bd29836
autopilot/agent: add weightedChoice and chooseN algorithm
The algorithms will be used to select nodes at random from the weighted
distribution set by the node's scores given by the heuristic.
2018-12-06 14:26:05 +01:00
Johan T. Halseth
be45697c6d
autopilot/prefattach_test: use NodeScores API for prefAttach tests
This commit converts the existing unit tests of Select into tests of
NodeScores.
2018-12-06 14:26:05 +01:00
Johan T. Halseth
5e8e54083f
autopilot/prefattach+interface: add API NodeScores
This commit adds a new method NodeScores to the AttachementHeuristic
interface. Its intended use is to score a set of nodes according to
their preference as channel counterparties.

The PrefAttach heuristic gets a NodeScores method that will score the
ndoes according to their number of already existing channels, similar to
what is done already in Select.
2018-12-06 14:26:05 +01:00
Johan T. Halseth
5ecc209c41
autopilot/interface+agent: remove NodeKey from AttachmentDirective
Instead parse the pubkey bytes only when needed.
2018-12-06 14:26:05 +01:00
Johan T. Halseth
89c3c5319f
autopilot/agent: split opening logic into own method
This commit takes the logic after the autopilot agent has decided that it
needs to open more channels, and moves it into a new method openChan.
2018-12-06 14:26:03 +01:00
Johan T. Halseth
26810fe928
autopilot/agent: split attachement directive attempts into method 2018-12-06 14:25:22 +01:00
Johan T. Halseth
fb10175ea5
autopilot/agent: add maps to agent struct
This commit moves the maps used by the controller loop to the Agent
struct, in preparation for breaking it up into smaller parts.
2018-12-06 14:24:18 +01:00
Johan T. Halseth
86e6d230f2
autopilot/agent: add attachment directive goroutine to wait group 2018-12-06 14:24:15 +01:00
Johan T. Halseth
35f4ec84d1
autopilot/prefattach: use HeuristicConstraints
This commit makes the pref attach heuristic and the agent use the
HeuristicConstraints internally.
2018-12-06 11:25:30 +01:00
Johan T. Halseth
e98d859882
autopilot: define HeuristicConstraints
This commit defines a new struct HeuristicConstraints that will be used
to keep track of the initial constraints the autopilot agent needs to
adhere to. This is currently done in the ConstrainedPrefAttachement
heuristic itself, but this lets us share these constraints and common
method netween several heuristics.
2018-12-06 11:20:09 +01:00
Olaoluwa Osuntokun
1fd3aac925
multi: switch from bolt packge to bbolt package for all imports 2018-11-29 20:33:49 -08:00
ErikEk
c5f61b3c06 Typo fix autopilot 2018-10-09 18:28:34 +02:00
Olaoluwa Osuntokun
3fda1029c0
Merge pull request #1786 from Roasbeef/golang-1.1
build+docs: bump to golang 1.11
2018-10-08 13:26:07 +09:00
Olaoluwa Osuntokun
d8e6085c17
multi: update to go 1.11 gofmt 2018-10-07 14:37:38 +09:00
Conner Fromknecht
59b459674d
multi: init subsystem loggers via build pkg 2018-10-05 13:04:45 +09:00
Conner Fromknecht
d5f97f7bdc
autopilot/multi: replace PubKey -> NodeKey on directive 2018-09-05 20:10:37 -07:00
Conner Fromknecht
e702a6a266
autopilot/agent_test: remove Fatalf calls from goroutines 2018-09-05 20:10:36 -07:00
Conner Fromknecht
2b578e06fc
autopilot/agent_test: ensure directives use unique keys
This commit ensures that the mock attachment
directives use unique keys, ensuring that they
aren't skipped due to already having pending
connection requests. The tests fail when
they're all the same since they collide
in the pendingConns map.
2018-09-05 20:10:35 -07:00
Conner Fromknecht
7d9483c20d
autopilot/agent_test: adds TestAgentSkipPendingConns
Adds a test asserting that the agent prevents
itself from making duplicate outstanding
connection requests to the same peer.
2018-09-05 20:10:35 -07:00
Conner Fromknecht
c214bea9db
autopilot/prefattach: set NodeID for selection candidates 2018-09-05 20:10:34 -07:00
Conner Fromknecht
08b6bf54fb
autopilot/interface: expose NodeID in AttachmentDirective 2018-09-05 20:10:34 -07:00
Conner Fromknecht
4599b0eac3
autopilot/agent: track pending connections
This commit modifies the autopilot agent to track
all pending connection requests, and forgo further
attempts if a connection is already present.
Previously, the agent would try and establish
hundreds of requests to a node, especially if the
connections were timing out and not returning.

This resulted in an OOM OMM when cranking up
maxchannels to 200, since there would be close
to 10k pending connections before the program was
terminated. The issue was compounded by periodic
batch timeouts, causing autopilot to try and
process thousands of triggers for failing
connections to the same peer.

With these fixes, autopilot will skip nodes that we
are trying to connect to during heuristic selection.
The CPU and memory utilization have been significantly
reduced as a result.
2018-09-05 20:10:34 -07:00
Olaoluwa Osuntokun
b0347879db
Merge pull request #1817 from halseth/autopilot-node-update
Reduce goroutine overhead on autopilot updates
2018-09-05 18:08:37 -07:00
Olaoluwa Osuntokun
1217992d9d
autopilot: optimize heavy loaded agent by fetching raw bytes for ChannelEdge
In this commit, we implement an optimization to the autopilot agent to
ensure that we don't spin and waste CPU when we either have a large
graph, or a high max channel target for the agent. Before this commit,
each time we went to read the state of a channel from disk, we would
decompress the EC Point each time. However, for the case of the instal
ChannlEdge struct to feed to the agent, we only actually need to obtain
the pubkey, and can save the potentially expensive point decompression
for each directional channel in the graph.
2018-09-04 16:43:07 -07:00
Johan T. Halseth
0d4df54118
autopilot/agent: signal balanceUpdates on own channel 2018-09-04 10:18:15 +02:00
Johan T. Halseth
a9a9c9aeb4
autopilot/agent: signal chanPendingOpenUpdates on own channel 2018-09-04 10:17:59 +02:00
Johan T. Halseth
186e6d4da4
autopilot/agent: signal chanOpenFailureUpdates on own channel
We do this to avoid a huge amount of goroutines piling up when autopilot
is trying to open many channels, as they will all block trying to send
the update on the stateUpdates channel. Now we instead send them on a
buffered channel, similar to what is done with the nodeUpdates.
2018-09-04 10:17:33 +02:00
Johan T. Halseth
4a88c61a90
autopilot/agent: signal nodeUpdates on own channel
We do this to avoid a huge amount of goroutines piling up on initial
graph sync, as they will all block trying to send the node update on the
stateUpdates channel. Now we instead make a new buffered channel
nodeUpdates, and just return immediately if there is already a signal in
the channel waiting to be processed.
2018-09-04 10:17:09 +02:00
Johan T. Halseth
3e992f094d
autopilot/agent: move signal processing out of select 2018-09-04 10:06:15 +02:00
Olaoluwa Osuntokun
4f43c1c943
Merge pull request #1811 from Roasbeef/autopilot-cpu-usage-fix
autopilot: modify the graph interface to return raw bytes for node pubkeys, not entire key
2018-09-03 19:56:51 -07:00
Olaoluwa Osuntokun
a429c56c10
autopilot: update the Node interface to return a raw bytes, not the key
In this commit, we modify the Node interface to return a set of raw
bytes, rather than the full pubkey struct. We do this as within the
package, commonly we only require the pubkey bytes for fingerprinting
purposes. Before this commit, we were forced to _always_ decompress the
pubkey which can be expensive done thousands of times a second.
2018-08-29 15:44:47 -07:00
Wilmer Paulino
e1a376d9f8
autopilot: use updateBalance rather than tracking balance explicitly
In this commit, we modify the balanceUpdate autopilot signal to update
the balance according to what's returned to the WalletBalance callback
rather than explicitly tracking the balance. This gives the agent a
better sense of what the wallet's balance actually is.
2018-08-29 02:06:02 -07:00
Conner Fromknecht
1898e57807
autopilot/agent_test: test that agent recovers from initial empty graph 2018-08-23 18:58:12 -07:00
Conner Fromknecht
602856750b
autopilot/agent: add OnNodeUpdates signal
Adds a new external signal alerting autopilot that
new nodes have been added to the channel graph or
an existing node has modified its channel
announcment. This allows autopilot to examine its
current state, and attempt to open channels if our
target state is not yet met.
2018-08-23 18:58:12 -07:00
Wilmer Paulino
aa7c2e6d47
autopilot: add OnChannelPendingOpen state update 2018-08-16 20:22:40 -07:00