Commit Graph

267 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Olaoluwa Osuntokun
2c08a22ed3
server: launch new invoiceRegistry goroutines on start up 2018-07-06 12:22:00 -07:00
Conner Fromknecht
5be6993a56
server: log pubkey hex in connection callbacks 2018-07-03 17:09:10 -07:00
Olaoluwa Osuntokun
17399994e4
config+server: update usage of lncfg methods to pass in resolver
In this commit, we update all the lncfg methods used to properly pass in
a new resolver. This is required in order to ensure that we don't leak
our DNS queries if Tor mode is active.
2018-06-27 18:10:34 -07:00
Olaoluwa Osuntokun
c03f731643
server: properly use the set of normalized external ips 2018-06-27 16:43:38 -07:00
Oliver Gugger
c1b1dd96ef
lncfg: move configuration helper methods to new package 2018-06-14 08:19:09 +02:00
Oliver Gugger
460fa25871
config+lnd+server: add unix socket support 2018-06-14 08:19:09 +02:00
Wilmer Paulino
8198466972
multi: move block epochs dependency from links to switch
In this commit, we move the block height dependency from the links in
the switch to the switch itself. This is possible due to a recent change
on the links no longer depending on the block height to update their
commitment fees.

We'll now only have the switch be alerted of new blocks coming in and
links will retrieve the height from it atomically.
2018-06-13 17:41:21 -07:00
Wilmer Paulino
9593e3772e
server: improve initial peer bootstrapping
In this commit, we address an existing issue with regards to the inital
peer bootstrapping stage. At times, the bootstrappers can be unreliable
by providing addresses for peers that no longer exist/are currently
offline. This would lead to nodes quickly entering an exponential
backoff method used to maintain a minimum target of peers without first
achieving said target.

We address this by separating the peer bootstrapper into two stages: the
initial peer bootstrapping and maintaining a target set of nodes to
maintain an up-to-date view of the network. The initial peer
bootstrapping stage has been made aggressive in order to provide such
view of the network as quickly as possible. Once done, we continue on
with the existing exponential backoff method responsible for maintaining
a target set of nodes.
2018-06-13 08:59:36 -07:00
Wilmer Paulino
6a6b490b50
server: add support to automatically advertise external IPs using NAT
traversal

In this commit, we allow our node to automatically advertise its
connection's external IPs on the ports it is currently listening on in
order to accept inbound connections. This is only done when specifying
a NAT traversal technique when starting the daemon.

We also include a handy method that watches for dynamic IP changes in
the background. If a new IP is detected, we'll craft a new node
announcement using the new IP and broadcast it to the network.
2018-06-12 18:36:30 -07:00
Wilmer Paulino
2ad9823945
server: include optional updates when generating a new node announcement 2018-06-12 18:36:29 -07:00
John Griffith
ba0db4ce91
Added some additional comments 2018-06-12 18:32:47 -07:00
John Griffith
1c3df21d18
Added NatPmp option 2018-06-12 18:32:46 -07:00
John Griffith
0d0078baac
Continue with server startup, even if UPNP has failed 2018-06-12 18:32:45 -07:00
John Griffith
b59077109c
Added Upnp support behind a configuration option, moved the logic to the server code 2018-06-12 18:32:44 -07:00
Olaoluwa Osuntokun
15da55effb
server: finish correction of inbound/outbound within the server
In this commit, we finish the fix for the inbound/outbound peer bool in
the server. The prior commit forgot to also flip the inbound/output maps
in Inbound/Outbound peer connected. As a result, the checks were
incorrect and could cause lnd to refuse to accept any more inbound
connections in the case of a concurrent connection attempt.
2018-06-10 23:02:22 -07:00
Olaoluwa Osuntokun
8885c3de8d
server: defer cancelling the outbound connection until the tie-breaker 2018-06-10 23:02:22 -07:00
Olaoluwa Osuntokun
c975753f1e
server: remove pending conn request if we recv a outbound conn after a scheduled callback
In this commit, we ensure that if we're already ignoring a connection,
then we also ignore the pending persistent connection request.
Otherwise, we'll move to accept the replaced connection, but then
continue to attempt connection requests.
2018-06-10 23:02:15 -07:00
Olaoluwa Osuntokun
dcf841c33b server: look up latest addr for node in peerTerminationWatcher
In this commit, we modify the look up for inbound peers to ensure that
we connect to the "freshest" address until we need to execute the
peerTerminationWatcher. We do this as it's possible for a channel to be
created by the remote peer during our session. If we don't query for the
node's address at the latest point, then we'll miss this new node
announcement for the node.
2018-06-10 23:02:10 -07:00
Conner Fromknecht
a670537f4c
server: expose FindPeer for lnpeer.Peer to gossiper 2018-06-08 13:47:57 -07:00
Olaoluwa Osuntokun
849ee5e0dc
Merge pull request #1008 from wpaulino/peer-connection-logic
server: fix inbound/outbound peer connection logic
2018-06-06 18:07:18 -07:00
Wilmer Paulino
09253eacc3
server: use correct inbound value for peerConnected calls
In this commit, we address the meaning of the inbound parameter to
peerConnected. An inbound connection is defined as a connection
initiated by the peer, rather than ourselves.

