Commit graph

2516 commits

Author SHA1 Message Date
Matt Corallo
e7560c83b4 Make errors actionable when failing to deserialize a ChannelManager 2021-06-30 16:12:21 +00:00
Matt Corallo
f4729075cb
Merge pull request #965 from TheBlueMatt/2021-06-log-cleanups
Cleanup logging
2021-06-29 20:13:50 +00:00
Matt Corallo
6d98aedaf5 Add debug log when we stop tracking confirmed on-chain packages 2021-06-29 19:36:47 +00:00
Matt Corallo
6d446a6249 Correct inbound HTLC upgrade logs on revoke_and_ack receipt 2021-06-29 19:36:47 +00:00
Matt Corallo
74717d390c Increase the log level of several channelmonitor/onchain logs.
ChannelMonitor and related log entries can generally lean towards
being higher log levels than they necessarily need to be, as they
should be exceedingly rare, if only because they require
confirmation of an on-chain transaction.
2021-06-29 19:36:47 +00:00
Matt Corallo
76ea83463b Add additional TRACE-level logging during pathfinding in router 2021-06-29 19:36:47 +00:00
Matt Corallo
7eff56b12f Update logging in channel and channelmanager to better levels
This updates a number of log sites in channel and channelmanager to
 * Be a bit more verbose at the TRACE level,
 * Move some error/useful messages to the ERROR/WARN/INFO level,
 * Add new logs to always log once at the DEBUG level when we
   send/receive a commitment_signed (with some extra data),
 * Include the channel id being operated on in more log messages.
2021-06-29 19:36:47 +00:00
Matt Corallo
1f592b045f Do not log_debug when we receive duplicate gossip messages
We very often receive duplicate gossip messages, which now causes us
to log at the DEBUG level, which is almost certainly not what a
user wants. Instead, we add a new form of ErrorAction which causes
us to only log at the TRACE level.
2021-06-29 19:36:47 +00:00
Matt Corallo
7fa6a7d48e Allow logging to specify an explicit log level instead of a macro
For log entries which may have a variable level, we can't call an
arbitrary macro and need to be able to pass an explicit level. This
does so without breaking the compile-time disabling of certain log
levels.

Further, we "fix" the comparison order of log levels to make more
significant levels sort "higher", which implicitly makes more sense
than sorting "lower".

Finally, we remove the "Off" log level as no log entry should ever
be logged at the "Off" level - that would be nonsensical.
2021-06-29 19:36:47 +00:00
Matt Corallo
d36a875f98 More consistently log in msg handling, incl full msg logging at trace
This much more consistently logs information about messages
sent/received, including logging the full messages being
sent/received at the TRACE log level. Many other log messages which
are more often of interest were moved to the DEBUG log level.
2021-06-29 19:36:47 +00:00
Matt Corallo
3ea4279d55 Unify message sending to use PeerManager::enqueue_message
This makes our logging consistent and somewhat simplifies message
sending code in a few places.
2021-06-29 19:36:47 +00:00
Matt Corallo
133e28ffe6 Add error logs when a ChannelManager as inconsistent monitor state
We had a client application which provided inconsistent monitor
state when deserializing a ChannelManager, resulting in opaque and
generic "InvalidData" deserialization failures. Instead, we log
some informative (and appropriately scary) warning messages in
such cases.
2021-06-29 19:36:47 +00:00
Matt Corallo
3791a7b2a5
Merge pull request #974 from sr-gi/message_signing_borrow
Passes references to the public and secret keys to sign/verify
2021-06-29 16:29:08 +00:00
Matt Corallo
74f10076b2
Merge pull request #966 from TheBlueMatt/2021-06-workaround-broken-lnd
Workaround lnd sending funding_locked before channel_reestablish
2021-06-29 16:28:38 +00:00
Sergi Delgado Segura
c1d2d156c9
Passes references to the public and secret keys to sign/verify
sign/verify should not take ownership of the keys.
2021-06-29 15:26:21 +02:00
Matt Corallo
8df141233f Workaround lnd sending funding_locked before channel_reestablish
lnd has a long-standing bug where, upon reconnection, if the
channel is not yet confirmed they will not send a
channel_reestablish until the channel locks in. Then, they will
send a funding_locked *before* sending the channel_reestablish
(which is clearly a violation of the BOLT specs). We copy
c-lightning's workaround here and simply store the funding_locked
message until we receive a channel_reestablish.

See-also https://github.com/lightningnetwork/lnd/issues/4006

