Commit graph

1297 commits

Author SHA1 Message Date
Matt Corallo
d271d74bc7 Use Channel::funding_txo instead of its channel_monitor.funding_txo
Currently Channel relies on its own internal channel_monitor copy
to keep track of funding_txo information, which is both a bit
awkward and not ideal if we want to get rid of the ChannelMonitor
copy in Channel.

Instead, just duplicate it (its small) and keep it directly in
Channel, allowing us to remove the (super awkward)
ChannelMonitor::unset_funding_txo().
2020-02-26 17:48:31 -05:00
Matt Corallo
6296eb1c5f Track counterparty's commitment secrets in Channel directly.
In the process of removing a local ChannelMonitor in each Channel,
we need to track our counterpartys' commitment secrets so that we
can check them locally instead of calling our channel monitor to
do that work for us.
2020-02-26 17:48:31 -05:00
Matt Corallo
27be07ba3e Swap out ChannelMonitor remote secret tracking for a struct.
In order to drop the ChannelMonitor from Channel, we need to track
remote per_commitment_secrets outside of the monitor to validate new
ones as they come in.

This just moves the current code from ChannelMonitor into a new
CounterpartyCommitmentSecrets struct in chan_utils.
2020-02-26 17:48:31 -05:00
Matt Corallo
72e32e7af6 Clarify the in-flight HTLC state-tracking structs a bit.
This also renames PendingForwardHTLCInfo to PendingHTLCInfo since
it now also encompasses Pending *Received* HTLCs.
2020-02-26 17:48:31 -05:00
Matt Corallo
3670dd086c
Merge pull request #509 from valentinewallace/chanmgr-tx-broadcaster-to-deref
multi: update ChannelManager tx broadcaster from Arc to Deref
2020-02-26 03:13:16 +00:00
Valentine Wallace
d768cc234e
multi: update ChannelManager tx broadcaster from Arc to Deref 2020-02-25 20:12:25 -05:00
Matt Corallo
f952cc27d6
Merge pull request #515 from TheBlueMatt/2020-02-further-peer-docs
Further clean up some comments wrt the peer socket handling API
2020-02-24 19:57:42 +00:00
Matt Corallo
a2fce3bbc0 Further clean up some comments wrt the peer socket handling API 2020-02-24 11:54:37 -05:00
Matt Corallo
2be0810e78
Merge pull request #512 from TheBlueMatt/2020-02-peer_handler-docs
Fix incorrect docs/disconnect handling in peer_handler
2020-02-21 19:02:21 +00:00
Matt Corallo
697b47974f
Merge pull request #474 from TheBlueMatt/2020-02-htlc-updated-in-monitors
Move pending-HTLC-updated ChannelMonitor from ManyChannelMonitor
2020-02-21 18:50:45 +00:00
Matt Corallo
faaa4d207d Fix incorrect docs around disconnect in peer_handler + rename fns
The way PeerHandler was written, it was supposed to remove from
self.peers iff the API docs indicate that disconnect_event should
NOT be called (and otherwise rely on disconnect_event to do so).

Sadly, the implementation was way out of whack with reality - in
the implementation, essentially anywhere where PeerHandler
originated the disconnection, the peer was removed and no
disconnect_event was expected. The docs, however, indicated that
disconnect_event should nearly only be called, only not doing so
when the initial handshake message never completed.

We opt to change the docs, mostly, as well as clean up the
ping/pong handling somewhat and rename a few functions to clarify
what they actually do.
2020-02-20 20:48:13 -05:00
Matt Corallo
d296360ba7 Test basic HTLC claim behavior from monitor -> manager on reorg 2020-02-20 20:31:51 -05:00
Matt Corallo
5e43070ef4 Move pending-HTLC-updated ChannelMonitor from ManyChannelMonitor
This is important for a number of reasons:
 * Firstly, I hit this trying to implement rescan in the demo
   bitcoinrpc client - if individual ChannelMonitors are out of
   sync with each other, we cannot add them all into a
   ManyChannelMonitor together and then rescan, but need to rescan
   them individually without having to do a bunch of manual work.
   Of the three return values in ChannelMonitor::block_connected,
   only the HTLCsource stuff that is moved here makes no sense to
   be exposed to the user.
 * Secondly, the logic currently in ManyChannelMonitor cannot be
   reproduced by the user! HTLCSource is deliberately an opaque
   type but we use its data to decide which things to keep when
   inserting into the HashMap. This would prevent a user from
   properly implementing a replacement ManyChannelMonitor, which is
   unacceptable.
 * Finally, by moving the tracking into ChannelMonitor, we can
   serialize them out, which prevents us from forgetting them when
   loading from disk, though there are still other races which need
   to be handled to make this fully safe (see TODOs in
   ChannelManager).

