Commit Graph
100 Commits
Author SHA1 Message Date
Conner Fromknecht f727b94e12 lnrpc/watchtowerrpc: prevent watchtowerrpc panic when tower not active 2019-07-02 15:06:12 -07:00
Conner Fromknecht 712e7f08f0 watchtower/server/server_test: add test vectors for server behavior 2018-10-24 20:18:22 -07:00
Conner Fromknecht db4c4488c5 watchtower/server/mock: create MockPeer for debug build 2018-10-24 20:18:22 -07:00
Conner Fromknecht 48643a1747 watchtower/server/interface: adds Server, Peer and DB 2018-10-24 20:18:22 -07:00
Conner Fromknecht a3e1bb15c5 watchtower/server/log: adds wt SRVR sublogger 2018-10-24 20:18:21 -07:00
Conner Fromknecht 73709530e3 watchtower/server/server: server skeleton 2018-10-24 20:18:21 -07:00
Conner Fromknecht 8b47a96459 watchtower/wtdb/session_state_update: adds session state 2018-10-24 20:18:21 -07:00
Conner Fromknecht 405838d29c watchtower/wtdb/session_info: adds SessionInfo 2018-10-24 20:18:21 -07:00
Conner Fromknecht e825a756f4 watchtower/wtdb/session_id: adds SessoinID, client pubkey 2018-10-24 20:18:21 -07:00
Conner Fromknecht bc86ccf212 watchtower/wtdb/breach_hint: adds BreachHint, txid prefix 2018-10-24 20:18:17 -07:00
Conner Fromknecht 8acd13a094 watchtower/wtwire/wtwire_test: adds quick tests wtwire msgs 2018-10-23 18:28:30 -07:00
Conner Fromknecht 42a4b373a6 watchtower/wtwire/state_update_reply: ack w/ highest seqnum or error 2018-10-23 18:28:28 -07:00
Conner Fromknecht fdd3ad3149 watchtower/wtwire/state_update: sends encrypted blobs 2018-10-23 18:28:27 -07:00
Conner Fromknecht 216c77e10e watchtower/wtwire/create_session_reply: accept/deny session init 2018-10-23 18:28:26 -07:00
Conner Fromknecht 71541bc94e watchtower/wtwire/create_session: propose new session 2018-10-23 18:28:25 -07:00
Conner Fromknecht 49b2a3bdb5 watchtower/wtwire/message: define wtwire message interface 2018-10-23 18:28:18 -07:00
Conner Fromknecht 11f02de3b3 htlcswitch/link_test: removes unnecessary WaitForShutdown
The new RemoveLink method blocks until the link has
been fully stopped, so we no longer need to wait
for it explicitly.
2018-08-10 11:42:25 -07:00
Conner Fromknecht b507d265b4 htlcswitch/link: only update contract signals on start if live link 2018-08-10 11:42:25 -07:00
Conner Fromknecht a6e7b35872 server: use blocking RemoveLink to shutdown links 2018-08-10 11:42:25 -07:00
Conner Fromknecht c78e81d32b htlcswitch/switch: synchronous stop of links after removal 2018-08-10 11:42:25 -07:00
Conner Fromknecht 258019eb24 htlcswitch/switch_test: update reverted test to use...
current initialization methods
2018-08-10 11:42:24 -07:00
Conner Fromknecht 1113684dc3 Revert "htlcswitch: in event of duplicate link add, prefer newer link"
This reverts commit e60d2b774a.
2018-08-10 11:42:20 -07:00
Conner Fromknecht 085e1f9ca8 watchtower/blob/justice_kit_test: add encrypt/decrypt test vectors 2018-07-24 19:55:07 -07:00
Conner Fromknecht 9749096403 watchtower/blob/justice_kit: adds v0 encoding and encryption 2018-07-24 19:55:07 -07:00
Conner Fromknecht b0379dfa59 lnwallet/channel: use exposed CommitScriptUnencumbered 2018-07-24 16:54:30 -07:00
Conner Fromknecht 1eba460a2c lnwallet/script_utils_test: use exposed CommitScriptUnencumbered 2018-07-24 16:54:30 -07:00
Conner Fromknecht afd8dfb9b4 lnwallet/script_utils: expose CommitScriptUnencumbered 2018-07-24 16:54:30 -07:00
Conner Fromknecht a3acd9c23f docs/INSTALL: fix mismatched code blocks 2018-07-10 19:03:06 -07:00
Conner Fromknecht daa28e0d0f routing/chainview/bitcoind: improve filterMtx locking
In this commit, we modify the granularity of the locking
around the filterMtx in the bitcoind chainview, such that
we only lock once per block connected or filter update.
Currently, we acquire and release the lock for every
update to the map.

