Commit Graph
100 Commits
Author SHA1 Message Date
Conner Fromknecht 73cf352daa brontide/conn: migrate to WriteMessage + Flush
This commit modifies WriteMessage to only perform encryption on the
passed plaintext, and buffer the ciphertext within the connection
object. We then modify internal uses of WriteMessage to follow with a
call to Flush, which actually writes the message to the wire.
Additionally, since WriteMessage does not actually perform the write
itself, the io.Writer argument is removed from the function signature
and all call sites.
2019-04-22 16:03:56 -07:00
Conner Fromknecht ed8fe4bc82 brontide/noise: add Flush method
This commit adds a Flush method to the brontide.Machine, which can write
out a buffered message to an io.Writer. This is a preliminary change
which will allow the encryption of the plaintext to be done in a
distinct method from actually writing the bytes to the wire.
2019-04-22 16:03:39 -07:00
Conner Fromknecht ab4a6750cc Merge pull request #1865 from ExchangeUnion/litecoin-simnet
config: Experimental support for Litecoin/simnet
2019-04-19 14:43:47 -07:00
Conner Fromknecht 9946372d52 make/testing_flags: extend itest timeout from 20m to 30m 2019-04-11 18:13:33 -07:00
Conner Fromknecht fd80866627 lnd_test: bump timeout for darwin builds 2019-04-11 16:26:11 -07:00
Conner Fromknecht 5b3170d542 lnd_test: apply AsyncBenchmarkTimeout to async_payments_benchmark
It was mistakenly only applied to async_bidirectional_payments, which
can also see timeouts due to darwin fsync performance regression.
2019-04-11 15:54:21 -07:00
Conner Fromknecht 057bed2b92 htlcswitch/link: delay restored channel reestablish
This commit adds a brief delay when sending our channel reestablish
message if the link contains a restored channel to ensure we first have
a stable connection. Sending the message will cause the remote peer to
force close the channel, which currently may not be resumed reliably if
the connection is being torn town simultaneously. This delay can be
removed after the force close is reliable, but in the meantime it
improves the reliability of successfully closing out the channel and
allows the `channel_backup_restore/restore_during_creation` to pass
reliably.
2019-04-11 15:42:02 -07:00
Conner Fromknecht f19a6a0ba2 lnd_test: use WaitNoError when testing num singles in...
export_channel_backup. Fixes a local flake hit reliably on darwin.
2019-04-10 19:23:08 -07:00
Conner Fromknecht f82b7c9bac channeldb/graph: remove MarkEdgeZombie
This commit removes the MarkEdgeZombie method from channeldb. This
method is currently not used in any live code paths in production, and
is only used in unit tests. However, incorrect usage of this method
could result in an edge being present in both the zombie and channel
indexes, which deviates from any state we would expect to see in
production. Removing the method will help mitigate the potential for
writing incorrect unit tests in the future, by forcing zombie edges to
be created via the relevant, production APIs, e.g. DeleteChannelEdge.

The existing unit tests that use this method have been modified to use
the DeleteChannelEdge instead. No regressions were discovered in the
process.
2019-04-09 22:12:02 -07:00
Conner Fromknecht 4a755435e6 channeldb/graph: skip unknown edges in FetchChanInfos
This commit modifies FetchChanInfos to skip any channels that are not in
the graph at the time of the call. Currently the entire call will fail
if the edge is not found, which stalls a gossip sync in the following
scenario:

 1. Remote peer queries for a channel range
 2. We return the set of channel ids in that range
 3. A channel from that set is removed from the graph, e.g. via close.
 4. Remote peer queries for removed edge, causing the query to fail.

