]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
3 years agoAdd unknown message handler to peer manager 2021-07-custom-msg-suggestion
Tibo-lg [Wed, 14 Jul 2021 02:44:36 +0000 (11:44 +0900)]
Add unknown message handler to peer manager

3 years agoMake ser macro public
Tibo-lg [Fri, 9 Jul 2021 11:40:43 +0000 (20:40 +0900)]
Make ser macro public

3 years agoMerge pull request #949 from TheBlueMatt/2021-06-send-priv-update
Matt Corallo [Wed, 7 Jul 2021 20:17:10 +0000 (20:17 +0000)]
Merge pull request #949 from TheBlueMatt/2021-06-send-priv-update

Send channel_update messages to direct peers on private channels

3 years agoIgnore our own gossip if it is sent to us from our counterparty 2021-06-send-priv-update
Matt Corallo [Wed, 30 Jun 2021 00:27:24 +0000 (00:27 +0000)]
Ignore our own gossip if it is sent to us from our counterparty

If our channel party sends us our own channel_update message, we'll
erroneously use the information in that message to update our view
of the forwarding parameters our counterparty requires of us,
ultimately generating invoices with bogus forwarding information.

This fixes that behavior by checking the channel_update's
directionality before handling it.

3 years agoFix spelling in ChannelManager comment
Matt Corallo [Mon, 14 Jun 2021 15:14:18 +0000 (15:14 +0000)]
Fix spelling in ChannelManager comment

3 years agoSend channel_update messages to direct peers on private channels
Matt Corallo [Sat, 12 Jun 2021 21:58:50 +0000 (21:58 +0000)]
Send channel_update messages to direct peers on private channels

If we are a public node and have a private channel, our
counterparty needs to know the fees which we will charge to forward
payments to them. Without sending them a channel_update, they have
no way to learn that information, resulting in the channel being
effectively useless for outbound-from-us payments.

This commit fixes our lack of channel_update messages to private
channel counterparties, ensuring we always send them a
channel_update after the channel funding is confirmed.

3 years agoMerge pull request #984 from TheBlueMatt/2021-06-more-chan-data
Matt Corallo [Tue, 6 Jul 2021 00:53:12 +0000 (00:53 +0000)]
Merge pull request #984 from TheBlueMatt/2021-06-more-chan-data

Expose More Information about Channels and structs

3 years agoTweak documentation in `BestBlock` to be a bit more clear 2021-06-more-chan-data
Matt Corallo [Mon, 5 Jul 2021 18:31:32 +0000 (18:31 +0000)]
Tweak documentation in `BestBlock` to be a bit more clear

3 years agoExpose the current best chain tip from ChannelManager + Monitors
Matt Corallo [Sat, 3 Jul 2021 01:58:30 +0000 (01:58 +0000)]
Expose the current best chain tip from ChannelManager + Monitors

Fixes #979

3 years agoExpand the fields exposed to users in `ChannelDetails`
Matt Corallo [Fri, 2 Jul 2021 23:54:57 +0000 (23:54 +0000)]
Expand the fields exposed to users in `ChannelDetails`

This adds four new fields in `ChannelDetails`:
1. holder_selected_ and counterparty_selected_channel_reserve_delay
   are useful to determine what amount of the channel is
   unavailable for payments.
2. confirmations_required is useful when awaiting funding
   confirmation to determine how long you will need to wait.
3. to_self_delay is useful to determine how long it will take to
   receive funds after a force-close.

Fixes #983.

3 years agoDrop Channel HTLC transaction building thin wrapper function
Matt Corallo [Sun, 4 Jul 2021 14:13:10 +0000 (14:13 +0000)]
Drop Channel HTLC transaction building thin wrapper function

3 years agoMake channel fields which are from accept_channel Optional
Matt Corallo [Sat, 3 Jul 2021 15:27:12 +0000 (15:27 +0000)]
Make channel fields which are from accept_channel Optional

These fields are set with a dummy value, which we should generally
be avoiding since Rust gives us a nice `Option` type to use
instead.

Further, we stop rejecting channel_update messages outright when
the htlc_maximum_msat field includes the reserve values, which
nodes could reasonably do without it meriting a channel closure.

3 years agoMerge pull request #958 from TheBlueMatt/2021-06-fix-router-panic
Matt Corallo [Mon, 5 Jul 2021 00:01:43 +0000 (00:01 +0000)]
Merge pull request #958 from TheBlueMatt/2021-06-fix-router-panic