Fixes #963
2021-06-28 02:05:33 +00:00
Matt Corallo
ecddfe1766
Merge pull request #968 from TheBlueMatt/2021-06-no-invoice-dylib
Drop the cdylib export of lightning-invoice
2021-06-25 17:42:40 +00:00
Matt Corallo
b9aa71f056
Merge pull request #964 from valentinewallace/2021-06-tlv-ser
Fix TLV serialization to work with large types
2021-06-24 22:44:41 +00:00
Valentine Wallace
40959b74b7
Fix TLV serialization to work with large types.
Previous to this PR, TLV serialization involved iterating from 0 to the highest
given TLV type. This worked until we decided to implement keysend, which has a
TLV type of ~5.48 billion.

So instead, we now specify the type of whatever is being (de)serialized (which
can be an Option, a Vec type, or a non-Option (specified in the serialization macros as "required").
2021-06-24 16:25:31 -04:00
Matt Corallo
b786adff5b Drop the cdylib export of lightning-invoice
There are ~zero functions in lightning-invoice that are materially
callable from C, so there isn't any reason to tag it as a cdylib
(and make rustc build it as such). Instead, we have C bindings now.
2021-06-24 04:32:25 +00:00
Matt Corallo
bfd9646092
Merge pull request #950 from TheBlueMatt/2021-06-changelog
Add a dummy first CHANGELOG entry for future tracking
2021-06-23 17:22:11 +00:00
Matt Corallo
66726fb508 Add a dummy first CHANGELOG entry for future tracking 2021-06-23 16:43:18 +00:00
Matt Corallo
a146ef2be2 Do not generate error messages when we receive our own gossip
When a peer sends us the routing graph, it may include gossip
messages for our channels, despite it not being a party to them.
This is completely fine, but we currently print a somewhat-scary
looking log messages in these cases, eg:

```
ERROR [lightning::ln::channelmanager:4104] Got a message for a channel from the wrong node!
TRACE [lightning::ln::peer_handler:1267] Handling SendErrorMessage HandleError event in peer_handler for node ... with message Got a message for a channel from the wrong node!
```

Instead, we should simply not consider this an "error" condition
and stay silent.
2021-06-23 01:35:26 +00:00
Matt Corallo
95f9523097 Drop rust-bitcoin crate patches in fuzz now that they're merged
These patches have been merged upstream and are in releases now so
we don't need to patch them locally.
2021-06-23 01:35:26 +00:00
Matt Corallo
c5a6135edc log_debug information about network graph updates from payments 2021-06-23 01:35:26 +00:00
Matt Corallo
d61d698bb8 Don't print file paths in fuzz logger as they can be very long 2021-06-23 01:35:23 +00:00
Matt Corallo
073afbb244
Merge pull request #957 from TheBlueMatt/2021-06-p2p-no-deadlock
Fix P2P Deadlocks
2021-06-23 01:34:55 +00:00
Matt Corallo
05157b1755 Clean up docs on peer_handler significantly.
There are various typo and grammatical fixes here, as well as
concrete updates to correctness.
2021-06-23 00:51:31 +00:00
Matt Corallo
656ed89388 No longer block disconnect_socket calls in lightning-net-tokio
See the previous commit for more information.
2021-06-23 00:51:31 +00:00
Matt Corallo
4703d4e725 Do not require that no calls are made post-disconnect_socket
The only practical way to meet this requirement is to block
disconnect_socket until any pending events are fully processed,
leading to this trivial deadlock:

 * Thread 1: select() woken up due to a read event
 * Thread 2: Event processing causes a disconnect_socket call to
             fire while the PeerManager lock is held.
 * Thread 2: disconnect_socket blocks until the read event in
             thread 1 completes.
 * Thread 1: bytes are read from the socket and
             PeerManager::read_event is called, waiting on the lock
             still held by thread 2.

There isn't a trivial way to address this deadlock without simply
making the final read_event call return immediately, which we do
here. This also implies that users can freely call event methods
after disconnect_socket, but only so far as the socket descriptor
is different from any later socket descriptor (ie until the file
descriptor is re-used).
2021-06-21 20:25:40 +00:00
Matt Corallo
2f6205bfb0
Merge pull request #948 from TheBlueMatt/2021-06-p2p-fixes
Clean up message forwarding and relay gossip messages
2021-06-21 20:23:39 +00:00
Matt Corallo
895d1a8504 [peer_handler] Drop unused return from get_peer_for_forwarding!()
This avoids a now-unnecessary SocketDescriptor clone() call in
addition to cleaning up the callsite code somewhat.
2021-06-21 19:45:17 +00:00
Matt Corallo
f76e14c425 Somewhat simplify message handling error mapping in peer_handler 2021-06-21 19:45:17 +00:00
Matt Corallo
ae39b2ce19 Drop peers_needing_send tracking and try to write for each peer
We do a lot of work to track which peers have buffers which need
to be flushed, when we could instead just try to flush ever peer's
buffer.
2021-06-21 19:45:17 +00:00
Matt Corallo
0426d6e7a9 Skip forwarding gossip messages to peers if their buffer is over-full 2021-06-21 19:45:17 +00:00
Matt Corallo
c56cd1ef3a Forward gossip msgs 2021-06-21 16:02:18 +00:00
Matt Corallo
9de22ae6fc Refactor message broadcasting out into a utility method
This will allow us to broadcast messages received in the next
commit.
2021-06-21 16:02:18 +00:00
Matt Corallo
a6463ec6cd Fix bogus reentrancy from read_event -> do_attempt_write_data
`Julian Knutsen <julianknutsen@users.noreply.github.com>` pointed
out in a previous discussion that `read_event` can reenter user
code despite the documentation stating explicitly that it will not.

This was addressed in #456 by simply codifying the reentrancy, but
its somewhat simpler to just drop the `do_attempt_write_data` call.

Ideally we could land most of Julian's work, but its still in need
of substantial git history cleanup to get it in a reviewable state
and this solves the immediate issue.
2021-06-21 16:02:18 +00:00
Matt Corallo
f4323d98b8 Drop unused "peer gone" handling in get_peer_for_forwarding!()
We can never assume that messages were reliably delivered whether
we placed them in the socket or not, so there isn't a lot of use in
explicitly handling the case that a peer was not connected when we
went to send it a message.

Two TODOs are left for the generation of a `FundingAbandoned` (or
similar) event, though it ultimately belongs in `ChannelManager`.
2021-06-21 16:02:18 +00:00
Matt Corallo
94528f00f5
Merge pull request #947 from GeneFerneau/hash
Use hashbrown replacements for std equivalents
2021-06-20 02:20:19 +00:00
Gene Ferneau
da7a851d47
Use hashbrown replacements for std equivalents 2021-06-18 21:54:21 +00:00
Matt Corallo
4d1c1a32f2
Merge pull request #956 from jkczyz/2021-06-validate-pub
Increase poll::Validate visibility to pub
2021-06-18 18:06:45 +00:00
Matt Corallo
244ad8349e
Merge pull request #955 from TheBlueMatt/2021-06-rustc-bugz
Fix trivial doc warnings and make CI use old rustc
2021-06-18 15:24:21 +00:00
Jeffrey Czyz
7302c8c38a
Remove unnecessary spaces 2021-06-18 00:26:36 -05:00
Jeffrey Czyz
8cc026b406
Increase poll::Validate visibility to pub
Previously, poll::Validate was pub(crate) to force external implementors
of Poll to define their implementation in terms of ChainPoller. This was
because ChainPoller::look_up_previous_header checks for consistency
between headers and any errors would be checked at that level rather
than by the caller. Otherwise, if performed by the caller, a Poll
implementation would not be aware if the underlying BlockSource was
providing bad data and therefore couldn't react accordingly.

Widening the visibility to pub relaxes this requirement, although it's
still encourage to use ChainPoller to implement Poll. This permits
either copying or moving lightning-block-sync's test utilities to a
separate crate since they use poll::Validate.
2021-06-18 00:26:33 -05:00
Matt Corallo
f875579311 Clarify invoice comment noting the relevant final-cltv-expiry vals 2021-06-17 20:17:24 +00:00
Matt Corallo
84ac66e80f Make links in message signing docs rustdoc links
Latest rustc warns that "this URL is not a hyperlink" and notes that
"bare URLs are not automatically turned into clickable links". This
resolves those warnings.

Thanks to Joshua Nelson for pointing out the correct syntax for
this.
2021-06-17 16:58:59 +00:00
Matt Corallo
e7974dac84 Expose doc-linked constants in lightning-invoice
These constants are generally useful, and are linked from
documentation, so should be exposed in any case.
2021-06-17 15:48:20 +00:00
Matt Corallo
27d9feda58 Only check docs on rustc 1.52 as rustc stable now crashes 2021-06-17 15:41:16 +00:00
Matt Corallo
294009969a
Merge pull request #944 from TheBlueMatt/2021-06-0.0.99
0.0.98
2021-06-11 17:02:11 +00:00