]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
8 months agopub(crate) visibility for routing/test_utils.rs
Jeffrey Czyz [Tue, 19 Mar 2024 21:07:20 +0000 (16:07 -0500)]
pub(crate) visibility for routing/test_utils.rs

Give pub(crate) visibility to some routing test utilities to facilitate
testing DefaultMessageRouter in functional tests.

8 months agoFix sender is the introduction node onion messages
Jeffrey Czyz [Tue, 19 Mar 2024 21:04:43 +0000 (16:04 -0500)]
Fix sender is the introduction node onion messages

DefaultMessageRouter will form an OnionMessagePath from a BlindedPath
where the sender is the introduction node but only if the sender is
announced. If the sender is unannounced, then DefaultMessageRouter will
fail. While DefaultMessageRouter will only create a blinded path with an
announced introduction node, it may receive one where the introduction
node is unannounced. Don't return an error in this case, as the
OnionMessenger can advance the blinded path by one hop.

This may occur when two nodes have an unannounced channel and one (the
offer creator) wants to use it for payments without an intermediary node
and without putting its node id in the offer.

8 months agoInclude SocketAddress in test node_announcement
Jeffrey Czyz [Tue, 19 Mar 2024 19:20:55 +0000 (14:20 -0500)]
Include SocketAddress in test node_announcement

8 months agoRe-order imports
Jeffrey Czyz [Tue, 19 Mar 2024 19:19:59 +0000 (14:19 -0500)]
Re-order imports

8 months agoMerge pull request #2903 from jkczyz/2024-02-bindings-builders
valentinewallace [Fri, 8 Mar 2024 21:07:10 +0000 (16:07 -0500)]
Merge pull request #2903 from jkczyz/2024-02-bindings-builders

Offers builders for C-bindings

8 months agoMerge pull request #2926 from tnull/2024-03-derive-eq-for-offer-refund
Matt Corallo [Fri, 8 Mar 2024 17:34:37 +0000 (17:34 +0000)]
Merge pull request #2926 from tnull/2024-03-derive-eq-for-offer-refund

Impl `PartialEq`/`Eq` for `Offer`/`Refund`

8 months agoDrop error type parameter from SignError
Jeffrey Czyz [Thu, 7 Mar 2024 22:59:09 +0000 (16:59 -0600)]
Drop error type parameter from SignError

SignError allows implementors of SignFunction to return a custom error
type. Drop this as an unconstrained type causes problems with bindings
and isn't useful unless the caller can take some sort of action based on
different errors.

8 months agoFix unused import warning
Jeffrey Czyz [Fri, 1 Mar 2024 16:27:54 +0000 (10:27 -0600)]
Fix unused import warning

8 months agoSupport BOLT 12 signing in c_bindings
Jeffrey Czyz [Fri, 1 Mar 2024 16:17:08 +0000 (10:17 -0600)]
Support BOLT 12 signing in c_bindings

Replace the Fn trait bound on signing methods with a dedicated trait
since Fn is not supported in bindings. Implement the trait for Fn so
that closures can still be used in Rust.

8 months agoAdd c_bindings version of InvoiceBuilder
Jeffrey Czyz [Mon, 26 Feb 2024 02:42:57 +0000 (20:42 -0600)]
Add c_bindings version of InvoiceBuilder

Use the macros introduced in the previous commit to define two builders
for each type parameterization of InvoiceBuilder
- InvoiceWithExplicitSigningPubkeyBuilder
- InvoiceWithDerivedSigningPubkeyBuilder

The difference between these and InvoiceBuilder is that these have
methods that take `self` by mutable reference instead of by value and
don't return anything instead returning the modified builder. This is
required because bindings don't support move semantics nor impl blocks
specific to a certain type parameterization. Because of this, the
builder's contents must be cloned when building a Bolt12Invoice.

Keeps InvoiceBuilder defined so that it can be used internally in
ChannelManager's OffersMessageHandler even when compiled for c_bindings.

8 months agoImplement `Hash` for `Offer` and `Refund`
Elias Rohrer [Fri, 8 Mar 2024 15:43:45 +0000 (16:43 +0100)]
Implement `Hash` for `Offer` and `Refund`

8 months agoImpl `PartialEq`/`Eq` for `Offer`/`Refund`
Elias Rohrer [Fri, 8 Mar 2024 09:24:50 +0000 (10:24 +0100)]
Impl `PartialEq`/`Eq` for `Offer`/`Refund`

We add custom implementations based on comparing the `bytes` for
`Offer`/`Refund` themselves as this is sufficient and should be faster
than comapring all fields in the worst case.

8 months agoMerge pull request #2923 from tnull/2024-03-improve-best-block
Matt Corallo [Thu, 7 Mar 2024 17:55:59 +0000 (17:55 +0000)]
Merge pull request #2923 from tnull/2024-03-improve-best-block