Fix panic in router given to bogus last-hop hints

3 years agoFix panic in router given to bogus last-hop hints 2021-06-fix-router-panic
Matt Corallo [Fri, 18 Jun 2021 04:31:50 +0000 (04:31 +0000)]
Fix panic in router given to bogus last-hop hints

See new comments and test cases for more info

3 years agoReject minimum_depth of 0 on channel opens
Matt Corallo [Sun, 4 Jul 2021 14:13:45 +0000 (14:13 +0000)]
Reject minimum_depth of 0 on channel opens

We don't support turbo channels so this is a pretty clear
indication that there is some incompatibility.

3 years agoNever generate a `BroadcastChannelUpdate` for priv channels
Matt Corallo [Fri, 11 Jun 2021 16:03:34 +0000 (16:03 +0000)]
Never generate a `BroadcastChannelUpdate` for priv channels

Currently we always generate a
`MessageSendEvent::BroadcastChannelUpdate` when a channel is closed
even if the channel is private. Our immediate peers should ignore
such messages as they haven't seen a corresponding
`channel_announcement`, but we are still giving up some privacy by
informing our immediate peers of which channels were ours.

Here we split `ChannelManager::get_channel_update` into a
`get_channel_update_for_broadcast` and
`get_channel_update_for_unicast`. The first is used when we are
broadcasting a `channel_update`, allowing us to refuse to do so
for private channels. The second is used when failing a payment (in
which case the recipient has already shown that they are aware of
the channel so no such privacy concerns exist).

3 years agoMerge pull request #970 from TheBlueMatt/2021-06-no-confirmed-csv-delay
Matt Corallo [Fri, 2 Jul 2021 17:55:17 +0000 (17:55 +0000)]
Merge pull request #970 from TheBlueMatt/2021-06-no-confirmed-csv-delay

Create SpendableOutputs events no matter the chain::Confirm order

3 years agoClean up get_broadcasted_holder_claims confirmation height param use 2021-06-no-confirmed-csv-delay
Matt Corallo [Sat, 26 Jun 2021 00:56:52 +0000 (00:56 +0000)]
Clean up get_broadcasted_holder_claims confirmation height param use

3 years agoClarify when height is the *current* vs a *confirmation* height
Matt Corallo [Fri, 25 Jun 2021 20:27:38 +0000 (20:27 +0000)]
Clarify when height is the *current* vs a *confirmation* height

3 years agoCreate SpendableOutputs events no matter the chain::Confirm order
Matt Corallo [Fri, 25 Jun 2021 04:16:35 +0000 (04:16 +0000)]
Create SpendableOutputs events no matter the chain::Confirm order

We had a user who pointed out that we weren't creating
`SpendableOutputs` events when we should have been after they
called `ChannelMonitor::best_block_updated` with a block well
after a CSV locktime and then called
`ChannelMonitor::transactions_confirmed` with the transaction which
we should have been spending (with a block height/hash a ways in
the past).

This was due to `ChannelMonitor::transactions_confirmed` only
calling `ChannelMonitor::block_confirmed` with the height at which
the transactions were confirmed, resulting in all checks being done
against that, not the current height.

Further, in the same scenario, we also would not fail-back and HTLC
where the HTLC-Timeout transaction was confirmed more than
ANTI_REORG_DELAY blocks ago.

To address this, we use the best block height for confirmation
threshold checks in `ChannelMonitor::block_confirmed` and pass both
the confirmation and current heights through to
`OnchainTx::update_claims_view`, using each as appropriate.

Fixes #962.

3 years agoUpdate `ChannelMonitor::best_block` before calling block_confirmed
Matt Corallo [Mon, 28 Jun 2021 16:23:19 +0000 (16:23 +0000)]
Update `ChannelMonitor::best_block` before calling block_confirmed

No matter the context, if we're told about a block which is
guaranteed by our API semantics to be on the best chain, and it has
a higher height than our current understanding of the best chain,
we should update our understanding. This avoids complexity
in `block_confirmed` by never having a height set which is *higher*
than our current best chain, potentially avoiding some bugs in the
rather-complicated code.

It also requires a minor test tweak as we in some cases now no
longer broadcast a conflicting transaction after the original has
reached the ANTI_REORG_DELAY.

3 years agoAvoid calling OnchainTx::block_disconnected if no block was discon'd
Matt Corallo [Fri, 25 Jun 2021 04:14:50 +0000 (04:14 +0000)]
Avoid calling OnchainTx::block_disconnected if no block was discon'd

