Commit Graph

26 Commits

Author SHA1 Message Date
Andras Banki-Horvath
be83d504f8 autopilot: introduce NodeMetric interface for arbitrary graph metrics
This commit adds the NodeMetric interface which will be used for all
graph metrics not directly part of the autopilot but are useful in
composite heuristics to drive autopilot decisions and improve node
scores.
2020-03-27 10:36:28 +01:00
Johan T. Halseth
bf7f392c11
autopilot: use subtractFees when funding channel
To make the autopilot able to account for fees, we let it use the
subtractFees option when opening channels.

This makes sure that each channel we attempt to open will eat at most
Amt out of our budget. Previously fees would eat into our funds in
addition, causing us to deplete our funds more than expected on each
channel opening.
2019-07-18 00:58:12 +02:00
Johan T. Halseth
9a7f24d2d3
autopilot: extract default fee estimate target conf into constant 2019-06-08 17:22:34 +02:00
Johan T. Halseth
b23e53ea33
autopilot/interface+externalscoreattach: define ScoreSettable
ScoreSettable is an interface that let caller set external scores for
the heuristic. The ExternalScoreAttachment and WeightedCombAttachment
heuristics implement this interface.
2019-02-14 11:41:47 +01:00
Johan T. Halseth
dff61facf2
autopilot: add ExternalScoreAttachment heuristic
This commit adds a new autopilot heuristic that is scoring based. It is
a simple heuristic that will keep a list of pubkeys and scores, and will
try opening channels with the nodes with the largest score first.
2019-02-14 11:37:47 +01:00
Johan T. Halseth
36e7694e8e
config+pilot: define autopilot.heuristic
And validate the config set by the user.
2019-01-23 09:05:42 +01:00
Johan T. Halseth
c0fed861d2
autopilot/interface: add Name() to AttachmentHeuristic interface 2019-01-23 09:05:42 +01:00
Johan T. Halseth
592ce92c72
autopilot/interface+prefattach: scale node scores to range [0.0, 1.0]
To prepare for combinning scores from multiple heuristics, we require the
scores returned from the NodeSores API to be in the range [0.0, 1.0].

The prefAttach heuristic is altered to scale the returned scores such
that the most connected node in the grpah is given a score of 1.0.
2019-01-21 09:44:37 +01:00
Johan T. Halseth
5b1e72a019
autopilot/interface+agent: return NodeScore from NodeScores
Since NodeScores no longer returns fully populated AttachmentDirectives,
we make this explicit by defining a new type NodeScore that includes a
subset of what the AttachmentDirective does.
2019-01-08 10:23:50 +01:00
Johan T. Halseth
25de66d27b
autopilot/interface+choice: add NodeScore type
We create a new type NodeScore which is a tuple (NodeID, score). The
weightedChoice and chooseN algorithms are altered to expect this type.

This is done in order to simplify the types we are using, since we were
only using a subset of the fields in AttachmentDirective.
2019-01-08 10:23:48 +01:00
Johan T. Halseth
cfd237bf1f
autopilot: move determining chanSize from heuristic to agent
Since we want to combine scores from multiple heuristics, things get
complicated if the heuristics report their own individual channel sizes.
Therefore we change the NodeScores interface slightly, letting the agent
specify the wanted channel size, and let the heuristic score the nodes
accordingly.
2019-01-08 10:10:59 +01:00
Johan T. Halseth
d0c4e253c6
autopilot/interface: remove NeedMoreChans from AttachmentHeuristic
Since the agent is now querying the constraints directly, NeedMoreChans
is no longer needed on the heuristic.
2019-01-08 10:10:59 +01:00
Johan T. Halseth
6130189d95
autopilot/interface+agent: remove Select 2018-12-06 14:26:28 +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
Conner Fromknecht
d5f97f7bdc
autopilot/multi: replace PubKey -> NodeKey on directive 2018-09-05 20:10:37 -07:00
Conner Fromknecht
08b6bf54fb
autopilot/interface: expose NodeID in AttachmentDirective 2018-09-05 20:10:34 -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
2fbe95ebba
autopilot: modify OpenChannel to no longer take in set of addrs 2018-08-16 19:19:30 -07:00
Conner Fromknecht
1ded697e8d
multi: sort import paths with gofmt 2018-08-02 18:20:49 -07:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Olaoluwa Osuntokun
9f52372cd2
autopilot: modify interfaces to specify *exactly* how many chans to open
In this commit, we fix a regression introduced by a recent change which
would allow the agent to detect a channel as failed, and blacklist the
node, promising faster convergence with the ideal state of the
heuristic.

The source of this bug is that we would use the set of blacklisted
nodes in order to compute how many additional channels we should open.
If 10 failures happened, then we would think that we had opened up 10
channels, and stop much earlier than we actually should.

To fix this, while ensuring we don’t retry to failed peers, the
NeedMoreChans method will now return *how* anymore channels to open,
and the Select method will take in how many channels it should try to
open *exactly*.
2018-02-08 20:08:18 -08:00
Daniel McNally
8543497dcc multi: fixing it's/its typos in comments 2018-02-06 19:13:07 -08:00
Matt Drollette
adf0d98194 multi: fix several typos in godoc comments 2017-12-17 18:40:05 -08:00
Olaoluwa Osuntokun
77e3e74ea2
autopilot: for ConstrainedPrefAttachment.Select factor in skipNodes
This commit modifies the Select method for the
ConstrainedPrefAttachment attachment heuristic slightly. Previously, it
was possible for an autopilot.Agent to go over the allotted number of
channels as it would unconditionally attempt to establish channel with
all returned Attachment Directives. To remedy this, we now assume that
we already have active, or pending channels to each of the nodes in the
set of skipNodes. Therefore, we now use the size of the skipNodes map
as an  upper limit within the primary selection loop.
2017-08-22 00:51:43 -07:00
Olaoluwa Osuntokun
306c4aef8e
autopilot: "Look ma no hands!", introducing autopilot mode
This commit introduces the initial implementation of the autopilot
mode. Autopilot is new mode within lnd that enables automatic channel
management. This means that if enabled lnd will attempt to
automatically manage channels according to a set of heuristic defined
within the main configuration for autopilot.Agent instance.

The autopilot.Agent implements a simple closed control loop. It takes
in external signals such as wallet balance updates, new open channel,
and channels that are now closed the updates its internal state. With
each external trigger it will consult the registered
AttachmentHeuristic to decide: if it needs to open any more channels,
and if so how much it should use to open the channels, ultimately
returning a set of recommended AttachmentDirectives. The
autopilot.Agent loop will then take those attempt to establish
connection, and go back in waiting for a new external signal.

With this first implementation the default heuristic is the
ConstrainedPrefAttachment implementation of AttachmentHeuristic. Given
a min and max channel size, a limit on the number of channels, and the
percentage of wallet funds to allocate to channels, it will attempt to
execute a heuristic drive by the Barabási–Albert model model in order
to attempt to drive the global graph towards a scale free topology.

This is commit implements a foundational layer for future simulations,
optimization, and additional heuristics.
2017-08-10 21:14:55 -07:00