Commit Graph

313 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
6aebd053a3
Merge pull request #1823 from cfromknecht/dont-dc-on-link-fail
peer: ensure link failures are processed in peer life cycle
2018-09-03 19:56:19 -07:00
Olaoluwa Osuntokun
edf304ad8b
peer: ensure we unlock the msgCond during peer msgConsumer exit 2018-09-03 17:03:05 -07:00
Conner Fromknecht
48dc38d9f9
peer: ensure link failures are processed in peer life cycle 2018-08-30 17:36:13 -07:00
Olaoluwa Osuntokun
28a59362d6
peer: ensure readHandler doesn't block on AddMsg to msgStream
In this commit, we add a quit channel to the AddMsg method of the
msgStream struct. Before this commit, if the queue was full, the
readHandler would block and be unable to exit. We remedy this by
leveraging the existing quit channel of the peer as an additional select
case within the AddMsg method.
2018-08-26 20:02:50 -07:00
Olaoluwa Osuntokun
f2db18733b
peer: before and after obtaining link for chan update, check quit signal 2018-08-25 17:30:17 -07:00
Olaoluwa Osuntokun
7f480f723c
peer: add QuitSignal to ensure peer struct adheres to lnpeer.Peer interface 2018-08-25 17:30:14 -07:00
Olaoluwa Osuntokun
0e510c8b5c
funding+peer: don't attempt to deliver messages if the peer is shutting down 2018-08-25 17:30:11 -07:00
Olaoluwa Osuntokun
d6f534cfa5
peer: don't attempt to re-enable any private channels 2018-08-25 17:30:09 -07:00
Olaoluwa Osuntokun
5130949604
peer: allow msgConsumers to also exit on peer quit send 2018-08-25 17:30:07 -07:00
Olaoluwa Osuntokun
33c5c9661e
peer: allow msgStream goroutines to quit within the apply function
In this commit, we thread through the quit of the peer to the execution
of the apply function for a msgStream. This change ensures that if the
target is still processing the message, then the peer is able to exit
cleanly and not block insensately.
2018-08-25 17:30:05 -07:00
Olaoluwa Osuntokun
e4e4a6ab58
peer: move atomic var increment in msgConsumer goroutine to defer
In this commit we move the atomic var increment that signals the
consumer goourtine has exited to the top of the method in a defer
statement. This cleans up some duplicate code and also adheres to the
pattern of using defers to signal cleaning up any dependent goroutine
state on exit.
2018-08-25 17:30:02 -07:00
Olaoluwa Osuntokun
a7656454aa
peer: stop chanMsg streams in defer right after creation 2018-08-25 17:29:59 -07:00
Olaoluwa Osuntokun
ce115a6a59 peer: raise readHandler wait group done to defer statement
In this commit, we raise the readHandler wait group done into a defer
statement at the top of the method. This fixes an existing but that
would cause the readHandler to declare it had exited, yet possibly still
be waiting on the chan message stream below to exit.
2018-08-24 18:53:28 -07:00
Johan T. Halseth
e9066c2d34
peer: print warning if selfPolicy not found 2018-08-23 07:50:18 +02:00
Johan T. Halseth
19e3a194fa
peer+server: make fetchLastChanUpdate _always_ fetch our own update
This commit fixes a bug that would cause us to fetch our peer's
ChannelUpdate in some cases, where we really wanted to fetch our own.

The reason this happened was that we passed the peer's pubkey to
fetchLastChanUpdate, making us match on their policy. This would lead to
ChannelUpdates being sent during routing which would have no effect on
the attempted path.

We fix this by always use our own pubkey in fetchLastChanUpdate, and
also uses the common methods within the server to be able to extract the
update even when only one policy is known.
2018-08-23 07:50:18 +02:00
Johan T. Halseth
de5e9e139c
server: make extractChannelUpdate extract from set of potential policies 2018-08-23 07:50:17 +02:00
Johan T. Halseth
229fd88289
peer: use custom MinHTLC value at initial link add
This commit fixes a bug within the peer, where we would always use the
default forwarding policy when adding new links to the switch. Mostly
this wasn't a problem, as we most often are using default values for new
channels, but the min_htlc value is a value that is set by the remote,
not us.