This is safe as no two entries can have the same HTLCSource across
different channels (or, if they did, it would be a rather serious
bug), though note that, IIRC, when this code was added, the
HTLCSource field in the values was not present.

We also take this opportunity to rename the fetch function to match
our other event interfaces, makaing it clear that by calling the
function the set of HTLCUpdates will also be cleared.
2020-02-20 20:31:51 -05:00
Matt Corallo
9666fcc5ce
Merge pull request #514 from TheBlueMatt/2020-02-no-lto-travis-fuzz
Skip lto on travis when building fuzz targets as it takes 30 min
2020-02-21 01:30:17 +00:00
Matt Corallo
1b47ddd226 Skip lto on travis when building fuzz targets as it takes 30 min 2020-02-20 20:02:26 -05:00
Matt Corallo
3122d5c377
Merge pull request #510 from TheBlueMatt/2020-02-fewer-fuzz-rustc-warns
Silence new rustc warnings re: extra ()s, dyn, and unused params
2020-02-20 22:29:10 +00:00
Matt Corallo
76f6822e98
Merge pull request #511 from TheBlueMatt/2020-02-test-pub-in-test-only
Only expose constants exposed for testing in cfg(test)
2020-02-20 21:12:10 +00:00
Matt Corallo
09ba0baf2c Only expose constants exposed for testing in cfg(test) 2020-02-20 15:10:09 -05:00
Matt Corallo
78627de05f Silence new rustc warnings re: extra ()s, dyn, and unused params 2020-02-20 15:08:51 -05:00
Matt Corallo
3e726c4c8e
Merge pull request #506 from arik-so/ping_encryption_fix
Encrypt ping messages before sending them
2020-02-20 19:50:20 +00:00
Arik Sosman
d9e1f98323
Remove unused code in peer handler test utility method. 2020-02-19 17:57:03 -08:00
Matt Corallo
edbc7e8d99
Merge pull request #508 from maxgiraldo/2020-02-sp-grammar
docs(CONTRIBUTING): fix spelling and grammar
2020-02-20 00:10:15 +00:00
Arik Sosman
b317f5221f
Fix ping message sent on timer ticks to be encrypted so the peer can decrypt it instead of shutting down the connection. 2020-02-19 14:08:56 -08:00
Max Giraldo
01ed08d20e
docs(CONTRIBUTING): fix spelling and grammar
Fix some minor spelling and grammar mistakes.
2020-02-19 16:56:43 -05:00
Matt Corallo
2f346414ad
Merge pull request #502 from rloomba/rloomba/add_unregister_listener
[chaininterface] Add ability for BlockNotifier to unregister listeners
2020-02-19 19:02:47 +00:00
Steve Lee
3cfd07f330
Add project tracking and conventions we want to adopt 2020-02-18 17:04:55 -08:00
Matt Corallo
69c3eb2702
Merge pull request #503 from TheBlueMatt/2020-02-chanmon-ser-roundtrip
Fix Two Bugs around ChannelManager serialization round-trip
2020-02-19 00:26:47 +00:00
Matt Corallo
29d14dda26
Merge pull request #455 from TheBlueMatt/2020-01-monitor-reload-watch
Track the full list of outpoints a chanmon wants monitoring for
2020-02-19 00:06:26 +00:00
Matt Corallo
4b189bd09f Allow deserialization of new Channels before we've seen a block
Previously, if we have a live ChannelManager (that has seen blocks)
and we open a new Channel, if we serialize that ChannelManager
before a new block comes in, we'll fail to deserialize it. This is
the result of an overly-ambigious last_block_connected check which
would see 0s for the new channel but the previous block for the
ChannelManager as a whole.

We add a new test which catches this error as well as hopefully
getting some test coverage for other similar issues in the future.
2020-02-18 18:22:06 -05:00
Matt Corallo
ed2a5fdab9 Fix serialization rt bug in Channel and test in functional_tests
Previously, when attempting to write out a channel with some
RemoteAnnounced pending inbound HTLCs, we'd write out the count
without them, but write out some of their fields. We should drop
them as intended as they will need to be reannounced upon
reconnection.