We also fix a bug that would cause us to not fully remove
all previous outpoints spent by a txn when doing manual
filter, as we previously would only remove the first output
detected.
2018-07-06 19:08:17 -07:00
Conner Fromknecht 0f6bc3538d routing/chainview/btcd: improve filterMtx locking
In this commit, we modify the granularity of the locking
around the filterMtx in the btcd chainview, such that we
only lock once per block connected or filter update.
Currently, we acquire and release the lock for every
update to the map.

We also fix a bug that would cause us to not fully remove
all previous outpoints spent by a txn when doing manual
filter, as we previously would only remove the first output
detected.
2018-07-06 19:08:17 -07:00
Conner Fromknecht 5be6993a56 server: log pubkey hex in connection callbacks 2018-07-03 17:09:10 -07:00
Conner Fromknecht 7d116abedb config: disable debug-htlc mode on mainnet 2018-07-03 17:08:53 -07:00
Conner Fromknecht 61c2493b7d lnwire/query_short_chan_ids: short circuit if 0 sids
In this commit, we alter the behavior of the regular
short channel id encoding, such that it returns a nil
slice if the decoded number of elements is 0. This is
done so that it matches the behavior of the zlib
decompression, allowing us to test both in using the
same corpus.
2018-07-03 17:08:40 -07:00
Conner Fromknecht 8cc217b526 lnwire/lnwire_test: use nil slice when 0 sids
Modifies the behavior of the quick test for
MsgQueryShortChanIDs, such that the generated
slice of expected short chan ids is always nil
if no elements are returned. This mimics the
behavior of the zlib decompression, where
elements are appended to the slice, instead of
assigning to preallocated slice.
2018-07-03 17:08:39 -07:00
Conner Fromknecht 92cbfbccca lnd_test: remove itest race caused by mining extra block 2018-07-03 17:08:21 -07:00
Conner Fromknecht 2843df88c0 lnwallet/script_utils_test: use public commit script helpers 2018-07-03 17:07:48 -07:00
Conner Fromknecht a66c488546 lnwallet/wallet: use public witness script hash helper 2018-07-03 17:07:48 -07:00
Conner Fromknecht bb808a1937 lnwallet/channel: use public variant of script helpers 2018-07-03 17:07:48 -07:00
Conner Fromknecht b507ea0ca3 lnwallet/script_utils: expose commit script helpers
Makes the helper methods for constructing witness script
hash and to-local outputs. This will allow watchtowers to
import and reuse this logic when sweeping outputs.
2018-07-03 17:07:48 -07:00
Conner Fromknecht 75d7436f7a channledb/codec: add net.Addr and []net.Addr to codec 2018-07-03 17:07:10 -07:00
Conner Fromknecht 4cb7953f66 channledb/addr: remove silent encoding failure for unknown types 2018-07-03 17:07:10 -07:00
Conner Fromknecht c6c442f6b6 channledb/addr_test: add negative test for unknown types 2018-07-03 17:07:10 -07:00
Conner Fromknecht 21674c05e5 channeldb/codec: add concrete error for unknown types 2018-07-03 17:07:09 -07:00
Conner Fromknecht 1d5189bd25 channeldb/forwarding_log: use public Read/WriteElements 2018-07-03 17:07:09 -07:00
Conner Fromknecht 30ff91913d channeldb/channel: use public Read/WriteElements 2018-07-03 17:07:09 -07:00
Conner Fromknecht ec029ac7fd channeldb/codec: exposes Read/WriteElements 2018-07-03 17:07:09 -07:00
Conner Fromknecht 12f74f762d htlcswitch/test_utils: use realistic link timeouts 2018-06-30 11:51:47 -07:00
Conner Fromknecht 10ecf2307f htlcswitch/link_test: use realistic link timeouts 2018-06-30 11:42:36 -07:00
Conner Fromknecht 5fa8124aa1 htlcswitch/link: correct bias in fee update backoff
This commit corrects the distribution used to
schedule a link's randomized backoff for fee
updates. Currently, our algorithm biases the
lowest value in the range, with probability
equal to lower/upper, or the ratio of the lower
bound to the upper. This distribution is skewed
more heavily as lower approaches upper.

