Commit Graph

7132 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
f40ddd36d5
chanbackup: close temp SCB file before rename
It has been reported that on Windows, the current file swap process
doesn't properly work since we still have the file open when we try to
rename it. In order to fix this, we'll now close the file _before_ we
rename it.
2019-05-27 15:36:55 -07:00
Olaoluwa Osuntokun
9523be7170
Merge pull request #3114 from Roasbeef/btcwallet-18-fix-deadlock
build: update btcd to latest version, btcwallet to bitcoind 0.18 compliant version
2019-05-27 15:30:33 -07:00
Olaoluwa Osuntokun
b8690d504d
Merge pull request #3095 from Roasbeef/cnct-timeout-fix
multi: always fail pending htlcs on commitment confirmation
2019-05-27 15:29:20 -07:00
Olaoluwa Osuntokun
2011ccc571
contractcourt: write confirmed CommitSet to disk before MarkChannelClosed
In this commit, we make a series of changes to ensure that we'll be able
to properly survive restarts if we crash right after we call
MarkChannelClosed. In order to ensure we can survive restarts, we'll now
long the confirmed CommitSet to disk right before we close the channel.
Upon restart, we'll read these from disk so we can pick up where we left
over.

Additionally, we also will now consult the legacy chain actions if it
turns out that the channel has been closed, but we don't have a
confCommitSet written to disk. This will only be the case for nodes that
had pending close channels before this commitment.
2019-05-27 15:26:46 -07:00
Olaoluwa Osuntokun
364c0dd9f1
contractcourt: add storage for the confirmed CommitSet
In this commit, we add storage to the Briefcase for reading/writing a
confirmed CommitSet. This will be used in follow up commits to ensure
that we're able to survive restarts after we mark a channel as pending
closed. Along the way, we also re-add the FetchChainActions struct as
legacy nodes will need this storage.
2019-05-27 15:26:44 -07:00
Olaoluwa Osuntokun
086f4eb8b3
contractcourt: add new TestChannelArbitratorDanglingCommitForceClose test 2019-05-27 15:26:43 -07:00
Olaoluwa Osuntokun
b4a116fd07
contractcourt: update TestChannelArbitratorLocalForceClosePendingHtlc to assert resolution msg delivery 2019-05-27 15:26:42 -07:00
Olaoluwa Osuntokun
ea7bae8492
contractcourt: remove the now unused chain actions methods
We still keep the `actionsBucketKey` variable around so current
contracts will clean up the existing state once they've been fully
resolved.
2019-05-27 15:26:41 -07:00
Olaoluwa Osuntokun
087e22d817
contractcourt: obtain supplementary HTLC info from the htlcSets
Since we no longer have up to date chain actions on disk, we'll use the
HTLC sets in memory which contain the necessary information we need to
in order to obtain the HTLC amounts.
2019-05-27 15:26:40 -07:00
Olaoluwa Osuntokun
8a34b1ae88
contractcourt: only send resolution messages if we have any to send 2019-05-27 15:26:39 -07:00
Olaoluwa Osuntokun
877b8c55d3
contractcourt: stop writing chain actions to disk
We don't need them as we'll just reconstruct the chain actions once a
commitment has actually confirmed.
2019-05-27 15:26:38 -07:00
Olaoluwa Osuntokun
fb91f0be70
contractcourt: reconstruct chain actions at time of commitment confirmation
In this commit, we change the behavior of the channel arb to no longer
write chain actions to disk. Instead, using the new CommitSet struct,
we'll replay our set of prior actions based on what actually got into
the chain. As a result, we no longer need to write the chain actions at
all, instead they're reconstructed at run time to determine decisions,
and before any commitments are broadcast in order to determine if we
need to go to chain at all.
2019-05-27 15:26:37 -07:00
Olaoluwa Osuntokun
fc617cd041
contractcourt: add new checkLocalChainActions method use in main state step
In this commit, we add a new `checkLocalChainActions` method. This
method differs from the existing `checkChainActions` method in that it's
only concerned with actions we should take on chain for our local state
based on the local _and_ remote state. This change ensures that we'll
now to go to chain order to cancel an HTLC that was on the remote
party's commitment transaction, but not our own.
2019-05-27 15:26:36 -07:00
Olaoluwa Osuntokun
5f0fad85be multi: address lingering TODO by no longer wiping out local HTLCs on remote close
In this commit, we fix a lingering TOOD statement in the channel arb.
Before this commitment, we would simply wipe our our local HTLC set of
the HTLC set that was on the remote commitment transaction on force
close. This was incorrect as if our commitment transaction had an HTLC
that the remote commitment didn't, then we would fail to cancel that
back, and cause both channels to time out on chain.

In order to remedy this, we introduce a new `HtlcSetKey` struct to track
all 3 possible in-flight set of HTLCs: ours, theirs, and their pending.

