Commit graph

1077 commits

Author SHA1 Message Date
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
Antoine Riard
d53f48e157 Add timer_chan_freshness_every_min
Latency/peer disconnection may trigger us to mark as disabled
some of our channels. After some time, if channels are still
disabled we need to broadcast ChannelUpdate to inform other network
peers about the uselessness of these channels.
2019-11-29 18:12:40 -05:00
Antoine Riard
f564df3892 Add UpdateStatus in Channel to track freshness of gossiped liveness.
Added enum and method are only used in next commit.
2019-11-29 18:12:38 -05:00
Matt Corallo
09b8c9e98b Fix add_update_monitor check to unwrap() instead of an unused bool 2019-11-28 01:21:41 -05:00
Matt Corallo
a62e96bcd9 Move test profile to crate root, so it has effect again 2019-11-28 01:21:41 -05:00
Matt Corallo
c1349e82cd Add dyn tags in fuzz_targets
We only support newish rust in fuzz_targets, so this is fine.
2019-11-28 01:21:41 -05:00
Matt Corallo
be7d3d17ac
Merge pull request #401 from ariard/2019-11-log-tx-broadcast
Add log for every tx broadcast
2019-11-25 22:39:48 +00:00
Antoine Riard
9df0250dbb Add log for every tx broadcast
Added macro log_tx in macro_logger.rs
2019-11-25 16:55:14 -05:00
Matt Corallo
01ae452120
Merge pull request #399 from TheBlueMatt/2019-11-fuzz-top-level
Move fuzz to top level.
2019-11-25 21:19:23 +00:00
Matt Corallo
9501ecce49 Move fuzz to top level. 2019-11-25 15:42:07 -05:00
Matt Corallo
65f7c9f542
Merge pull request #389 from valentinewallace/split-chain-watch-interface
remove circular references in channelmanager and channelmonitor
2019-11-22 18:26:44 +00:00
Valentine Wallace
f71518365f
chaininterface+multi: add filter_block and reentered to ChainWatchInterface
Because filter_block takes a  and returns a list of s , we must add a lifetime to the ChainWatchInterface, which bubbles up in a lot of places. These places include adding a lifetime  to the Node struct, which causes a lot of rearranging tests so that variables don't go out of scope before the Node that owns them does.
2019-11-21 20:35:53 -05:00
Valentine Wallace
969f863013
chaininterface: add BlockNotifier struct
Adding this struct will allow us to remove the circular reference
between ChainListeners and the ChainWatchInterface, because it
separates out the responsibility of notifying listeners about new
blocks from the responsibility of storing and retrieving watched
transactions.
2019-11-21 20:34:00 -05:00
Valentine Wallace
1ec0c14fce
multi: remove listeners field and method from ChainWatchInterface
This includes the purpose of this PR, which is to remove the circular reference created by ChainListeners self-adding themselves to their ChainWatchInterface's `listeners` field.
2019-11-21 18:06:35 -05:00
Matt Corallo
8d2c4e7c96
Merge pull request #397 from ariard/2019-11-doc-announce-sigs
Doc announce_sigs
2019-11-21 03:11:46 +00:00
Antoine Riard
13e52426c7 Extend test for announcement_sigs 2019-11-19 18:03:05 -05:00
Antoine Riard
e938e592b2 Document our handling of announcement_sigs
We may have in the future to rebroadcast announcement_sigs at
peer reconnection if this a burning issue as spec lacks
a acknowledgement mechanism.
2019-11-19 17:48:22 -05:00
Matt Corallo
126b514168
Merge pull request #379 from rrybarczyk/use-workspaces
Use workspaces to separate crates
2019-11-19 01:52:13 +00:00
RJ Rybarczyk
06091cee0f Merge branch 'master' of github.com:rust-bitcoin/rust-lightning into use-workspaces 2019-11-18 23:51:21 +00:00
RJ Rybarczyk
404081a755 Update travis file to accommodate workspaces 2019-11-18 23:50:15 +00:00
Matt Corallo
63c1fa6db5
Merge pull request #395 from ariard/2019-11-expected-amt-claim-funds
Avoid probing attacks with same hash lower amounts
2019-11-18 23:08:33 +00:00
Antoine Riard
5e047cc55e Add test_check_htlc_underpaying 2019-11-18 17:25:36 -05:00
Antoine Riard
6493efe329 Check expected amount in claim_funds
Require to specify expected amount so that we can claim only
payment for thhe correct amount, and reject payments for incorrect
amounts (which are probably middle nodes probing to break our privacy).

Send back incorrect_or_unknown_payments_details (PERM|15) to avoid
the probe node learning that final node is waiting a payment with
the routed hash.
2019-11-18 17:25:34 -05:00
RJ Rybarczyk
5305223495 Merge branch 'master' of github.com:rust-bitcoin/rust-lightning into use-workspaces 2019-11-18 19:44:55 +00:00
Matt Corallo
ae0ad19db5
Merge pull request #394 from TheBlueMatt/2019-11-broken-build
Fix broken build
2019-11-15 22:47:34 +00:00
Matt Corallo
f08383edce Drop needless mut 2019-11-15 17:20:03 -05:00
Matt Corallo
2118feb090 Fix build broken by silent merge conflicts 2019-11-15 17:20:03 -05:00
Matt Corallo
148c79719e
Merge pull request #393 from ariard/2019-11-send-cmt-error-handling
Fulfill error handling for send_commitment in processing htlcs forward
2019-11-15 21:58:37 +00:00
Matt Corallo
2e1b7ab86a
Merge pull request #390 from ariard/2019-11-consistent-errors
Make field error of ErrorPacket (former HandleError) mandatory
2019-11-15 21:57:36 +00:00
Matt Corallo
b9274328de
Merge pull request #392 from ariard/2019-11-manager-init-height
Add init height in ChannelManager constructor
2019-11-15 21:38:04 +00:00
Antoine Riard
ddbe53f836 Make field error of LightingError mandatory
We also fulfilled last empty ErrorAction:
- Router secp fail : IgnoreError
- processing error in Router : IgnoreError
- get_channel_update too early : IgnoreError
2019-11-15 16:24:42 -05:00
Antoine Riard
9a015236d0 Add init height in ChannelManager constructor 2019-11-15 16:11:47 -05:00