To remedy this, we will now skip any edges that are not known in the
database at the time of the query. This prevents the syncer state
machines from halting, which otherwise could only be resolved by
disconnecting and reconnecting.
2019-04-09 17:35:58 -07:00
Conner Fromknecht a4b4fe666a discovery: make batch size distinct from chunk size, reduce to 500
This commit reduces the number of channels a syncer will request from
the remote node in a single QueryShortChanIDs message. The current size
is derived from the chunkSize, which is meant to signal the maximum
number of short chan ids that can fit in a single ReplyChannelRange
message. For EncodingSortedPlain, this number is 8000, and we use the
same number to dictate the size of the batch from the remote peer.

We modify this by introducing a separately configurable batchSize, so
that both can be tuned independently. The value is chosen to reduce the
amount of buffering the remote party will perform, only requiring them
queue 500 responses, as opposed to 8000. In turn, this reduces larges
spikes in allocation on the remote node at the expense of a few extra
round trips for the control messages. However, will be negligible since
the control messages are much smaller than the messages being returned.
2019-04-06 15:27:26 -07:00
Conner Fromknecht 9df6af237e discovery/sync_manager: restore lazy gossip sends 2019-04-06 03:32:03 -07:00
Conner Fromknecht 25d2b1b537 Merge pull request #2885 from cfromknecht/stagger-initial-reconnect
server: stagger initial reconnects
2019-04-05 15:46:12 -07:00
Conner Fromknecht caa0e2f0b8 Merge pull request #2879 from joostjager/outgoing-go-to-chain
htlcswitch: revert forwarding policy block delta requirements
2019-04-05 15:45:30 -07:00
Conner Fromknecht 209c2c6ead Merge pull request #2841 from philippgille/patch-4
docs: fix broken TOC in Tor docs
2019-04-05 15:35:50 -07:00
Conner Fromknecht a52f013161 Merge pull request #2893 from cfromknecht/no-want-zombie
channeldb/graph: filter zombie channels in FilterKnownChanIDs
2019-04-05 14:45:11 -07:00
Conner Fromknecht a12b30f620 Merge pull request #2896 from halseth/make-fmt-routerrpc
[trivial] lnrpc/routerrpc: make fmt on router backend test
2019-04-05 14:03:31 -07:00
Conner Fromknecht e91bacd1bc channeldb/graph: filter zombie channels in FilterKnownChanIDs
This commit modifies FilterKnownChanIDs to skip edges that
we ourselves have deemed zombies. This prevents us from requesting
the updates from them, as this wastes bandwidth and cpu cycles.
2019-04-05 13:01:08 -07:00
Conner Fromknecht cf80476e01 server: stagger initial reconnects
This commit adds optional jitter to our initial reconnection to our
persistent peers. Currently we will attempt reconnections to all peers
simultaneously, which results in large amount of contention as the
number of channels a node has grows.

We resolve this by adding a randomized delay between 0 and 30 seconds
for all persistent peers. This spreads out the load and contention to
resources such as the database, read/write pools, and memory
allocations. On my node, this allows to start up with about 80% of the
memory burst compared to the all-at-once approach.

This also has a second-order effect in better distributing messages sent
at constant intervals, such as pings. This reduces the concurrent jobs
submitted to the read and write pools at any given time, resulting in
better reuse of read/write buffers and fewer bursty allocation and
garbage collection cycles.
2019-04-05 02:31:58 -07:00
Conner Fromknecht 7a718a401e Merge pull request #2890 from wpaulino/walletunlocker-rest-proxy-dest
lnd+rpcserver: refactor TLS configuration
2019-04-05 00:10:39 -07:00
Conner Fromknecht 12ec69a48b Merge pull request #2883 from cfromknecht/chan-restore-child-harness
lnd_test: use child harness chan backup restore cases
2019-04-05 00:04:25 -07:00
Conner Fromknecht 4de7d0c561 Merge pull request #2889 from grunch/fix-verifychanbackup-help
Remove equal sign on verifychanbackup cmd argument
2019-04-04 15:49:22 -07:00
Conner Fromknecht 9e8fc90754 Merge pull request #2888 from grunch/add-space-on-exportchanbackup-description
Add a missing white space on exportchanbackup command description
2019-04-04 13:08:31 -07:00
Conner Fromknecht 8f5ddf39ca lnd_test: use child harness chan backup restore cases
This prevents a panic during test failure due to a child test calling
FailNow on a parent test context. The sub tests now capture the
testing.T object provided in each closure as opposed to ignoring it and
using the parent context.
2019-04-04 02:36:32 -07:00
Conner Fromknecht b96da69476 Merge pull request #2880 from Roasbeef/windows-signals
signal: don't attempt to catch SIGSTOP
2019-04-03 14:36:10 -07:00
Conner Fromknecht 90ffc4a0ab chainntnfs/bitcoindnotify: improve historical conf dispatch logging 2019-04-01 18:21:07 -07:00
Conner Fromknecht 7a08825b1e chainntnfs/bitcoindnotify: always call UpdateSpendDetails
This commit fixes a bug that would cause the
notifier not to commit spend hints for items
that are not found. This is done by calling
UpdateSpendDetails with a nil detail, permitting
the notifier to begin updating the spend hints
with new blocks that arrive at tip. The change
is designed to mimic the behavior for historical
confirmation dispatch.

