Commit Graph

228 Commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun
de0a2ee49b
server: don't directly mutate net.TCPAddr for inbound connections to set peer port
In this commit, we fix a minor logging bug introduced in a prior commit.
Before we would directly modify the *net.TCPAddr that was a part of the
brontide connection. This achieved our goal, but would print weird log
messages as we mutated the port in the already established connection.

In this commit, we fix that by ensuring we create a copy iff it's a
net.TCPAddr, then modify that and replace the instance in the
lnwire.NetAddress.

Fixes #991.
2018-04-02 16:14:33 -07:00
Olaoluwa Osuntokun
9b729654f6
server: remove all pending conn reqs within DisconnectPeer 2018-03-31 16:26:19 -07:00
Olaoluwa Osuntokun
6be6b48e09
Merge pull request #840 from halseth/openchannel-csv-delay
Add CSV delay flag to openchannel
2018-03-31 16:05:08 -07:00
Conner Fromknecht
2490b9b6e3
server: cleanup persistent connection retries
This commits changes the behavior of our connection
reestablishment, and resolves some minor issues that
could lead to uncancelled requests or an infinite
connection loop.

 - Will not attempt to Remove connection requests with
   an ID of 0. This can happen for reconnect attempts
   that get scheduled, but have not started at the
   time the server cancels the connection requests.

 - Adds a per-peer cancellation channel, that is
   closed upon a successful inbound or outbound
   connection. The goroutine spwaned to handle the
   reconnect by the peerTerminationWatch now
   selects on this channel, and skips reconnecting
   if it is closed before the backoff matures.

 - Properly computes the backoff when no entry in
   persistentPeersBackoff is found. Previously, a
   value of 0 would be returned, cause all subsequent
   backoff attempts to use a backoff of 0.

 - Cancels a peers retries and remove connections
   immediately after receiving an inbound connection,
   to mimic the structure of OutboundPeerConnected.

 - Cancels all persistent connection requests after
   calling DisconnectPeers.

 - Allow additional connection attempts to peers, even if
   there already exists a pending connection attempt.
2018-03-31 00:51:12 -07:00
Olaoluwa Osuntokun
4480052cd6
server: ensure a default backoff is always used 2018-03-30 19:11:12 -07:00
Olaoluwa Osuntokun
d34c37f3dd
server: when constructing peer addr's attempt to locate proper port, fallback to default port
In this commit, we fix an existing bug within the codebase: if a peer
connected to us inbound, then we'd attempt to use the assigned port when
re-establishing a connection to them. We fix this issue in this commit
by adding a new method to look up any advertisements for the peer, and
use the specified port that matches our connection attempt. If we can't
find a proper advertisement, then we'll simply use the default peer
port.
2018-03-30 15:59:11 -07:00
Olaoluwa Osuntokun
b2e1d6988c
server: don't immediately add bootstrap peer to set of persistent connections 2018-03-30 15:16:18 -07:00
Olaoluwa Osuntokun
90636b49b2 server: properly format peer pubkey in NotifyWhenOnline logging msg
Fixes #978.
2018-03-30 13:15:49 -07:00
Johan T. Halseth
6f98803967
server: add remoteCsvDelay to openChanReq 2018-03-22 14:53:59 +01:00
Olaoluwa Osuntokun
9ec80e2083
server: properly segment the nursery store according to active net 2018-03-14 18:27:28 -07:00
Conner Fromknecht
a9904b328f
servrer: pass ExtractErrorEncrypter 2018-03-13 16:33:29 -07:00
Olaoluwa Osuntokun
800eea931f
build+multi: switch from bolt to bbolt
In this commit, we switch from boltbd/bolt to coreos/bbolt as the
former is no longer being actively maintained.
2018-03-10 19:01:13 -08:00
Olaoluwa Osuntokun
2a6876bde2
server: ensure the replay database is stored under the graph+network namespace
In this commit we modify the storage location of the sphinx replay
database to be under the precise network, and not only the graph sub
directory. Before this commit, due to the usage of filepath.Dir(), the
db would lie under /graph/, rather than say, /graph/simnet.
2018-03-10 13:02:29 -08:00
Conner Fromknecht
c976a550cb
server: initialize switch with circuit db 2018-03-09 21:18:15 -08:00
Conner Fromknecht
a4d8b30367
server: initialize server with persistent sphinx router 2018-03-08 21:12:05 -05:00
Olaoluwa Osuntokun
a540003bb9
server: set the FwdingLog attribute in the switch's config 2018-03-06 13:56:12 -05:00
Johan T. Halseth
3dc9e3c7d4
server: express fee rates using fee rate types 2018-02-26 22:42:26 +01:00
MeshCollider
2c2ed3c6a9 multi: Unify use of NodeKey in log messages 2018-02-19 17:48:39 -08:00
MeshCollider
4c42079436 multi: ensure NodeKey is set in rpc/cli 2018-02-19 17:48:39 -08:00
MeshCollider
915c4201b9 multi: remove internal peer_id usage 2018-02-19 17:48:39 -08:00
Conner Fromknecht
a03e95410b
server: adds truncated exponential backoff + rand for retry
This commit adds an backoff policy to the peer termination
watcher to avoid getting stuck in tight connection loops
with failing peers. The maximum backoff is now set to 128s,
and each backoff is randomized so that two instances using
the same algorithm have some hope of desynchronizing.
2018-02-08 18:15:20 -08:00
Olaoluwa Osuntokun
22951cb364
lnd: account for new lnwire.Sig API and channeldb API changes 2018-02-06 20:14:33 -08:00
Daniel McNally
8543497dcc multi: fixing it's/its typos in comments 2018-02-06 19:13:07 -08:00
practicalswift
a93736d21e multi: comprehensive typo fixes across all packages 2018-02-06 19:11:11 -08:00
MeshCollider
4b1cc98808 multi: apply roasbeef diff to support incoming socks.ProxiedAddr 2018-02-05 17:37:46 -08:00
MeshCollider
4affab7bd7 multi: Addressing Tor support review comments 2018-02-05 17:37:46 -08:00
nsa
698df2ac16 torsvc: added new type that multiplexes torsvc and net packages
This commit adds the `lnnet` package which contains an
implementation of the newly created LightningNet interface which
multiplexes the Dial and DNS-related functions to use net
by default and torsvc if a flag is specified. This modularization
makes for cleaner code.
2018-02-05 17:37:46 -08:00
nsa
8c482f2be7 multi: Added a NetInterface to clean up config.go
This commit adds a new interface named NetInterface and two
implementations of it: RegularNet & TorProxyNet. These two structs
are used in config.go in an attempt to clean up the code and
abstract away the dialer and DNS functions.
2018-02-05 17:37:46 -08:00
nsa
e132ad8433 torsvc: Added new module to house Tor functions
This commit adds a new module named 'torsvc' which houses all Tor
functionality in an attempt to isolate it and make it reusable in
other projecs. Some additional tweaks were made to config.go and
to the bootstrapper.
2018-02-05 17:37:46 -08:00
nsa
e2142c778f multi: Added Tor support
This commit adds Tor support. Users can set the --TorSocks flag
to specify which port Tor's SOCKS5 proxy is listening on so that
lnd can connect to it. When this flag is set, ALL traffic gets
routed over Tor including DNS traffic. Special functions for
DNS lookups were added, and since Tor doesn't natively support
SRV requests, the proxySRV function routes connects us to
a DNS server via Tor and SRV requests can be issued directly
to the DNS server.