There are no visible effects of this, but it seems like good code
hygiene to not call a disconnect function in a different file if no
disconnect happened.

3 years agoAdd new expect_payment_failure_chan_update!() macro in tests
Matt Corallo [Fri, 25 Jun 2021 16:48:34 +0000 (16:48 +0000)]
Add new expect_payment_failure_chan_update!() macro in tests

This further DRYs up some functional_test code and increases
coverage.

3 years agoMerge pull request #976 from TheBlueMatt/2021-06-actionable-errors
Matt Corallo [Thu, 1 Jul 2021 03:33:15 +0000 (03:33 +0000)]
Merge pull request #976 from TheBlueMatt/2021-06-actionable-errors

Make errors actionable when failing to deserialize a ChannelManager

3 years agoMerge pull request #954 from TheBlueMatt/2021-06-no-spurious-forward-fails
Matt Corallo [Thu, 1 Jul 2021 03:28:30 +0000 (03:28 +0000)]
Merge pull request #954 from TheBlueMatt/2021-06-no-spurious-forward-fails

Consider channels "live" even if they are awaiting a monitor update

3 years agoConsider channels "live" even if they are awaiting a monitor update 2021-06-no-spurious-forward-fails
Matt Corallo [Wed, 16 Jun 2021 22:57:38 +0000 (22:57 +0000)]
Consider channels "live" even if they are awaiting a monitor update

We use `Channel::is_live()` to gate inclusion of a channel in
`ChannelManager::list_usable_channels()` and when sending an
HTLC to select whether a channel is available for
forwarding through/sending to.

In both of these cases, we should consider a channel `is_live()` when
they are pending a monitor update. Some clients may update monitors
asynchronously, thus we may simply be waiting a short duration for a
monitor update to complete, and shouldn't fail all forwarding HTLCs
during that time.

After #851, we always ensure any holding cells are free'd when
sending P2P messages, making this change much more trivially
correct - instead of having to ensure that we always free the holding
cell when a channel becomes live again after adding something to the
holding cell, we can simply rely on the fact that it always happens.

Fixes #661.

3 years agoMerge pull request #972 from TheBlueMatt/2021-06-skip-notify-chansync
Matt Corallo [Wed, 30 Jun 2021 20:32:35 +0000 (20:32 +0000)]
Merge pull request #972 from TheBlueMatt/2021-06-skip-notify-chansync

Do not always persist ChannelManager on channel_update messages

3 years agoFix unused import in peer_handler introduced in 1f592b045fb6b2788c5 2021-06-skip-notify-chansync
Matt Corallo [Tue, 29 Jun 2021 23:44:31 +0000 (23:44 +0000)]
Fix unused import in peer_handler introduced in 1f592b045fb6b2788c5

3 years agoDo not always persist ChannelManager on channel_update messages
Matt Corallo [Mon, 28 Jun 2021 00:54:24 +0000 (00:54 +0000)]
Do not always persist ChannelManager on channel_update messages

If we receive a `channel_update` message for a channel unrelated to
our own, we shouldn't trigger a persistence of our
`ChannelManager`. This avoids significant persistence traffic during
initial node startup.

3 years agoCorrect test log printing due to inverted comparison 2021-06-actionable-errors
Matt Corallo [Wed, 30 Jun 2021 02:19:28 +0000 (02:19 +0000)]
Correct test log printing due to inverted comparison

We changed the sort order of log levels to be more natural, but this
comparison wasn't updated accordingly. Likely the reason it was
left strange for so long is it also had the comparison argument
ordering flipped.

3 years agoMake errors actionable when failing to deserialize a ChannelManager
Matt Corallo [Wed, 30 Jun 2021 00:38:49 +0000 (00:38 +0000)]
Make errors actionable when failing to deserialize a ChannelManager

3 years agoMerge pull request #973 from TheBlueMatt/2021-06-fix-broken-event-ser
Matt Corallo [Wed, 30 Jun 2021 01:19:30 +0000 (01:19 +0000)]
Merge pull request #973 from TheBlueMatt/2021-06-fix-broken-event-ser

Fix bogus `Event::PaymentSent` serialization

3 years agoClean up check_spendable_outputs!() test macro somewhat
Matt Corallo [Fri, 25 Jun 2021 03:45:52 +0000 (03:45 +0000)]
Clean up check_spendable_outputs!() test macro somewhat

