Commit graph

1058 commits

Author SHA1 Message Date
Matt Corallo
33810eddb5 Drop duplicative current-local-tx storage in channel.
We now have current-local-tx broadcast ability in channel monitors
directly (for ChannelManager deserialization), so we can just use
that instead of always having the Channel store signed ready-to-go
copies of the latest local commitment transaction.

This is further kinda nice since ChannelMonitor is live and can, eg
broadcast HTLC-Success transactions immediately as they will be
generated at broadcast time instead of in advance.

Finally, this lets us clean up a tiny bit in Channel.
2019-12-24 12:14:09 -05:00
Matt Corallo
eeac6c9695 Fix parameter name incorrectly changed in 4ebe64fafd 2019-12-24 12:13:29 -05:00
Matt Corallo
f755ae5bba
Merge pull request #426 from TheBlueMatt/2019-12-bad-lifetimes
Remove unused lifetimes.
2019-12-21 00:35:10 +00:00
Matt Corallo
d6382f5ed4 Remove unused lifetimes.
f71518365f added a series of lifetimes
which were required for an earlier version of the patch but not the
final version. They can be freely removed.
2019-12-20 14:54:23 -05:00
Matt Corallo
3b76c77d8c
Merge pull request #419 from TheBlueMatt/2019-12-simple-signer-api-step
Few more simple signer API additions
2019-12-13 22:04:53 +00:00
Matt Corallo
4ebe64fafd Use external key signer to generate closing transaction signatures 2019-12-13 16:16:33 -05:00
Matt Corallo
b1ed0ee033 Sign channel_announcements via a new ChannelKeys API 2019-12-12 14:36:41 -05:00
Matt Corallo
ae16c5ca34 Use EnforcingChannelKeys in fuzz targets to get more coverage 2019-12-12 13:37:07 -05:00
Matt Corallo
edab29e8d8
Merge pull request #404 from TheBlueMatt/2019-11-signer-api
Replace keys API with Signer API to support hardware wallets eventually
2019-12-12 18:01:46 +00:00
Matt Corallo
71e6995086
Merge pull request #417 from TheBlueMatt/2019-12-ver-bump
Bump to 0.0.10
2019-12-12 16:45:18 +00:00
Matt Corallo
1e52786e1c Bump versions to 0.0.10 2019-12-11 18:17:54 -05:00
Matt Corallo
6fc775da45 Bump bitcoin dep to 0.21 2019-12-11 18:17:54 -05:00
Matt Corallo
ccd4f12078 Pre-build fuzz targets at once in travis instead of as we need them 2019-12-11 18:17:54 -05:00
Antoine Riard
35814b653f Document more current security assumption of KeysInterface
Improve some comments of interface methods.
2019-12-11 17:29:42 -05:00
Matt Corallo
262666ad7f Make commitment transaction signing a part of ChannelKeys.
This adds a new fn to ChannelKeys which is called when we generte
a new remote commitment transaction for signing. While it may be
theoretically possible to unwind state updates by disconnecting and
reconnecting as well as making appropriate state machine changes,
the effort required to get it correct likely outweighs the UX cost
of "preflighting" the requests to hardwre wallets.
2019-12-11 17:29:42 -05:00
Matt Corallo
f2a2fd0d48 Make ChannelKeys an API and template Channel with it.
Instead of having in-memory access to the list of private keys
associated with a channel, we should have a generic API which
allows us to request signing, allowing the user to store private
keys any way they like.

