Commit Graph

6535 Commits

Author SHA1 Message Date
Matt Corallo
c6e4debee9 Bump versions to 0.0.119/lightning-invoice 0.27 2023-12-15 23:53:40 +00:00
Matt Corallo
d6c16aa1ae Add CHANGELOG entries for 0.0.119 2023-12-15 23:53:40 +00:00
Matt Corallo
ef2156ae8b
Merge pull request #2798 from TheBlueMatt/2023-12-119-bindings-upstream
Small API cleanups pre-0.0.119
2023-12-15 23:40:57 +00:00
Wilmer Paulino
f5e87d8441
Merge pull request #2795 from TheBlueMatt/2023-11-robuster-chan-to-peer
Move channel -> peer tracking to OutPoints from Channel IDs
2023-12-15 15:36:52 -08:00
Matt Corallo
2aecfa45ba Fix dev MSRV build of lightning-transaction-sync
...due to a transitive dependency of the `bitcoind` crate.
2023-12-15 22:39:57 +00:00
Matt Corallo
642240e867 Use correct default value when comparing to htlc_maximum_msat
62f8669654 added two
`htlc_maximum_msat.unwrap_or`s, but used a default value of 0,
spuriously causing all HTLCs to fail if we don't have an htlc
maximum value. This should be mostly harmless, but we should fix it
anyway.
2023-12-15 22:32:24 +00:00
Matt Corallo
bb0ddad00d Make FinalOnionHopData public
In 4b5db8c3ce, `channelmanager::PendingHTLCRouting` was made
public, exposing a `FinalOnionHopData` field to the world. However,
`FinalOnionHopData` was left crate-private, making the enum
impossible to construct.

There isn't a strong reason for this (even though the
`FinalOnionHopData` API is somewhat confusing, being separated from
the rest of the onion structs), so we expose it here.
2023-12-15 22:31:51 +00:00
Matt Corallo
83e76d78b7 Drop explicit bitcoin_hashes dependency in lightning-invoice
Since `lightning-invoice` now depends on the `bitcoin` crate
directly, also depending on the `bitcoin_hashes` crate is redundant
and just means we confuse users by setting the `std` flag only on
`bitcoin`. Thus, we drop the explicit dependency here and replace
it with `bitcoin::hashes`.
2023-12-15 22:31:51 +00:00
Matt Corallo
90cc9930b7 Un-export the PrivateRoute inner field as there are invariants
When we make the `PrivateRoute` inner `RouteHint` `pub`, we failed
to note that the `PrivateRoute::new` constructor actually verifies
a length invariant. Thus, we un-export the inner field and force
users to go back through the `new` fn.
2023-12-15 22:31:51 +00:00
Matt Corallo
b9797ebdd9
Merge pull request #2781 from jkczyz/2023-09-multihop-paths
Multi-hop `BlindedPath` creation interface
2023-12-15 22:30:43 +00:00
Jeffrey Czyz
37319a6193
Fix build warning 2023-12-15 15:40:10 -06:00
Jeffrey Czyz
164c8553e5
Use one-hop blinded paths only for announced nodes
To avoid exposing a node's identity in a blinded path, only create
one-hop blinded paths if the node has been announced, and thus has
public channels. Otherwise, there is no way to route a payment to the
node, exposing its identity needlessly.
2023-12-15 15:40:10 -06:00
Jeffrey Czyz
16ee24086c
DRY up OffersMessage::InvoiceRequest handling 2023-12-15 15:40:10 -06:00
Jeffrey Czyz
827833c933
Multi-hop blinded payment paths in ChannelManager
When constructing blinded payment paths for Bolt12Invoice, delegate to
Router::create_blinded_payment_paths which may produce multi-hop blinded
paths. Fallback to one-hop blinded paths if the Router fails or returns
no paths.
2023-12-15 15:40:09 -06:00
Jeffrey Czyz
62f8669654
Add create_blinded_payment_paths to Router
The Router trait is used to find a Route for paying a node. Expand the
interface with a create_blinded_payment paths method for creating such
paths to a recipient node.

