Commit graph

327 commits

Author SHA1 Message Date
Jeffrey Czyz
9dd2be15e9 Remove duplicate specification of features
Features for a given context are duplicated throughout the features
module. Use a macro for defining a Context and the applicable features
such that features only need to be defined for a Context in one place.
The Context provides bitmasks for selecting known and unknown feature
flags.

BOLT 1 and BOLT 9 refer to features as "known" if a peer understands
them. They also use the term "supported" to mean either optional or
required.

Update the features module to use similar terminology.
- Define contexts in terms of required and optional features rather than
  just supported features
- Define known features as those that are optional or required
- Rename supported() constructor to known()

For completeness, clear_optional_bit for each feature is now called
clear_bits and clears both optional and required bits.
2020-04-29 11:09:23 -07:00
Dr. Maxim Orlovsky
dde344a51d Adopting (W)PubkeyHash types 2020-04-29 12:37:57 +02:00
Dr. Maxim Orlovsky
27079e04d7 Adopting new bitcoin hash types and crate version 2020-04-29 12:37:46 +02:00
Dr. Maxim Orlovsky
eff8af2110 BDR: Linearizing secp256k1 deps 2020-04-28 16:17:44 +02:00
Dr. Maxim Orlovsky
4909d3cd6a Bitcoin deps refactoring (BDR): Linearizing bitcoin_hash deps 2020-04-28 16:17:42 +02:00
Matt Corallo
4dc0dd17c0
Merge pull request #579 from ariard/2020-04-sanitize-cltv-delay
Sanititze and document incoming HTLC cltv_expiry handling
2020-04-24 22:50:45 +00:00
Antoine Riard
886223a313 Sanitize outgoing HTLC cltv_value 2020-04-24 18:31:07 -04:00
Matt Corallo
ecb94689bf Include color when building fuzz targets in CI 2020-04-24 17:35:18 -04:00
Matt Corallo
764e6e71e3 Disable timeout for full_stack_target runs in CI
It seems we've recently been seeing sporadic long-running
full_stack_target cases when running honggfuzz in CI. These
shouldn't be killed (as its possible they hit an error or a deadlock,
especially since the longest-running tests probably have the most
coverage).
2020-04-24 16:56:20 -04:00
Matt Corallo
2e997d758f Silence fuzz build unused import warnings 2020-04-24 16:55:09 -04:00
Matt Corallo
0d75545632
Merge pull request #593 from TheBlueMatt/2020-04-par-fuzz-check
Thread fuzz test cases
2020-04-24 20:52:19 +00:00
Matt Corallo
6745aff9b6 Thread fuzz test cases
Adds threading (with logger capture) to fuzz targets so that we can
more effeciently test a failing fuzz corpus on new code changes.
2020-04-24 16:06:34 -04:00
Matt Corallo
86a2607b00
Merge pull request #601 from D4nte/ci-in-github-action
Add GitHub Action to build the project
2020-04-24 18:14:55 +00:00
Franck Royer
e6e69f51b9
Use more generic name as it will be use in GitHub Action too 2020-04-23 09:36:48 +10:00
Matt Corallo
b04219a767 Drop ChannelMonitor::write_for_watchtower
Not only was watchtower mode never implemented, but the bits that
we had were removed some time ago. It doesn't seem likely we'll
move forward with a "watchtower-mode" ChannelMonitor, instead
we'll likely have some other, separate struct for this.
2020-04-22 16:48:13 -04:00
Matt Corallo
7e0b57615f Concretize some types in fuzz, addressing new rustc warnings 2020-04-18 20:47:16 -04:00
Matt Corallo
59b1bf6d0f Pass Route to send_payment as a reference, not move
ChannelManager::send_payment stopped utilizing its ownership of the
Route with MPP (which, for readability, now clone()s the individual
paths when creating HTLCSource::OutboundRoute objects). While this
isn't ideal, it likely also makes sense to ensure that the user has
access to the Route after sending to correlate individual path
failures with the paths in the route or, in the future, retry
individual paths.

Thus, the easiest solution is to just take the Route by reference,
allowing the user to retain ownership.
2020-04-14 20:50:42 -04:00
Matt Corallo
03a1b5264d Test basic AMP payments in chanmon_consistency 2020-04-14 20:50:42 -04:00
Matt Corallo
5260e81033 Expand the Route object to include multiple paths.
Rather big diff, but its all mechanical and doesn't introduce any
new features.
2020-04-14 19:54:17 -04:00
Matt Corallo
6d1bd8bc98 Impl Base AMP in the receive pipeline and expose payment_secret
Base AMP is centered around the concept of a 'payment_secret` - an
opaque 32-byte random string which is used to authenticate the
sender to the recipient as well as tie the various HTLCs which
make up one payment together. This new field gets exposed in a
number of places, though sadly only as an Option for backwards
compatibility when sending to a receiver/receiving from a sender
which does not support Base AMP.

Sadly a huge diff here, but almost all of it is changing the method
signatures for sending/receiving/failing HTLCs and the
PaymentReceived event, which all now need to expose an
Option<[u8; 32]> for the payment_secret.

