Commit Graph
100 Commits
Author SHA1 Message Date
Johan T. Halseth c1ab49909f Merge pull request #2517 from roeierez/chain_control_cleanup
Proper cleanup neutrino database in case of error
2019-02-07 17:26:44 +01:00
Johan T. Halseth 351865ac67 Merge pull request #2591 from halseth/fndg-dont-spew-shortchanid
[trivial] fundingmanager: don't spew log shortChanID
2019-02-07 11:36:12 +01:00
Johan T. Halseth 4698d18294 fundingmanager: don't spew shortChanID
gives uneccessary output as

2019-02-06 11:26:45.338 [INF] FNDG: Announcing ChannelPoint(cf659a58d68f206531136bf19dea82863a488937f9f4c3d489c450ad81c1724e:0), short_chan_id=(*lnwire.ShortChannelID)(0xc000670a60)(1977:1:0)
2019-02-06 16:04:16 +01:00
Johan T. Halseth 5181f100ed subscribe: add new subscribe package
This commit creates a new package 'subscribe', that exposes a common
Client-Server subscription system, that can be shared among packages.
2019-02-05 18:17:54 -08:00
Johan T. Halseth 49a85b2eb3 autopilot/agent_test: add TestAgentQuitWhenPendingConns
TestAgentQuitWhenPendingConns tests that we are able to stop the autopilot
agent even though there are pending connections to nodes.
2019-02-05 10:45:53 +01:00
Johan T. Halseth c19763c03f autopilot/agent: don't block Stop on pending connetion
To ensure a call to ConnectToPeer doesn't block the agent from
shutting down, we'll launch it in a non-waitgrouped goroutine, that
will signal when a result is returned.
2019-02-05 10:45:53 +01:00
Johan T. Halseth 19ecc19d55 chainnrnfs/neutrino: return on historicalConf error
Would otherwise update height hint cache even on error during rescan.
2019-02-04 21:31:24 +01:00
Johan T. Halseth 5d33d7226c Merge pull request #2477 from cfromknecht/utxo-lnrpc
lnrpc: replace ChanPoint w/ OutPoint in ListUnspent resp
2019-02-04 12:50:57 +01:00
Johan T. Halseth 9d9d148262 utxonursery: use baby expiry as height hint
Previously we would use the best known height as height hint, which
could lead to using a height hint above the actual block it confirms,
hence losing track of the confirmation.
2019-02-04 12:30:05 +01:00
Johan T. Halseth 5d7bb7406f Merge pull request #2568 from cfromknecht/lint-all-travis-builds
Makefile: lint all travis builds
2019-02-04 10:30:07 +01:00
Johan T. Halseth 3daaa8cf74 lndrpc/invoicesrpc+walletrpc: clean up imports 2019-02-02 15:48:22 +01:00
Johan T. Halseth 7dab8b8f2d lnrpc/autopilotrpc: remove unused "os" import
This would cause the build to fail since the import is not used. It was
not detected since the file is under a build flag.
2019-02-02 15:48:15 +01:00
Johan T. Halseth 47918bd6ce lnwallet/channel: add restoration sanity check
To avoid more bugs slipping through where the logIndex is not set, we
panic to catch this. This was earlier done for Adds and the htlcCounter,
which did lead us to find the resulting retoration bug.
2019-01-31 09:24:50 +01:00
Johan T. Halseth 9a0f87fd8e lnwallet/channel_test: add TestFeeUpdateOldDiskFormat
TestFeeUpdateOldDiskFormat tests that we properly recover FeeUpdates
written to disk using the old format, where the logIndex was not
written.
2019-01-31 09:24:50 +01:00
Johan T. Halseth b593c1c7c7 lnwallet/channel: set logIndex for restored FeeUpdate
Earlier versions did not write the log index to disk for fee updates, so
they will be unset. To account for this we set them to to current update
log index.
2019-01-31 09:24:49 +01:00
Johan T. Halseth da42ad245f funding: cap the max_htlc value at channel capacity
We are not longer validating the max_value_in_flight field set by the
remote peer, so it is not always less than the channel capacity anymore.
We therefore make sure to cap it before advertising it.
2019-01-30 09:05:01 +01:00
Johan T. Halseth 6a78141a2d Merge pull request #2536 from cfromknecht/notify-online-log
server: fix notify-online log message
2019-01-25 13:29:03 +01:00
Johan T. Halseth 5306ed5b68 lncli: add autopilot query command
To query the autopilot heuristics for scores.
2019-01-23 09:05:43 +01:00
Johan T. Halseth 8874be764e lnrpc/autopilotrpc: implement QueryScores RPC 2019-01-23 09:05:43 +01:00
Johan T. Halseth a654be5884 lnrpc/autopilotrpc: add QueryScores API
Adds a new lnrpc API that lets the caller get ("dry run") the scores
that would be given to a set of node by the available autopilot
heuristics.
2019-01-23 09:05:43 +01:00
Johan T. Halseth 8f54a2bd6f autopilot/manager: add QueryHeuristics
Proxies a query request to the active agent.
2019-01-23 09:05:43 +01:00
Johan T. Halseth 6c556fd92a autopilot/agent: add queryHeuristics
This commit adds a method queryHeuristic that will query all simple
heuristics for node scores, in addition to the current active heuristic.
2019-01-23 09:05:43 +01:00
Johan T. Halseth cf01879d96 autopilot/agent: protect chanState with mutex
Since we want to access the current channel state outside the main
autopilot agent goroutine, we make sure it is protected by a mutex.
2019-01-23 09:05:42 +01:00
Johan T. Halseth 8ab718368d lnd+pilot+autopilot: use config to set active autopilot heuristics 2019-01-23 09:05:42 +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 33b2d92b80 lnd_test: don't shadow predErr
Would lead to the printed predErr not being set. We instead use the new
WaitNoError method to avoid this.
2019-01-22 13:41:51 +01:00
Johan T. Halseth 0714ffa0d7 lntest/harness: add WaitNoError 2019-01-22 13:38:05 +01:00
Johan T. Halseth adb512e6bf lntest/node: print amounts in same format 2019-01-22 13:23:30 +01:00
Johan T. Halseth 7d34ce9d08 lnwire+multi: define HasMaxHtlc helper on msgFlags 2019-01-22 08:42:30 +01:00
Johan T. Halseth 4f9de9bf1d fundingmanager_test: add TestFundingManagerRejectInvalidMaxValueInFlight 2019-01-22 08:42:30 +01:00
Johan T. Halseth 4aa52d267f funding+lnwallet: ensure max_htlc_value_in_flight smaller than capacity
Return an error to the remote if larger.
2019-01-22 08:42:29 +01:00
Johan T. Halseth 01e679786d channeldb/graph_test: add TestEdgePolicyMissingMaxHtcl 2019-01-22 08:42:28 +01:00
Johan T. Halseth 6fcc76fc68 channeldb/channel: ignore ChannelEdgePolicy with missing max_htlc
If the max_htlc field is not found when fetching a ChannelEdgePolicy
from the DB, we treat this as an unknown policy.