3 years agoMerge pull request #965 from TheBlueMatt/2021-06-log-cleanups
Matt Corallo [Tue, 29 Jun 2021 20:13:50 +0000 (20:13 +0000)]
Merge pull request #965 from TheBlueMatt/2021-06-log-cleanups

Cleanup logging

3 years agoAdd debug log when we stop tracking confirmed on-chain packages 2021-06-log-cleanups
Matt Corallo [Sun, 27 Jun 2021 22:02:15 +0000 (22:02 +0000)]
Add debug log when we stop tracking confirmed on-chain packages

3 years agoCorrect inbound HTLC upgrade logs on revoke_and_ack receipt
Matt Corallo [Sun, 27 Jun 2021 03:20:36 +0000 (03:20 +0000)]
Correct inbound HTLC upgrade logs on revoke_and_ack receipt

3 years agoIncrease the log level of several channelmonitor/onchain logs.
Matt Corallo [Wed, 23 Jun 2021 03:32:32 +0000 (03:32 +0000)]
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.

3 years agoAdd additional TRACE-level logging during pathfinding in router
Matt Corallo [Wed, 23 Jun 2021 03:24:31 +0000 (03:24 +0000)]
Add additional TRACE-level logging during pathfinding in router

3 years agoUpdate logging in channel and channelmanager to better levels
Matt Corallo [Tue, 22 Jun 2021 03:35:52 +0000 (03:35 +0000)]
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.

3 years agoDo not log_debug when we receive duplicate gossip messages
Matt Corallo [Tue, 22 Jun 2021 01:33:44 +0000 (01:33 +0000)]
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.

3 years agoAllow logging to specify an explicit log level instead of a macro
Matt Corallo [Mon, 28 Jun 2021 20:38:48 +0000 (20:38 +0000)]
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.

3 years agoMore consistently log in msg handling, incl full msg logging at trace
Matt Corallo [Tue, 22 Jun 2021 03:36:36 +0000 (03:36 +0000)]
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.

3 years agoUnify message sending to use PeerManager::enqueue_message
Matt Corallo [Tue, 22 Jun 2021 01:30:19 +0000 (01:30 +0000)]
Unify message sending to use PeerManager::enqueue_message

This makes our logging consistent and somewhat simplifies message
sending code in a few places.

3 years agoAdd error logs when a ChannelManager as inconsistent monitor state
Matt Corallo [Mon, 21 Jun 2021 18:03:19 +0000 (18:03 +0000)]
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.

3 years agoMerge pull request #974 from sr-gi/message_signing_borrow
Matt Corallo [Tue, 29 Jun 2021 16:29:08 +0000 (16:29 +0000)]
Merge pull request #974 from sr-gi/message_signing_borrow

Passes references to the public and secret keys to sign/verify

3 years agoMerge pull request #966 from TheBlueMatt/2021-06-workaround-broken-lnd
Matt Corallo [Tue, 29 Jun 2021 16:28:38 +0000 (16:28 +0000)]
Merge pull request #966 from TheBlueMatt/2021-06-workaround-broken-lnd

Workaround lnd sending funding_locked before channel_reestablish

3 years agoPasses references to the public and secret keys to sign/verify
Sergi Delgado Segura [Tue, 29 Jun 2021 13:26:21 +0000 (15:26 +0200)]
Passes references to the public and secret keys to sign/verify

sign/verify should not take ownership of the keys.

3 years agoFix bogus `Event::PaymentSent` serialization 2021-06-fix-broken-event-ser
Matt Corallo [Mon, 28 Jun 2021 23:31:29 +0000 (23:31 +0000)]
Fix bogus `Event::PaymentSent` serialization

`Event::PaymentSent` serialization has a bug where we
double-serialize the payment_preimage field but do not attempt to
read it twice. This results in a failure to read `ChannelManager`s
from disk if we have a pending `Event::PaymentSent` pending
awaiting handling when we serialize.

Instead of attempting to read both versions, we opt to simply fix
the serialization, assuming it is exceedingly rare for such a
scenario to appear (and if it does, we can assist in manual
recovery).

The release notes have been updated to note this inconsistency.

Found by the chanmon_consistency fuzz target.

3 years agoWorkaround lnd sending funding_locked before channel_reestablish 2021-06-workaround-broken-lnd
Matt Corallo [Wed, 23 Jun 2021 16:39:27 +0000 (16:39 +0000)]
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

