Commit graph

6783 commits

Author SHA1 Message Date
Duncan Dean
c5f5b9224f
Add V2 constructors to ChannelId 2024-02-20 09:15:10 +02:00
Matt Corallo
cd847574f2
Merge pull request #2891 from TheBlueMatt/2024-02-no-ahash
Drop the `ahash` dependency
2024-02-19 22:17:35 +00:00
Matt Corallo
6fa1cb2ce8
Merge pull request #2897 from TheBlueMatt/2024-02-fix-route-ser
Fix `Route` serialization round-trip
2024-02-16 21:15:45 +00:00
Matt Corallo
eecd2cdf4f Drop lightning-invoice dependency on hashbrown` 2024-02-16 20:34:41 +00:00
Matt Corallo
3096061bef 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.
2024-02-16 20:34:41 +00:00
Matt Corallo
65108a022f 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.
2024-02-16 20:34:40 +00:00
Matt Corallo
24d02ff287 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.
2024-02-16 19:26:32 +00:00
Matt Corallo
4026d4efd1 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.
2024-02-16 19:26:22 +00:00
Matt Corallo
2ada7911b1 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.
2024-02-16 18:42:29 +00:00
Matt Corallo
f3067b84c6 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.
2024-02-16 18:42:29 +00:00
Elias Rohrer
e32020c449
Merge pull request #2894 from TheBlueMatt/2024-02-future-poll-leak
Never store more than one StdWaker per live Future
2024-02-16 11:55:56 +01:00
Matt Corallo
8157c01eab 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
2024-02-15 21:52:06 +00:00
Matt Corallo
5f404b9d0a Give Futures 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.
2024-02-15 21:52:06 +00:00
Matt Corallo
2c987209f9 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.
2024-02-15 21:52:06 +00:00
Elias Rohrer
3fd4b3963c
Merge pull request #2895 from TheBlueMatt/2024-02-logging-tweaks
Minor Logging tweaks
2024-02-14 10:29:09 +01:00
Elias Rohrer
3fd85c8cf8
Merge pull request #2883 from tnull/2024-02-dyn-kvstore-blanket-impls
Add blanket `Persist`/`Persister` impls for `dyn KVStore + Send + Sync`
2024-02-14 09:01:51 +01:00
Matt Corallo
89101531aa 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.
2024-02-13 23:43:19 +00:00
Matt Corallo
9125de22c5 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.
2024-02-13 23:43:02 +00:00
Matt Corallo
aab5b102e4 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).
2024-02-13 23:06:48 +00:00
Matt Corallo
96b141c503 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
2024-02-13 23:06:38 +00:00
Matt Corallo
73da722d18
Merge pull request #2861 from tnull/2024-01-introduce-cargo-audit
Introduce CI workflow running `cargo audit`
2024-02-13 21:35:51 +00:00
Matt Corallo
f98a652f11
Merge pull request #2816 from wpaulino/retryable-holder-sigs
Allow holder commitment and HTLC signature requests to fail
2024-02-13 21:22:55 +00:00
Elias Rohrer
0995de7fa8
Merge pull request #2892 from TheBlueMatt/2024-02-destination-eq
Add further standard derives to various onion message structs
2024-02-13 09:21:04 +01:00
Elias Rohrer
fd705c7919
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.
2024-02-13 09:16:57 +01:00
Matt Corallo
6f02025246 Add further standard derives to various onion message structs 2024-02-12 23:54:14 +00:00
Elias Rohrer
0c2a715c01
Merge pull request #2888 from TheBlueMatt/2024-02-destination-eq
Implement `Debug`/`PartialEq`/`Eq` for `Destination`
2024-02-12 13:29:15 +01:00
Elias Rohrer
7299fe62c3
Drop reqwest pin
.. since a version with fixed MSRV was released by now.
2024-02-12 10:42:10 +01:00
Elias Rohrer
9ac42ed394
Move lightning-transaction-sync to main workspace
.. so it's actually included in the audit.
2024-02-12 10:42:09 +01:00
Elias Rohrer
a386ba5314
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.
2024-02-12 10:42:07 +01:00
Matt Corallo
71c0d56415 Implement Debug/PartialEq/Eq for Destination 2024-02-10 02:27:59 +00:00
Matt Corallo
d70124cec4
Merge pull request #2850 from TheBlueMatt/2024-01-fuzz-gossip 2024-02-09 00:49:33 +00:00
Matt Corallo
81cc0d3d6c
Merge pull request #2886 from TheBlueMatt/2024-02-actually-fix-build
Fix silent merge conflict introduced in d3ddf15 @TheBlueMatt
2024-02-09 00:08:28 +00:00
Matt Corallo
ee34bcf2d6 Replace spaces with tabs in msgs.rs 2024-02-08 23:05:08 +00:00
Matt Corallo
5faca20934 Fix silent merge conflict introduced in d3ddf15357 2024-02-08 23:05:08 +00:00
Matt Corallo
aaacaf45e3
Merge pull request #2885 from benthecarman/tiny-opt
Worlds smallest optimization
2024-02-08 22:55:53 +00:00
benthecarman
0769b22f5c
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
2024-02-08 22:40:48 +00:00
Matt Corallo
c93b59e13d
Merge pull request #2871 from dunxen/2024-02-msgcommonfields
Combine common fields for OpenChannel and AcceptChannel V1 & V2
2024-02-08 21:50:27 +00:00
Wilmer Paulino
e38dccaef4
Allow holder commitment and HTLC signature requests to fail
As part of the ongoing async signer work, our holder signatures must
also be capable of being obtained asynchronously. We expose a new
`ChannelMonitor::signer_unblocked` method to retry pending onchain
claims by re-signing and rebroadcasting transactions. Unfortunately, we
cannot retry said claims without them being registered first, so if
we're not able to obtain the signature synchronously, we must return the
transaction as unsigned and ensure it is not broadcast.
2024-02-07 15:44:23 -08:00
Wilmer Paulino
043ab75bb4
Introduce FeerateStrategy enum for onchain claims
This refactors the existing `force_feerate_bump` flag into an enum as we
plan to introduce a new flag/enum variant in a future commit.
2024-02-07 15:42:28 -08:00
Wilmer Paulino
71b4bd0811
Rework get_latest_holder_commitment_txn to broadcast for users
This method is meant to be used as a last resort when a user is forced
to broadcast the current state, even if it is stale, in an attempt to
claim their funds in the channel. Previously, we'd return the commitment
and HTLC transactions such that they broadcast them themselves. Doing so
required a different code path, one which was not tested, to obtain
these transactions than our usual path when force closing. It's not
worth maintaining both, and it's much simpler for us to broadcast
instead.
2024-02-07 15:42:26 -08:00
Matt Corallo
e0323ec049
Merge pull request #2856 from valentinewallace/2024-01-blinded-payinfo-min-final-cltv
Route blinding: add `min_final_cltv_delta` to aggregated CLTV delta
2024-02-07 22:12:59 +00:00
Valentine Wallace
fff1aa7cb0
Add min_final_cltv_delta to aggregated CLTV delta.
The spec was previously missing this requirement.
2024-02-07 12:02:26 -05:00
Valentine Wallace
fa44185ba8
Parameterize BlindedPath::new_for_payment by min final CLTV delta.
Currently we are not including this value in the aggregated CLTV delta, which
is wrong.
2024-02-07 12:02:24 -05:00
Elias Rohrer
bf4c7292c6
Impl Sync and Send for TestStore 2024-02-07 12:56:06 +01:00
Elias Rohrer
a85d5b1444
Add blanket Persist/Persister impls for dyn KVStore + Send + Sync
Previously, we only had blanket impls for `KVStore`. However, in order
to enable the use of `dyn KVStore + Send + Sync` instead of a `KVStore`
generic, we here also add the corresponding blanket implementations for
said type signature.
2024-02-07 12:56:06 +01:00
Matt Corallo
7aa06d25f2 [fuzz] Add fst coverage for ChannelManager::update_channel_config 2024-02-07 02:32:52 +00:00
Matt Corallo
e63fc65ce0 [fuzz] Add a second full_stack_target seed test for gossip 2024-02-07 02:32:52 +00:00
Matt Corallo
207fbb0296 [fuzz] De-dup hex in test_no_existing_test_breakage
This will make test_no_existing_test_breakage marginally easier to
update.
2024-02-07 02:32:52 +00:00
Matt Corallo
a4cacee4b1 [fuzz] Add additional method calls in full_stack_target
The whole point of full_stack_target is to just expose our entire
API to the fuzzer and see what happens. Sadly, we're really only
exposing a small subset of our API. This improves that by exposing
a handful of other assorted methods from ChannelManager and
PeerManager.
2024-02-07 02:32:52 +00:00
Matt Corallo
a17df4f8eb [fuzz] Use batch funding in full_stack_target
To potentially get more test coverage
2024-02-07 02:32:52 +00:00