The symptom of this bug is needing to do many
long rescans on startup, even if new blocks
arrive after the rescan had completed. With
this change, nodes will have to do the scans
once more before their hints will be properly
updated. Restarts from then on should not
have this behavior.
2019-04-01 18:20:52 -07:00
Conner Fromknecht 5d98a94d60 channeldb: write chan updates through reject+channel cache 2019-04-01 16:34:51 -07:00
Conner Fromknecht 63b15fd8fb lnd: pass CLI reject+channel cache sizes to channeldb Open 2019-04-01 16:34:30 -07:00
Conner Fromknecht 433665932c config: expose Caches subconfig 2019-04-01 16:34:17 -07:00
Conner Fromknecht 7504d46e84 lncfg/caches: adds Caches sub config 2019-04-01 16:34:04 -07:00
Conner Fromknecht 5c8ba59790 lncfg/interface: define Validator iface + variadic Validate
This commit introduces the Validator interface, which
is intended to be implemented by any sub configs. It
specifies a Validate() error method that should fail
if a sub configuration contains any invalid or insane
parameters.

In addition, a package-level Validate method can be
used to check a variadic number of sub configs
implementing the Validator interface. This allows the
primary config struct to be extended via targeted
and/or specialized sub configs, and validate all of
them in sequence without bloating the main package
with the actual validation logic.
2019-04-01 16:33:50 -07:00
Conner Fromknecht 6d3e081f7b channeldb: accept cache sizes in ChannelGraph 2019-04-01 16:33:36 -07:00
Conner Fromknecht baa968b1ff channeldb/options: add Options w/ functional modifiers 2019-04-01 16:33:13 -07:00
Conner Fromknecht ae3a00a5da channeldb/graph+db: integrate reject and channel caches 2019-04-01 16:32:52 -07:00
Conner Fromknecht b20a254faa channeldb/channel_cache: add channelCache w/ randomized eviction 2019-04-01 16:25:31 -07:00
Conner Fromknecht af0ea3590b channeldb/reject_cache: add rejectCache w/ randomized eviction 2019-04-01 16:25:31 -07:00
Conner Fromknecht 3c46ceec1d channeldb/db: init one ChannelGraph per channeldb.DB 2019-04-01 16:25:30 -07:00
Conner Fromknecht ecbb78651a channeldb/graph: add newChannelGraph constructor 2019-04-01 16:25:30 -07:00
Conner Fromknecht ac315fd051 channeldb/db: remove unused buffer pool 2019-04-01 16:25:30 -07:00
Conner Fromknecht 2f927493c8 Revert "channeldb: convert invoice settle/cancel calls to use Batch"
This reverts commit da76c34418.
2019-04-01 16:25:30 -07:00
Conner Fromknecht e35f676b4c Revert "channeldb: convert concurrent channel state machine calls to use Batch"
This reverts commit e8da6dd0b4.
2019-04-01 16:25:30 -07:00
Conner Fromknecht f6d93c8e5d Revert "channeldb: convert all Update calls to use Batch"
This reverts commit 3555d3dbd4.
2019-04-01 16:25:26 -07:00
Conner Fromknecht e3c65e1a49 Merge pull request #2845 from joostjager/routerrpc-log
routerrpc: register router sub server logger
2019-03-27 21:04:32 -07:00
Conner Fromknecht f3f4093ef0 lntest/timeouts: split into darwin and non-darwin timeouts 2019-03-27 19:00:39 -07:00
Conner Fromknecht 6e61ee2710 lnd_test: use one timeout context per AddInvoice 2019-03-27 19:00:27 -07:00
Conner Fromknecht c5365160fb server: wrap peer connection tiebreaking to 80 chars 2019-03-26 16:41:30 -07:00
Conner Fromknecht 7358535725 peer+server: log pubkey@addr 2019-03-26 16:41:13 -07:00
Conner Fromknecht 60467bef7b lncfg/workers: bump default read/write workers from 16 -> 100
Bumps the default read and write handlers to be well
above the average number of peers a node has. Since
the worker counts specify only a maximum number of
concurrent read/write workers, it is expected that
the actual usage would converge to the requirements
of the node anyway. However, in preparation for a
major release, this is a conservative measure to
ensure that the default values aren't too low and
improve network instability.
2019-03-26 16:40:57 -07:00
Conner Fromknecht 93e56f9ee8 peer: add symmetric write idle timeout
In this commit, we add a 5 minute idle timer to
the write handler. After catching the write
timeouts, it's been observed that some connections
have trouble reading a message for several hours.
This typically points to a deeper issue w/ the peer
or, e.g. the remote peer switched networks. This now
mirrors the idle timeout used in the read handler,
such that we will disconnect a peer if we are unable
to send or receive a message from the peer after 5
minutes.