We also update the inbound value for the peerConnected calls within
OutboundPeerConnected and InboundPeerConnected to reflect the definition
above.
2018-06-06 16:30:40 -07:00
Johan T. Halseth
ac1ab6f516
server: hold mutex shorter during broadcast
We remove the internale broadcastMessage method, and instead handle the
mutex handling within BroadcastMessage. This lets us hold the mutex only
when neccessary.
2018-06-06 12:20:25 +02:00
Johan T. Halseth
b8512c3568
server: don't hold mutex while sending to peer
This commit removes the sendToPeer method from the server, and instead
moves the necessary logic into SendToPeer. This let's us make the mutex
acquisition more fine-grained, only holding it while reading from the
peer map. Earlier it was required to be held during the whole call to
sendToPeer, as the method would access the map internally.
2018-06-06 12:20:06 +02:00
Olaoluwa Osuntokun
d98d4523e1
Merge pull request #1159 from wpaulino/onion-service-support
multi: add onion services support
2018-06-04 21:46:51 -07:00
Wilmer Paulino
2e0484be19
multi: ensure addresses are no longer assumed to be TCP addresses only
In this commit, we go through the codebase looking for TCP address
assumptions and modifying them to include the recently introduced onion
addresses. This enables us to fully support onion addresses within the
daemon.
2018-06-04 20:41:49 -07:00
Wilmer Paulino
08f80b6cf3
server: use advertised address when reestablishing inbound connections
In this commit, we update the way we reestablish inbound connections if
we lose connectivity to a node we have an open channel with. Rather than
fetching the node's advertised port, we'll fetch one of their advertised
addresses instead. This ensure that if the remote node is running behind
a proxy, we do not see the proxy's address.
2018-06-04 20:41:48 -07:00
Wilmer Paulino
1012f876e1
server: add automatic creation of v2 onion services
In this commit, we allow the daemon to use the recently introduced Tor
Controller implementation. This will automatically create a v2 onion
service at startup in order to listen for inbound connections over Tor.

Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:45 -07:00
Wilmer Paulino
3bb1733fa2
discovery+server: use network-specific functions for fallback SRV lookup
In this commit, we fix a bug where a fallback SRV lookup would leak
information if `lnd` was set to route connections over Tor. We solve
this by using the network-specific functions rather than the standard
ones found in the `net` package.
2018-06-04 20:41:43 -07:00
Wilmer Paulino
3669a40c52
server: add support to advertise onion addresses
In this commit, we allow `lnd` to properly parse onion addresses in
order to advertise them to the network when set through the
`--externalip` flag.

Co-Authored-By: Eugene <crypt-iq@users.noreply.github.com>
2018-06-04 20:41:41 -07:00
maurycy
3be08e69cf multi: 64bit aligment of atomic vars on arm/x86-32 2018-06-04 20:02:34 -07:00
Olaoluwa Osuntokun
d2bcb708f3
server: demote 'sending message' log to trace 2018-06-04 19:50:44 -07:00
Johan T. Halseth
08d9edd059
server: increase updateChan buffer to 2 2018-06-01 08:55:06 +02:00
Olaoluwa Osuntokun
d7b21859d5
server: upon disconnect, prune peer query state from gossiper 2018-05-31 16:30:57 -07:00
Olaoluwa Osuntokun
199bbe2fd4
server: if remote peer knows of gossip queries, skip initial table dump 2018-05-31 16:30:57 -07:00
Olaoluwa Osuntokun
f70f1f318d
server: set the dataloss protect and gossip queries feature bits 2018-05-31 16:30:57 -07:00
Olaoluwa Osuntokun
486f87576c
server: instantiate the chanSeries struct in the gossiper's config 2018-05-31 16:30:56 -07:00
Wilmer Paulino
4a200d28eb
lnd: add interrupt handler to handle shutdown requests while syncing
chain backend
2018-05-23 11:26:07 -04:00
Olaoluwa Osuntokun
f494433cbf
routing+server: add new QueryBandwidth method to reduce outbound failures
In this commit, we introduce a new method to the channel router's config
struct: QueryBandwidth. This method allows the channel router to query
for the up-to-date available bandwidth of a particular link. In the case
that this link emanates from/to us, then we can query the switch to see
if the link is active (if not bandwidth is zero), and return the current
best estimate for the available bandwidth of the link. If the link,
isn't one of ours, then we can thread through the total maximal
capacity of the link.

