Commit Graph

50 Commits

Author SHA1 Message Date
Joost Jager
3d7de2ad39
multi: remove dead code 2019-09-10 17:21:59 +02: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
Joost Jager
d55a8b7b29
channel+cnct: remove preimage from channel and resolution
Now that the success resolver preimage field is always populated by the
incoming contest resolver, preimage lookups earlier in the
process (channel and channel arbitrator) can mostly be removed.
2019-05-15 14:41:49 +02:00
Johan T. Halseth
b53899c43c
lnd: rename package main->lnd 2019-04-23 20:57:33 +02:00
Conner Fromknecht
9523b420bc
breacharbiter_test: add table-driven breach spend tests 2019-03-19 19:25:57 -07:00
Conner Fromknecht
29f07a58cb
cnct+lnwl+hswc: use lntypes.Preimage for witness beacon 2019-02-19 17:06:00 -08:00
Joost Jager
9e012ecc93
multi: move Input interface and related code
This commit is a step to split the lnwallet package. It puts the Input
interface and implementations in a separate package along with all their
dependencies from lnwallet.
2019-01-31 13:25:33 +01:00
Olaoluwa Osuntokun
821de3e107
test: remove FullSync call from breacharbiter_test.go
In this commit, we remove an extra openChannel.FullSync() call from
breacharbiter_test.go. Before this collective diff, calling
SyncPending() then FullSync() didn't result in an error. However, a
prior commit now makes this an error to ensure we don't attempt to
override any existing channels. This is the only area in the codebase
that we made this mistake which in this case, was benign.
2019-01-28 20:24:43 -08:00
Wilmer Paulino
b951f06456
multi: move CsvDelay into ChannelConstraints 2019-01-11 16:58:15 -08:00
Conner Fromknecht
eb2f5cecf6
multi: remove breach tx arg from NewBreachRetribution args
This commit removes the breach transaction from the
arguments passed to NewBreachRetribution. We already
keep all prior remote commitments on disk in the
commitment log, and load that transaction from disk
inside the method. In practice, the one loaded from
disk will be the same one that is passed in by the
caller, so there should be no change in behavior
as we've already derived the appropriate state number.

This changes makes integration with the watchtower
client simpler, since we no longer need to acquire
the breaching commitment transaction to be able to
construct the BreachRetribution. This simplifies
not only the logic surrounding transient backsups,
but also on startup (and later, retroactively
backing up historic updates).
2019-01-10 13:13:38 -08:00
Joost Jager
91f3df07e4
lnwallet: prevent static fee estimator fees from being modified
Modifying the static fees is not thread safe. In this commit the fees
are made immutable.
2018-12-18 10:50:05 +01:00
Olaoluwa Osuntokun
fa160f559c
multi: replace per channel sigPool with global daemon level sigPool
In this commit, we remove the per channel `sigPool` within the
`lnwallet.LightningChannel` struct. With this change, we ensure that as
the number of channels grows, the number of gouroutines idling in the
sigPool stays constant. It's the case that currently on the daemon, most
channels are likely inactive, with only a hand full actually
consistently carrying out channel updates. As a result, this change
should reduce the amount of idle CPU usage, as we have less active
goroutines in select loops.

In order to make this change, the `SigPool` itself has been publicly
exported such that outside callers can make a `SigPool` and pass it into
newly created channels. Since the sig pool now lives outside the
channel, we were also able to do away with the Stop() method on the
channel all together.

Finally, the server is the sub-system that is currently responsible for
managing the `SigPool` within lnd.
2018-12-16 15:40:14 -08:00
Olaoluwa Osuntokun
1fd3aac925
multi: switch from bolt packge to bbolt package for all imports 2018-11-29 20:33:49 -08:00
Conner Fromknecht
10b35a8f20
main: remove disable log in testing + clean up imports 2018-10-05 13:04:45 +09:00
Wilmer Paulino
9d2eeb6304
multi: update to latest fee estimation interface 2018-08-09 17:29:52 -07:00
Conner Fromknecht
cf2c371042
multi: fix linting errors 2018-08-02 18:20:50 -07:00
Olaoluwa Osuntokun
067db8572c
test+lnd: update unit test mocks to adhere to new interface API's 2018-07-31 21:28:58 -07:00
Olaoluwa Osuntokun
2d421b8e3c
breacharbiter: update breachArbiter to register for conf's using pkScripts 2018-07-31 21:28:51 -07:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Johan T. Halseth
e0560741b4
breacharbiter test: add TestBreachSecondLevelTransfer 2018-06-15 12:11:13 +02:00
Johan T. Halseth
9aa55b164e
breacharbiter test: extract common init logic 2018-06-15 12:11:13 +02:00
Conner Fromknecht
f963f91a3c
multi: use mutex-guarded ShortChanID() on OpenChannel 2018-05-09 16:06:49 -07:00
Johan T. Halseth
690992043b
breacharbiter_test: add double handoff event 2018-05-02 08:43:32 +02:00
Johan T. Halseth
55ac8735b6
breacharbiter_test: use ContractBreaches channel 2018-05-02 08:43:30 +02:00
Johan T. Halseth
634e23720e
breacharbiter_test: use RemoteUnilateralCloseSummary and LocalForceCloseSummary 2018-04-25 09:37:23 +02:00
Olaoluwa Osuntokun
4253b85309
test: ensure tests convert from BTC to SAT properly
This commit is a follow up to the prior commit which fixed a rounding
error bug in lnwallet. For uniformity, we also fix other occurrences in
the breach arbiter, as well as the integration tests.
2018-03-25 19:17:01 -07:00
Conner Fromknecht
5df8b52dae
multi: set initiator funding txn 2018-03-11 15:06:22 -07:00
Conner Fromknecht
5de0c62ae6
breacharbiter_test: init packager 2018-03-09 21:18:14 -08:00
Conner Fromknecht
aeecb9cdf5
breacharbiter_test: utilize update channel state transition APIs 2018-03-09 17:35:54 -08:00
Conner Fromknecht
970006ff2a
breacharbiter_test: init open channels with Pacakager 2018-03-09 14:45:30 -08:00
Olaoluwa Osuntokun
4b20e805fe
multi: update packages due to recent SignDescriptor and WalletController changes 2018-03-06 16:04:03 -05:00
Johan T. Halseth
7b30425111
multi test: update tests/mocks to use EstimateFeePerVSize 2018-02-26 22:42:27 +01:00
Johan T. Halseth
f6d357e122
breacharbiter tests: set MinHtlc=0 during tests 2018-02-08 18:35:25 -05:00
practicalswift
a93736d21e multi: comprehensive typo fixes across all packages 2018-02-06 19:11:11 -08:00
Olaoluwa Osuntokun
2faafbcd93
breacharbiter: properly account for second-level spends during breach remedy
In this commit, we address an un accounted for case during the breach
remedy process. If the remote node actually went directly to the second
layer during a channel breach attempt, then we wouldn’t properly be
able to sweep with out justice transaction, as some HTLC inputs may
actually be spent at that point.