The first step is the (rather mechanical) process of templating
the entire tree of ChannelManager -> Channel impls by the
key-providing type. In a later commit we should expose only public
keys where possible.
2019-12-11 17:29:42 -05:00
Matt Corallo
8defcf1107 Bump versions to 0.0.10 2019-12-11 17:29:42 -05:00
Matt Corallo
580a4234fd Bump bitcoin dep to 0.21 2019-12-11 17:29:42 -05:00
Matt Corallo
be677dc4f4
Merge pull request #416 from TheBlueMatt/2019-12-fuzz-clib
Refactor fuzzing to be a C-callable library plus rust binaries
2019-12-11 22:06:46 +00:00
Matt Corallo
e28fd78e67 Refactor fuzzing to be a C-callable library plus rust binaries
This should help us avoid rust's at-load syscalls by calling the
tests from a C program.
2019-12-11 15:13:14 -05:00
Matt Corallo
cd21a357d8
Merge pull request #414 from TheBlueMatt/2019-12-347-nits
347 with travis fix and a few nits.
2019-12-11 19:50:52 +00:00
Matt Corallo
4275b7744a Avoid cloning RBF state when we just want to modify fields. 2019-12-10 19:35:43 -05:00
Antoine Riard
85c03c1139 Add test_bump_txn_sanitize_tracking_maps
Extend test visibility of claim-tracking maps to do so.

Cover both "If 2 claimable-outpoint-spending txn are in 1 block,
clean up properly" and "Clean up claimable_outpoints when
pending_claim_requests is cleaned" fix commits in same patchset.
2019-12-10 19:35:43 -05:00
Antoine Riard
0150b1f6f6 Sanitize pending_claim_requests if no more outpoints to claim 2019-12-10 19:35:42 -05:00
Matt Corallo
6a775ea1e9 Dont RBF a tx twice if it hits RBF timer when one input is spent 2019-12-10 17:42:58 -05:00
Matt Corallo
ae042ebedb Clean up claimable_outpoints when pending_claim_requests is cleaned
When claimable_outpoints was introduced in "Move
our_claim_txn_waiting_first_conf to pending_claim_requests", removal
of elements from it (which are just pointers into
pending_claim_requests) was never added.
2019-12-10 17:42:58 -05:00
Matt Corallo
475719d01c If 2 claimable-outpoint-spending txn are in 1 block, clean up properly
This resolves an issue where we will never track 2 on-chain events
which are waiting for ANTI_REORG_DELAY at the same height.

This partially reverts and fixes "Move our_claim_txn_waiting_first_conf
to pending_claim_requests".
2019-12-10 17:42:58 -05:00
Antoine Riard
9eb87802c5 Log block tick in ChannelMonitor 2019-12-10 17:42:58 -05:00
Matt Corallo
2c8bc3c64e Correct input comparison for input-subset RBF bump creation
This resolves a regression introduced in "Implement bumping engine in
ChannelMonitor::block_connected" in which not all inputs are checked.
Several opportunities to clarify and clean up comments are also taken.

Fix test_bump_penalty_txn_on_revoked_htlcs as now remote claim txn
build the same way than us are going to be register as cleaning
pending_claim_request after ANTI_REORG_DELAY. It means during this
delay we are going to generate invalid bumped claiming txn on
already claimed outpoints. Previously these txn weren't issued
because all their outpoints would have been removed.

Fix full_stack_target by adding more input for FuzzEstimator
2019-12-10 17:42:40 -05:00
Matt Corallo
7be903ba00 Dont forget RBF previous-feerate info if tx size changed.
While our fee may change wildly (or even go down), the previous
fee *rate* is still valid, and we should use that as the basis for
our RBF.
2019-12-10 15:50:56 -05:00
Antoine Riard
d421816e84 Add test_set_outpoints_partial_claiming 2019-12-10 15:50:56 -05:00
Antoine Riard
feb472dc9e Track and react to remote partial-claiming of pending claim request
A pending claim request may contain a set of multiple outpoints.
If one or multiple of them get claimed by remote party, our in-flight
claiming transactions aren't valid anymore so we need to react
quickly and regenerate claiming transaction with accurate set.

However, a claimed outpoint may be disconnected and we need to resurrect
back outpoint among set of orignal pending claim request.

To guarantee consistency of contentious claimed outpoint we cache it
as OnchainEvent::ContentionsOutpoint and only delete it after
ANTI_REORG_DELAY.