3 years agoMerge pull request #968 from TheBlueMatt/2021-06-no-invoice-dylib
Matt Corallo [Fri, 25 Jun 2021 17:42:40 +0000 (17:42 +0000)]
Merge pull request #968 from TheBlueMatt/2021-06-no-invoice-dylib

Drop the cdylib export of lightning-invoice

3 years agoMerge pull request #964 from valentinewallace/2021-06-tlv-ser
Matt Corallo [Thu, 24 Jun 2021 22:44:41 +0000 (22:44 +0000)]
Merge pull request #964 from valentinewallace/2021-06-tlv-ser

Fix TLV serialization to work with large types

3 years agoFix TLV serialization to work with large types.
Valentine Wallace [Tue, 22 Jun 2021 20:50:18 +0000 (16:50 -0400)]
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").

3 years agoDrop the cdylib export of lightning-invoice 2021-06-no-invoice-dylib
Matt Corallo [Thu, 24 Jun 2021 04:31:33 +0000 (04:31 +0000)]
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.

3 years agoMerge pull request #950 from TheBlueMatt/2021-06-changelog
Matt Corallo [Wed, 23 Jun 2021 17:22:11 +0000 (17:22 +0000)]
Merge pull request #950 from TheBlueMatt/2021-06-changelog

Add a dummy first CHANGELOG entry for future tracking

3 years agoAdd a dummy first CHANGELOG entry for future tracking 2021-06-changelog
Matt Corallo [Sat, 12 Jun 2021 22:59:14 +0000 (22:59 +0000)]
Add a dummy first CHANGELOG entry for future tracking

3 years agoDo not generate error messages when we receive our own gossip
Matt Corallo [Mon, 21 Jun 2021 17:36:46 +0000 (17:36 +0000)]
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.

3 years agoDrop rust-bitcoin crate patches in fuzz now that they're merged
Matt Corallo [Mon, 21 Jun 2021 16:00:27 +0000 (16:00 +0000)]
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.

3 years agolog_debug information about network graph updates from payments
Matt Corallo [Fri, 18 Jun 2021 20:21:58 +0000 (20:21 +0000)]
log_debug information about network graph updates from payments

3 years agoDon't print file paths in fuzz logger as they can be very long
Matt Corallo [Fri, 18 Jun 2021 20:21:42 +0000 (20:21 +0000)]
Don't print file paths in fuzz logger as they can be very long

3 years agoMerge pull request #957 from TheBlueMatt/2021-06-p2p-no-deadlock
Matt Corallo [Wed, 23 Jun 2021 01:34:55 +0000 (01:34 +0000)]
Merge pull request #957 from TheBlueMatt/2021-06-p2p-no-deadlock

Fix P2P Deadlocks

3 years agoClean up docs on peer_handler significantly. 2021-06-p2p-no-deadlock
Matt Corallo [Thu, 17 Jun 2021 22:54:46 +0000 (22:54 +0000)]
Clean up docs on peer_handler significantly.

There are various typo and grammatical fixes here, as well as
concrete updates to correctness.

3 years agoNo longer block disconnect_socket calls in lightning-net-tokio
Matt Corallo [Thu, 17 Jun 2021 22:54:06 +0000 (22:54 +0000)]
No longer block disconnect_socket calls in lightning-net-tokio

See the previous commit for more information.

3 years agoDo not require that no calls are made post-disconnect_socket
Matt Corallo [Thu, 17 Jun 2021 22:30:09 +0000 (22:30 +0000)]
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).

3 years agoMerge pull request #948 from TheBlueMatt/2021-06-p2p-fixes
Matt Corallo [Mon, 21 Jun 2021 20:23:39 +0000 (20:23 +0000)]
Merge pull request #948 from TheBlueMatt/2021-06-p2p-fixes

Clean up message forwarding and relay gossip messages

