Commit Graph

7820 Commits

Author SHA1 Message Date
Johan T. Halseth
89fd43ebcb
channeldb: add Route (de)serialization + test
We will store the routes used during payment attempts, so we need
serialization code.
2019-05-09 09:59:43 +02:00
Joost Jager
7a5bd29a69
lnrpc+routing: remove k shortest path finding 2019-05-07 19:54:06 +02:00
Johan T. Halseth
c4415f0400
Merge pull request #3044 from cfromknecht/spelling-fixes
multi: fix spelling mistakes
2019-05-07 08:50:36 +02:00
Olaoluwa Osuntokun
8307ac89a4
Merge pull request #3050 from cfromknecht/break-router-rescans
routing/router: break rescans on router quit
2019-05-06 16:21:35 -07:00
Olaoluwa Osuntokun
1d7d498d01
Merge pull request #3049 from cfromknecht/break-sync-send-server-quit
peer: break sendMessage on server quit
2019-05-06 16:15:04 -07:00
Conner Fromknecht
3f59e31248
routing/router: break rescans on router quit
This commit reevaluates the router's quit channel between each block
during the initial call to syncGraphWithChain, which, in the worst case,
may have to scan several thousand blocks on startup if the node has not
been active for some time. Without this, attempting to stop the daemon
will not exit until the rescan has completed, which for certain backends
could be several hours.
2019-05-06 15:04:40 -07:00
Conner Fromknecht
a11a8693ae
peer: break sendMessage on server quit
This commit modifies sendMessage to break on the server's quit channel,
which allows synchronous callers of SendMessage or SendLazyMessage to
receive an error during server shutdown which can be independent of a
particular peer's shutdown.

As of https://github.com/lightningnetwork/lnd/pull/2916, all replies
made by gossip syncers were modified to be synchronous. In certain
cases, This would prevent the syncers from shutting down promptly, as
they would try to offload a batch a of messages that could not be
aborted. Now, an error will be propagated back to the caller, allowing
them to detect the error condition, and reevaluate their own quit
signals, releasing any waitgrouped goroutines and permitting a quick
shutdown.
2019-05-06 14:56:52 -07:00
Olaoluwa Osuntokun
b31510102a
build: update release.sh to account for new lnd package 2019-05-06 12:18:44 -07:00
Olaoluwa Osuntokun
aeda418ea8
Merge pull request #3045 from erkarl/fix/litecoin-simnet-config
config: fix litecoin simnet mode
2019-05-06 11:38:04 -07:00
Karl Ranna
d941220762 config: fix litecoin simnet mode
This commit fixes a bug where it was impossible to run lnd in litecoin's
simnet mode because of code duplication. As a result `numNets > 1`
conditional was always true when running lnd with `cfg.Litecoin.SimNet`
flag.
2019-05-05 18:35:20 +03:00
Conner Fromknecht
17b2140cb5
multi: fix spelling mistakes 2019-05-04 15:35:37 -07:00
Olaoluwa Osuntokun
7f08c097fb
build: bump version to 0.6.1-beta 2019-05-03 17:04:27 -07:00
Olaoluwa Osuntokun
a8fa4094ba
Merge pull request #3027 from Roasbeef/new-onion-structs
router+build: update to the latest version of lightning-onion
2019-05-03 13:30:41 -07:00
Olaoluwa Osuntokun
649991c46f
Merge pull request #2887 from joostjager/asym-broadcast-delta
config: lower outgoing htlc broadcast delta
2019-05-03 13:28:31 -07:00
Olaoluwa Osuntokun
44eb2320c7
Merge pull request #3038 from wpaulino/tor-version-check
tor: use string comparison to check min supported version
2019-05-03 13:12:44 -07:00
Wilmer Paulino
4eb9ff2abf
tor: use string comparison to check min supported version
The current method would not allow version strings like 0.4.0.5 since it
would check every number of the version string individually.
2019-05-03 11:26:59 -07:00
Joost Jager
f5f6a52ed8
htlcswitch: check channel policy for local htlcs 2019-05-03 12:22:36 +02:00
Joost Jager
e571532d9a
htlcswitch: reorder policy checks
This commit reorders the policies check as a preparation for splitting
the checks in separate sets for the incoming and outgoing htlc.
2019-05-03 12:22:33 +02:00
Joost Jager
5d2de91241
config: update broadcast delta to reduce risk of channel force close 2019-05-03 12:22:30 +02:00
Olaoluwa Osuntokun
2f2a907b58
test: update itest to no longer expect incorrect message for sphinx replay test
In this commit, we update the itests to expect the correct message for
the sphinx replay test. Before the fixes in the prior commits, we
expected the wrong error since we were actually unable to decrypt these
converted malformed HTLC errors. Now, we'll properly return a parse able
error, so we assert against that error instead of the failure to decode
an error.
2019-04-30 20:13:40 -07:00
Olaoluwa Osuntokun
56c969c911
htlcswitch: add new TestUpdateFailMalformedHTLCErrorConversion test
In this commit, we add a new test to ensure that we're able to properly
convert malformed HTLC errors that are sourced from multiple hops away,
or our direct channel peers. In order to test this effectively, we force
the onion decryptors of various peers to always fail which will trigger
the malformed HTLC logic.
2019-04-30 20:13:38 -07:00
Olaoluwa Osuntokun
be63c7d286
htlcswitch: properly convert multi-hop malformed HTLC failures
In this commit, we now properly convert multi-hop malformed HTLC
failures. Before this commit, we wouldn't properly add a layer of
encryption to these errors meaning that the destination would fail to
decrypt the error as it was actually plaintext.