In order to address this case, we’ll now catch the transaction
rejection, then check to see which input was spent, promote that to a
second level spend, and repeat as necessary. At the end of this loop,
any inputs which have been spent to the second level will have had the
prevouts and witnesses updated.

In order to perform this transition, we now also store the second level
witness script in the database. This allow us to modify the sign desc
with the proper input value, as well as witness script.
2018-01-22 19:20:01 -08:00
Olaoluwa Osuntokun
0d75dde153
breacharbiter: also listen for the co-op chan close signal 2018-01-22 19:19:55 -08:00
Olaoluwa Osuntokun
94504a9d41
breacharbiter: notify the ChainArbitrator of fresh signals for a channel on startup 2018-01-22 19:19:37 -08:00
Conner Fromknecht
ff3a1389e5
breacharbiter_test: remove channel close summary fields 2018-01-05 13:47:16 -08:00
Matt Drollette
adf0d98194 multi: fix several typos in godoc comments 2017-12-17 18:40:05 -08:00
Olaoluwa Osuntokun
841f4f73cf
breacharbiter: update tests to add chainHash to retributionInfo in test data 2017-11-10 19:51:09 -08:00
Conner Fromknecht
4c19320ea0
breacharbiter_test: updated test vectors for new retInfo struct 2017-09-25 18:57:03 -07:00
Conner Fromknecht
7ee7bf840a
breacharbiter_test: properly assigns SignDescriptor w/o ptr 2017-09-19 19:18:20 -07:00
Conner Fromknecht
9cc9977f95
breacharbiter_test: modify test vectors to support new structs 2017-09-19 19:18:19 -07:00
Olaoluwa Osuntokun
2c556d11c7
build: update travis config to use go 1.9 and 1.8.3 2017-08-30 20:37:47 -07:00
Conner Fromknecht
501e1dae23 breacharbiter_test: improves documentation for ba test cases 2017-08-25 17:56:50 -07:00
Conner Fromknecht
ce17d18249 breacharbiter_test: adds RetributionStore persistence unit tests 2017-08-25 17:56:50 -07:00
Conner Fromknecht
c3736e6893 breacharbiter: adds persistence to retribution flow
This commit introduces a RetributionStore interface, which
  establishes the methods used to access persisted information
  regarding breached channels. A RetributionStore is used to
  persist retributionInfo regarding all channels for which
  the wallet has signaled a breach.

  The current design could be improved by moving certain
  functionality, e.g. closing channels and htlc links, such
  that they are handled by upstream by their respective
  subsystems. This was investigated, but deemed preferable to
  postpone to a later update to prevent the current
  implementation from sprawling amongst too many packages.

  The test suite creates a mockRetributionStore and ensures that
  it exhibits the same behavior as the retribution store backed
  by a channeldb.DB.
2017-08-25 17:56:50 -07:00
Conner Fromknecht
8698085e35 breacharbiter: reverts retributionInfo naming and realign diffs 2017-08-25 17:56:50 -07:00
Philip Hayes
ce411f8e22 lint: fix linter complaints 2017-08-25 17:56:50 -07:00
Philip Hayes
b19c483a04 breacharbiter: add retribution state persistence
This commit adds a breached contract retribution storage layer using
boltdb to the breach arbiter. The breach arbiter now stores retribution
state on disk between detecting a contract breach, broadcasting a
justice transaction that sweeps the channel, and finally witnessing the
justice transaction confirm on the blockchain. It is critical that such
state is persisted on disk, so that if our node restarts at any point
during the retribution procedure, we can recover and continue from the
persisted state.
2017-08-25 17:56:50 -07:00