Commit graph

7896 commits

Author SHA1 Message Date
Matt Corallo
7cf4a1995d
Merge pull request #3260 from TheBlueMatt/2024-08-more-deref
Bound `Persister`'s `WriteableScore` by `Deref`
2024-08-21 19:55:44 +00:00
Matt Corallo
2ce2fe9392 Disambiguate blinded path ForwardNodes between payment + message
We currently have two structs with identical names in our public
API - `blinded_path::message::ForwardNode` and
`blinded_path::payment::ForwardNode`. This makes the API somewhat
awkward to use - users have to try (and fail) to import
`ForwardNode` twice only to then have to change their imports.

More importantly, however, this makes the API very hard to use in
some bindings languages where rename-imports or module imports
aren't available.

Thus, here, we rename both to give them context.
2024-08-21 19:48:34 +00:00
Matt Corallo
11ab302087 Remove uneccessary std bounds on many tests
We never actually build with `#![no_std]` in tests as Rust does
not support it. Thus, many tests have spurious `std` feature gates
when they run just fine without them. Here we remove those gates,
though note that tests that depend on behavior elsewhere in the
codebase which is `std`-gated obviously need to retain their
feature gates.
2024-08-21 14:11:01 +00:00
Matt Corallo
5412784893 Reduce feature = std flags in gossip.rs somewhat
Fewer feature flags makes for more readable code, so we opt for
that over very marginally more effecient code here.
2024-08-21 14:11:01 +00:00
Matt Corallo
75a2089c15 Drop std::Error impl for PeerHandleError
Not sure why we ever really had this, no one really ever bounds
anything on `std::Error` and its kinda a dead type, so there's no
need for us to `impl` it for our types.
2024-08-21 14:11:01 +00:00
Matt Corallo
d89a487d5b Simplify Instant mocking in outbound payments
To handle `std` and `no-std` concepts of time in scoring, we'd
originally written a generic `Time` trait which we could use to
fetch the current time, observe real (not wall-clock) elapsed time,
and serialize the time.

Eventually, scoring stopped using this `Time` trait but outbound
payment retry expiry started using it instead to mock time in
tests.

Since scoring no longer uses the full features which required the
`Time` trait, we can substantially simplify by just having the
mocking option.
2024-08-21 14:11:01 +00:00
Matt Corallo
1c83e612ad Remove note about std/no-std scorer serialization compat
In 81389dee30 we removed a note about
mixing the `std` and `no-std` feature when de/serializing
`ProbabilisticScorer`s but forgot to note that there was a second
copy of that note in the module documentation.

This removes that note.
2024-08-21 14:11:01 +00:00
Matt Corallo
636125e089 Bound Persister's WriteableScore by Deref
This makes the trait marginally more flexible, but more importantly
matches our normal structure which makes the bindings generator a
bit happier.
2024-08-21 13:48:19 +00:00
Elias Rohrer
b3abb192cc
Rename ChannelDetails::is_public to is_announced
Referring to announced/unannounced channels as 'public'/'private'
regularly leads to confusion on what they are and when which should be
used. To avoid perpetuating this confusion, we should avoid referring to
announced channels as 'public' in our API.

Here we rename `ChannelDetails::is_public` (which breaks
previously-released API) to align it with the changes in
`OpenChannelRequest`.
2024-08-21 12:40:21 +02:00
Elias Rohrer
b9c73b1767
Rename OpenChannelRequest::is_public to is_announced
Referring to announced/unannounced channels as 'public'/'private'
regularly leads to confusion on what they are and when which should be
used. To avoid perpetuating this confusion, we should avoid referring to
announced channels as 'public' in our API.