To remedy this, we'll now check if we need to convert an error, and if
so we'll encrypt it as if it we were the source of the error (the true
source is our direct channel peer).
2019-04-30 20:13:37 -07:00
Olaoluwa Osuntokun
cdc4aca40f
htlcswitch: properly handle direct link malformed HTLC failures
In this commit, we fix a bug that caused us to be unable to properly
handle malformed HTLC failures from our direct link. Before this commit,
we would attempt to decrypt it and fail since it wasn't well formed. In
this commit, if its an error for a local payment, and it needed to be
converted, then we'll decode it w/o decrypting since it's already
plaintext.
2019-04-30 20:13:36 -07:00
Olaoluwa Osuntokun
c67ca0a329
htlcswitch: add new EncryptMalformedError method to ErrorEncrypter
In this commit, we add a new method to the ErrorEncrypter interface:
`EncryptMalformedError`. This takes a raw error (no encryption or MAC),
and encrypts it as if we were the originator of this error. This will be
used by the switch to convert malformed fail errors to regular fully
encrypted errors.
2019-04-30 20:13:35 -07:00
Olaoluwa Osuntokun
649e080da6
htlcswitch: for UpdateFailMalformedHTLC packets mark fail as needing conversion
In this commit, we start the first phase of fixing an existing bug
within the switch. As is, we don't properly convert
`UpdateFailMalformedHTLC` to regular `UpdateFailHTLC` messages that are
fully encrypted. When we receive a `UpdateFailMalformedHTLC` today,
we'll convert it into a regular fail message by simply encoding the
failure message raw. This failure message doesn't have  a MAC yet, so if
we sent it backwards, then the destination wouldn't be able to decrypt
it. We can recognize this type of failure as it'll be the same size as
the raw failure message max size, but it has 4 extra bytes for the
encoding. When we come across this message, we'll mark is as needing
conversion so the switch can take care of it.
2019-04-30 20:13:34 -07:00
Olaoluwa Osuntokun
558c8ca2a8
lnwire: export failureMessageLength constant 2019-04-30 20:13:33 -07:00
Olaoluwa Osuntokun
bab957382f
router: convert Route.ToHopPayloads() to Route.ToSphinxPath()
In this commit, we update the process that we use to generate a sphinx
packet to send our onion routed HTLC. Due to recent changes in the
`sphinx` package we use, we now need to use a new PaymentPath struct. As
a result, it no longer makes sense to split up the nodes in a route and
their per hop paylods as they're now in the same struct. All tests have
been updated accordingly.
2019-04-30 20:13:32 -07:00
Olaoluwa Osuntokun
cba803b856 build: update to latest lightning-onion version 2019-04-30 20:13:15 -07:00
Olaoluwa Osuntokun
1acd38e48c
Merge pull request #2855 from Roasbeef/output-based-force-close-detection
contractcourt: detect local force closes based on commitment outputs
2019-04-30 15:39:41 -07:00
Olaoluwa Osuntokun
985902be27
Merge pull request #2916 from cfromknecht/split-syncer-query-reply
discovery: make gossip replies synchronous
2019-04-29 17:40:13 -07:00
Conner Fromknecht
517cdd66bf
Merge pull request #2189 from sparkswap/sparkswap/litecoin-regtest
add litecoin regtest to lnd
2019-04-29 15:46:15 -07:00
Olaoluwa Osuntokun
84dd949132
Merge pull request #2958 from halseth/route-sub-package
multi: move Route to sub-pkg routing/route
2019-04-29 15:36:38 -07:00
Johan T. Halseth
ee257fd0eb
multi: move Route to sub-pkg routing/route 2019-04-29 14:52:33 +02:00
Danny Paz
6fd5ef88b6 add litecoin regtest configuration to lnd
regtest change to chainregistry for default port number