Refactor `BestBlock` to expose inner fields

8 months agoImplement `Hash` for `BestBlock`
Elias Rohrer [Thu, 7 Mar 2024 16:35:38 +0000 (17:35 +0100)]
Implement `Hash` for `BestBlock`

8 months agoMerge pull request #2912 from jkczyz/2024-02-prefer-more-connections
Elias Rohrer [Thu, 7 Mar 2024 11:06:42 +0000 (12:06 +0100)]
Merge pull request #2912 from jkczyz/2024-02-prefer-more-connections

Order blinded paths by reliability criteria

8 months agoImplement `Debug` for `BestBlock`
Elias Rohrer [Thu, 7 Mar 2024 08:45:45 +0000 (09:45 +0100)]
Implement `Debug` for `BestBlock`

8 months agoRefactor `BestBlock` to expose inner fields rather than accessors
Elias Rohrer [Thu, 7 Mar 2024 08:44:45 +0000 (09:44 +0100)]
Refactor `BestBlock` to expose inner fields rather than accessors

.. which is more idiomatic Rust, and easier to handle in (downstream)
bindings.

8 months agoMacro-ize InvoiceBuilder
Jeffrey Czyz [Sun, 25 Feb 2024 20:58:07 +0000 (14:58 -0600)]
Macro-ize InvoiceBuilder

InvoiceBuilder is not exported to bindings because it has methods that
take `self` by value and are only implemented for certain type
parameterizations. Define these methods using macros such that different
builders and related methods can be defined for c_bindings.

8 months agoMerge similar InvoiceBuilder impl blocks
Jeffrey Czyz [Sun, 25 Feb 2024 17:32:02 +0000 (11:32 -0600)]
Merge similar InvoiceBuilder impl blocks

This avoids needing to create additional macros when adding c_bindings
support.

8 months agoAdd c_bindings version of InvoiceRequestBuilder
Jeffrey Czyz [Fri, 23 Feb 2024 19:34:24 +0000 (13:34 -0600)]
Add c_bindings version of InvoiceRequestBuilder

Use the macros introduced in the previous commit to define two builders
for each type parameterization of InvoiceRequestBuilder
- InvoiceRequestWithExplicitPayerIdBuilder
- InvoiceRequestWithDerivedPayerIdBuilder

The difference between these and InvoiceRequestBuilder is that these
have methods that take `self` by mutable reference instead of by value
and don't return anything instead returning the modified builder. This
is required because bindings don't support move semantics nor impl
blocks specific to a certain type parameterization. Because of this, the
builder's contents must be cloned when building an InvoiceRequest.

Keeps InvoiceRequestBuilder defined so that it can be used internally in
ChannelManager::pay_for_offer even when compiled for c_bindings.

8 months agoMacro-ize InvoiceRequestBuilder
Jeffrey Czyz [Thu, 22 Feb 2024 22:47:38 +0000 (16:47 -0600)]
Macro-ize InvoiceRequestBuilder

InvoiceRequestBuilder is not exported to bindings because it has methods
that take `self` by value and are only implemented for certain type
parameterizations. Define these methods using macros such that different
builders and related methods can be defined for c_bindings.

8 months agoMerge similar InvoiceRequestBuilder impl blocks
Jeffrey Czyz [Thu, 22 Feb 2024 21:13:32 +0000 (15:13 -0600)]
Merge similar InvoiceRequestBuilder impl blocks

This avoids needing to create additional macros when adding c_bindings
support.

8 months agoAdd c_bindings version of RefundBuilder
Jeffrey Czyz [Sat, 24 Feb 2024 02:30:50 +0000 (20:30 -0600)]
Add c_bindings version of RefundBuilder

Use the macros introduced in the previous commit to define a builder
called RefundMaybeWithDerivedMetadataBuilder.

The difference between this and RefundBuilder is that this has methods
that take `self` by mutable reference instead of by value and don't
return anything instead returning the modified builder. This is required
because bindings don't support move semantics. Because of this, the
builder's contents must be cloned when building a Refund.

Keeps RefundBuilder defined so that it can be used internally in
ChannelManager::create_refund_builder even when compiled for c_bindings.

8 months agoMacro-ize RefundBuilder
Jeffrey Czyz [Fri, 23 Feb 2024 22:52:49 +0000 (16:52 -0600)]
Macro-ize RefundBuilder

RefundBuilder is not exported to bindings because it has methods that
take `self` by value. Define these methods using macros such that
different builders and related methods can be defined for c_bindings.

8 months agoAdd c_bindings version of OfferBuilder
Jeffrey Czyz [Fri, 23 Feb 2024 22:33:23 +0000 (16:33 -0600)]
Add c_bindings version of OfferBuilder

