Commit Graph

4018 Commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun
355355b81e
Merge pull request #1180 from halseth/empty-commitsig-fix
Empty commitsig fix
2018-05-09 16:02:49 -07:00
Johan T. Halseth
854e2a0581
link test: add TestChannelLinkWaitForRevocation
This commit adds a test where we trigger a situation which would
previously make the link think it was never in sync, and potentially
create a lot of empty state updates. This would happen if we were
waiting for a revocation, while still receiving updates from the remote.
Since in this case we could not ACK the updates because of the exhausted
revocation window, our local commitchain would extend, while the remote
chain would stall. When we finally got the revocation the local
commitment height would be far larger than the remote, and FullySynced
would return false from that point on.
2018-05-09 08:47:21 +02:00
Johan T. Halseth
db254c1258
link test: add TestChannelLinkNoMoreUpdates
This commit adds a new test that makes sure we don't try to send
commitments for states where there are now new updates. Before the
recent change to FullySynced we would do this in this test scenario, as
the local an remote commitment heights would differ.

The test makes the local commitment chain extend by 1 vs the remote,
which would earlier trigger another state update, and checks taht no
such state update is made.
2018-05-09 08:47:21 +02:00
Johan T. Halseth
71228a6b06
lnwallet/channel: don't use commit height to determine FullySynced
This commit removes a faulty check we did to determine if the channel
commitments were fully synced. We assumed that if out local commitment
chain had a height higher than the remote, then we would have state
updates present in our chain but not in theirs, and owed a commitment.
However, there were cases where this wasn't true, and we would send a
new commitment even though we had no new updates to sign. This is a
protocol violation.