It doesn't yet properly fail back pending HTLCs when the full AMP
payment is never received (which should result in accidental
channel force-closures). Further, as sending AMP payments is not
yet supported, the only test here is a simple single-path payment
with a payment_secret in it.
2020-04-14 19:54:17 -04:00
Arik Sosman
d0f941f732
Mandate new line at end of file in editorconfig. 2020-04-11 11:33:07 -07:00
Arik Sosman
cdb1f8e48a
Update documentation to reflect target-dependent local reproduction steps. 2020-04-10 17:15:12 -07:00
Arik Sosman
aea2971f5c
Add details on asserting latest version in the dependencies and listing targets. 2020-04-10 11:22:46 -07:00
Arik Sosman
df18f99b5a
Create docs for fuzzing 2020-04-10 01:28:45 -07:00
Matt Corallo
03b5da10b7 Broadcast final local txn via ChannelMonitorUpdate 2020-03-19 19:21:36 -04:00
Matt Corallo
8a03830d43 Don't return a feerate of 0 in full_stack_target fuzz on EOF
This triggered a (legitimate) panic in OnChainTxHandler that the
feerate in use was non-0, which is required by the feerate API.
2020-03-16 22:09:08 -04:00
Matt Corallo
6f06858304 Swap read_event read type for a slice isntead of a Vec
It looks like we don't currently use the Vec as a Vec, and can
happily take a slice, which makes things easier on the calling
side.
2020-03-10 11:52:12 -04:00
Matt Corallo
107da97cd0 Allow more than one address per type in node_announcement messages
lnd has been blatantly ignoring this line in the spec forever, so
its somewhat of a lost cause trying to enforce it.
2020-03-05 18:42:49 -05:00
Matt Corallo
32ca8ec13e Make Readable::read a templated on the stream, not Readable itself
This makes Readable symmetric with Writeable and makes sense -
something which is Readable should be Readable for any stream which
implements std::io::Read, not only for a stream type it decides on.

This solves some lifetime-compatibility issues in trying to read()
from a LengthLimitingReader in arbitrary Readable impls.
2020-03-04 14:29:06 -05:00
Christopher Coverdale
53c894bcaa Add an override optional UserConfig per new outbound channel 2020-02-28 22:58:26 +00:00
Valentine Wallace
f5b5bf2acb
Update ChannelManager's FeeEstimator from Arc to Deref. 2020-02-27 15:27:58 -05:00
Valentine Wallace
bff9982299
multi: update ChannelManager's keys manager from Arc to Deref 2020-02-27 11:55:18 -05:00
Matt Corallo
3e26bd7a1d Rm ChannelMonitor merge capabilities in favor of explicit add/update
This removes the ability to merge ChannelMonitors in favor of
explicit ChannelMonitorUpdates. It further removes
ChannelManager::test_restore_channel_monitor in favor of the new
ChannelManager::channel_monitor_updated method, which explicitly
confirms a set of updates instead of providing the latest copy of
each ChannelMonitor to the user.

This removes almost all need for Channels to have the latest
channel_monitor, except for broadcasting the latest local state.
2020-02-26 19:15:32 -05:00
Matt Corallo
3b277cc394 Add types for updating ChannelMonitors without copying them.
This is the first step in migrating ChannelMonitor updating logic
to use incremental Update objects instead of copying the
ChannelMonitors themselves and insert_combine()ing them.

This adds most of the scaffolding and updates relevant comments to
refer to the new architecture, without changing how any actual
updates occur.
2020-02-26 19:15:32 -05:00
Valentine Wallace
d768cc234e
multi: update ChannelManager tx broadcaster from Arc to Deref 2020-02-25 20:12:25 -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
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
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
1b47ddd226 Skip lto on travis when building fuzz targets as it takes 30 min 2020-02-20 20:02:26 -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
c94e53d9dd Add support for variable-length onion payload reads using TLV 2020-02-11 16:27:38 -05:00
Matt Corallo
87a0018e3e Better document msg fuzz target behavior and be slightly more strict 2020-02-11 13:48:56 -05:00
Matt Corallo
425e4adbf2
Merge pull request #454 from TheBlueMatt/2020-01-fuzz-mega-value
Panic on txn with value > 21mill in ChannelMonitor::block_connected, Clean up fuzz targets a bit
2020-02-05 01:23:44 +00:00
Devrandom
c20e930b31 Add ChannelKeys to ChannelMonitor 2020-02-04 16:24:11 -08:00
Matt Corallo
af4738b778
Merge pull request #460 from lightning-signer/channel-value
Channel value to ChannelKeys constructor
2020-01-25 21:17:12 +00:00
Valentine Wallace
4833d1acf9 Update ChannelManager's ChannelMonitor Arc to be a Deref
Additional changes:
* Update fuzz crate to match ChannelManager's new API
* Update lightning-net-tokio library to match ChannelManager's new ChannelMonitor Deref API
* Update tests to match ChannelManager's new ChannelMonitor Deref API
2020-01-25 14:39:52 -05:00
Devrandom
d14ece4ac0 channel value to ChannelKeys constructor 2020-01-23 19:06:57 -08:00
Matt Corallo
912f877482 Pass node features through to RouteHops
This exposes the latest Init-context features in the ChannelDetails
passed to the Router during route calculation, which combines those
with the Node-context features tracked from node_announcements to
provide the latest Node-context features in RouteHop structs.

Fields are also added for Channel-context features, though those are
only partially used since no such features are defined today anyway.

These will be useful when determining whether to use new
TLV-formatted onion hop datas when generating onions for peers.
2020-01-21 15:09:12 -05:00
Matt Corallo
d2ba7caf47 Pass peer's Init message through to ChannelManager 2020-01-19 22:47:08 -05:00
Matt Corallo
f263b3793f
Merge pull request #451 from lightning-signer/txkeys
Provide remote channel public keys to signer
2020-01-20 03:46:00 +00:00