Use the macros introduced in the previous commit to define two builders
for each type parameterization of OfferBuilder
- OfferWithExplicitMetadataBuilder
- OfferWithDerivedMetadataBuilder

The difference between these and OfferBuilder is that these have methods
that take `self` by mutable reference instead of by value and don't
return anything instead returning the modified builder. This is required
because bindings don't support move semantics nor impl blocks specific
to a certain type parameterization. Because of this, the builder's
contents must be cloned when building an Offer.

Keeps OfferBuilder defined so that it can be used internally in
ChannelManager::create_offer_builder even when compiled for c_bindings.

8 months agoMerge pull request #2919 from tnull/2024-03-fix-hashtables-rustfmt
Matt Corallo [Mon, 4 Mar 2024 16:30:29 +0000 (16:30 +0000)]
Merge pull request #2919 from tnull/2024-03-fix-hashtables-rustfmt

`rustfmt`: Fix CI by running `rustfmt` on `util/hash_tables.rs`

8 months agoRun `rustfmt` on `util/hash_tables.rs`
Elias Rohrer [Fri, 23 Feb 2024 10:51:50 +0000 (11:51 +0100)]
Run `rustfmt` on `util/hash_tables.rs`

.. to fix the silent rebase conflict.

8 months agoMerge pull request #2918 from tnull/2024-03-prefer-from-over-into
Matt Corallo [Fri, 1 Mar 2024 21:01:32 +0000 (21:01 +0000)]
Merge pull request #2918 from tnull/2024-03-prefer-from-over-into

8 months agoPrefer implementing `From` over `Into`
Elias Rohrer [Fri, 1 Mar 2024 10:42:54 +0000 (11:42 +0100)]
Prefer implementing `From` over `Into`

.. as the std library docs state that implementing Into should be avoided:
"One should avoid implementing Into and implement From instead.
Implementing From automatically provides one with an implementation of
Into thanks to the blanket implementation in the standard library."

8 months agoMerge pull request #2916 from sr-gi/2024-02-29-payment-preimage-hash
Matt Corallo [Thu, 29 Feb 2024 21:48:40 +0000 (21:48 +0000)]
Merge pull request #2916 from sr-gi/2024-02-29-payment-preimage-hash

util: Adds Into<PaymentHash> for PaymentPreimage

8 months agoutil: Adds Into<PaymentHash> for PaymentPreimage
Sergi Delgado Segura [Thu, 29 Feb 2024 19:51:38 +0000 (14:51 -0500)]
util: Adds Into<PaymentHash> for PaymentPreimage

This seems like a useful interface to have for downstream users

8 months agoMerge pull request #2915 from TheBlueMatt/2024-02-better-rnf-docs
Elias Rohrer [Thu, 29 Feb 2024 14:58:56 +0000 (15:58 +0100)]
Merge pull request #2915 from TheBlueMatt/2024-02-better-rnf-docs

Update docs on `PaymentFailureReason::RouteNotFound` to add context

8 months agoUpdate docs on `PaymentFailureReason::RouteNotFound` to add context 2024-02-better-rnf-docs
Matt Corallo [Thu, 29 Feb 2024 14:50:26 +0000 (14:50 +0000)]
Update docs on `PaymentFailureReason::RouteNotFound` to add context

tnull noted on discord that its somewhat unclear to users what
`RouteNotFound` actually means - that we ran out of routes, rather
than could not find a route at all - so the docs are updated here.

8 months agoMerge pull request #2913 from arik-so/2024/02/serialize-socket-address-vectors
Elias Rohrer [Thu, 29 Feb 2024 08:29:40 +0000 (09:29 +0100)]
Merge pull request #2913 from arik-so/2024/02/serialize-socket-address-vectors

Serialize SocketAddress vectors

8 months agoSerialize SocketAddress vectors.
Arik Sosman [Thu, 29 Feb 2024 07:21:53 +0000 (23:21 -0800)]
Serialize SocketAddress vectors.

8 months agoPrefer one-hop blinded path to Tor intro nodes
Jeffrey Czyz [Wed, 28 Feb 2024 21:58:14 +0000 (15:58 -0600)]
Prefer one-hop blinded path to Tor intro nodes

If a node is announced, prefer using a one-hop blinded path with it as
the introduction node to using a two-hop blinded path with a Tor-only
introduction node. The one-hop blinded path is more reliable, thus only
use Tor-only nodes if the recipient is unannounced. And then, prefer
non-Tor-only nodes.

8 months agoPrefer well-connected nodes for introduction nodes
Jeffrey Czyz [Wed, 28 Feb 2024 17:23:56 +0000 (11:23 -0600)]
Prefer well-connected nodes for introduction nodes

When forming blinded paths, using a reliable node as the introduction
node is important to ensure onion message reliability. Order blinded
paths by how well-connected the introduction node is as a proxy for
reliability.