We also modify the readHandler to drain its
idleTimer's channel in the even that the timer had
already fired, but we successfully sent the message.
2019-03-26 16:40:41 -07:00
Conner Fromknecht b78e5f6742 peer: reduce write timeout to 5 seconds
This commit reduces the peer's write timeout to 5s.
Now that the peer catches write timeouts and doesn't
disconnect, this will ensure we spend less time blocking
in the write pool in case others also need to access the
workers concurrently. Slower peers will now only block
for 5s, after every reattempt w/ exponential backoff.
2019-03-26 16:40:24 -07:00
Conner Fromknecht 99150b41d6 peer: retry writes with delay on timeout errors
This commit modifies the writeHandler to catch timeout
errors, and retry writes to the socket after a small
backoff, which increases exponentially from 5s to 1m.
With the growing channel graph size, some lower-powered
devices can be slow to pull messages off the wire during
validation. The current behavior will cause us to
disconnect the peer, and resend all of the messages that
the remote peer is slow to validate. Catching the timeout
helps in preventing such expensive reconnection cycles,
especially as the network continues to grow.

This is also a preliminary step to reducing the
write timeout constant. This will allow concurrent usage
of the write pools w/out devoting excessive amounts of
time blocking the pool for slow peers.
2019-03-26 16:40:07 -07:00
Conner Fromknecht 0c519778a1 watchtower/wtserver/server_test: add TestServerDeleteSession 2019-03-19 19:41:17 -07:00
Conner Fromknecht 3564406dc1 watchtower/wtserver/server_test: cleanup test framework, remove test case indexes 2019-03-19 19:38:57 -07:00
Conner Fromknecht 26adf735c4 watchtower/wtserver: add DeleteSession handler 2019-03-19 19:38:46 -07:00
Conner Fromknecht 8e4a20e1a5 watchtower/wtserver/interface: add DeleteSession + mock impl 2019-03-19 19:38:34 -07:00
Conner Fromknecht 25b2a352cb watchtower/wtserver: refactor server handlers into own files 2019-03-19 19:38:20 -07:00
Conner Fromknecht 3d934d0978 watchtower/wtwire: add DeleteSession and DeleteSessionReply message 2019-03-19 19:38:09 -07:00
Conner Fromknecht 9523b420bc breacharbiter_test: add table-driven breach spend tests 2019-03-19 19:25:57 -07:00
Conner Fromknecht 6f06c30421 mock: support late registration of spend ntfns 2019-03-19 19:22:47 -07:00
Conner Fromknecht 997aa3ecf0 breacharbiter: detect all spends, add terminal states
This commit modifies the breach arbiter to monitor
all breached inputs for spends and remove them from
the set of inputs to be swept if they are spent to
a terminal state. Prior, we would only watch for
spends on htlcs that may need to transition and
sweep the corresponding second-level htlc.