This is done to ensure we won't propagate invalid data further. The data
will be overwritten with a valid one when we receive an update for this
channel.

It shouldn't be very common, but old data could be lingering in the DB
added before this field was validated.
2019-01-22 08:42:28 +01:00
Johan T. HalsethandValentine Wallace 8dd074ee57 channeldb/graph_test: assert MaxHTLC field correctness
Co-authored-by: Valentine Wallace <valentine.m.wallace@gmail.com>
2019-01-22 08:42:27 +01:00
Johan T. Halseth b9c5248915 channeldb/graph: extract ChannelEdgePolicy serialization 2019-01-22 08:42:27 +01:00
Johan T. Halseth 91c9e45031 channeldb/graph: check correct bucket for nilness 2019-01-22 08:42:27 +01:00
Johan T. Halseth f48c8f91c4 lnd+pilot: use WeightedCombAttachment
We make the default autopilot agent use the WeightedCombAttachment.
Currently it uses only one sub-heuristic, prefAttachment.
2019-01-21 09:44:38 +01:00
Johan T. Halseth bdbadeaa75 autopilot: add WeightedCombAttachment
This commit defines a new heuristic WeightedCombAttachment that takes a
set of sub-heuristics, and produces a final node score by querying the
sub-heuristics and combining the scores from them according to their
weights.