For short paths (e.g., when the sender and recipient share an LSP), this
may also result in a scenario where initiating a direct connection isn't
necessary. That is helpful when using RGS since it currently doesn't
include node announcements and thus cannot initiate a direct connection.

8 months agoMerge pull request #2911 from jkczyz/2024-02-sort-blinded-paths
Elias Rohrer [Wed, 28 Feb 2024 11:01:55 +0000 (12:01 +0100)]
Merge pull request #2911 from jkczyz/2024-02-sort-blinded-paths

Prefer non-Tor nodes when creating blinded paths

8 months agoPrefer non-Tor nodes when creating blinded paths
Jeffrey Czyz [Wed, 28 Feb 2024 00:37:39 +0000 (18:37 -0600)]
Prefer non-Tor nodes when creating blinded paths

Tor nodes can have high latency which can have a detrimental effect on
onion message reliability. Prefer using nodes that aren't Tor-only when
creating blinded paths both in offers and in onion message reply paths.

8 months agoAdd NodeInfo::is_tor_only
Jeffrey Czyz [Tue, 27 Feb 2024 19:25:25 +0000 (13:25 -0600)]
Add NodeInfo::is_tor_only

Add a method to NodeInfo to determine if the node has only announced Tor
addresses. Useful for preferring blinded paths that don't use Tor for
better reliability and improved latency.

9 months agoMacro-ize OfferBuilder
Jeffrey Czyz [Tue, 20 Feb 2024 00:43:59 +0000 (18:43 -0600)]
Macro-ize OfferBuilder

OfferBuilder is not exported to bindings because it has methods that
take `self` by value and are only implemented for certain type
parameterizations. Define these methods using macros such that different
builders and related methods can be defined for c_bindings.

9 months agoMerge pull request #2909 from benthecarman/inv-pk-helper
Matt Corallo [Thu, 22 Feb 2024 19:32:02 +0000 (19:32 +0000)]
Merge pull request #2909 from benthecarman/inv-pk-helper

Add helper function to properly get invoice pubkey

9 months agoMerge pull request #2877 from tnull/2024-02-start-rustfmt-journey
Matt Corallo [Thu, 22 Feb 2024 19:30:17 +0000 (19:30 +0000)]
Merge pull request #2877 from tnull/2024-02-start-rustfmt-journey

`rustfmt`: Add CI scripts and format `onion_utils.rs`

9 months agoAdd helper function to properly get invoice pubkey
benthecarman [Thu, 22 Feb 2024 18:05:37 +0000 (18:05 +0000)]
Add helper function to properly get invoice pubkey

9 months agoMerge pull request #2908 from TheBlueMatt/2024-02-drop-useless-refs
Elias Rohrer [Thu, 22 Feb 2024 10:36:38 +0000 (11:36 +0100)]
Merge pull request #2908 from TheBlueMatt/2024-02-drop-useless-refs

Drop unnecessary int reference in SCID conversion utilities

9 months agoMerge pull request #2905 from tnull/2024-02-expose-init-features
Matt Corallo [Thu, 22 Feb 2024 00:06:30 +0000 (00:06 +0000)]
Merge pull request #2905 from tnull/2024-02-expose-init-features

Refactor `PeerManager::get_peer_node_ids` in favor of `list_peers`/`peer_by_node_id` returning additional information

9 months agoDrop unnecessary int reference in SCID conversion utilities 2024-02-drop-useless-refs
Matt Corallo [Wed, 21 Feb 2024 22:25:54 +0000 (22:25 +0000)]
Drop unnecessary int reference in SCID conversion utilities

9 months agoMerge pull request #2770 from dunxen/2023-12-dualfundingpreliminaries
Matt Corallo [Wed, 21 Feb 2024 21:09:26 +0000 (21:09 +0000)]
Merge pull request #2770 from dunxen/2023-12-dualfundingpreliminaries

Preliminary refactoring & structure for dual-funded channels

9 months agoIntroduce `PeerManager::list_peers` and `peer_by_node_id`
Elias Rohrer [Tue, 20 Feb 2024 12:36:45 +0000 (13:36 +0100)]
Introduce `PeerManager::list_peers` and `peer_by_node_id`

.. returning `PeerDetails` rather than tuples of peer-associated values.

Previously, we wouldn't offer any way to retrieve the features a
peer provided in their `Init` message.

Here, we allow to retrieve them via a new `PeerDetails` struct,
side-by-side with `SocketAddress`es and a bool indicating the direction
of the peer connection.

9 months agoMerge pull request #2898 from tnull/2024-02-ignore-RUSTSEC-2021-0145
Matt Corallo [Tue, 20 Feb 2024 17:42:18 +0000 (17:42 +0000)]
Merge pull request #2898 from tnull/2024-02-ignore-RUSTSEC-2021-0145