With these changes, we will no monitor commitment
outputs for spends, as well as spends from the
second level htlcs themselves. If either of these
is detected, we remove them from the set of inputs
to sweep via the justice transaction because there
is nothing the breach arbiter can do.

This functionality will be needed when adding
watchtower support, as the breach arbiter must
detect the case when the tower sweeps on behalf of
the user and stop pursuing the sweep itself. In
addition, this now properly handles the potential
case where somehow the remote party is able to sweep
the their commitment or second-level htlc to their
wallet, and prevent the breach arbiter from trying
to sweep the outputs as it would now.

Note that in the latter event, the internal
accounting may still be incorrect, as it is assumed
that all breached funds return to the victim.
However, these issues will deferred and fixed at a
later date, as the more crucial aspect is that the
breach arbiter doesn't blow up as a result of towers
sweeping channels.
2019-03-19 19:22:35 -07:00
Conner Fromknecht 3641beb002 breacharbiter: capitalize "unable to" error msgs 2019-03-19 19:21:03 -07:00
Conner Fromknecht 32c4201edd cmd/lncli: increase default recovery window to 2.5k
Increases the default window from 250 to 2.5k. Many
users have reported attempting recovery with the
default value only to find an empty wallet. This
change should help ensure that the first recovery
attempt succeeds for the majority of nodes that
have modest load. It might prudent to consider
increasing this value further in the future if
the issue persists or average node age increases.
2019-03-15 02:54:07 -07:00
Conner Fromknecht 05e3a7f6c0 watchtower/wtmock/peer: set local pubkey 2019-03-15 02:34:00 -07:00
Conner Fromknecht 80040d9d96 watchtower/wtclient/client_test: adds client-server upload test 2019-03-15 02:33:47 -07:00
Conner Fromknecht e1e805d1b8 watchtower/wtserver/server: fix race condition on Stop 2019-03-15 02:33:33 -07:00
Conner Fromknecht a222a63d81 watchtower/wtserver/server: no ack updates 2019-03-15 02:33:20 -07:00
Conner Fromknecht 8b0cc487f0 watchtower/wtdb+wtserver: allow retransmission of last update 2019-03-15 02:33:06 -07:00
Conner Fromknecht 81497eceaf watchtower/wtmock/peer: create mock net.Conn using bidi MockPeer 2019-03-15 02:32:53 -07:00
Conner Fromknecht 87e8700c5d watchtower/wtmock/client_db: add mock client db 2019-03-15 02:32:40 -07:00
Conner Fromknecht f00b4c5e96 watchtower/wtclient/client: hook up full client pipeline 2019-03-15 02:32:27 -07:00
Conner Fromknecht abef9e09e7 watchtower/wtclient/stats: adds clientStats 2019-03-15 02:32:15 -07:00
Conner Fromknecht aa2b21117c watchtower/wtclient/session_queue: batch upload state updates 2019-03-15 02:32:02 -07:00
Conner Fromknecht 65d09fca64 watchtower/wtclient/task_pipeline: add reliable task aggregator 2019-03-15 02:31:50 -07:00
Conner Fromknecht 95fa7659e0 watchtower/wtclient/session_negotiator: add session negotiation 2019-03-15 02:31:37 -07:00
Conner Fromknecht a8721bcedf watchtower/wtclient/tower_candidate_iterator: linked-list iterator 2019-03-15 02:31:24 -07:00
Conner Fromknecht b23bff62d5 watchtower/wtclient/errors 2019-03-15 02:31:11 -07:00
Conner Fromknecht 4642954e72 watchtower/wtclient/backup_task: bind to ClientSession instead of SessionInfo 2019-03-15 02:30:59 -07:00
Conner Fromknecht b1903451d9 watchtower/wtclient/interface: add DB ifaces 2019-03-15 02:30:47 -07:00
Conner Fromknecht 04bbf39f51 watchtower/wtclient/log: adds wtclient logging 2019-03-15 02:30:35 -07:00
Conner Fromknecht 9177358a3c watchtower/wtdb/client_session: add ClientSession 2019-03-15 02:30:22 -07:00
Conner Fromknecht 247978dfe2 watchtower/wtdb/tower: store wt pk and addrs 2019-03-15 02:30:09 -07:00
Conner Fromknecht 99dbbf48aa watchtower/wtwire/error_code: add human-readable descriptors 2019-03-15 02:29:55 -07:00
Conner Fromknecht 9c70f49901 watchtower/wtwire/create_session_reply: remove extra Reject from code 2019-03-15 02:29:42 -07:00
Conner Fromknecht d81ce61033 config: add sanity check to prevent non-negative worker counts 2019-03-13 20:32:52 -07:00
Conner Fromknecht 76116f0d1a config: use CLI worker configuration instead of NumCPU() 2019-03-13 20:32:39 -07:00
Conner Fromknecht 3f181b3c06 lncfg/workers: configurable read, write, and sig pool workers 2019-03-13 20:32:25 -07:00
Conner Fromknecht 714e42fce2 netann/chan_status_manager: remove unknown edges from passive disable
Modifies the netann.ChanStatusManager to remove outpoints
from the set of tracked channels when it encounters a
channeldb.ErrEdgeNotFound when passively disabling. It is
possible for this to occur if a channel is closed w/o first
being disabled, which may happen if the remote party force
closes.
2019-03-12 17:35:12 -07:00
Conner Fromknecht f525d313b2 test_utils: start chan status manager 2019-03-12 17:34:57 -07:00
Conner Fromknecht 8baa6d6601 lnd_test: test disable is sent during close 2019-03-12 17:34:42 -07:00
Conner Fromknecht 325d77c431 chancloser+cnct: disable channel before closing 2019-03-12 17:34:28 -07:00
Conner Fromknecht e0886ff1f5 Merge pull request #2739 from wpaulino/make-flake-unit-fix
Makefile: fix unit test flakehunter when running on specific package
2019-03-07 20:38:14 -08:00
Conner Fromknecht 29fe6e61e2 Makefile: actually install btcd w/ make btcd 2019-03-07 17:56:37 -08:00
Conner Fromknecht 935ea7d450 server: broadcast using SendMessageLazy, remove unused sendPeerMessages 2019-03-05 17:09:14 -08:00
Conner Fromknecht b50fd33915 server: remove unused SendToPeer method 2019-03-05 17:09:01 -08:00
Conner Fromknecht 0ae06c8189 discovery+server: send lazy gossip msgs 2019-03-05 17:08:48 -08:00
Conner Fromknecht 2e5bc783f7 peer: preallocate errchans opt 2019-03-05 17:08:35 -08:00
Conner Fromknecht f39edd8000 peer: add SendMessageLazy 2019-03-05 17:08:22 -08:00
Conner Fromknecht 660bbaf646 peer: add message reordering based on priority 2019-03-05 17:08:05 -08:00
Conner Fromknecht 6f1ccf14e9 Revert "peer: reduce write timeout to 10s"
This reverts commit db2c104111.
2019-03-04 13:55:09 -08:00