This way it will look like a regular, single heuristic to the autopilot
agemnt, but can be a more complex combination of several.
2019-01-21 09:44:38 +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 4cbc6e6e07 make: build lnd-itest before flakehunting 2019-01-17 14:40:20 +01:00
Johan T. Halseth 8af2473644 channeldb/addr_test: add tests for invalid onion addresses 2019-01-17 14:16:15 +01:00
Johan T. Halseth 6a3e1423d2 channeldb/addr: sanity check onion address length before writing to db 2019-01-17 14:16:15 +01:00
Johan T. Halseth e2e00f9dd2 channeldb/addr_test: add invalid TCP cases
These are invalid length IP addresses that earlier would not fail to
serialize.
2019-01-17 14:16:15 +01:00
Johan T. Halseth 02b7bb356a channeldb/addr: validate ip before writing 2019-01-17 14:16:12 +01:00
Johan T. Halseth 6f605b2de2 channeldb/addr_test: inspect error string
Lets us match on more than static errors.
2019-01-17 14:14:24 +01:00
Johan T. Halseth 5dc87ad4d7 gitignore: ignore .minerlogs folder 2019-01-16 10:11:47 +01:00
Johan T. Halseth 2b16fb7271 lnd_test: fix reorg test by using new Node RPC
Since the chain backend and miner is now seperate nodes, the reorg test
must be slightly rewritten. We use the Btcd Node RPC to connect and
disconnect the three bitcoin nodes in question (chain backend, miner,
temp miner) to control the reorg scenario.
2019-01-16 10:10:22 +01:00
Johan T. Halseth 92b984a233 lnd_test+lntest: seperate miner and chain backend
Since we are no longer passing in the miner as the chain backend, we
don't have to export the fields.
2019-01-16 10:10:22 +01:00
Johan T. Halseth 989fe50da8 lntest: define BackendCfg and btcd impl
BackendCfg is an interface that can be backed by different Bitcoin node
implementations. We currently use the btcdHarness as our chain backend.
2019-01-16 09:44:29 +01:00
Johan T. Halseth a324691013 Merge pull request #2289 from ccdle12/unsettled-balance
rpcserver+lnd_test: fixing unassigned UnsettledBalance field
2019-01-11 10:50:56 +01:00
Johan T. Halseth 3c2b46eb8c Merge pull request #2445 from cfromknecht/netann-logging
netann: Add NANN subsystem logger
2019-01-11 10:45:29 +01:00
Johan T. Halseth 058b0e5767 Merge pull request #2454 from cfromknecht/handle-write-errors
peer: handle message encoding errors on write
2019-01-11 09:36:21 +01:00
Johan T. Halseth e6ee835bbe lnwallet/channel_test: assert FeeUpdate is removed from logs after lock-in 2019-01-10 12:31:12 +01:00
Johan T. Halseth dadfcefc07 lnwallet/channel: don't return feePerKw from computeView
Since the feerate is part of the computed view now, we don't have to
pass the found feerate as a distinct parameter.
2019-01-10 12:31:12 +01:00
Johan T. Halseth 7e015258cd lnwallet/channel test: add TestUpdateFeeConcurrentSig
This tests make sure we don't reset our expected fee upate after signing
our next commitment. This test would fail without the previous set of
commits.
2019-01-10 12:31:12 +01:00
Johan T. Halseth 6ffd354d63 lnwallet/channel: add fee updates to update logs
Instead of special casing the UpdateFee messages, we instead add them to
the update logs like any other HTLC update message. This lets us avoid
having to keep an extra set of variables to keep track of the fee
updates, and instead reuse the commit/ack logic used for other updates.