Fix test broken by change, partial claiming on revoked txn
force us to regenerate txn
2019-12-10 15:50:56 -05:00
Antoine Riard
a0373dc83e Add test_bump_penalty_txn_on_remote_commitment 2019-12-10 15:50:56 -05:00
Antoine Riard
d2b5999dc0 Add test_bump_penalty_txn_on_revoked_htlcs 2019-12-10 15:50:56 -05:00
Antoine Riard
4e63dff5d4 Add test_bump_penalty_txn_on_revoked_commitment
Test multiple rounds of 25% heuristic in bump_claim_tx on remote revoked commitment
txn with htlcs pending in both directions.
2019-12-10 15:50:56 -05:00
Antoine Riard
6eb290d780 Add RBF-bumping of preimage/timeout txn on remote HTLC outputs
Given they are only signed by us we can RBF at wish

Fix tests broken by introduction of more txn broadcast
(channel_monitor_network_test)

Add locktime in RemoteHTLC as it's needed to generate
timeout txn.
2019-12-10 15:50:51 -05:00
Antoine Riard
116b1eb028 Implement bumping engine in ChannelMonitor::block_connected
Add RBF-bumping of justice txn, given they are only signed by us we
can RBF at wish.

Aggregation of bump-candidates and more aggresive bumping heuristics
are left open

Fix tests broken by introduction of more txn broadcast.
Some tests may have a relaxed check (claim_htlc_ouputs_single_tx)
as broadcast bumped txn are now interwining in previous broadcast ones
and breaking simple expectations

Use bumping engine to rebuild claiming transaction in case of partial-
claim of its outpoints set.
2019-12-09 22:22:54 -05:00
Antoine Riard
6a7c471369 Remove superflous pending_claims
As local onchain txn are already monitored in block_connected by
check_spend_local_transaction, it's useless to generate twice
pending claims for HTLC outputs on local commitment tx.

We could do the alternative.
2019-12-09 22:22:52 -05:00
Antoine Riard
0011713d2c Move our_claim_txn_waiting_first_conf to pending_claim_requests
Add claimable_outpoints maps.

Both structures are tied and should ensure their mutual consistency.

Pending_claim_requests is cached by original claim txid. Medatada
and per input material should be constant between bumped transactions,
only change should be partial-claiming of outpoints set and block
reorgs.

Due to RBF rules, if an input has been part of an aggregate tx
at first claim try, if we want the bumped tx to land nicely
in the mempool, inputs should be distributed in multiple
bumped tx but still be aggregate in a new bumped tx.
2019-12-09 22:22:35 -05:00
Antoine Riard
09ca1e93a4 Add log_trace on bump candidates tracking-buffer insertions 2019-12-09 22:19:44 -05:00
Antoine Riard
201fb4b56a Add MIN_RELAY_FEE_SAT_PER_1000_WEIGHT
Hardcode min relay fee as its value is fixed on the bitcoin network
and updating it would be done really conservatively.
2019-12-09 22:19:43 -05:00
Matt Corallo
821357ea61
Merge pull request #413 from TheBlueMatt/2019-12-381-nits
381 with a few nits resolved.
2019-12-09 21:41:53 +00:00
Steven Roose
cd31cdb6b1 Document the default values of configs 2019-12-09 15:56:51 -05:00
Steven Roose
3f3dc6c067 Change the new() functions for config to Default::default() 2019-12-09 15:56:51 -05:00
Matt Corallo
9f30b305e6
Merge pull request #403 from TheBlueMatt/2019-11-rand-onion
Randomize initial onion packet data.
2019-12-03 19:37:34 +00:00
Matt Corallo
fd1d5fd62c Randomize initial onion packet data.
This avoids at least the trivial hop count discovery attack, though
other obvious ones remain and are slightly harder to avoid.

See https://github.com/lightningnetwork/lightning-rfc/pull/697
2019-12-01 19:22:44 -05:00
Matt Corallo
1b9bbe547a
Merge pull request #405 from TheBlueMatt/2019-11-cleanups
Misc Cleanups
2019-11-30 04:00:45 +00:00
Matt Corallo
7591eda7a8
Merge pull request #407 from TheBlueMatt/2019-11-396-english
#396 with a few english fixes
2019-11-30 04:00:27 +00:00
Matt Corallo
fbe3943cab Update comments to be a bit more descriptive and fix english a bit 2019-11-29 20:38:03 -05:00
Antoine Riard
da94bac7ab Add test_announce_disable_channels 2019-11-29 18:12:44 -05:00