Provide an implementation for DefaultRouter that creates two-hop
blinded paths where the recipient's peers serve as the introduction
nodes.
2023-12-15 15:40:09 -06:00
Jeffrey Czyz
edb5892030
CounterpartyForwardingInfo to PaymentRelay mapping 2023-12-15 15:40:09 -06:00
Jeffrey Czyz
4da08623a6
Fix broken doc link in create_refund_builder 2023-12-15 15:40:09 -06:00
Jeffrey Czyz
606304aa32
Multi-hop blinded paths in ChannelManager
When constructing blinded paths for Offer and Refund, delegate to
MessageRouter::create_blinded_paths which may produce multi-hop blinded
paths. Fallback to one-hop blinded paths if the MessageRouter fails or
returns no paths.

Likewise, do the same for InvoiceRequest and Bolt12Invoice reply paths.
2023-12-15 15:40:09 -06:00
Jeffrey Czyz
dcd8d58346
Use CLTV_FAR_FAR_AWAY in PaymentConstraints
When finding a route through a blinded path, a random CLTV offset may be
added to the path in order to preserve privacy. This needs to be
accounted for in the blinded path's PaymentConstraints. Add
CLTV_FAR_FAR_AWAY to the max_cltv_expiry constraint to allow for such
offsets.
2023-12-15 15:37:18 -06:00
Matt Corallo
e9452c701b Consistently clean up when failing in internal_funding_created
When we fail to accept a counterparty's funding for various
reasons, we should ensure we call the correct cleanup methods in
`internal_funding_created` to remove the temporary data for the
channel in our various internal structs (primarily the SCID alias
map).

This adds the missing cleanup, using `convert_chan_phase_err`
consistently in all the error paths.