This fixes a bug where we would reset the pendingFeeUpdate variable
after signing our next commitment, which would make us calculate the new
fee incorrectly if the remote sent a commitment concurrently.

When restoring state logs, we also make sure to re-add any fee updates.
2019-01-10 12:31:12 +01:00
Johan T. Halseth 810c56cdb9 lnwallet/channel: process FeeUpdate found in update log
This commit makes the evaluateHTLCView method process any found
FeeUpdates in the logs, by returning the last set feerate.
2019-01-10 12:31:11 +01:00
Johan T. Halseth 277949cb0e lnwallet/channel: remove FeeUpdates when compacting logs
When compacting the update logs we remove any fee updates when they
remove height is passed. We do this since we'll assume fee updates are
added and removed at the same commit height, as they will apply for all
commitments following the fee update.
2019-01-10 12:26:41 +01:00
Johan T. Halseth 480f43f1dc lnwallet/channel: add lnwire<->PaymentDescriptor FeeUpdate conversion
This commit adds conversion between the lnwire.UpdateFee message and the
new FeeUpdate PaymentDescriptor. We re-purpose the existing Amount field
in the PaymentDescriptor stuct to hold the feerate.
2019-01-10 12:26:33 +01:00
Johan T. Halseth 36857a1042 lnwallet/channel: add new PaymentDescriptor type FeeUpdate
This commit adds a new updateType that can be used for
PaymentDescriptors: FeeUpdate. We repurpose the fields of the existing
PaymentDescriptor struct such that we can easily re-use the commit/ack
logic used for other update types also for fee updates.
2019-01-10 12:23:56 +01:00
Johan T. Halseth 3ab01898fb Merge pull request #2417 from cfromknecht/min-backoff
server: configurable min backoff
2019-01-08 15:07:50 +01:00
Johan T. Halseth 5c41243f35 Merge pull request #2118 from halseth/make-fmt-2
make: ensure make fmt is run with -s flag
2019-01-08 10:32:34 +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 3739c19ef8 autopilot/pref_attachment: rename ConstrainedPrefAttachment->PrefAttachment
Since the ConstrainedPrefAttachment no longers require the heuristic to
be aware of the autopilot constraints, we rename it PrefAttachment.
2019-01-08 10:10:59 +01:00
Johan T. Halseth ccf4b7feab autopilot: move address lookup from heuristic to agent
To avoid having the heuristics deal with (possibly conflicting) address
lookups, we let the agent handle them.
2019-01-08 10:10:59 +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 d5f3714f86 autopilot/agent: return early if no funds available
If there are less funds available than the minumum channel size, there's
no reason to score candidates, so we continue early.
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 fbfc9a53af autopilot: TestConstrainedPrefAttachmentNeedMoreChan->TestConstraintsChannelBudget
Since the constraints are no longer something the heuristic needs to be
aware of, we move the test.
2019-01-08 10:10:58 +01:00
Johan T. Halseth 0e1713956b autopilot/agent: call ChannelBudget on constrainsts
We let the agent call ChannelBudget on its constraints directly, and
not go through the heuristic. This is needed since when we want to have
multiple active heuristics concurrently, it won't make sense anymore to
ask each of the heuristics.