Co-authored-by: MeshCollider <dobsonsa68@gmail.com>
2018-02-05 17:37:46 -08:00
Olaoluwa Osuntokun
47dc2d3b70
server: grab the read-mutex within the main loop of the peerBootstrapper
A recent commit modified the mutex in the server to the read/write. In
order to further reduce contention, we’ll grab the read lock when we’re
examining get set of peers to ignore.
2018-01-28 14:50:25 -08:00
Olaoluwa Osuntokun
eddb8dae0c
Merge pull request #655 from cfromknecht/server-locking-improvments
Server: Reduce Contention due to Exclusive Locking
2018-01-26 12:18:27 -08:00
Olaoluwa Osuntokun
4f91b66c51
Merge pull request #467 from bcongdon/feature/customize-alias-and-color
cmd/lncli+lnd: Add alias and color customization
2018-01-24 16:48:36 -08:00
Conner Fromknecht
a514f7e6b0
server: improve server contention around mutex
This commit aims to reduce the contention on the server's primary
mutex by (1) replacing it with a RWMutex, and (2) not holding an
exclusive lock throughout the duration of the SendToPeer method.

For the latter, we now only have to hold a shared lock until all
messages have been queued, where as before an exclusive lock
was held until all messages had been acknowledged by the target
peer's write handler. Since the initial syncing of announcements
with peer now comprises a couple thousand messages on testnet,
these changes should help keep the server from deadlocking while
completing and long-lived syncing operations.
2018-01-23 19:14:20 -08:00
Olaoluwa Osuntokun
5df6704a9c
contractcourt: make synchronous chain watcher notifications optional
In this commit, we modify the way that notifications are dispatched
within the chainWatcher. Before we would *always* wait for an ack back
before we started to clean up he database state. This would at times
lead to deadlocks. To remedy this, we now allow callers to decide if
they want notifications to be sync or not. The only current caller that
requires this is the breach arbiter.
2018-01-22 19:19:58 -08:00
Olaoluwa Osuntokun
783f01e1c7
multi: fix linter warnings 2018-01-22 19:19:56 -08:00
Olaoluwa Osuntokun
bbca53507f
contractcourt: extend the ChainArbitratorConfig with IsOurAddress closure
In this commit, we add the IsOurAddress field into the config of the
chain arb. With this new function closure, the chain arb is able to
detect co-op on chain closes automatically.
2018-01-22 19:19:53 -08:00
Olaoluwa Osuntokun
a0cc1d1b2d
breacharbiter: utilize new channel on-chain event stream to watch for breaches
In this commit, we modify the breach arbiter to no longer require
holding a channel object directly in order to receive new notifications
about possible breaches. Instead, we’ll contact the chain arbiter to
request a new channel event subscription.

As a result of the new architecture, we no longer need to receive a
handoff once the new channel comes online, as the chainWatcher will
always be active and watching the channel until it’s been closed.
2018-01-22 19:19:50 -08:00
Olaoluwa Osuntokun
24a16b4f49
lnd: properly initialize entities of new contractcourt package 2018-01-22 19:19:42 -08:00