Here we rename the recently introduced field in `OpenChannelRequest`
(which doesn't break released API), and will align the pre-existing
instances of `is_public` in the following commit (which will break API).
2024-08-21 12:38:27 +02:00
Jeffrey Czyz
76c9fdad58
Rename construct_keys_callback functions 2024-08-20 16:54:10 -05:00
Jeffrey Czyz
b4073b0a7f
Require Destination in construct_keys_callback 2024-08-20 16:54:09 -05:00
Jeffrey Czyz
2787ffef1e
Use a single iterator to construct a BlindedPath
Instead of using separate iterators for pubkeys and TLVs, use an
iterator that yields a tuple of them. This allows for holding a mutable
reference to the TLVs such that they can be padded. With two iterators,
the pubkey iterator would have a reference to the ForwardNode slice when
constructing a payment path. However, this would prevent holding mutable
references in the TLVs iterator.
2024-08-20 16:47:33 -05:00
Jeffrey Czyz
b28fc40260
Generalize build_keys_helper
When constructing a blinded path, two iterators are used: one for the
pubkeys and another for Writeable TLVs. The first iterator is used in
the build_keys_helper utility function while the second is used inside
of a callback. Update this utility to work on any type that can be
borrowed as a PublicKey. This allows for using a single iterator of
tuples, which is necessary for padding the hops without additional
allocations and clones.
2024-08-20 16:35:43 -05:00
Jeffrey Czyz
51d9218f67
Add a construct_keys_callback for blinded paths
When constructing a BlindedPath, an Option<Destination> parameter to
construct_keys_callback is never passed. Make a separate utility
function that doesn't take this parameter. This allows for using the
build_keys_helper macro with a Iterator yielding items other than
PublicKey.
2024-08-20 16:35:43 -05:00
Jeffrey Czyz
4922548bf2
Use PublicKey values in construct_keys_callback
Instead of accepting iterators yielding PublicKey by reference in
utils::construct_keys_callback, take iterators yielding values since
these implement Copy and need to be copied anyway. This will help avoid
a situation when padding where both a reference and mutable reference
are needed.
2024-08-20 16:35:40 -05:00
Jeffrey Czyz
8d22f99740
Refactor helper macro from construct_keys_callback
When constructing a BlindedPath, utils::construct_blinded_hops uses two
iterators. However, this makes it difficult to pad blinded hops to equal
sizes without allocating a vector or cloning data. Refactor the
construct_keys_callback utility function so that is can be used with an
Iterator with different Item types. This allows using a single Iterator
of tuples while still supporting its use only with pubkeys.
2024-08-20 16:00:19 -05:00
Matt Corallo
bbfa15eb18
Merge pull request #3247 from dunxen/2024-08-deprecate-balancemsat
Deprecate AvailableBalances::balance_msat
2024-08-20 20:52:10 +00:00
Matt Corallo
3605777c01
Merge pull request #3258 from TheBlueMatt/2024-08-default-for-bindings
Consistently pass `DefaultRouter::new` `Default` scoring parameters
2024-08-20 20:46:27 +00:00
G8XSU
29451bf720
Doc Clarity: Handling gaps in persisted ChannelMonitorUpdates
If there are any gaps in the persisted [`ChannelMonitorUpdate`]s,
implementer can safely ignore [`ChannelMonitorUpdate`]s after the gap and load without them.
Since, acc. to channel-manager, we have only made progress if all contiguos
ChannelMonitorUpdates have been persisted.
2024-08-20 10:23:30 -07:00
Duncan Dean
0a1adeb376
Test ChannelDetails serialization to catch mutants 2024-08-20 17:24:59 +02:00
valentinewallace
b2cdc2cb31
Merge pull request #3254 from TheBlueMatt/2024-08-flaky-test
Correct `peer_handler::test_process_events_multithreaded`
2024-08-20 11:13:25 -04:00
Duncan Dean
70762f90ca
Deprecate AvailableBalances::balance_msat
The ChannelMonitor::get_claimable_balances method provides a more
straightforward approach to the balance of a channel, which satisfies
most use cases. The computation of AvailableBalances::balance_msat is
complex and originally had a different purpose that is not applicable
anymore. We deprecate AvailableBalances::balance_msat now and will remove
it in a following release.

Co-authored-by: Willem Van Lint <noreply@wvanlint.dev>
2024-08-20 17:08:34 +02:00
Matt Corallo
841e9deae0 Consistently pass DefaultRouter::new Default scoring parameters
In 26c1639ab6 (and later in
50c55dcf32 and
fb693ecbf8) we switched to using
`Default::default()` to initialize `()` for scoring parameters in
tests. One `()`s slipped back in recently, which we replace here.
2024-08-20 14:33:42 +00:00
Matt Corallo
f89e963d4b
Merge pull request #3255 from TheBlueMatt/2024-08-124-beta
Bump version numbers to 0.0.124-beta/invoice 0.32-beta
2024-08-20 13:26:35 +00:00
Elias Rohrer
680d399da3
Merge pull request #3253 from TheBlueMatt/2024-08-new-types-export
Re-export `lightning_types` in top-level `lightning` modules
2024-08-20 08:56:15 +02:00
Matt Corallo
cd0ca28945 Bump version numbers to 0.0.124-beta/invoice 0.32-beta 2024-08-20 00:29:12 +00:00
Matt Corallo
61153f10eb
Merge pull request #3245 from valentinewallace/2024-07-blinded-pay-path-refactor
Move `BlindedPayInfo` into `BlindedPaymentPath`
2024-08-19 23:24:15 +00:00
Matt Corallo
e34519b31a Correct peer_handler::test_process_events_multithreaded
This test was added some time ago in
0c034e9a82, but never made any sense.
`PeerManager::process_events` will go around its loop as many times
is required to ensure we've always processed all events which were
pending prior to a `process_events` call, so having a test that
checks that we never go around more than twice is obviously broken.

And, indeed, in CI this tests fails with some regularity.

Instead, the test here is changed to ensure that we detectably go
around the loop again at least once.

Fixes #2385
2024-08-19 21:14:27 +00:00
Valentine Wallace
4ef83a0566
Test blinded PaymentParameter round trip serialization. 2024-08-19 16:42:23 -04:00
Valentine Wallace
db94d930f0
Move BlindedPayInfo into blinded_path::payment module. 2024-08-19 16:42:22 -04:00
Valentine Wallace
7038906890
Move BlindedPayInfo into BlindedPaymentPath.
Also removes the implementation of Writeable for BlindedPaymentPath, to ensure
callsites are explicit about what they're writing.
2024-08-19 16:28:30 -04:00
Matt Corallo
fb4403f8ae
Merge pull request #3204 from valentinewallace/2024-07-rb-test-vectors
Implement route blinding test vectors
2024-08-19 19:57:04 +00:00
Matt Corallo
05ed0db67f
Merge pull request #3188 from TheBlueMatt/2023-12-cache-scoring-points
Better Encapsulate Scoring and Cache Point Count
2024-08-19 19:02:05 +00:00
Matt Corallo
37154109c1
Merge pull request #3249 from TheBlueMatt/2024-08-feature-cleanup-1
bitcoin 0.32 upgrade followups
2024-08-19 18:50:52 +00:00
Alec Chen
5f3c6bfdd6 Consolidate sign_closing_transaction callsites to get_closing_signed_msg 2024-08-19 11:24:56 -07:00
Matt Corallo
bad5e32694
Merge pull request #3222 from tnull/2024-08-rustfmt-lightning-persister
`rustfmt`: Run on `lightning-persister`
2024-08-19 17:18:04 +00:00
Valentine Wallace
6f6115f177
Avoid && in public API for onion peeling/decoding.
No reason to take a reference to a Deref.
2024-08-19 12:47:42 -04:00
Valentine Wallace
8739b06620
Implement route blinding spec test vectors. 2024-08-19 12:47:42 -04:00
Valentine Wallace
9dba36a441
Fix blinded hop feature serialization.
We were writing a length redundantly...
2024-08-19 12:47:42 -04:00
Valentine Wallace
f68b1249a9
Support next_blinding_override in blinded payment paths.
This allow us to forward blinded payments where the blinded path that we are
forwarding within was concatenated to another blinded path that starts at the
next hop.

Also allows constructing blinded paths using this override.
2024-08-19 12:47:40 -04:00
Matt Corallo
8049f99ebc Remove the std feature implications from the lightning crate
Now that we don't have to have everything in our entire ecosystem
use the same `std`/`no-std` feature combinations we should start by
untangling our own features a bit.

This takes one last step, removing the implications of the `std`
feature from the `lightning` crate.
2024-08-19 15:09:40 +00:00
Matt Corallo
3fe4ef9640 Drop the _test_vectors feature in favor of a cfg flag
This exists just for tests, so there's no reason for it to be
publicly visible.
2024-08-19 15:09:40 +00:00
Matt Corallo
e212d74298 Somewhat clean up ci-tests.sh and sort by RUSTFLAGS 2024-08-19 15:09:40 +00:00
Matt Corallo
51f5bc881f Drop the no-std feature from lightning-rapid-gossip-sync
Now that we don't have to have everything in our entire ecosystem
use the same `std`/`no-std` feature combinations we should start by
untangling our own features a bit.

This takes another step by removing the `no-std` feature entirely
from the `lightning-rapid-gossip-sync` crate and removing all
feature implications on dependencies from the remaining `std`
feature.
2024-08-19 15:09:40 +00:00
Matt Corallo
31a9cd2d3d Drop the no-std feature from lightning-invoice
Now that we don't have to have everything in our entire ecosystem
use the same `std`/`no-std` feature combinations we should start by
untangling our own features a bit.

This takes another step by removing the `no-std` feature entirely
from the `lightning-invoice` crate and removing all feature
implications on dependencies from the remaining `std` feature.
2024-08-19 15:09:40 +00:00
Matt Corallo
5e37074246 Drop the no-std feature from BP and drop feature implications
Now that we don't have to have everything in our entire ecosystem
use the same `std`/`no-std` feature combinations we should start by
untangling our own features a bit.

This takes the first step by removing the `no-std` feature entirely
from the `lightning-background-processor` crate and removing most
feature implications on dependencies from the remaining `std`
feature.

It also addresses a CI oversight where we were not testing
`lightning-background-processor` without the `std` feature in CI at
all.
2024-08-19 15:09:40 +00:00
Matt Corallo
9ca38c59f4 Ensure we always pass a path for in-workspace dependencies
In order to ensure our crates depend on the workspace copies of
each other in test builds we need to override the crates.io
dependency with a local `path`.

We can do this in one of two ways - either specify the `path` in
the dependency listing in each crate's `Cargo.toml` or use the
workspace `Cargo.toml` to `patch` all dependencies. The first is
tedious while the second lets us have it all in one place. However,
the second option does break `cargo *` in individual crate
directories (forcing the use of `cargo -p crate *` instead) and
makes it rather difficult to depend on local versions of workspace
crates.

Thus, here we drop the `patch.crates-io` from our top-level
`Cargo.toml` entirely.

Still, we do update the `ci/ci-tests.sh` script here to use
`cargo -p crate` instead of switching to each crate's directory as
it allows `cargo` to use a shared `target` and may speed up tests.
2024-08-19 15:09:38 +00:00
Matt Corallo
f8b7ad242d Optimize BufReader somewhat for the only used case
`rust-bitcoin` doesn't ever actually *use* its `BufRead`
requirement when deserializing objects, and forcing it is somewhat
inefficient, so we optimize the only (actual) case here by passing
reads straight through to the backing stream.
2024-08-19 14:55:28 +00:00
Matt Corallo
aadf233d6c Fix bug in BufReader::fill_buf when reaching EOF
When we reach EOF we may return a full buffer when we should return
an empty one.
2024-08-19 14:55:28 +00:00