If the remote specified a custom min_htlc during channel creation, we
would still use our DefaultMinHtlc value when first adding the link,
making us try to forward HTLCs that would be rejected by the remote.

We fix this by getting the required min_htlc value from the channel
state machine, and setting this for the link's forwarding policy.

Note that on restarts we will query the database for our latest
ChannelEdgePolicy, and use that to craft the forwardingPolicy. This
means that the value will be set correctly if the policy is found in the
database.
2018-08-23 07:50:17 +02:00
Johan T. Halseth
5deffd228c
peer: call disableChannel with disabled=false after loading channels
This to ensure now active channel is available in the router, for path
finding, as it might have been disabled if the peer has been offline a
while.
2018-08-17 23:24:13 +02:00
Johan T. Halseth
b5bfdd72b5
server+peer: rename disableChannel->announceChanStatus
Now takes a boolean whether to disable/activate, and keeps track of the
last update sent to avoid sending duplicates.
2018-08-17 23:24:12 +02:00
Conner Fromknecht
d4d90979ef
peer: increase peer write timeout to 50 seconds
Sometimes when performing an initial sync, the remote
node isn't able to pull messages off the wire because
of long running tasks and queues are saturated. With
a shorter write timeout, we will give up trying to send
messages and teardown the connection, even though the
peer is still active.
2018-08-13 21:55:32 -07:00
Conner Fromknecht
a1abb11dc5
peer: add ready chan arg to WaitForDisconnect
This commit adds additional synchronization logic to
WaitForDisconnect, such that it can be spawned before
Start has been executed by the server. Without
modification, the current version will return
immediately since no goroutines will have been
spawned.

To solve this, we modify WaitForDisconnect to block until:
 1) the peer is disconnected,
 2) the peer is successfully started,
before watching the waitgroup.