merge w/ master
2019-04-26 21:14:26 -07:00
Conner Fromknecht
5251ebe117
discovery/syncer_test: fix benign off-by-one in DelayDOS test
Prior to this change, the numQueryResponses that we calculated would be
one more than what we actually wanted since it didn't account for the
initial QueryChannelRange msg. This resulted in the test sending one
extra delayed query than was configured. This doesn't fundamentally
impact the test, but does make what happens in the test more reflective
of the configuration.
2019-04-26 20:05:23 -07:00
Conner Fromknecht
bf4543e2bd
discovery/syncer: make gossip sends synchronous
This commit makes all replies in the gossip syncer synchronous, meaning
that they will wait for each message to be successfully written to the
remote peer before attempting to send the next. This helps throttle
messages the remote peer has requested, preventing unintended
disconnects when the remote peer is slow to process messages. This
changes also helps out congestion in the peer by forcing the syncer to
buffer the messages instead of dumping them into the peer's queue.
2019-04-26 20:05:10 -07:00
Conner Fromknecht
ca358e9673
lnpeer+peer: use importable lnpeer.ErrPeerExiting
As a prepatory step to making gossip replies synchronous, we will move
the ErrPeerExiting error into the lnpeer package so that it can be
imported by the discovery package. With synchronous sends, this error
can now be detected and handled by goroutines in the syncer, and cause
them to exit instead of continue to sending backlogs.
2019-04-26 20:04:49 -07:00
Conner Fromknecht
23d10336c2
discovery/syncer: separate query + reply handlers
This commit creates a distinct replyHandler, completely isolating the
requesting state machine from the processing of queries from the remote
peer. Before the two were interlaced, and the syncer could only reply to
messages in certain states. Now the two will be complete separated,
which is preliminary step to make the replies synchronous (as otherwise
we would be blocking our own requesting state machine).

With this changes, the channelGraphSyncer of each peer will drive the
replyHanlder of the other. The two can now operate independently, or
even spun up conditionally depending on advertised support for gossip
queries, as shown below:

          A                                 B
 channelGraphSyncer ---control-msg--->
                                        replyHandler
 channelGraphSyncer <--control-msg----
           gossiper <--gossip-msgs----

                    <--control-msg---- channelGraphSyncer
       replyHandler
                    ---control-msg---> channelGraphSyncer
                    ---gossip-msgs---> gossiper
2019-04-26 20:03:14 -07:00
Olaoluwa Osuntokun
42b081bb37
Merge pull request #2924 from cfromknecht/write-and-flush
peer: resume partial writes due to timeouts
2019-04-26 18:25:37 -07:00
Olaoluwa Osuntokun
0393793733
Merge pull request #2783 from cfromknecht/wtserver-db
watchtower/wtdb: add bbolt-backed tower database
2019-04-26 18:08:32 -07:00
Conner Fromknecht
54c908be1a
watchtower/wtserver/create_session: log missing error in create session 2019-04-26 17:22:02 -07:00
Conner Fromknecht
b7cd70f186
watchtower/wtdb/tower_db_test: add mock+bolt iface tests 2019-04-26 17:21:48 -07:00
Conner Fromknecht
3ef2a36733
watchtower/wtdb/tower_db: add TowerDB and db versioning 2019-04-26 17:21:35 -07:00
Conner Fromknecht
c99d1313fe
watchtower/wtdb/log: add WTDB logs 2019-04-26 17:21:20 -07:00
Conner Fromknecht
a36397e21a
watchtower/wtdb/codec_test: encode/decode quick checks 2019-04-26 17:21:05 -07:00
Conner Fromknecht
7ba197c6a7
watchtower/wtdb: add encode/decode to session info + updates 2019-04-26 17:20:52 -07:00
Conner Fromknecht
dccef4c8bf
watchtower/wtdb/codec: import channeldb code for extension 2019-04-26 17:20:36 -07:00
Conner Fromknecht
678ca9feff
channeldb/codec: add NewUnknownElementType constructor 2019-04-26 17:20:23 -07:00
Conner Fromknecht
2ce6228021
watchtower/wtmock/tower_db: move mock tower db to wtmock pkg 2019-04-26 17:19:58 -07:00
Olaoluwa Osuntokun
a783f35ad4
Merge pull request #2932 from wpaulino/sync-manager-improvements
discovery: SyncManager improvements
2019-04-26 15:59:38 -07:00