Commit Graph

4086 Commits

Author SHA1 Message Date
72d9726e7f channeldb/channel: update IsPending godoc
The pending state definitin in ChannelCloseSummary was slightly changed
in such a way that channels that has had their commitment broadcasted
now is no longer considered "pending close". They now instead stay in
the open chan bucket with the ChanStatus "CommitmentBroadcasted" until
their commitment is confirmed. This commit updates the IsPending godoc
to reflect this.
2018-05-23 12:07:35 +02:00
74205a64fd lnd_test: check for coop closed channel among WaitingClose instead of PendingClosed 2018-05-22 14:30:30 +02:00
921f02fe22 contractcourt/chain_arbitrator: markChanClosed->notifyChanClosed
We no longer have to mark the channel as fully closed in the database,
as it is done directly in the chainWatcher. Instead, we stop the watcher
and delete it from the set of active watchers.
2018-05-22 14:30:19 +02:00
0f077fcb54 contractcourt/chain_watcher: mark fully closed in dispatchCoopClose
This commit makes the dispatchCooperativeClose method mark the channel
fully closed directly, without registering for confirmation
notifications first. We can do this as recent changes to the
contractcourt changed the definition of a closed channel in the database
to have had its closing tx confirmed, and we only dispatch the
cooperative close once the transaction has 1 confirmation.

We also rename the markChanClosed method to notifyChanClosed, to more
clearly indicate that the ChainArbitrator no longer has to mark the
channel fully closed in the database.
2018-05-22 14:26:02 +02:00
af14a2fc57 contractcourt/chain_watcher: remove CooperativeCloseCtx
Removes CooperativeCloseCtx and methods.
2018-05-22 14:21:43 +02:00
21d1cc3fe8 contractcourt/chain_arbitrator: remove BeginCoopChanClose 2018-05-22 12:06:33 +02:00
bb611e065d peer: don't pass closeCtx to chanCloser 2018-05-22 12:06:33 +02:00
0809880426 chancloser: don't log potential closes to the chainwatcher
This commit stops the chan closer from sending the potential coop close
transactions to the chainwatcher, as this is no longer needed. The
chainwatcher recently was modified to watch for any potential close, and
will because of this handle the close regardless of which one appears in
chain.

When the chancloser broadcast the final close transaction, we mark it as
CommitmentBroadcasted in the database.
2018-05-22 12:05:47 +02:00
9ddd484524 lnwallet/channel: export method MarkCommitmentBroadcasted 2018-05-22 12:03:35 +02:00
7cd783d7bb lnwallet/channel: remove unused method DeleteState 2018-05-22 11:51:30 +02:00
95293f5102 lnwallet: add assertion in createCommitmentTx to detect overdraw attempts
In this commit, we add a precautionary assertion at the end of
createCommitmentTx. This assertion is meant to ensure that we don't
accept or propose a commitment transaction that attempts to send out
more than it was funded with.
2018-05-21 16:52:57 -07:00
c7afb867bc lnwallet: add additional assertions to TestChanReserve, fix bug before final case
In this commit, we add a series of additional balance assertions to
ensure that the balance of the two channels at each stage match up with
our expectations. Additionally, we also fix a bug at the end of the test
which would result in Alice accidentally overdrawing her balance in the
channel. The issue was that the test attempted to settle HTLCs that
weren't yet fully locked in. We fix this by adding an additional state
transition before settling the final set of HTLCs.
2018-05-21 16:51:39 -07:00
0570e80fd2 lnwallet: check commitment sanity within createCommitmentTx
In this commit, we move the check to CheckTransactionSanity into
createCommitmentTx. We do this as within wallet.go (during the funding
process) we actually end up calling this helper function twice, and also
moving it up until right when we create the fully commitment transaction
ensures we making our assertion against the final version.
2018-05-21 16:47:08 -07:00
6a2a049df1 Merge pull request #1255 from halseth/htlc-mismatch
HTLC restoration
2018-05-18 16:47:18 -07:00
e422883069 Merge pull request #1137 from guggero/macaroon-tests
macaroons: add unit tests and documentation
2018-05-18 16:39:37 -07:00
9dcd98ad9c contractcourt: prevent scoping bug by re-binding channel pointer
In this commit, we attempt to fix a bug that's possible within the
Start() method of the ChainArbiter. We pass the channel pointer directly
into the newActiveChannelArbitrator function causing it to close over
the loop variable. We later use the channel point directly to send
messages to other sub-systems. It's possible that we actually have the
shadowed loop variable and will send an incorrect message. Defensively,
we now re-bind the loop variable in order to ensure we point to the
proper channel.
2018-05-18 16:21:06 -07:00
f22b0ccdbc macaroons: fix incorrect comparison in isRegistered, wrap long lines 2018-05-18 10:14:06 +02:00
3eff9804ee macaroons: add technical documentation, fix comments 2018-05-18 10:13:25 +02:00
8e4e2bd889 macaroons: add tests for service and constraints 2018-05-18 10:08:05 +02:00
04f4dbe639 macaroons: add utilities for constraint tests 2018-05-18 10:08:05 +02:00
a2f900ec2d macaroons: add constraints unit tests 2018-05-18 10:08:05 +02:00
38a92b5ac9 docker: use go 1.10 for btcd and ltcd containers 2018-05-16 18:55:34 -07:00
fbc722147f lnd+docker: add "Production" Docker Image
This commit satisfies the auto-build functionality desired in #722 without changing anything in the docker folder. This allows development and testing to continue to build and use images locally, but external users get a very lean Docker image they can use. The size difference is appreciable.

REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
lnd                            latest              3634dcf5df68        17 seconds ago      1.19GB
lnd-single                     latest              b295cc248447        30 minutes ago      56MB
Right before merging this PR, an Automated Build repository should be configured on the appropriate account (lightningnetwork?) on Docker Hub with the name of lnd in order to match documentation.

I see there are already some repositories created, however I think best practice for Docker is to have a single repository and different tags for different architectures. The included image is based off of Alpine, but in the future we could extend into multiple Dockerfiles (example: ARM support, or being Ubuntu based).

So in this proposed scenario, lightningnetwork/lnd:latest would be alpine, but lightningnetwork/lnd:ubuntu would be an ubuntu-based image, for example.

(With thanks to @alingenhag for https://github.com/f-u-z-z-l-e/docker-lnd/ from which I borrowed heavily)
2018-05-16 18:50:25 -07:00
d0c0e5c7c2 docker: build lnd locally, optimize 2018-05-16 17:56:53 -07:00
9c7163187b lnwallet/channel: don't restore htlcs uneccessary
This commit removes redundant HTLC restoring. We don't have to restore
outgoing HTLCs from the local commitment, as we _know_ they will always
be added to the remote commitment first. Also, when receiving
Settles/Fails, they will be removed from the local commitment first.
This way we can be sure that outgoing HTLCs found on the local
commitment always will be found on the remote commitment

Similarly we don't have to restore incoming HTLCs from the remote
commitment, as they will be added to the local commitment first.
2018-05-16 21:02:17 +02:00
c1e96e01e6 lnwallet/channel: remove restoreHtlc from pendingRemoteCommit
This commit removes the stage during updateLog restoration where we
would attempt to restore incoming HLTCs from the pendingRemoteCommit, in
addition to update our log and htlc counter to reflect this state. The
reason we can safely remove this is to observe that a pending remote
commit is always created from a commitDiff which only contains updates
made by _us_, and thus only taken from the localUpdateLog. The same can
be said for the counters, when creating a commitDiff we'll always use
the remoteACKedIndex as the index into the remoteUpdateLog, meaning that
all potential updates will already be included in the remote commit that
has been ACKed.
2018-05-16 21:02:17 +02:00
fad7821e45 lnwallet/channel test: add TestChannelRestoreUpdateLogsFailedHTLC
This commit adds a test that runs through a scenario where an HTLC is
added then failed, making sure the update logs are properly restored at
any point during the process.
2018-05-16 21:02:14 +02:00
d69c358dc6 lnwallet/channel_test: add TestChannelRestoreUpdateLogs
This commit adds a test ensuring that the fix applied in the previous
commit works as expected. The test exercises the scenario where the
HTLCs on the local, remote and pending remote commitment differ, and we
attempt to restore the update logs. We now check that in this case the
logs before and after restart are equivalent.
2018-05-16 21:01:32 +02:00
902e1e77cb lnwallet/channel: init localUpdateLog with index from remoteCommit,
remoteUpdateLog from localCommit

This commit fixes a bug within channel.go that would lead to the
content of the update logs and their indexes getting out of sync during
restores.

The scenario that could occur was that the localUpdateLog was initiated
with a log index taken from the localCommitment. Updates we send (which
are added to the localUpdateLog) will be added to the remote commitment
first. The problem happened when an update was sent and added to the
remote commitment, but not ACKed. Since it was not ACKed, we would not
add it to our local commitment. During a restart/restore we would init
the localUpdateLog with a height too low, such that when going through
the outgoing HTLCs on the remote commitment, we would restore an HTLC at
an index higher than our local log HTLC counter.

The symmetric change is done to the remoteUpdateLog.
2018-05-16 20:53:33 +02:00
321cc69e4e Merge pull request #1215 from wpaulino/fee-dust-adherence
lnwallet: enforce fee floor and dust-reserve adherence
2018-05-15 16:09:58 -07:00
9f6af3a2c1 Merge pull request #1203 from Roasbeef/router-view-switch
routing+server: add new QueryBandwidth method to reduce outbound fail…
2018-05-14 17:13:58 -07:00
70a5444857 Merge pull request #1245 from halseth/chanarb-test-publish-doublespend
[test] add TestChannelArbitratorLocalForceDoubleSpend
2018-05-14 16:56:01 -07:00
f494433cbf routing+server: add new QueryBandwidth method to reduce outbound failures
In this commit, we introduce a new method to the channel router's config
struct: QueryBandwidth. This method allows the channel router to query
for the up-to-date available bandwidth of a particular link. In the case
that this link emanates from/to us, then we can query the switch to see
if the link is active (if not bandwidth is zero), and return the current
best estimate for the available bandwidth of the link. If the link,
isn't one of ours, then we can thread through the total maximal
capacity of the link.

In order to implement this, the missionControl struct will now query the
switch upon creation to obtain a fresh bandwidth snapshot. We take care
to do this in a distinct db transaction in order to now introduced a
circular waiting condition between the mutexes in bolt, and the channel
state machine.

The aim of this change is to reduce the number of unnecessary failures
during HTLC payment routing as we'll now skip any links that are
inactive, or just don't have enough bandwidth for the payment. Nodes
that have several hundred channels (all of which in various states of
activity and available bandwidth) should see a nice gain from this w.r.t
payment latency.
2018-05-14 16:23:54 -07:00
c96d07c1ae docs: add note about bitcoind with multiple lnd instances 2018-05-14 15:59:10 -07:00
cc494bd47f docs/INSTALL: update non-make installation to include lncli
The make file contains installing lncli, which has to be installed 
manually when not using make.
2018-05-14 15:56:36 -07:00
3a982063a0 fundingmanager+lnwallet: ensure proposed channel reserve is above dust limit 2018-05-14 14:20:20 -04:00
2e076ba21e fundingmanager+lnd: propose remote channel reserve above dust limit 2018-05-14 14:20:19 -04:00
3c33a8cb67 lnwallet: enforce backend node's min relay fee floor
In this commit, we fix an issue where sometimes transactions wouldn't
provide enough of a fee to be relayed by the backend node. This would
especially cause issues when sweeping outputs after a contract breach,
etc.

Now, we'll fetch the minimum relay fee from the backend node and ensure
it is set as a lower bound if the estimated fee ends up dipping below
it.
2018-05-14 14:20:18 -04:00
ec93bf581d contractcourt test: add TestChannelArbitratorLocalForceDoubleSpend
This commit adds a test for the case where the ChannelArbitrator fails
to broadcast its commitment during a force close because of
ErrDoubleSpend. We test that in this case it will still wait for a
commitment getting confirmed in-chain, then resolve.
2018-05-14 14:21:06 +02:00
28b12116e4 Merge pull request #1230 from wpaulino/wait-for-chan-updates-flake
test: fix update channel policy flake
2018-05-11 13:32:13 -07:00
b73eef12b3 Merge pull request #945 from jimpo/decayedlog
Move DecayedLog from lightning-onion to htlcswitch.
2018-05-10 20:06:53 -07:00
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
e5052f124b lnd_test: fix update channel policy flake
In this commit, we address a timeout issue on our Travis builds within
the update channel policy integration test. Before asserting the policy
for the channel between Alice and Bob, we need to make sure we receive
the updates responsible for modifying this policy first. At times, the
update wasn't received in time before checking the policy, which led to
us checking the old policy. We fix this by explicitly making sure we
wait for the updates first.
2018-05-10 20:03:01 -04:00
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
444a6c08cc Merge pull request #1166 from cfromknecht/switch-isolate-pending-channels
Isolate Pending Channels in Switch
2018-05-09 16:58:26 -07:00
941e0fb9bb aezeed: fix README links 2018-05-09 16:36:40 -07:00
03a7c027e4 Merge pull request #1210 from halseth/route-hints-flake
[integration flake] Fix route hints flake
2018-05-09 16:33:45 -07:00
3d26748906 Merge pull request #1208 from cfromknecht/cache-chainview-filter-entries
routing/chainview/neutrino: cache filter entries
2018-05-09 16:31:18 -07:00
0c22297379 fundingmanager_test: mock ReportShortChanID w/o sid arg 2018-05-09 16:07:52 -07:00
2f52e29a5b fundingmanager: remove sid arg from ReportShortChanID 2018-05-09 16:07:52 -07:00