The solution is to sample a random value in the
range upper-lower, then add this to our lower
bound. The effect is a uniformly distributed
timeout in [lower, upper).
2018-06-30 10:22:38 -07:00
Conner Fromknecht 5144df645b rpcserver: request shutdown from signal package 2018-06-28 16:17:02 -07:00
Conner Fromknecht 95440bc723 lnd: switch to lnd signal package 2018-06-28 16:17:02 -07:00
Conner Fromknecht aaf0c228d5 log: pass LTND subsystem logger to signal pkg 2018-06-28 16:17:02 -07:00
Conner Fromknecht 3aa8f7a6b9 signal/log: adds signal logger 2018-06-28 16:17:01 -07:00
Conner Fromknecht 0ae6dec4f3 signal/signal: creates package for monitoring of OS signals 2018-06-28 16:16:58 -07:00
Conner Fromknecht e85fa1af96 htlcswitch/decayedlog_test: fix bug in gc unit test
This commit fixes a bug in the
TestDecayedLogPersistentGarbageCollector unit test.
The test generates a second hash prefix, which is never
added to the log, and used to query for the final
existence check. This commit reverts the behavior so
that the same hash prefix is used throughout the test.
2018-06-27 14:40:28 -07:00
Conner Fromknecht 66c4240234 htlcswitch/link: add WaitForShutdown method for testing 2018-06-26 18:28:54 -07:00
Conner Fromknecht 23f2d93402 htlcswitch/link_test: wait for link shutdown after removal 2018-06-26 18:28:53 -07:00
Conner Fromknecht 56e5eed037 channeldb/channel: update short chan id for fwd packager 2018-06-19 13:48:08 +01:00
Conner Fromknecht 639c9875b2 channeldb/channel_test: test packager source updated 2018-06-19 13:48:08 +01:00
Conner Fromknecht 92711c4d32 utxonursery: rebroadcast finalized kinder txns on startup
Alters the utxonursery to rebroadcast finalized sweep txns
that sweep kindergarten (CSV-delayed) outputs. Currently, we
reregister for confirmation notifications, but we make no
attempt to rebroadcast. The htlc-timeout transactions are
rebroadcast correctly, so this changes make the handling of
crib and kinder outputs symmetric on startup.
2018-06-13 01:40:05 -07:00
Conner Fromknecht e5233c8ec7 htlcswitch/switch: reject duplicate links, purge link indexes 2018-06-09 04:33:04 -07:00
Conner Fromknecht a779befda5 htlcswitch/switch_test: adds duplicate link add test 2018-06-09 04:28:03 -07:00
Conner Fromknecht 4dace6c941 htlcswitch/multi: update tests for lnpeer.Peer iface 2018-06-08 16:29:49 -07:00
Conner Fromknecht 4380c67124 htlcswitch/link: upgrade to use lnpeer.Peer.SendMessage 2018-06-08 16:29:49 -07:00
Conner Fromknecht 3046ea6c5b htlcswitch/interfaces: removes Peer iface, use new lnpeer.Peer 2018-06-08 16:29:48 -07:00
Conner Fromknecht bf515a2341 discovery/gossiper: mostly deprecate SendToPeer
This commit changes the gossiper to direct messages to
peer objects, instead of sending them through the
server every time. The primary motivation is to reduce
contention on the server's mutex and, more importantly,
avoid deadlocks in the Triangle of Death.
2018-06-08 16:29:48 -07:00
Conner Fromknecht a670537f4c server: expose FindPeer for lnpeer.Peer to gossiper 2018-06-08 13:47:57 -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
Conner Fromknecht 769f0f0a94 discovery/gossiper_test: mock out new lnpeer.Peer 2018-06-08 13:47:57 -07:00
Conner Fromknecht dcf76a59b2 lnpeer: birth of peer package!
This commit moves the generic interface for
Lightning Network peers so that it can be
imported directly into the switch and gossiper.
Eventually, the majority of the peer logic
would be moved into this package for testing
and modularization.
2018-06-08 13:47:57 -07:00
Conner Fromknecht c180065a84 htlcswitch/link: remove deadlock in htlc validation
This commit removes a possible deadlock in the switch,
which can be triggered under certain failure conditions.
Previously, we would acquire the link's read lock for
the duration of HtlcSatisfiesPolicy, though we only
need to use it grab the current policy. The deadlock could
be caused in the cases where we attempt to log the failure,
which access the read-protected ShortChanID method.
2018-06-06 18:11:36 -07:00
Conner Fromknecht 086b44c1f4 channeldb/waitingproof: improve external consistency of store
This commit synchronizes the in-memory cache with the
on-disk state to ensure the waiting proof store is
externally consistent. Currently, there are scenarios
where the in-memory state is updated, and not reverted
if the write fails. The general fix is to wait to apply
modifications until the write succeeds, and use a
read/write lock to synchronize access with db operations.
2018-06-05 21:33:47 -07:00
Conner Fromknecht d62d142d18 htlcswitch/decayedlog_test: create unique test dbs
This commit changes the decayed log tests to create
a new temporary database for each test. Previously, all
instances referenced the same db path. Since the tests
are run in parallel, the tests would create/delete the
shared db out from under each other, causing flakes in
the unit tests.
2018-05-31 16:05:02 -07:00
Conner Fromknecht c285c32678 lnwallet/channel_test: test locked in settle/fail 2018-05-28 16:13:07 -07:00
Conner Fromknecht e693f89cb0 lnwallet/channel: locked in settle/fail 2018-05-28 13:17:28 -07:00
Conner Fromknecht 0c22297379 fundingmanager_test: mock ReportShortChanID w/o sid arg 2018-05-09 16:07:52 -07:00
Conner Fromknecht 2f52e29a5b fundingmanager: remove sid arg from ReportShortChanID 2018-05-09 16:07:52 -07:00
Conner Fromknecht d6628574ca lnd: remove sid arg to UpdateShortChanID 2018-05-09 16:07:52 -07:00
Conner Fromknecht 57551fbd74 htlcswitch/mailbox_test: add orchestrator pending/live test 2018-05-09 16:07:52 -07:00
Conner Fromknecht 418983cadc htlcswitch/switch_test: test send pending channel 2018-05-09 16:07:51 -07:00
Conner Fromknecht c290398b4b htlcswitch/mailbox: adds mailOrchestrator 2018-05-09 16:07:51 -07:00
Conner Fromknecht d3403306b6 htlcswitch/switch: segment pending links from live links 2018-05-09 16:07:51 -07:00
Conner Fromknecht 1dace1fed4 htlcswitch/mock: impl UpdateShortChanID w/ error 2018-05-09 16:07:25 -07:00
Conner Fromknecht 3e46a5e815 htlcswitch/link: fix UpdateShortChanID 2018-05-09 16:07:25 -07:00
Conner Fromknecht b5591cd66c htlcswitch/interfaces: return err from UpdateShortChanID 2018-05-09 16:06:49 -07:00
Conner Fromknecht f963f91a3c multi: use mutex-guarded ShortChanID() on OpenChannel 2018-05-09 16:06:49 -07:00
Conner Fromknecht 19b5eaa4dc channeldb/channel_test: adds RefreshShortChanID test 2018-05-09 16:06:49 -07:00
Conner Fromknecht 7ad56943c7 channeldb/channel: adds RefreshShortChanID 2018-05-09 16:06:49 -07:00
Conner Fromknecht 1b1f5f197a routing/chainview/neutrino: cache filter entries
This commit alters the neutrino chainview such that it
caches the filter entries corresponding to watched
outpoints at the moment they are added to the filter.
Previously, we would rederive each filter entry when
reconstructing the relevant filter entries, which
would lead to unnecessary work on the gc. Now, each is
created at most once, and reused across subsequent
reconstructions.
2018-05-08 20:46:46 -07:00
Conner Fromknecht de9de771bb htlcswitch/link: ensure circuits are committed in-order
This commit makes the call to forwardBatch after locking
in Adds synchronous. This ensures that circuits for any Add
packets are added to the switch in the same order that they
are prescribed in the channel state. Though it is very unlikely
this case would arise, it may happen under more greater loads.