This also ensures we get a `ChannelClosed` event when relevant.
2023-12-15 21:08:14 +00:00
Jeffrey Czyz
c558ccd6a9
Fix create_one_hop_blinded_payment_path docs 2023-12-15 14:52:07 -06:00
Jeffrey Czyz
bedc2c64fc
Require any Router also implements MessageRouter
ChannelManager is parameterized by a Router in order to find routes when
sending and retrying payments. For the offers flow, it needs to be able
to construct blinded paths (e.g., in the offer and in reply paths).
Instead of adding yet another parameter to ChannelManager, require that
any Router also implements MessageRouter. Implement this for
DefaultRouter by delegating to a DefaultMessageRouter.
2023-12-15 14:52:07 -06:00
Jeffrey Czyz
97049daac2
Add create_blinded_paths to MessageRouter
The MessageRouter trait is used to find an OnionMessagePath to a
Destination (e.g., to a BlindedPath). Expand the interface with a
create_blinded_paths method for creating such paths to a recipient.
Provide a default implementation creating two-hop blinded paths where
the recipient's peers serve as introduction nodes.
2023-12-15 14:52:07 -06:00
Jeffrey Czyz
ffb0d83298
Add RouteBlinding feature flag
The RouteBlinding feature flag is signals support for relaying payments
over blinded paths. It is used for paying BOLT 12 invoices, which are
required to included at least one blinded path.
2023-12-15 14:52:07 -06:00
Jeffrey Czyz
ee026d4357
Re-order AnchorsZeroFeeHtlcTx in module docs/tests
Move AnchorsZeroFeeHtlcTx after Wumbo to keep order by feature bit.
Also, update setting order and comment in tests.
2023-12-15 14:52:07 -06:00
Matt Corallo
c92db69183
Merge pull request #2656 from TheBlueMatt/2023-09-scoring-decay-timer
Stop decaying liquidity information during scoring
2023-12-15 20:06:30 +00:00
Matt Corallo
922cc84480
Merge pull request #2796 from yellowred/fix/bitcoind_parse_txid
Fixes bug that causes incorrect conversion of JsonValue to Txid.
2023-12-15 19:27:15 +00:00
Elias Rohrer
e1897de606
Merge pull request #2779 from G8XSU/2706-stop
Stop cleaning monitor updates on new block connect
2023-12-15 09:28:31 +01:00
olegkubrakov
6b3c2c6430 Fixes bug with incorrect conversion of JsonValue to Txid.
The bug happens when there is a call to a bitcoind that expects a transaction id as a response and
results in a corrupted Txid being returned.
2023-12-14 16:34:01 -08:00
Gursharan Singh
ef0909627d
Stop cleaning monitor updates on new block connect
Previously, we used to cleanup monitor updates at both consolidation
threshold and new block connects. With this change we will only
cleanup when our consolidation criteria is met. Also, we remove
monitor read from cleanup logic, in case of update consolidation.
Note: In case of channel-closing monitor update, we still need to
read the old monitor before persisting the new one in order to
determine the cleanup range.
2023-12-14 10:29:12 -08:00
Wilmer Paulino
c9d52cf185
Merge pull request #2792 from TheBlueMatt/2023-12-no-async-signing
cfg-gate async signing logic
2023-12-14 08:52:11 -08:00
Matt Corallo
f8fb70a765 Drop fake time advancing in scoring tests
Now that we use explicit times passed to decay methods, there's no
reason to make calls to `SinceEpoch::advance` in scoring tests.
2023-12-13 23:26:09 +00:00
Matt Corallo
18b42319bc Drop half-life-based bucket decay in update_history_buckets
Because we decay the bucket information in the background, there's
not much reason to try to decay them immediately prior to updating,
and in removing that we can also clean up a good bit of dead code,
which we do here.
2023-12-13 23:26:09 +00:00
Matt Corallo
21facd0d17 Make scorer decay + persistence more frequent
There's some edge cases in our scoring when the information really
should be decayed but hasn't yet been prior to an update. Rather
than try to fix them exactly, we instead decay the scorer a bit
more often, which largely solves them but also gives us a bit more
accurate bounds on our channels, allowing us to reuse channels at
a similar amount to what just failed immediately, but at a
substantial penalty.
2023-12-13 23:26:09 +00:00
Matt Corallo
81389dee30 Drop warning about mixing no-std and std ProbabilisticScorers
Now that the serialization format of `no-std` and `std`
`ProbabilisticScorer`s both just use `Duration` since UNIX epoch
and don't care about time except when decaying, we don't need to
warn users to not mix the scorers across `no-std` and `std` flags.

Fixes #2539
2023-12-13 23:26:09 +00:00
Matt Corallo
40b4094e87 Add a benchmark for decaying a 100k channel scorer's liquidity info
This is a good gut-check to ensure we don't end up taking a ton of
time decaying channel liquidity info.