In order to implement this, the missionControl struct will now query the
switch upon creation to obtain a fresh bandwidth snapshot. We take care
to do this in a distinct db transaction in order to now introduced a
circular waiting condition between the mutexes in bolt, and the channel
state machine.

The aim of this change is to reduce the number of unnecessary failures
during HTLC payment routing as we'll now skip any links that are
inactive, or just don't have enough bandwidth for the payment. Nodes
that have several hundred channels (all of which in various states of
activity and available bandwidth) should see a nice gain from this w.r.t
payment latency.
2018-05-14 16:23:54 -07:00
Olaoluwa Osuntokun
b73eef12b3
Merge pull request #945 from jimpo/decayedlog
Move DecayedLog from lightning-onion to htlcswitch.
2018-05-10 20:06:53 -07:00
Olaoluwa Osuntokun
f0050e7ffb
Merge pull request #1201 from lightningnetwork/peer-async-disconnect
server: Peer Async Disconnect w/ Scheduled peerConnected
2018-05-10 17:05:16 -07:00
Olaoluwa Osuntokun
b271ed5ffb
Merge pull request #1199 from cfromknecht/queue-msg-err-chans
peer/server: Remove Broadcast err chans
2018-05-10 16:55:57 -07:00
Conner Fromknecht
8c04dd0030
server: add peer connection callback scheduling
This commit adds a simple scheduling mechanism for
resolving potential deadlocks when dropping a stale
connection (via pubkey inspection).

Ideally, we'd like to wait to activate a new peer until
the previous one has exited entirely. However, the current
logic attempts to disconnect (and wait) until the peer
has been cleaned up fully, which can result in
deadlocks with other portions of the codebase, since
other blocking methods may also need acquire the mutex
before the peer can exit.

When existing connections are replaced, they now
schedule a callback that is executed inside the
peerTerminationWatcher. Since the peer now waits for
the clean exit of the prior peer, this callback is
now executed with a clean slate, adds the peer to
the server's maps, and initiates peer's Start() method.
2018-05-08 16:37:14 -07:00
Conner Fromknecht
d20adc8e0e
server: use nil errChan for broadcasts
This skips creating errChans when sending messages to
peer during broadcast. This should be a minor memory
optimization, as well as not requiring channel sends
on those which will never be read.
2018-05-08 16:35:49 -07:00
Olaoluwa Osuntokun
72f48b6abe
htlcswitch+server: ensure we always send an update w/ a TempChannelFailure
In this commit, we ensure that any time we send a TempChannelFailure
that's destined for a multi-hop source sender, then we'll always package
the latest channel update along with it.
2018-05-08 13:00:28 -04:00
Jim Posen
56e65339e0 multi: Complete upgrade to new sphinx package interface. 2018-05-02 00:22:25 -07:00
Johan T. Halseth
e9eab3f79f
server: reliably hand off breach from the ChainArbitrator to the breachArb
This commit make the server populate the ChainArbitrator's
ContractBreach method, by a method that will reliably handoff the breach
event ot the breachArbiter. The server will now forward the breach event
to the breachArbiter, and only let the closure return a non-nil error
when the breachArbiter ACKs this event.
2018-05-02 08:43:32 +02:00
Sean Erle Johnson
938d367232 server: change PeerNotFound to PeerNotConnected 2018-04-18 12:34:57 -07:00
Dimitris Tsapakidis
4009f7f874 multi: fix typos in comments 2018-04-17 19:03:27 -07:00
Olaoluwa Osuntokun
9d29c4f43d
server: only swap out the port for inbound connections
Note that the check is actually reversed to the quirk atm in the server
logic, where inbound and outbound are reversed.

Fixes #1063.
2018-04-09 19:55:01 -07:00