We also we start to tack on additional data to all the unilateral close
messages we send to subscribers. This new data is the CommitSet, or the
set of valid commitments at channel closure time. This new information
will be used by the channel arb in an upcoming commit to ensure it will
cancel back HTLCs in the case of split commitment state.

Finally, we start to thread through an optional *CommitSet to the
advanceState method. This additional information will give the channel
arb addition information it needs to ensure it properly cancels back
HTLCs that are about to time out or may time out depending on which
commitment is played.

Within the htlcswitch pakage, we modify the `SignNextCommitment` method
to return the new set of pending HTLCs for the remote party's commitment
transaction and `ReceiveRevocation` to return the latest set of
commitment transactions on the remote party's commitment as well. This
is a preparatory change which is part of a larger change to address a
lingering TODO in the cnct.

Additionally, rather than just send of the set of HTLCs after the we
revoke, we'll also send of the set of HTLCs after the remote party
revokes, and we create a pending commitment state for it.
2019-05-27 14:34:13 -07:00
Johan T. Halseth
6e102d64b9
Merge pull request #3101 from AdamISZ/make-unit-cover-pkg
Allow unit-cover target for make to filter by package
2019-05-27 13:18:45 +02:00
Olaoluwa Osuntokun
6e3b92b55f
Merge pull request #3106 from cfromknecht/wtclient-db
watchtower/wtdb: add bbolt-backed ClientDB
2019-05-24 18:53:00 -07:00
Conner Fromknecht
28bf49807e
watchtower/wtdb: add CSessionStatus field to ClientSession
This commit adds persisted status bit-field to ClientSessions, that can
be used to modify behavior of their handling in the client. Currently,
only a default CSessionActive status is defined. However, the intention
is that this could later be used to signal that a session is abandoned
without needing to perform a db migration to add the field. As we move
forward with testing, this will likely be useful if a session gets
borked and we need a simple method of the client to temporarily ignore
certain sessions.

The field may be useful in signaling other types of status changes,
though this was the primary motivation that warranted the addition.
2019-05-24 18:24:41 -07:00
Conner Fromknecht
9157c88f93
watchtower/wtclient: dedup backups across restarts
Now that the committed and acked updates are persisted across restarts,
we will use them to filter out duplicate commit heights presented by the
client.
2019-05-24 18:24:41 -07:00
Conner Fromknecht
3be651b0b3
watchtower/wtdb: add ClientDB
This commit adds the full bbolt-backed client database as well as a set
of unit tests to assert that it exactly implements the same behavior as
the mock ClientDB.
2019-05-24 18:24:41 -07:00
Olaoluwa Osuntokun
eba989048c
Merge pull request #3117 from halseth/update-neutrino-dep
[dependency update]: update to latest neutrino dep
2019-05-24 13:02:06 -07:00
AdamISZ
9b3676fdd4
Allow unit-cover target for make to filter by package
Previous to this commit, running `make unit-cover pkg=xx`
would ignore the selected package and run unit tests and
coverage for all packages.
After this commit, the package selected with pkg= is the
only one that is tested and coverage output generated for.
If no pkg is selected, the default is as before, all pkgs.
2019-05-24 12:51:35 +02:00
Johan T. Halseth
ea50502a79
go mod: update to latest neutrino dep 2019-05-24 12:41:31 +02:00
Johan T. Halseth
af3b04e53f
Merge pull request #3103 from halseth/syncmanager-resync-historical
discovery/sync_manager: restart historical sync on first connected peer
2019-05-24 12:17:02 +02:00
Johan T. Halseth
6ba6982ae7
discovery/sync_manager_test: add TestSyncManagerHistoricalSyncOnReconnect
TestSyncManagerHistoricalSyncOnReconnect tests that the sync manager will
re-trigger a historical sync when a new peer connects after a historical
sync has completed, but we have lost all peers.
2019-05-24 11:05:30 +02:00
Johan T. Halseth
526486ae24
discovery/sync_manager: restart historical sync on first connected peer
To handle the case where we have been without peers, and get a new
connection, we reset the historical scan booleans when the first active
syncer is connected to trigger another historical sync.
2019-05-24 11:05:29 +02:00
Conner Fromknecht
b35a5b8892
watchtower/wtclient: integrate ClientChannelSummaries
In this commit, we utilize the more generic ClientChanSummary instead of
exposing methods that only allow us to set and fetch sweep pkscripts.
2019-05-23 20:48:50 -07:00
Conner Fromknecht
25fc464a6e
watchtower/wtdb/client_chan_summary: add ClientChanSummary
A ClientChanSummary will be inserted for each channel registered with
the client, which for now will just track the sweep pkscript to use. In
the future, this will be extended with additional information to enable
the client to efficiently compute which historical states need to be
backed up under a given policy.
2019-05-23 20:48:36 -07:00
Conner Fromknecht
440ae7818a
watchtower/wtmock/client_db: adjust mock clientdb behavior
In advance of the upcoming wtdb.ClientDB, we'll modify the behavior
of the mockdb to be more like the final bbolt backed one, and assert
that all or our tests are still passing.
2019-05-23 20:48:23 -07:00
Conner Fromknecht
2a904cb69f
watchtower/wtdb: add Encode/Decode methods to wtclient structs 2019-05-23 20:48:08 -07:00
Conner Fromknecht
1db9bf2fd4
watchtower/wtdb: create embedded ClientSessionBody
This commit splits out the portions of the ClientSession into an
embedded ClientSessionBody, since these fields will be serialized
together on-disk.
2019-05-23 20:47:49 -07:00
Conner Fromknecht
5ad9530502
watchtower/wtdb: return sorted ClientSession.CommittedUpdates
This commit replaces the map-based CommittedUpdates field with a slice.
When reading from disk, these will already be sorted by bbolt, so the
client restore the updates as presented without needing to sort them
first.

