Commit graph

3535 commits

Author SHA1 Message Date
Matt Corallo
79a0a0c959 Migrate ChannelMonitor serialization to new ser framework(ish)
Sadly we can't straight up use the new serialization framework as
we have a few different serialization variants, but that's OK, it
looks identical and is just missing the Writeable impl
2018-09-20 10:46:13 -04:00
Matt Corallo
28d0d44e44 Move ChannelMonitor deserialization to new ser framework 2018-09-20 10:46:13 -04:00
Matt Corallo
c43e535bc0 Simplify DecodeError enum by removing some useless distinctions 2018-09-20 10:46:12 -04:00
Matt Corallo
66fbc66da0
Merge pull request #192 from TheBlueMatt/2018-09-docs-docs-docs
Add module and all-pub-things docs and deny missing docs
2018-09-20 10:44:23 -04:00
Matt Corallo
3aeec96470 Add module and all-pub-things docs and deny missing docs 2018-09-19 23:07:02 -04:00
Matt Corallo
7f6c31ea15 Document ConfirmationTarget a little bit (closes #101) 2018-09-19 23:07:02 -04:00
Matt Corallo
a4528faa54 Document all the fields in Errors 2018-09-19 23:07:02 -04:00
Matt Corallo
9373c5993f Make message fields pub(crate) and hide a few internal fns 2018-09-19 23:07:02 -04:00
Matt Corallo
fe90e13f84 Log peer features in peer_handler (and check for all req bits) 2018-09-19 22:47:14 -04:00
Matt Corallo
da6171d50d Remove fuzz channel_target.
It has bitrotted a lot and doesn't really make sense given all the
precondition enforcement that is in channelmanager, sadly.
2018-09-19 22:47:07 -04:00
Matt Corallo
ac821e448f
Merge pull request #186 from TheBlueMatt/2018-09-ser-rework-2
Drop old serialization framework
2018-09-18 16:14:49 -04:00
Matt Corallo
e0fad3f8a3
Merge pull request #185 from TheBlueMatt/2018-09-ser-rework
Serialization Framework Tweaks
2018-09-18 16:14:40 -04:00
Matt Corallo
c91f72c131 Drop MsgEncodable in favor of default fns on Writeable 2018-09-16 14:33:50 -04:00
Matt Corallo
8a7dd2f9b8 Fix peer_handler message serialization
Fixes a bug introduced in 3e89106163
where messages were being encoded with their size instead of their
type.
Also utilizes the new size_hinting in peer_handler
2018-09-16 14:33:50 -04:00
Matt Corallo
e8a66ef0ea Make Writeable::write typed instead of Writeable
This lets us add some untyped default functions to the trait
2018-09-16 14:33:50 -04:00
Matt Corallo
19b92448c5 Utilize Writer size hinting in message fuzz targets and check them 2018-09-16 14:33:50 -04:00
Matt Corallo
8322c756cb Stop checking size > 64KB in serialization
This removes a bunch of potentially new error handling in writers
and the checks were kinda useless anyway - in normal operation we
unwrap()ed anyway, and we're gonna want to use the serializtion
framework for ChannelMonitor/ChannelManager serialization, which
may generate things larger than 64KB anyway.
2018-09-16 14:33:50 -04:00
Matt Corallo
712051a9fc Add size_hint in ser and call size_hint in all message serializers 2018-09-16 14:33:50 -04:00
Matt Corallo
dfbdcf9e01 Remove MsgDecodable and most MsgEncodable impls 2018-09-16 14:33:50 -04:00
Matt Corallo
ee9533a905 Split out Vec<u8> and Vec<Signature> ser impls cause there's 2
Should resolve any performance issues with Vec<u8> serialization.
2018-09-16 14:33:50 -04:00
Matt Corallo
8c460c1239 Remove uses of MsgDecodable from ChannelManager 2018-09-16 14:33:50 -04:00
Matt Corallo
1f1f82569a Simplify serialization a bit by removing the useless newtypes 2018-09-16 14:33:50 -04:00
Matt Corallo
51ba6ad2e9 Expose (de)serialziers as we'll need them and I don't like warnings 2018-09-16 14:33:48 -04:00
Matt Corallo
97488ad36e
Merge pull request #178 from TheBlueMatt/2018-09-channel_reestablish
Handle peer disconnect tracking/channel_reestablish
2018-09-15 11:36:59 -04:00
Matt Corallo
e606f13664 Constify 2**48-1 and add some additional comments in Channel 2018-09-15 10:53:16 -04:00
Matt Corallo
c003d043de Add a simple channel_reestablish test 2018-09-15 10:53:16 -04:00
Matt Corallo
28c5f6f309 Track peer-disconnection in Channel and handle channel_reestablish 2018-09-15 10:53:16 -04:00
Matt Corallo
ca712dfa36 Add a Disconnected ChannelState and check/handle it everywhere
Setting/removing it comes next
2018-09-15 10:53:16 -04:00
Matt Corallo
12a50627a3 Add channel_reestablish + peer_connected events to channel handler 2018-09-15 10:53:16 -04:00
Matt Corallo
4bcf00e5b8 Clarify update_fail/fulfill_htlc holding cell allowed Errs
Specifically, there really should be no Errs, but in case there is
some case where duplicate HTLC removes are possible, return
IgnoreError and debug_assert to see if fuzzing can find them.
2018-09-15 10:53:16 -04:00
Matt Corallo
5fe598c073 Drop channels on disconnection if we haven't funded them yet 2018-09-15 10:53:16 -04:00
Matt Corallo
f55f055b4e Remove/fail uncommitted HTLCs upon peer disconnection 2018-09-15 10:53:16 -04:00
Matt Corallo
2be7eda3b5
Merge pull request #179 from TheBlueMatt/2018-09-pre-178-cleanups
Pre-reconnect ChannelManager test cleanups
2018-09-15 10:50:57 -04:00
Matt Corallo
ed71995f15
Merge pull request #183 from yuntai/201809-unwrap-getopenchannel
unwrap channel.get_open_channel
2018-09-15 10:48:54 -04:00
Yuntai Kyong
4e4fa56e2b unwrap channel.get_open_channel 2018-09-15 07:33:20 +09:00
Matt Corallo
5737b32424 Split claim and fail payment functions to be able to skip one hop 2018-09-14 16:24:30 -04:00
Matt Corallo
4f36f379e7 Move all-events check into framework instead of per-test 2018-09-14 16:24:30 -04:00
Matt Corallo
adee6719c4 Split up send_commitment into a const and non-const version 2018-09-14 16:24:30 -04:00
Matt Corallo
9252ddbb1d Remove unused import and uneccessary mut 2018-09-14 16:24:30 -04:00
Matt Corallo
1e3d875be0
Merge pull request #180 from TheBlueMatt/2018-09-htlc-tx-unwrap-fix
Ignore HTLC txn we dont know how to claim instead of unwrap()ing and Do not fail-backwards LocalAnnounced HTLCs upon force-close.
2018-09-14 16:19:38 -04:00
Matt Corallo
aa17defa04 Tweak + extend full_stack_target sample to incl HTLC tx broadcasts 2018-09-14 15:27:54 -04:00
Matt Corallo
68be3c0353 Test that we do not fail-backwards HTLCs that the remote on-chained 2018-09-14 15:27:54 -04:00
Matt Corallo
f48fe4bd8c Make the commitment signed dance a macro in ChannelManager tests 2018-09-14 15:27:53 -04:00
Matt Corallo
5ef88cea34 Do not fail-backwards LocalAnnounced HTLCs upon force-close.
This is completely unsafe as we have provided the remote side with
a commitment_signed which they can broadcast, including the HTLC
transaction, and then could claim it on-chain after we've failed it
backwards!
2018-09-14 15:27:53 -04:00
Matt Corallo
a55355e641 Ignore HTLC txn we dont know how to claim instead of unwrap()ing
This fixes a crash introduced in 3e149b1fb6
and introduces a test which will tickle the bug.
2018-09-14 15:27:39 -04:00
Matt Corallo
e323c13a59
Merge pull request #177 from TheBlueMatt/2018-09-163-cleanups
Optimize some ChannelMonitor stuff after #163
2018-09-13 20:18:21 -04:00
Matt Corallo
66d5d764aa Clean up and clarify tx broadcast checks in channelmonitor tests
This effecitlvey reverts the refactors in 383bd90a48,
however keeps the actully new test code.

It also writes documentation for the super confusing tx test func
and makes it a bit less permissive.
2018-09-13 14:24:37 -04:00
Matt Corallo
e9e27f277a There can only be one input in matched txn in ChannelMonitor
This lets us simplify a few tidbits of loop.
2018-09-13 14:05:08 -04:00
Matt Corallo
27d5a3a94f Optimize check_spend_remote HTLC a tad by avoiding indirections
Instead of hopping a pointer, we're only ever going to return one
Transaction at max, so skip the Vec. Also avoid
re-pubkey-converting the revocation key.
2018-09-13 14:05:08 -04:00
Matt Corallo
01c8e4f56f
Merge pull request #163 from ariard/claim_revoked_htlc_tx
Implement claiming of revoked HTLC transactions by ChannelMonitor
2018-09-13 13:53:47 -04:00