It currently clocks in around 1.25ms on an i7-1360P.
2023-12-13 23:26:09 +00:00
Matt Corallo
512f44cf15 Drop now-trivial decayed_offset_msat helper utility
As we now no longer decay bounds information when fetching them,
there is no need to have a decaying-fetching helper utility.
2023-12-13 23:26:09 +00:00
Matt Corallo
d15a354f77 Drop now-unused T: Time bound on ProbabilisticScorer
Now that we don't access time via the `Time` trait in
`ProbabilisticScorer`, we can finally drop the `Time` bound
entirely, removing the `ProbabilisticScorerUsingTime` and type
alias indirection and replacing it with a simple struct.
2023-12-13 23:26:09 +00:00
Matt Corallo
22888425f7 Use Duration based time info in scoring rather than Time
In the coming commits, the `T: Time` bound on `ProbabilisticScorer`
will be removed. In order to enable that, we need to switch over to
using the `ScoreUpdate`-provided current time (as a `Duration`
since the unix epoch), making the `T` bound entirely unused.
2023-12-13 23:26:09 +00:00
Matt Corallo
d54c93065a Pipe Duration-based time information through scoring pipeline
In the coming commits, the `T: Time` bound on `ProbabilisticScorer`
will be removed. In order to enable that, we need to pass the
current time (as a `Duration` since the unix epoch) through the
score updating pipeline, allowing us to keep the
`*last_updated_time` fields up-to-date as we go.
2023-12-13 23:26:09 +00:00
Matt Corallo
5ac68c1af3 Update history bucket last_update time immediately on update
Now that we aren't decaying during scoring, when we set the
last_updated time in the history bucket logic doesn't matter, so
we should just update it when we've just updated the history
buckets.
2023-12-13 23:26:09 +00:00
Matt Corallo
6f8838fe70 Stop decaying liquidity information during bounds-based scoring
Because scoring is an incredibly performance-sensitive operation,
doing liquidity information decay (and especially fetching the
current time!) during scoring isn't really a great idea. Now that
we decay liquidity information in the background, we don't have any
reason to decay during scoring, and we ultimately remove it
entirely here.
2023-12-13 23:26:09 +00:00
Matt Corallo
35b49645c4 Stop decaying historical liquidity information during scoring
Because scoring is an incredibly performance-sensitive operation,
doing liquidity information decay (and especially fetching the
current time!) during scoring isn't really a great idea. Now that
we decay liquidity information in the background, we don't have any
reason to decay during scoring, and we remove the historical bucket
liquidity decaying here.
2023-12-13 23:26:09 +00:00
Matt Corallo
9659c06955 Impl decaying in ProbabilisticScorer::decay_liquidity_certainty
This implements decaying in the `ProbabilisticScorer`'s
`ScoreLookup::decay_liquidity_certainty` implementation, using
floats for accuracy since we're no longer particularly
time-sensitive. Further, it (finally) removes score entries which
have decayed to zero.
2023-12-13 23:26:09 +00:00
Matt Corallo
f0f8194719 Track historical liquidity update time separately from the bounds
In the next commit, we'll start to use the new
`ScoreUpdate::decay_liquidity_certainty` to decay our bounds in the
background. This will result in the `last_updated` field getting
updated regularly on decay, rather than only on update. While this
isn't an issue for the regular liquidity bounds, it poses a problem
for the historical liquidity buckets, which are decayed on a
separate (and by default much longer) timer. If we didn't move to
tracking their decays separately, we'd never let the `last_updated`
field get old enough for the historical buckets to decay at all.

Instead, here we introduce a new `Duration` in the
`ChannelLiquidity` which tracks the last time the historical
liquidity buckets were last updated. We initialize it to a copy of
`last_updated` on deserialization if it is missing.
2023-12-13 23:26:09 +00:00
Matt Corallo
b84842a904 Add a scoring decay method to the ScoreUpdate trait
Rather than relying on fetching the current time during
routefinding, here we introduce a new trait method to `ScoreUpdate`
to do so. This largely mirrors what we do with the `NetworkGraph`,
and allows us to take on much more expensive operations (floating
point exponentiation) in our decaying.
2023-12-13 23:26:09 +00:00
Matt Corallo
a866ba7ee3 cfg-gate async signing logic
We are intending to release without having completed our async
signing logic, which sadly means we need to cfg-gate it to ensure
we restore the previous state of panicking on signer errors, rather
than putting us in a stuck state with no way to recover.

Here we add a new `async_signing` cfg flag and use it to gate all
the new logic from #2558 effectively reverting commits
1da29290e7 through
014a336e59.
2023-12-13 22:58:34 +00:00
Matt Corallo
304224e69d
Merge pull request #2790 from yellowred/tokio-ver-bump
Update tokio version to the latest to avoid tokio versions with security bugs
2023-12-13 20:40:08 +00:00
olegkubrakov
348db3baf7 Update tokio version to the latest to avoid tokio versions with security bugs.
This commit will set tokio version requirement to >=1.35.0, <2.0.0 to avoid versions with security issues (https://rustsec.org/packages/tokio.html).
2023-12-13 10:37:58 -08:00
Matt Corallo
6c366cf35f Pass the current time through ScoreUpDate methods
In the coming commits, we'll stop relying on fetching the time
during routefetching, preferring to decay score data in the
background instead.

The first step towards this - passing the current time through into
the scorer when updating.
2023-12-13 18:36:40 +00:00