3 years ago[peer_handler] Drop unused return from get_peer_for_forwarding!() 2021-06-p2p-fixes
Matt Corallo [Mon, 21 Jun 2021 18:48:51 +0000 (18:48 +0000)]
[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.

3 years agoSomewhat simplify message handling error mapping in peer_handler
Matt Corallo [Thu, 17 Jun 2021 15:31:05 +0000 (15:31 +0000)]
Somewhat simplify message handling error mapping in peer_handler

3 years agoDrop peers_needing_send tracking and try to write for each peer
Matt Corallo [Thu, 10 Jun 2021 18:46:24 +0000 (18:46 +0000)]
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.

3 years agoSkip forwarding gossip messages to peers if their buffer is over-full
Matt Corallo [Thu, 10 Jun 2021 18:26:57 +0000 (18:26 +0000)]
Skip forwarding gossip messages to peers if their buffer is over-full

3 years agoForward gossip msgs
Matt Corallo [Thu, 10 Jun 2021 18:20:16 +0000 (18:20 +0000)]
Forward gossip msgs

3 years agoRefactor message broadcasting out into a utility method
Matt Corallo [Thu, 10 Jun 2021 18:48:59 +0000 (18:48 +0000)]
Refactor message broadcasting out into a utility method

This will allow us to broadcast messages received in the next
commit.

3 years agoFix bogus reentrancy from read_event -> do_attempt_write_data
Matt Corallo [Wed, 16 Jun 2021 18:57:21 +0000 (18:57 +0000)]
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.

3 years agoDrop unused "peer gone" handling in get_peer_for_forwarding!()
Matt Corallo [Thu, 10 Jun 2021 16:26:33 +0000 (16:26 +0000)]
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`.

3 years agoMerge pull request #947 from GeneFerneau/hash
Matt Corallo [Sun, 20 Jun 2021 02:20:19 +0000 (02:20 +0000)]
Merge pull request #947 from GeneFerneau/hash

Use hashbrown replacements for std equivalents

3 years agoUse hashbrown replacements for std equivalents
Gene Ferneau [Thu, 27 May 2021 04:04:20 +0000 (04:04 +0000)]
Use hashbrown replacements for std equivalents

3 years agoMerge pull request #956 from jkczyz/2021-06-validate-pub
Matt Corallo [Fri, 18 Jun 2021 18:06:45 +0000 (18:06 +0000)]
Merge pull request #956 from jkczyz/2021-06-validate-pub

Increase poll::Validate visibility to pub

3 years agoMerge pull request #955 from TheBlueMatt/2021-06-rustc-bugz
Matt Corallo [Fri, 18 Jun 2021 15:24:21 +0000 (15:24 +0000)]
Merge pull request #955 from TheBlueMatt/2021-06-rustc-bugz

Fix trivial doc warnings and make CI use old rustc

3 years agoRemove unnecessary spaces
Jeffrey Czyz [Thu, 17 Jun 2021 18:55:11 +0000 (13:55 -0500)]
Remove unnecessary spaces

3 years agoIncrease poll::Validate visibility to pub
Jeffrey Czyz [Thu, 17 Jun 2021 18:40:52 +0000 (13:40 -0500)]
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.

3 years agoClarify invoice comment noting the relevant final-cltv-expiry vals 2021-06-rustc-bugz
Matt Corallo [Thu, 17 Jun 2021 20:15:39 +0000 (20:15 +0000)]
Clarify invoice comment noting the relevant final-cltv-expiry vals

3 years agoMake links in message signing docs rustdoc links
Matt Corallo [Thu, 17 Jun 2021 15:49:17 +0000 (15:49 +0000)]
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.

3 years agoExpose doc-linked constants in lightning-invoice
Matt Corallo [Thu, 17 Jun 2021 15:48:20 +0000 (15:48 +0000)]
Expose doc-linked constants in lightning-invoice

These constants are generally useful, and are linked from
documentation, so should be exposed in any case.

3 years agoOnly check docs on rustc 1.52 as rustc stable now crashes
Matt Corallo [Thu, 17 Jun 2021 15:41:16 +0000 (15:41 +0000)]
Only check docs on rustc 1.52 as rustc stable now crashes

3 years agoMerge pull request #944 from TheBlueMatt/2021-06-0.0.99 v0.0.98
Matt Corallo [Fri, 11 Jun 2021 17:02:11 +0000 (17:02 +0000)]
Merge pull request #944 from TheBlueMatt/2021-06-0.0.99

0.0.98

3 years agoMerge pull request #946 from jkczyz/2021-06-get-route-interface
Matt Corallo [Fri, 11 Jun 2021 16:51:48 +0000 (16:51 +0000)]
Merge pull request #946 from jkczyz/2021-06-get-route-interface

Align get_route's interface with ChannelManager and Invoice

3 years agoFix type name in docs
Jeffrey Czyz [Thu, 10 Jun 2021 02:25:40 +0000 (19:25 -0700)]
Fix type name in docs

3 years agoAccept multi-hop route hints in get_route
Jeffrey Czyz [Thu, 10 Jun 2021 22:49:14 +0000 (15:49 -0700)]
Accept multi-hop route hints in get_route

Lightning invoices allow for zero or more multi-hop route hints. Update
get_route's interface to accept such hints, although only the last hop
from each is used for the time being.

Moves RouteHint from lightning-invoice crate to lightning crate. Adds a
PrivateRoute wrapper around RouteHint for use in lightning-invoice.

3 years agoAdd find_all_extract macro to lightning-invoice
Jeffrey Czyz [Thu, 10 Jun 2021 19:29:55 +0000 (12:29 -0700)]
Add find_all_extract macro to lightning-invoice

Used for extracting more than one field of the same type.

3 years agoBump versions to 0.0.98, lightning-invoice to 0.6.0 2021-06-0.0.99
Matt Corallo [Tue, 8 Jun 2021 21:07:38 +0000 (21:07 +0000)]
Bump versions to 0.0.98, lightning-invoice to 0.6.0

3 years agoMerge pull request #940 from TheBlueMatt/2021-06-fix-docs
Matt Corallo [Tue, 8 Jun 2021 02:28:46 +0000 (02:28 +0000)]
Merge pull request #940 from TheBlueMatt/2021-06-fix-docs

Clean up docs on public chan_utils methods to be more useful

3 years agoMerge pull request #936 from TheBlueMatt/2021-05-spendable-event-locktime-delay
Matt Corallo [Tue, 8 Jun 2021 01:53:03 +0000 (01:53 +0000)]
Merge pull request #936 from TheBlueMatt/2021-05-spendable-event-locktime-delay

Delay DelayedPaymentOutput spendable events until the CSV delay

3 years agoMerge pull request #943 from lightning-signer/2021-06-signet
Matt Corallo [Tue, 8 Jun 2021 01:52:38 +0000 (01:52 +0000)]
Merge pull request #943 from lightning-signer/2021-06-signet

Add proper signet support for invoices

3 years agoClean up docs on public chan_utils methods to be more useful 2021-06-fix-docs
Matt Corallo [Mon, 7 Jun 2021 01:41:51 +0000 (01:41 +0000)]
Clean up docs on public chan_utils methods to be more useful

3 years agoMerge pull request #939 from TheBlueMatt/2021-05-derives
Matt Corallo [Tue, 8 Jun 2021 01:51:41 +0000 (01:51 +0000)]
Merge pull request #939 from TheBlueMatt/2021-05-derives

Add additional derives for a few structs

3 years agoMerge pull request #942 from lightning-signer/2021-06-accept-channel-reserve-dust
Matt Corallo [Mon, 7 Jun 2021 22:03:11 +0000 (22:03 +0000)]
Merge pull request #942 from lightning-signer/2021-06-accept-channel-reserve-dust

Remove unwanted check in accept_channel

3 years agoAdd proper signet support for invoices
Devrandom [Mon, 7 Jun 2021 14:29:39 +0000 (16:29 +0200)]
Add proper signet support for invoices

3 years agoRemove unwanted check in accept_channel
Devrandom [Mon, 7 Jun 2021 14:22:07 +0000 (16:22 +0200)]
Remove unwanted check in accept_channel

This caused an interoperability issue with lnd, because they can propose a reserve lower than their dust limit (but not lower than ours).

3 years agoAdd additional derives for a few structs 2021-05-derives
Matt Corallo [Wed, 2 Jun 2021 16:20:31 +0000 (16:20 +0000)]
Add additional derives for a few structs

3 years agoDelay DelayedPaymentOutput spendable events until the CSV delay 2021-05-spendable-event-locktime-delay
Matt Corallo [Mon, 31 May 2021 20:04:36 +0000 (20:04 +0000)]
Delay DelayedPaymentOutput spendable events until the CSV delay

3 years agoMerge pull request #935 from TheBlueMatt/2021-05-enum-tlvs
Matt Corallo [Tue, 1 Jun 2021 21:53:15 +0000 (21:53 +0000)]
Merge pull request #935 from TheBlueMatt/2021-05-enum-tlvs

TLV-ize enum serialization and a few additional structs

3 years agoUpdate network graph sample used in benchmarks
Matt Corallo [Tue, 1 Jun 2021 02:02:40 +0000 (02:02 +0000)]
Update network graph sample used in benchmarks