In the first case, the waitgroup will block until all
(if any) spawned goroutines have exited. Otherwise, if
the Start is successful, we can switch to watching the
waitgroup, knowing that waitgroup counter is positive.
2018-08-13 21:52:32 -07:00
Olaoluwa Osuntokun
7a113d469b
Merge pull request #1551 from cfromknecht/switch-revert-replace-link
[htlcswitch]: revert replace link, ensure removed links are stopped
2018-08-13 21:44:42 -07:00
Johan T. Halseth
64c2c6b118
peer: print ChanStatus return value, not address 2018-08-11 12:51:50 +02:00
Conner Fromknecht
5f90973f76
peer: always purge link before adding new one 2018-08-10 11:42:25 -07:00
Conner Fromknecht
1113684dc3
Revert "htlcswitch: in event of duplicate link add, prefer newer link"
This reverts commit e60d2b774a35e446081f9be2d4901925cac05379.
2018-08-10 11:42:20 -07:00
Olaoluwa Osuntokun
d3b1b9aa98
Merge pull request #1668 from cfromknecht/interface-tickers
Ticker Package
2018-08-09 20:55:25 -07:00
Wilmer Paulino
9d2eeb6304
multi: update to latest fee estimation interface 2018-08-09 17:29:52 -07:00
Conner Fromknecht
2762546eeb
peer: replace NewBatchTicker with ticker.New 2018-08-09 02:48:07 -07:00
Conner Fromknecht
60edca164c
peer: adds StartTime() used to compute backoff relaxation 2018-08-07 14:50:07 -07:00
Olaoluwa Osuntokun
07defe5f93
rpc+peer: use pkScripts for close ntfns 2018-07-31 21:28:52 -07:00
Olaoluwa Osuntokun
1e39cfc65f
Merge pull request #1364 from halseth/data-loss-protect
Data loss protection
2018-07-31 20:53:42 -07:00
Johan T. Halseth
ea6aca26a5
channeldb: make chanStatus unexported
Since the ChanStatus field can be changed from concurrent callers, we
make it unexported and add the method ChanStatus() for safe retrieval.
2018-07-31 15:07:30 +02:00
Conner Fromknecht
0efe5ca49d
peer: only pass duration to htlcswitch.NewBatchTicker 2018-07-30 22:33:37 -07:00
Olaoluwa Osuntokun
e0baa49690
Merge pull request #1387 from wpaulino/send-disable-chan-update
multi: send a channel update with disabled flag set on channel close
2018-07-23 17:46:37 -07:00
Olaoluwa Osuntokun
bca926d6af
Merge pull request #1371 from wpaulino/prune-link-nodes
server: prune link nodes without any open channels
2018-07-21 18:55:38 -07:00
Wilmer Paulino
9cedef9245
fundingmanager: send messages to peers directly
In this commit, we modify the existing message sending functionality
within the fundingmanager. Due to each mesage send requiring to hold the
server's lock to retrieve the peer, we might run into a case where the
lock is held for a larger than usual amount of time and would therefore
block on sending the message within the fundingmanager. We remedy this
by taking a similar approach to some recent changes within the gossiper.
We now keep track of each peer within the internal fundingmanager
messages and send messages directly to them.
2018-07-19 12:34:11 -07:00
Wilmer Paulino
6504a9cfa8
fundingmanager+peer: modify fundingErrorMsg to use peer key 2018-07-19 12:32:31 -07:00
Wilmer Paulino
3ab17063ff
multi: satisfy new lnpeer interface 2018-07-19 12:32:29 -07:00
Wilmer Paulino
38b52df51f
peer+server: remove persistent connections for peers with no open channels remaining 2018-07-17 17:35:30 -07:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Wilmer Paulino
873cccc7a6
multi: send channel update with disabled active on force and coop chan closes 2018-07-11 17:07:03 -07:00
Yaacov Akiba Slama
17223c1215 peer: add write timeout within writeMessage
In this commit, we add a timeout within the writeMessage method when we go to write to the socket. We do this as otherwise, if the other peer is blocked for some reason, we'll never actually unblock ourselves, which may cause issues in other sub-systems waiting on this write call. For now, we use a value of 10 seconds, and will adjust in the future if we deem this time period too short.
2018-06-26 17:27:22 -07:00
Wilmer Paulino
b1ba83bf2b
peer: prevent processing close msg if channel is not found 2018-06-25 13:13:12 -07:00
Johan T. Halseth
55c8741e42
peer: don't stop nil channel 2018-06-19 12:48:11 +01:00
Wilmer Paulino
90a50bd893
peer: remove no longer needed block epoch 2018-06-13 19:23:44 -07: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
4cc60493d2
peer+htlcswitch: randomize link commitment fee updates
In this commit, we modify the behavior of links updating their
commitment fees. Rather than attempting to update the commitment fee for
each link every time a new block comes in, we'll use a timer with a
random interval between 10 and 60 minutes for each link to determine
when to update their corresponding commitment fee. This prevents us from
oscillating the fee rate for our various commitment transactions.
2018-06-13 17:41:01 -07:00
Olaoluwa Osuntokun
e60d2b774a
htlcswitch: in event of duplicate link add, prefer newer link 2018-06-12 00:44:30 -07:00
Olaoluwa Osuntokun
e1d8c37708
peer: only add an active link to the channelManager if addPeer succeeds
In this commit we fix an existing bug which could cause internal state
inconsistency between then switch, funding manager, and the peer. Before
this commit, we would _always_ add a new channel to the channelManager.
However, due to recent logic, it may be the case that this isn't the
channel that will ultimately reside in the link. As a result, we would
be unable to process incoming FundingLocked messages properly, as we
would mutate the incorrect channel in memory.

We remedy this by moving the inserting of the new channel into the
activeChannels map until the end of the loadActiveChannels method, where
we know that this will be the link that persists.
2018-06-12 00:44:26 -07:00
Conner Fromknecht
edf08458c1
peer: changes to satisfy lnpeer.Peer
This commit adds:
 - variadic SendMessage method (w/ sync bool reorder)
 - passes peer object directly to ProcessRemoteAnnouncment
 - adds IdentityKey() method for lnpeer.Peer
2018-06-08 13:47:57 -07:00