This was found while attempting to simply reproduce a different
bug by adding tests for ChannelManager serialization rount-trip at
the end of each functional_test (in Node::drop). That test is
included here to prevent some classes of similar bugs in the future.
2020-02-18 18:22:05 -05:00
Matt Corallo
5fceb0ff4f Add comment describing how ChannelMonitor::block_connected is called 2020-02-18 18:20:33 -05:00
Matt Corallo
662f13a858 Test that we don't forget to track any outputs at monitor-load
This tests, after each functional test, that if we serialize and
reload all of our ChannelMonitors we end up tracking the same set
of outputs as before.
2020-02-18 18:20:33 -05:00
Matt Corallo
73dce207dd Track the full list of outpoints a chanmon wants monitoring for.
Upon deserialization/reload we need to be able to register each
outpoint which spends the commitment txo which a channelmonitor
believes to be on chain. While our other internal tracking is
likely sufficient to regenerate these, its much easier to simply
track all outpouts we've ever generated, so we do that here.
2020-02-18 18:20:33 -05:00
Ryan Loomba
7d6234662c add functionality for BlockNotifier to unregister a previously registered listener, in order to no longer receive events 2020-02-17 21:33:56 -08:00
Matt Corallo
473f611d11
Merge pull request #440 from TheBlueMatt/2020-01-feature-sanity
Fix a bug in required feature checks
2020-02-17 23:47:06 +00:00
Matt Corallo
4f59b8e03f
Merge pull request #499 from moneyball/patch-1
add clarity to the language
2020-02-17 20:06:11 +00:00
Steve Lee
40e722d721
fixes per rloomba feedback 2020-02-15 11:45:11 -08:00
Matt Corallo
fc03ab1534
Merge pull request #501 from TheBlueMatt/2020-02-rescan-clarify
Clarify rescan rules for block_connected somewhat
2020-02-15 01:36:56 +00:00
Steve Lee
067dd3be52
fixes per arik feedback 2020-02-13 18:43:58 -08:00
Matt Corallo
ca4c970467 Clarify rescan rules for block_connected somewhat 2020-02-13 12:56:13 -05:00
Steve Lee
2314b0a25a
add clarity to the language 2020-02-12 19:36:08 -08:00
Matt Corallo
4ac9ed2f00 Add some basic sanity tests for feature flags 2020-02-12 17:16:42 -05:00
Matt Corallo
a3ddb9fb19 Avoid treating option_upfront_shutdown (req) as unknown_required.
This fixes the bitmask in requires_unknown_bits.
2020-02-12 17:13:50 -05:00
Matt Corallo
bae2338b4d
Merge pull request #470 from ariard/2020-01-contributing-draft
First draft, don't-cover-everything-but-yet-a-good-start-CONTRIBUTING.md
2020-02-12 19:31:26 +00:00
Matt Corallo
2514530a53
Merge pull request #496 from TheBlueMatt/2020-02-461-extra-mut
Remove unnecessary mut introduced in 0c595a7ff6
2020-02-12 18:53:36 +00:00
Antoine Riard
34871ea288 Add a first draft CONTRIBUTING.md 2020-02-12 13:34:10 -05:00
Matt Corallo
f137139672 Remove unnecessary mut introduced in 0c595a7ff6 2020-02-12 13:03:41 -05:00
Matt Corallo
c906f28432
Merge pull request #461 from ariard/2020-remove-duplicata
Remove some duplicata of broadcast txn from ChannelMonitor
2020-02-12 17:38:21 +00:00
Antoine Riard
494219e388 Remove duplicata of broadcast txn from ChannelMonitor
Previously, if new ouputs were found to be watched as part
of channel operations, the block was rescan which triggers
again parser and generation of transactions already issued.

This commit first modifies the test framework without
altering further ChannelMonitor.

ChannelMonitor refactoring is introduced in a latter commit.
2020-02-12 00:37:19 -05:00
Matt Corallo
3c9e8c9d77
Merge pull request #434 from TheBlueMatt/2019-12-var-len-onion
TLV-based Variable Length Onion
2020-02-11 22:49:39 +00:00