Have CI's `cargo audit` ignore `RUSTSEC-2021-0125`

9 months agoAdd V2 `ChannelPhase` variants
Duncan Dean [Wed, 13 Sep 2023 11:41:20 +0000 (13:41 +0200)]
Add V2 `ChannelPhase` variants

9 months agoAdd maybe_handle_error_without_close for OutboundV2Channel
Duncan Dean [Fri, 16 Feb 2024 06:01:16 +0000 (08:01 +0200)]
Add maybe_handle_error_without_close for OutboundV2Channel

9 months agoAdd `OutboundV2Channel` struct
Duncan Dean [Tue, 12 Sep 2023 19:27:14 +0000 (21:27 +0200)]
Add `OutboundV2Channel` struct

9 months agoCreate ChannelContext constructor for outbound channels
Duncan Dean [Fri, 24 Nov 2023 07:58:21 +0000 (09:58 +0200)]
Create ChannelContext constructor for outbound channels

9 months agoAdd `InboundV2Channel` struct
Duncan Dean [Tue, 12 Sep 2023 19:23:51 +0000 (21:23 +0200)]
Add `InboundV2Channel` struct

9 months agoCreate ChannelContext constructor for inbound channels
Duncan Dean [Fri, 24 Nov 2023 07:32:56 +0000 (09:32 +0200)]
Create ChannelContext constructor for inbound channels

9 months agoAdd `DualFundingChannelContext` struct
Duncan Dean [Tue, 12 Sep 2023 19:18:14 +0000 (21:18 +0200)]
Add `DualFundingChannelContext` struct

9 months agoTest builds with #[cfg(dual_funding)] enabled
Duncan Dean [Mon, 4 Dec 2023 07:22:14 +0000 (09:22 +0200)]
Test builds with #[cfg(dual_funding)] enabled

9 months agoAdd V2 constructors to `ChannelId`
Duncan Dean [Tue, 12 Sep 2023 08:52:50 +0000 (10:52 +0200)]
Add V2 constructors to `ChannelId`

9 months agoMerge pull request #2891 from TheBlueMatt/2024-02-no-ahash
Matt Corallo [Mon, 19 Feb 2024 22:17:35 +0000 (22:17 +0000)]
Merge pull request #2891 from TheBlueMatt/2024-02-no-ahash

Drop the `ahash` dependency

9 months agoHave CI's `cargo audit` ignore `RUSTSEC-2021-0125`
Elias Rohrer [Fri, 16 Feb 2024 10:33:37 +0000 (11:33 +0100)]
Have CI's `cargo audit` ignore `RUSTSEC-2021-0125`

This advisory is only relevant for a downstream dependency of
`criterion`, which we currently don't want to bump in order to continue
benchmarking with our MSRV 1.63.0.

We therefore just add it to our ignore list for now.

9 months agoMerge pull request #2897 from TheBlueMatt/2024-02-fix-route-ser
Matt Corallo [Fri, 16 Feb 2024 21:15:45 +0000 (21:15 +0000)]
Merge pull request #2897 from TheBlueMatt/2024-02-fix-route-ser

Fix `Route` serialization round-trip

9 months agoDrop `lightning-invoice` dependency on hashbrown` 2024-02-no-ahash
Matt Corallo [Tue, 13 Feb 2024 18:15:20 +0000 (18:15 +0000)]
Drop `lightning-invoice` dependency on hashbrown`

9 months agoDrop `ahash` dependency in favor of core's `SipHasher`
Matt Corallo [Mon, 12 Feb 2024 22:40:49 +0000 (22:40 +0000)]
Drop `ahash` dependency in favor of core's `SipHasher`

https://github.com/tkaitchuck/aHash/pull/196 bumped the MSRV of
`ahash` in a patch release, which makes it rather difficult for us
to have it as a dependency.

Further, it seems that `ahash` hasn't been particularly robust in
the past, notably
https://github.com/tkaitchuck/aHash/issues/163 and
https://github.com/tkaitchuck/aHash/issues/166.

Luckily, `core` provides `SipHasher` even on no-std (sadly its
SipHash-2-4 unlike the SipHash-1-3 used by the `DefaultHasher` in
`std`). Thus, we drop the `ahash` dependency entirely here and
simply wrap `SipHasher` for our `no-std` HashMaps.

9 months agoAdd a crate which wraps `getrandom` but always compiles
Matt Corallo [Mon, 12 Feb 2024 22:37:09 +0000 (22:37 +0000)]
Add a crate which wraps `getrandom` but always compiles

In the next commit we'll drop the `ahash` dependency in favor of
directly calling `getrandom` to seed our hash tables. However,
we'd like to depend on `getrandom` only on certain platforms *and*
only when certain features (no-std) are set.