The mockConstraints are also updated to act as the mockHeuristic did
before, by making it possible to control the responses it gives by
sending them on the contained channels.
2019-01-08 10:10:58 +01:00
Johan T. Halseth 1d82e12fcf autopilot: define AgentConstraints
To decouple the autopilot heuristic from the constraints, we start by
abstracting them behind an interface to make them easier to mock. We
also rename them HeuristicConstraints->AgentConstraints to make it clear
that they are now constraints the agent must adhere to.
2019-01-08 10:10:58 +01:00
Johan T. Halseth c9868aae8f htlcswitch test: add fwdinglog inspection on triggered FwdEventTicker 2018-12-20 08:57:22 +01:00
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 902d6edad2 autopilot/choice: add weightedChoice tests 2018-12-19 08:27:35 +01:00
Johan T. Halseth 4ac3c171ec autopilot/choice: avoid costly map allocations
This commit makes the weightedChoice algorithm take a slice of weights
instead of a map of node scores. This let us avoid costly map allocation
and iteration.

In addition we make the chooseN algorithm keep track of the remaining
nodes by keeping a slice of weights through its entire run, similarly
avoiding costly map allocation and iteration.

In total this brings the runtime of the TestChooseNSample testcase down
from ~73s to ~3.6s.
2018-12-19 08:27:34 +01:00
Johan T. Halseth 3d2a39a18c autopilot/choice_test: add chooseN tests 2018-12-19 08:27:34 +01:00
Johan T. Halseth a202860ce1 autopilot: make n uint32 in chooseN
To avoid negative values being input, as it doesn't really make sense.
2018-12-19 08:27:34 +01:00
Johan T. Halseth 80ac8c1df0 lncli: add lncli autopilot commands
This commit adds commands 'status', 'enable' and 'disable' for
autopilot.

The commands will only be enabled for autopilotrpc builds of lncli.
2018-12-13 13:02:40 +01:00
Johan T. Halseth fdf903b8a9 gitignore: only match binaries in current folder, remove main* 2018-12-13 12:33:45 +01:00
Johan T. Halseth 8754635de5 rpcsercer+subservercfg: populate autopilot RPC config 2018-12-13 12:33:45 +01:00
Johan T. Halseth 28a92185cc lnrpc: add autopilotrpc driver 2018-12-13 12:33:44 +01:00
Johan T. Halseth 568c32d1fa lnrpc/autopilotrpc: add lnrpc autopilot server 2018-12-13 12:33:44 +01:00
Johan T. Halseth 00376230ff lnrpc+log: add autopilot rpc logger 2018-12-13 12:33:44 +01:00
Johan T. Halseth 413aad5efa lnrpc+subserver_cfg: add configs for autopilot sub-server 2018-12-13 12:33:44 +01:00
Johan T. Halseth db4bbe1c3a lnrpc: add autopilotrpc subservice
This commit adds a new service lnrpc/autopilot, that is to be used to
communicate with the running autopilot. Currently a RPC for getting the
status of the agent is included, as well as enabling/disabling at
runtime.
2018-12-13 12:33:38 +01:00
Johan T. Halseth cff42e06c8 pilot+lnd: let autopilot.Manager manage pilot-agent
This commit moves the responsibility of managing the life cycle of the
autopilot from main to the autopilot Manager. It utilizes the recently
introduced autopilot Manager, and just sets up the necessary interfaces
for the Manager to properly set up the required subscriptions when
starting the agent.
2018-12-13 12:26:29 +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
Johan T. Halseth 3be292b36e lnd_test: use context with timeout instead of context.Background
To ensure RPC calls won't block indefinitely.
2018-12-13 08:34:57 +01:00
Johan T. Halseth f989b2ece8 lnd_test: let assertNumConnections set its own context 2018-12-13 08:33:13 +01:00
Johan T. Halseth 6a4edc8335 lnd_test: let assertNodeNumChannels set its own context 2018-12-13 08:33:12 +01:00
Johan T. Halseth 4db939069a lnd_test: use cancelable context for SendPayment 2018-12-13 08:31:58 +01:00
Johan T. Halseth fd347888bb lnd_test: make assertAmountPaid set its own context timeout
Let us avoid having to set it each time we call it.
2018-12-13 08:31:58 +01: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 71444e74ac Merge pull request #2033 from gitlikeagirl/ckc-hashinsendresponse
lnrpc: Add payment hash to SendResponse
2018-12-11 09:54:52 +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