Since the key in the map variant was the sequence number, we refactor
the CommittedUpdate struct to have a sequence number and an embedded
CommittedUpdateBody (which is equivalent to the old CommittedUpdate).
The database is then expected to populate the sequence number from the
key on disk.

Since the sequence number is now directly integrated in the
CommittedUpdate struct, this allow allows us to remove the now redundant
seqNum argument from CommitUpdate.
2019-05-23 20:47:36 -07:00
Conner Fromknecht
3509c0c991
watchtower/multi: use proper TowerID type
This allows serialization methods to be added with TowerID method
receivers.
2019-05-23 20:47:22 -07:00
Conner Fromknecht
ec7c16fdc1
watchtower/wtdb: prepare for addition of client db
This commit renames the variables dbName to towerDBName and dbVersions
to towerDBVersions, to distinguish between the upcoming clientDBName
clientDBVersions. We also move resusable portions of the database
initialization and default endianness to its own file so that it can be
shared between both tower and client databases.
2019-05-23 20:47:08 -07:00
Wilmer Paulino
6e0084fec9
Merge pull request #3075 from cfromknecht/crtr-nil-path-curves
routing/router: nil path pubkeys before spewing
2019-05-23 20:01:54 -07:00
Olaoluwa Osuntokun
0c762af263
scripts: update bitcoind version to 0.18 2019-05-23 18:08:58 -07:00
Olaoluwa Osuntokun
50f0ac5683
Merge pull request #2308 from chokoboko/channels-in-getnodeinfo
rpcserver: add channels to GetNodeInfo response
2019-05-23 18:01:12 -07:00
Olaoluwa Osuntokun
18b9e1dd16
build: update to latest btcwallet+btcd 2019-05-23 17:38:43 -07:00
chokoboko
51dc422721 rpcserver: add channels to GetNodeInfo response 2019-05-23 16:03:39 +03:00
Johan T. Halseth
6cd71b7f7a
Merge pull request #2312 from xsb/color-node-update
rpc: add node color to NodeUpdate and GetInfo
2019-05-23 14:21:05 +02:00
Xavi Soler
0e38c722b3
lncli: include color in getinfo response 2019-05-23 10:52:22 +02:00
Xavi Soler
f4f3cea9a6
rpcserver: include color to getinfo and topology update 2019-05-23 10:52:18 +02:00
Xavi Soler
28021361d1
routing: add color to node update 2019-05-23 10:52:12 +02:00
Xavi Soler
ee2e49141e
lnrpc: add color to GetInfoResponse and NodeUpdate 2019-05-23 10:51:59 +02:00
Olaoluwa Osuntokun
063ecedf3a
Merge pull request #3082 from joostjager/upgrade-gen-go
lnrpc: upgrade to protobuf v1.3.1
2019-05-22 21:10:26 -07:00
Olaoluwa Osuntokun
649b5208a6
Merge pull request #3111 from cfromknecht/fix-bitcoind-initial-install
scripts/install_bitcoind: fix initial install
2019-05-22 20:06:49 -07:00
Conner Fromknecht
b34150144d
scripts/install_bitcoind: fix initial install 2019-05-22 19:21:24 -07:00
Olaoluwa Osuntokun
c654b829f4
Merge pull request #3104 from wpaulino/lncli-create-restore-backup
cmd/lncli: properly parse channel backup within lncli create
2019-05-22 17:12:25 -07:00
Olaoluwa Osuntokun
0afc70ec67
Merge pull request #3108 from cfromknecht/build-bitcoind-0.17
travis: install bitcoind 0.17.1 binaries manually
2019-05-22 16:58:11 -07:00
Conner Fromknecht
98f8696e68
travis: install bitcoind 0.17.1 binaries 2019-05-22 16:35:46 -07:00
Johan T. Halseth
4806003b74
Merge pull request #2704 from MDrollette/multiple-opts
config: allow adding multiple tls ips and domains
2019-05-22 08:59:19 +02:00