This introduces an indirection crate to do so, allowing us to
depend on it only when `no-std` is set but only depending on
`getrandom` on platforms which it supports.

9 months agoTest `Route` serialization round-trip 2024-02-fix-route-ser
Matt Corallo [Fri, 16 Feb 2024 19:26:32 +0000 (19:26 +0000)]
Test `Route` serialization round-trip

This adds testing for the previous two commits by testing that all
routes generated in testing are able to survive a serialization
round-trip.

9 months agoFix `Route` serialization round-trip
Matt Corallo [Fri, 16 Feb 2024 19:26:22 +0000 (19:26 +0000)]
Fix `Route` serialization round-trip

When the `max_total_routing_fee_msat` parameter was added to
`RouteParameters`, the serialization used `map` to get the max fee,
accidentally writing an `Option<Option<u64>>`, but then read it as
an `Option<u64>`. Thus, any `Route`s with a `route_params` written
will fail to be read back.

Luckily, this is an incredibly rarely-used bit of code, so only one
user managed to hit it.

9 months agoFix blinded path serialization in `Route`
Matt Corallo [Fri, 16 Feb 2024 18:41:54 +0000 (18:41 +0000)]
Fix blinded path serialization in `Route`

`Route`'s blinded_path serialization logic writes a blinded path
`Option` per path hop, however on read we (correctly) only read one
blinded path `Option` per path. This causes serialization of
`Route`s with blinded paths to fail to round-trip.

Here we fix this by writing blinded paths per path.

9 months agoDrop the `fails_paying_for_bolt12_invoice` test
Matt Corallo [Fri, 16 Feb 2024 18:33:53 +0000 (18:33 +0000)]
Drop the `fails_paying_for_bolt12_invoice` test

`fails_paying_for_bolt12_invoice` tests that we fail to send a
payment if the router returns `Ok` but includes a bogus route (one
with 0-length paths). While this marginally increases our test
coverage, in the next commit we'll be testing that all routes
round-trip serialization, which fails here as bogus routes are not
supported in deserialization.

Because this isn't particularly critical test coverage, we simply
opt to drop the test entirely here.

9 months agoRemove `onion_utils.rs` from exclusion list
Elias Rohrer [Tue, 6 Feb 2024 15:22:04 +0000 (16:22 +0100)]
Remove `onion_utils.rs` from exclusion list

.. now continously checking its formatting in CI.

9 months agoRun `rustfmt` on `onion_utils.rs`
Elias Rohrer [Mon, 12 Feb 2024 13:14:53 +0000 (14:14 +0100)]
Run `rustfmt` on `onion_utils.rs`

9 months agoAdd `rustfmt::skip` and small adjustments where needed
Elias Rohrer [Tue, 6 Feb 2024 15:26:39 +0000 (16:26 +0100)]
Add `rustfmt::skip` and small adjustments where needed

9 months agoMerge pull request #2894 from TheBlueMatt/2024-02-future-poll-leak
Elias Rohrer [Fri, 16 Feb 2024 10:55:56 +0000 (11:55 +0100)]
Merge pull request #2894 from TheBlueMatt/2024-02-future-poll-leak

Never store more than one StdWaker per live Future

9 months agoNever store more than one `StdWaker` per live `Future` 2024-02-future-poll-leak
Matt Corallo [Tue, 13 Feb 2024 22:43:51 +0000 (22:43 +0000)]
Never store more than one `StdWaker` per live `Future`

When an `std::future::Future` is `poll()`ed, we're only supposed to
use the latest `Waker` provided. However, we currently push an
`StdWaker` onto our callback list every time `poll` is called,
waking every `Waker` but also using more and more memory until the
`Future` itself is woken.

Here we fix this by removing any `StdWaker`s stored for a given
`Future` when it is `drop`ped or prior to pushing a new `StdWaker`
onto the list when `poll`ed.

Sadly, the introduction of a `Drop` impl for `Future` means we
can't trivially destructure the struct any longer, causing a few
methods to need to take `Future`s by reference rather than
ownership and `clone` a few `Arc`s.

Fixes #2874

9 months agoGive `Future`s for a `FutureState` an idx and track `StdWaker` idxn
Matt Corallo [Tue, 13 Feb 2024 22:08:55 +0000 (22:08 +0000)]
Give `Future`s for a `FutureState` an idx and track `StdWaker` idxn

When an `std::future::Future` is `poll()`ed, we're only supposed to
use the latest `Waker` provided. However, we currently push an
`StdWaker` onto our callback list every time `poll` is called,
waking every `Waker` but also using more and more memory until the
`Future` itself is woken.

Here we take a step towards fixing this by giving each `Future` a
unique index and storing which `Future` an `StdWaker` came from in
the callback list. This sets us up to deduplicate `StdWaker`s by
`Future`s in the next commit.