Now we don't longer check the heights to determine if we are fully
synced. A consequence of this is that we also need to check if we have
any pending fee updates that are nopt yet signed, as those are
considered non-empty updates.
2018-05-09 08:47:21 +02:00
Olaoluwa Osuntokun
ddcbb40898
Merge pull request #1206 from wpaulino/temp-chan-failure-update
htlcswitch+server: ensure we always send an update w/ a TempChannelFailure
2018-05-08 19:33:20 -07:00
Olaoluwa Osuntokun
01a9b6b7da
Merge pull request #1202 from cfromknecht/link-sync-circuit-commit
htlcswitch/link: ensure circuits are committed in-order
2018-05-08 18:53:05 -07:00
Olaoluwa Osuntokun
b437553b5a
Merge pull request #1198 from cfromknecht/validation-barrier-quit
router: Validation Barrier Shutdown
2018-05-08 17:28:35 -07:00
Olaoluwa Osuntokun
eb5eb4a58b
Merge pull request #1179 from halseth/channel-entry-crash
Improve logging for missing HTLC entry crash
2018-05-08 17:21:40 -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
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
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
Johan T. Halseth
f26ec38a74
channeldb: return ErrNoPendingCommit in case of no channel bucket 2018-05-08 13:41:52 +02:00
Johan T. Halseth
9324bf7b1d
lnwallet/channel: return error in case of htlc index mismatch
This commit make us return an error in case a restored HTLC from a
pending remote commit has an index that is different from our local
update log index. It is appended with the assumption that these indexes
are the same, and if they are not we cannot really continue.
2018-05-08 13:41:52 +02:00
Johan T. Halseth
7e1f2a7dc3
lnwallet/channel: remove unused arguments 2018-05-08 13:41:52 +02:00
Johan T. Halseth
aa1c2cdf81
lnwallet/channel: add more info in case of crash
This commit adds a call to panic in case the HTLC we are looking for is
not found in the update log. It _should_ always be there, but we have
seen crashes resulting from it not being found. Since it will crash with
a nil pointer dereference below, we instead call panic giving us a bit
more information to work with.
2018-05-08 13:41:52 +02:00
Johan T. Halseth
1d676b77e1
lnwallet/channel: log pending remote commit during restore 2018-05-08 13:41:51 +02:00
Johan T. Halseth
1d172428c4
lnwallet/channel: return missing errors
This commit corrects a few cases where we would encounter errors, but
return nil by mistake.
2018-05-08 13:41:51 +02:00
Olaoluwa Osuntokun
27ca61aedf
Merge pull request #1196 from guggero/contribution-guideline
docs: add line wrap to contribution checklist
2018-05-07 21:37:44 -07:00
Olaoluwa Osuntokun
4a639fab14
Merge pull request #1193 from guggero/lncli-double-unlock
lncli: improve error message for unlock commands
2018-05-07 21:37:11 -07:00
littleskunk
d2a6c4eec9 htlcswitch: typo fix 2018-05-07 21:33:32 -07:00
Max Vernon
a126c91745 docs/INSTALL: add advice for using 127.0.0.1 for bitcoind backend on Windows (#1195)
Using localhost to connect lnd to bitcoind on Windows is very slow.  Use 127.0.0.1 instead.
2018-05-07 21:29:20 -07:00
Oliver Gugger
45ccace41c
docs: add line wrap to contribution checklist 2018-05-07 19:21:03 +03:00
Oliver Gugger
8ce73b3f74
lncli: improve error message for unlock commands 2018-05-07 18:44:03 +03:00
Olaoluwa Osuntokun
bdf3f4d775
Merge pull request #1158 from Roasbeef/play-all-commits
contractcourt+lnwallet: ensure the chainWatcher properly plays all remote commitments
2018-05-04 12:22:02 -07:00
Olaoluwa Osuntokun
7af699f3a7
contractcourt: update chain watcher tests to latest API 2018-05-03 21:29:30 -07:00
Olaoluwa Osuntokun
a3227ba147
contractcourt: add two new tests to ensure the chainWatcher is able to play all remote commitments 2018-05-03 21:29:29 -07:00
Olaoluwa Osuntokun
c8b15719f2
contractcourt: ensure the chainWatcher is able to play all remote commitments 2018-05-03 21:29:29 -07:00
Olaoluwa Osuntokun
88ff2af931
lnwallet: add new test to exercise creation of unilateral close summaries for pending broadcast commitments 2018-05-03 21:29:29 -07:00
Olaoluwa Osuntokun
8b06817482
lnwallet: modify NewUnilateralCloseSummary to be aware of pending remote commits
In this commit, we modify the NewUnilateralCloseSummary to be able to
distinguish between a unilateral closure using the lowest+highest
commitment the remote party possesses. Before this commit, if the remote
party broadcast their highest commitment, when they have a lower
unrevoked commitment, then this function would fail to find the proper
output, leaving funds on the chain.

To fix this, it's now the duty of the caller to pass remotePendingCommit
with the proper value. The caller should use the lowest unrevoked
commitment, and the height hint of the broadcast commitment to discern
if this is a pending commitment or not.
2018-05-03 21:29:28 -07:00
Olaoluwa Osuntokun
90bbc4f41b
lnwallet: move CreateTestChannels to new test_utils.go
In this commit, we move a set of useful functions for testing channels
into a new file. The old createTestChannels has been improved as it will
now properly set the height hint on the first created commitments, and
also no longer accepts any arguments as the revocation window no longer
exists.
2018-05-03 21:29:28 -07:00
Olaoluwa Osuntokun
1ec5dc3c2d
channeldb: additionally store static channel information in CloseChannelSummary
In this commit, we extend the CloseChannelSummary by also storing: the
current unrevoked revocation for the remote party, the next pending
unused revocation, and also the local channel config. We move to store
these as the provide an extra level of defense against bugs as we'll
always store information required to derive keys for any current and
prior states.
2018-05-03 21:29:23 -07:00
Olaoluwa Osuntokun
9017d18f14
Merge pull request #1178 from Roasbeef/travis-htlc-block-race-fix
test: attempt to account for internal block race in htlc force close …
2018-05-03 21:08:52 -07:00
Olaoluwa Osuntokun
d50247304b
test: fix flake in testInvoiceRoutingHints by using WaitPredicate 2018-05-03 21:07:11 -07:00
Olaoluwa Osuntokun
8712ab110d
test: fix revocation integration test flake
In this commit, we fix an existing flake within the set of revocation
integration tests. Right after Bob's restart, we attempt to force close
the channel. However, it may be the case that the chain arbitrator
hasn't yet been created. As a result, the request to force close the
channel will fail. We easily fix this by wrapping the force close
attempt in a WaitPredicate.
2018-05-03 20:50:04 -07:00
Olaoluwa Osuntokun
e54f1ea4db
test: account for block race by mining additional block in remote htlc force close test
This commit is similar to a recent commit which attempts to account for
internal block races by mining a second block if the initial assertion
for HTLC state fails. This can happen again if by the time that the
sweeping transaction is broadcast, it doesn't make it into the next
block mine.
2018-05-03 20:12:46 -07:00
Olaoluwa Osuntokun
1e7f2c32e9
test: attempt to account for internal block race in htlc force close test
In this commit, we modify the
testMultHopRemoteForceCloseOnChainHtlcTimeout test slightly to attempt
to account for a block race between the arrival of a message betwen the
contract resolver and the utxo nursery. If this message arrives "late"
(relative to the speed with which we mine blocks in test), then it'll be
detected as such by the utxo nursery. However, since we attempt to mine
a precise number of blocks, if this happens, then we'll never actually
mine that extra block to trigger a broadcast of the sweep transaction.
2018-05-03 20:12:46 -07:00
Olaoluwa Osuntokun
ddd12eff9c
htlcswitch: move link trimming to link start up
In this commit, we fix a race in the set of TestChannelLinkTrimCircuits*
tests. Before this commit, we would trim the circuits in the htlcManager
goroutine. However, this was problematic as the scheduling order of
goroutines isn't predictable. Instead, we'll now trim the circuits in
the Start method.

Additionally, we fix a series of off-by-2 bugs in the tests themselves.
2018-05-03 20:11:52 -07:00
Olaoluwa Osuntokun
d72f28839d
Merge pull request #1104 from halseth/chainwatcher-handoff-race
Fix chainwatcher handoff race
2018-05-03 17:18:31 -07:00
Olaoluwa Osuntokun
ecfde2e85f
Merge pull request #1149 from cfromknecht/trim-pending-htlc-index
Trim Open Circuits Using HTLC Index of Pending Commitments
2018-05-03 16:45:29 -07:00
Olaoluwa Osuntokun
dd60e9e720
docs: spell out go commands in case user doesn't have make
Fixes #1171.
2018-05-03 16:27:09 -07:00
Olaoluwa Osuntokun
5f059e74cb
peer: ensure msgConsumer sets the shutdown variable on exit
In this commit, we fix a bug that could at times cause a deadlock when a
peer is attempting to disconnect. The issue was that when a peer goes to
disconnect, it needs to stop any active msgStream instances. The Stop()
method of the msgStream would block until an atomic variable was set to
indicate that the stream had fully exited. However, in the case that we
disconnected lower in the msgConsumer loop, we would never set the
streamShutdown variable, meaning that msgStream.Stop() would never
unblock.

The fix for this is simple: set the streamShutdown variable within the
quit case of the second select statement in the msgConsumer goroutine.
2018-05-03 15:45:22 -07:00
Kenneth Perry
f7c5a7a19e routing/chainview/neutrino: error if we get a nil cfilter back (#1176) 2018-05-03 15:21:56 -07:00
Olaoluwa Osuntokun
a4b2765f83
Merge pull request #1165 from guggero/lncli-categories
lncli: group commands into categories
2018-05-03 15:20:50 -07:00
Oliver Gugger
80852601db
lncli: group startup commands, make full sentences 2018-05-03 11:49:09 +03:00