In addition, this also makes some trivial optimizations wrt. to
not spawning unnecessary goroutines if no settle/fail packets
are locked in.
2018-05-08 16:37:35 -07:00
Conner Fromknecht a2f7170ff0 peer: make Disconnect async, block on WaitForDisconnect 2018-05-08 16:37:14 -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
Conner Fromknecht 0691b21a30 peer: improves disconnect handling
This commit attempts to resolve some potential deadlock
scenarios during a peer disconnect.

Currently, writeMessage returns a nil error when disconnecting.
This should have minimal impact on the writeHanlder, as the
subsequent loop selects on the quit chan, and will cause it to
exit. However, if this happens when sending the init message,
the Start() method will attempt to proceed even though the peer
has been disconnected.

In addition, this commit changes the behavior of synchronous
write errors, by using a non-blocking select. Though unlikely,
this prevents any cases where multiple errors are returned, and
the errors are not being pulled from the other side of the errChan.
This removes any naked sends on the errChan from stalling the peer's
shutdown.
2018-05-08 16:35:49 -07:00
Conner Fromknecht 99e7ec0895 routing/validation_barrier_test: test semaphore and quit
Adds test checking the basic functionality of the barrier's
semaphore and behavior during shutdown.
2018-05-08 16:32:08 -07:00
Conner Fromknecht 995e3fa85f routing/validation_barrier: adds ErrVBarrierShuttingDown
Adds a new error ErrVBarrierShuttingDown that is returned
from WaitForDependants if the validation barrier's quit
chan is closed. This allows any blocked goroutines to
distinguish whether the dependent task has been completed,
or if validation should be aborted entirely.
2018-05-08 16:32:08 -07:00
Conner Fromknecht eaa8cdf916 routing/router: improve validation barrier shutdown
This commit improves the shutdown of the router's
pending validation tasks, by ensuring the pending
tasks exit early if the validation barrier
receives a shutdown request.

Currently, any goroutines blocked by WaitForDependants
will continue execution after a shutdown is signaled.
This may lead to unnexpected behavior as the relation
between updates is no longer upheld. It also has the
side effect of slowing down shutdown, since we
continue to process the remaining updates.

To remedy this, WaitForDependants now returns an error
that signals if a shutdown was requested. The blocked
goroutines can exit early upon seeing this error,
without also signaling completion of their task to
the dependent tasks, which should will now properly
wait to read the validation barrier's quit signal.
2018-05-08 16:32:08 -07:00
Conner Fromknecht 3854c1ed68 discovery/gossiper: exit early on validation barrier quit 2018-05-08 16:32:08 -07:00
Conner Fromknecht 42a9a78180 htlcswitch/link: trim fix 2018-05-02 01:12:18 -07:00
Conner Fromknecht ed4f77871a htlcswitch/circuit_map: trim using NextLocalHtlcIndex 2018-05-02 01:12:17 -07:00