9 months agoSplit lists of `Waker` and directly-registered `Future` callbacks
Matt Corallo [Tue, 13 Feb 2024 21:58:46 +0000 (21:58 +0000)]
Split lists of `Waker` and directly-registered `Future` callbacks

In the next commit we'll fix a memory leak due to keeping too many
`std::task::Waker` callbacks in `FutureState` from redundant `poll`
calls, but first we need to split handling of `StdWaker`-based
future wake callbacks from normal ones, which we do here.

9 months agoMerge pull request #2895 from TheBlueMatt/2024-02-logging-tweaks
Elias Rohrer [Wed, 14 Feb 2024 09:29:09 +0000 (10:29 +0100)]
Merge pull request #2895 from TheBlueMatt/2024-02-logging-tweaks

Minor Logging tweaks

9 months agoAdd `rustfmt` instructions to CONTRIBUTING.md
Elias Rohrer [Tue, 6 Feb 2024 18:16:54 +0000 (19:16 +0100)]
Add `rustfmt` instructions to CONTRIBUTING.md

9 months agoAdd `rustfmt` to CI, ignore all files
Elias Rohrer [Mon, 5 Feb 2024 14:44:08 +0000 (15:44 +0100)]
Add `rustfmt` to CI, ignore all files

We add the previously discussed `rustfmt.toml` and enforce it in CI for
any files that are not contained in an exclusion list.

To start, we add all current Rust files to this exclusion list. This
means that formatter rules will be enforced for any newly introduced
files, and we'll then start going through the codebase file-by-file,
removing them from the list as we go.

9 months agoMerge pull request #2883 from tnull/2024-02-dyn-kvstore-blanket-impls
Elias Rohrer [Wed, 14 Feb 2024 08:01:51 +0000 (09:01 +0100)]
Merge pull request #2883 from tnull/2024-02-dyn-kvstore-blanket-impls

Add blanket `Persist`/`Persister` impls for `dyn KVStore + Send + Sync`

9 months agoOpportunistically skip log in `update_claims_view_from_matched_txn` 2024-02-logging-tweaks
Matt Corallo [Tue, 13 Feb 2024 23:43:19 +0000 (23:43 +0000)]
Opportunistically skip log in `update_claims_view_from_matched_txn`

On each block, for each `ChannelMonitor`, we log two status
statements in `OnChainTx::update_claims_view_from_matched_txn`.
This can add up to quite a bit, and is generally not very
interesting when we don't actually do anything if there's no claims
to bump.

Here we drop both logs if we have no claims to work with, but
retain it if we process any claims.

9 months agoOpportunistically skip log in `update_claims_view_from_requests`
Matt Corallo [Tue, 13 Feb 2024 23:33:18 +0000 (23:33 +0000)]
Opportunistically skip log in `update_claims_view_from_requests`

On each block, for each `ChannelMonitor`, we log a status statement
in `OnChainTx::update_claims_view_from_requests`. This can add up
to quite a bit, and is generally not very interesting when we don't
actually do anything if there's no claims to bump.

Here we drop the log if we have no claims to work with, but retain
it if we process any claims.

9 months agoDrop some "Channel does not qualify for a feerate change" logs
Matt Corallo [Tue, 13 Feb 2024 23:00:38 +0000 (23:00 +0000)]
Drop some "Channel does not qualify for a feerate change" logs

On a high-traffic/channel node, `Channel .* does not qualify for a
feerate change.*` is our most common log, and it doesn't provide
much useful information. It's logged in two cases - (a) where the
estimator feerate is less than the current channel feerate but not
by more than half twice and (b) where we'd like to update the
channel feerate but the peer is disconnected or channel not
available for updates.

Because these conditions can persist and we log them once a minute
the volume of logs can add up quickly. Here we simply remove the
log in case (a), though leave (b) as its anticipated to be somewhat
quieter and does indicate a persistent issue that should be
addressed (possibly by closing the channel).

9 months agoMake peers sending gossip out of order logging less scary
Matt Corallo [Tue, 13 Feb 2024 22:57:18 +0000 (22:57 +0000)]
Make peers sending gossip out of order logging less scary

Multiple times we've had users wonder why they see `Error handling
message from.*; ignoring: Couldn't find channel for update` in
their logs and wonder if its related to their channel
force-closing. While this does indicate a peer is sending us gossip
our of order (and thus misbehaving), its not relevant to channel
operation and the logged message and level should indicate that.

Thus, here, we move the level to Gossip and add "gossip" between
"handling" and "message" (so it reads "Error handling gossip
message from.*").

Fixes #2471

9 months agoMerge pull request #2861 from tnull/2024-01-introduce-cargo-audit
Matt Corallo [Tue, 13 Feb 2024 21:35:51 +0000 (21:35 +0000)]
Merge pull request #2861 from tnull/2024-01-introduce-cargo-audit

Introduce CI workflow running `cargo audit`

9 months agoMerge pull request #2816 from wpaulino/retryable-holder-sigs
Matt Corallo [Tue, 13 Feb 2024 21:22:55 +0000 (21:22 +0000)]
Merge pull request #2816 from wpaulino/retryable-holder-sigs

Allow holder commitment and HTLC signature requests to fail

9 months agoMerge pull request #2892 from TheBlueMatt/2024-02-destination-eq
Elias Rohrer [Tue, 13 Feb 2024 08:21:04 +0000 (09:21 +0100)]
Merge pull request #2892 from TheBlueMatt/2024-02-destination-eq

Add further standard derives to various onion message structs

9 months agoIntroduce CI workflow running `cargo audit`
Elias Rohrer [Tue, 30 Jan 2024 11:41:05 +0000 (12:41 +0100)]
Introduce CI workflow running `cargo audit`

In order to continuously monitor our dependencies for security
vulnerabilities, we introduce a new CI job that will use `cargo audit`
to check for any known vulnerabilities.

This job is run on a daily schedule. For each new advisory, a new issue
will be created.

9 months agoAdd further standard derives to various onion message structs 2024-02-destination-eq
Matt Corallo [Mon, 12 Feb 2024 23:54:14 +0000 (23:54 +0000)]
Add further standard derives to various onion message structs

9 months agoMerge pull request #2888 from TheBlueMatt/2024-02-destination-eq
Elias Rohrer [Mon, 12 Feb 2024 12:29:15 +0000 (13:29 +0100)]
Merge pull request #2888 from TheBlueMatt/2024-02-destination-eq

Implement `Debug`/`PartialEq`/`Eq` for `Destination`

9 months agoDrop `reqwest` pin
Elias Rohrer [Thu, 1 Feb 2024 08:41:01 +0000 (09:41 +0100)]
Drop `reqwest` pin

.. since a version with fixed MSRV was released by now.

9 months agoMove `lightning-transaction-sync` to main workspace
Elias Rohrer [Thu, 1 Feb 2024 08:31:06 +0000 (09:31 +0100)]
Move `lightning-transaction-sync` to main workspace

.. so it's actually included in the audit.

9 months agoDisable `lightning-transaction-sync` integration tests on Windows
Elias Rohrer [Thu, 1 Feb 2024 08:57:05 +0000 (09:57 +0100)]
Disable `lightning-transaction-sync` integration tests on Windows

.. as the `electrsd` crate doesn't support it.

While we previously did so in our CI script, we now also `cfg`-gate the
tests and dependencies for easier handling.

9 months agoImplement `Debug`/`PartialEq`/`Eq` for `Destination`
Matt Corallo [Sat, 10 Feb 2024 02:27:59 +0000 (02:27 +0000)]
Implement `Debug`/`PartialEq`/`Eq` for `Destination`

9 months agoMerge pull request #2850 from TheBlueMatt/2024-01-fuzz-gossip
Matt Corallo [Fri, 9 Feb 2024 00:49:33 +0000 (00:49 +0000)]
Merge pull request #2850 from TheBlueMatt/2024-01-fuzz-gossip

9 months agoMerge pull request #2886 from TheBlueMatt/2024-02-actually-fix-build
Matt Corallo [Fri, 9 Feb 2024 00:08:28 +0000 (00:08 +0000)]
Merge pull request #2886 from TheBlueMatt/2024-02-actually-fix-build

 Fix silent merge conflict introduced in d3ddf15 @TheBlueMatt

9 months agoReplace spaces with tabs in msgs.rs 2024-02-actually-fix-build
Matt Corallo [Thu, 8 Feb 2024 23:03:44 +0000 (23:03 +0000)]
Replace spaces with tabs in msgs.rs

9 months agoFix silent merge conflict introduced in d3ddf15357589ed10f4c844dc22
Matt Corallo [Thu, 8 Feb 2024 23:04:19 +0000 (23:04 +0000)]
Fix silent merge conflict introduced in d3ddf15357589ed10f4c844dc22

9 months agoMerge pull request #2885 from benthecarman/tiny-opt
Matt Corallo [Thu, 8 Feb 2024 22:55:53 +0000 (22:55 +0000)]
Merge pull request #2885 from benthecarman/tiny-opt

Worlds smallest optimization

9 months agoWorlds smallest optimization
benthecarman [Thu, 8 Feb 2024 17:57:13 +0000 (17:57 +0000)]
Worlds smallest optimization

Preallocate for 8 items in the vec. I chose this value for

1. features
2. description
3. payment hash
4. expire time
5. min_final_cltv
6. payment secret
7. route hint
8. for the memes