Commit Graph

8234 Commits

Author SHA1 Message Date
Valentine Wallace
3945bf86f9
Add new PaymentFailureReason::BlindedPathCreationFailed
RouteNotFound did not fit here because that error is reserved for failing to
find a route for a payment, whereas here we are failing to create a blinded
path back to ourselves..
2024-10-30 16:13:56 -04:00
Jeffrey Czyz
e23f89ce43
Remove unneeded Eq and PartialEq derives
TlvRecord has a few fields, but comparing only the record_bytes is
sufficient for equality since the other fields are initialized from it.
Remove the Eq and PartialEq derives as they compare these other fields.
2024-10-29 18:31:43 -05:00
Jeffrey Czyz
a77300129c
Add optional lifetime to tlv_stream macro
Using the tlv_stream macro without a type needing a reference results in
a compilation error because of an unused lifetime parameter. To avoid
this, add an optional lifetime parameter to the macro. This allows for
experimental TLVs, which will be empty initially, and TLVs of entirely
primitive types.
2024-10-29 18:31:43 -05:00
Jeffrey Czyz
bbdd8738a8
Add parsing tests for unknown BOLT12 TLVs 2024-10-29 18:31:43 -05:00
Matt Corallo
ff93668ea2 Add additional test coverage of NetworkGraph counters
This would have caught the bug fixed in 0c0cb6fccb
in our tests.

Suggested by @valentinewallace.
2024-10-29 18:10:03 +00:00
Matt Corallo
948f1794a2 Re-broadcast channel_announcements every six blocks for a week
When we first get a public channel confirmed at six blocks, we
broadcast a `channel_announcement` once and then move on. As long
as it makes it into our local network graph that should be okay, as
we should send peers our network graph contents as they seek to
sync, however its possible an ill-timed shutdown could cause this
to fail, and relying on peers to do a full historical sync from us
may delay `channel_announcement` propagation.

Instead, here, we re-broadcast our `channel_announcement`s every
six blocks for a week, which should be way more than robust enough
to get them properly across the P2P network.

Fixes #2418
2024-10-29 17:53:11 +00:00
Matt Corallo
299b7bd714
Merge pull request #3367 from TheBlueMatt/2024-10-dense-counters
Don't bump the `next_node_counter` when using a removed counter
2024-10-29 17:48:57 +00:00
Matt Corallo
9e1853f9c8
Merge pull request #3380 from optout21/channel-funding-tx-simple
[Splicing] Preserve funding_transaction for the later lifecycle of the channel, simple solution
2024-10-29 14:57:17 +00:00
optout
5577a88ac0
Preserve funding_transaction for the later lifecycle of the channel, simple solution 2024-10-28 22:29:47 +01:00
Jeffrey Czyz
0e1723dc74
Owned and ref versions of Bolt11InvoiceDescription
Split Bolt11InvoiceDescription into a version used with references to
the description or description hash in the invoice and an owned version
of these for when constructing an invoice. The latter is useful as it
removes an unnecessary clone and can be used in a future change
specifying either a description or description hash in larger set of
invoice parameters. Since it doesn't use a reference, it can be exposed
in bindings as well.
2024-10-28 14:49:21 -05:00
Matt Corallo
bba3071cea
Merge pull request #3385 from arik-so/gossip-filter-event-send-logging
Log enqueueing of gossip messages
2024-10-28 14:10:18 +00:00
Matt Corallo
5c975f701a
Merge pull request #3322 from TheBlueMatt/2024-06-mpp-claim-without-man
Stop relying on ChannelMonitor persistence after manager read
2024-10-28 14:08:32 +00:00
Arik Sosman
0a8c05f8ba
Log enqueueing of gossip messages 2024-10-25 16:57:27 -07:00
Matt Corallo
ba264323f8 Doc the on-upgrade ChannelMonitor startup persistence semantics
Because the new startup `ChannelMonitor` persistence semantics rely
on new information stored in `ChannelMonitor` only for claims made
in the upgraded code, users upgrading from previous version of LDK
must apply the old `ChannelMonitor` persistence semantics at least
once (as the old code will be used to handle partial claims).
2024-10-24 17:44:33 +00:00
Matt Corallo
6c203d803e Stop relying on ChannelMonitor persistence after manager read
When we discover we've only partially claimed an MPP HTLC during
`ChannelManager` reading, we need to add the payment preimage to
all other `ChannelMonitor`s that were a part of the payment.

We previously did this with a direct call on the `ChannelMonitor`,
requiring users write the full `ChannelMonitor` to disk to ensure
that updated information made it.

This adds quite a bit of delay during initial startup - fully
resilvering each `ChannelMonitor` just to handle this one case is
incredibly excessive.

Over the past few commits we dropped the need to pass HTLCs
directly to the `ChannelMonitor`s using the background events to
provide `ChannelMonitorUpdate`s insetad.

Thus, here we finally drop the requirement to resilver
`ChannelMonitor`s on startup.
2024-10-24 17:44:33 +00:00
Matt Corallo
4896e20086 Replay MPP claims via background events using new CM metadata
When we claim an MPP payment, then crash before persisting all the
relevant `ChannelMonitor`s, we rely on the payment data being
available in the `ChannelManager` on restart to re-claim any parts
that haven't yet been claimed. This is fine as long as the
`ChannelManager` was persisted before the `PaymentClaimable` event
was processed, which is generally the case in our
`lightning-background-processor`, but may not be in other cases or
in a somewhat rare race.

In order to fix this, we need to track where all the MPP parts of
a payment are in the `ChannelMonitor`, allowing us to re-claim any
missing pieces without reference to any `ChannelManager` data.

Further, in order to properly generate a `PaymentClaimed` event
against the re-started claim, we have to store various payment
metadata with the HTLC list as well.

Here we finally implement claiming using the new MPP part list and
metadata stored in `ChannelMonitor`s. In doing so, we use much more
of the existing HTLC-claiming pipeline in `ChannelManager`,
utilizing the on-startup background events flow as well as properly
re-applying the RAA-blockers to ensure preimages cannot be lost.
2024-10-24 17:44:33 +00:00
Matt Corallo
254b78fd35 Handle duplicate payment claims during initialization
In the next commit we'll start using (much of) the normal HTLC
claim pipeline to replay payment claims on startup. In order to do
so, however, we have to properly handle cases where we get a
`DuplicateClaim` back from the channel for an inbound-payment HTLC.

Here we do so, handling the `MonitorUpdateCompletionAction` and
allowing an already-completed RAA blocker.
2024-10-24 17:44:33 +00:00
Matt Corallo
17cf179e75 Move payment claim initialization to an fn on ClaimablePayments
Here we wrap the logic which moves claimable payments from
`claimable_payments` to `pending_claiming_payments` to a new
utility function on `ClaimablePayments`. This will allow us to call
this new logic during `ChannelManager` deserialization in a few
commits.
2024-10-24 17:44:33 +00:00
Matt Corallo
a26033f0cb Move ChannelManager-read preimage relay to after struct build
In a coming commit we'll use the existing `ChannelManager` claim
flow to claim HTLCs which we found partially claimed on startup,
necessitating having a full `ChannelManager` when we go to do so.

Here we move the re-claim logic down in the `ChannelManager`-read
logic so that we have that.
2024-10-24 17:44:33 +00:00
Matt Corallo
7790e30880 Store info about claimed payments, incl HTLCs in ChannelMonitors
When we claim an MPP payment, then crash before persisting all the
relevant `ChannelMonitor`s, we rely on the payment data being
available in the `ChannelManager` on restart to re-claim any parts
that haven't yet been claimed. This is fine as long as the
`ChannelManager` was persisted before the `PaymentClaimable` event
was processed, which is generally the case in our
`lightning-background-processor`, but may not be in other cases or
in a somewhat rare race.

In order to fix this, we need to track where all the MPP parts of
a payment are in the `ChannelMonitor`, allowing us to re-claim any
missing pieces without reference to any `ChannelManager` data.

Further, in order to properly generate a `PaymentClaimed` event
against the re-started claim, we have to store various payment
metadata with the HTLC list as well.

Here we store the required MPP parts and metadata in
`ChannelMonitor`s and make them available to `ChannelManager` on
load.
2024-10-24 17:44:33 +00:00
Matt Corallo
b8661ef6cf Pass info about claimed payments, incl HTLCs to ChannelMonitors
When we claim an MPP payment, then crash before persisting all the
relevant `ChannelMonitor`s, we rely on the payment data being
available in the `ChannelManager` on restart to re-claim any parts
that haven't yet been claimed. This is fine as long as the
`ChannelManager` was persisted before the `PaymentClaimable` event
was processed, which is generally the case in our
`lightning-background-processor`, but may not be in other cases or
in a somewhat rare race.

In order to fix this, we need to track where all the MPP parts of
a payment are in the `ChannelMonitor`, allowing us to re-claim any
missing pieces without reference to any `ChannelManager` data.

Further, in order to properly generate a `PaymentClaimed` event
against the re-started claim, we have to store various payment
metadata with the HTLC list as well.

Here we take the first step, building a list of MPP parts and
metadata in `ChannelManager` and passing it through to
`ChannelMonitor` in the `ChannelMonitorUpdate`s.
2024-10-24 17:44:33 +00:00
Matt Corallo
d9175f454b Use a struct to track MPP parts pending claiming
When we started tracking which channels had MPP parts claimed
durably on-disk in their `ChannelMonitor`, we did so with a tuple.
This was fine in that it was only ever accessed in two places, but
as we will start tracking it through to the `ChannelMonitor`s
themselves in the coming commit(s), it is useful to have it in a
struct instead.
2024-10-24 17:44:33 +00:00
Valentine Wallace
cdc0c3b581
Fix unused warning in fuzz. 2024-10-24 10:37:26 -07:00
Matt Corallo
206ab82c02
Merge pull request #3007 from arik-so/arik/trampoline/2024-04-trampoline-blinded-hop-serialization
Serialize blinded Trampoline hops
2024-10-23 21:52:10 +00:00
Arik Sosman
d111981e13
Test non-legacy blinded Trampoline payloads. 2024-10-23 13:06:35 -07:00
Arik Sosman
9c9a31cd35
Add non-legacy blinded Trampoline payloads. 2024-10-23 13:06:35 -07:00
Arik Sosman
f6b3004659
Test blinded Trampoline payload serialization. 2024-10-23 13:06:35 -07:00
Arik Sosman
477216e7b1
Serialize blinded path forwards in Trampoline onions. 2024-10-23 13:06:35 -07:00
Matt Corallo
a65d37b48b Add missing inbound_payment_id_secret write in ChannelManager
In aa09c33a17 we added a new secret
in `ChannelManager` with which to derive inbound `PaymentId`s. We
added read support for the new field, but forgot to add writing
support for it. Here we fix this oversight.
2024-10-23 16:15:01 +00:00
Matt Corallo
4741653f76 Allow clippy::unwrap-or-default because its usually wrong
`or_default` is generally less readable than writing out the thing
we're writing, as `Default` is opaque but explicit constructors
generally are not. Thus, we ignore the clippy lint (ideally we
could invert it and ban the use of `Default` in the crate entirely
but alas).
2024-10-23 16:15:00 +00:00
Matt Corallo
e0838be5e4
Merge pull request #3379 from arik-so/exclude-windows-msrv
Skip MSRV on Windows in CI
2024-10-23 13:53:18 +00:00
Matt Corallo
3c868dd311
Merge pull request #3142 from TheBlueMatt/2024-06-robust-updates
Reliably deliver gossip messages from our `ChannelMessageHandler`
2024-10-23 00:12:03 +00:00
Arik Sosman
3d50b1d83b
Skip MSRV on Windows in CI 2024-10-22 13:09:24 -07:00
Matt Corallo
b2bcfca30e
Merge pull request #3376 from yellowred/yellowred/monitor_update_name_pub
Make monitor update name public
2024-10-22 17:13:05 +00:00
olegkubrakov
01529dcba6 Make monitor update name public
These structs are meant for MonitoringUpdatingPersister implementation, but some
external implementations may still reuse them, so going to make them public.
2024-10-22 10:03:51 -07:00
Matt Corallo
6104eb0c6e
Merge pull request #3377 from G8XSU/hex-impls
Implement to_lower_hex() Display/Debug for PaymentId & OfferId
2024-10-22 13:55:34 +00:00
Gursharan Singh
66e445811b
Merge pull request #3267 from arik-so/rgs_metrics_2024-08
Update RGS stats for August 2024.
2024-10-21 16:15:43 -07:00
G8XSU
2e118415e0
Implement to_lower_hex() Display/Debug for OfferId. 2024-10-21 15:41:42 -07:00
G8XSU
c75730a55f
Implement to_lower_hex() Display/Debug for PaymentId. 2024-10-21 15:40:02 -07:00
Arik Sosman
2c1e828922
Update processing times for iPhone. 2024-10-21 15:04:27 -07:00
Arik Sosman
160de118a5
Update RGS stats for August 2024. 2024-10-21 15:04:27 -07:00
Matt Corallo
260322ea72
Merge pull request #3370 from dunxen/2024-10-dry-funding-created-signed
DRY `funding_created()` and `funding_signed()` for V1 channels
2024-10-21 19:25:18 +00:00
Duncan Dean
2db1aa27b6
DRY funding_created() and funding_signed() for V1 channels
There is a decent amount of shared code in these two methods so we make
an attempt to share that code here by introducing the
`InitialRemoteCommitmentReceiver` trait. This trait will also come in
handy when we need similar commitment_signed handling behaviour for
dual-funded channels.
2024-10-21 16:25:22 +02:00
Matt Corallo
1e0f43f108
Merge pull request #3356 from jkczyz/2024-10-inflight-scoring
Don't over-penalize channels with inflight HTLCs
2024-10-19 13:41:11 +00:00
Jeffrey Czyz
0305000850
Use total_inflight_amount_msat for probability fns
Rename parameters used when calculating success probability to make it
clear that the total mount in-flight should be used rather than the
payment amount.
2024-10-18 18:28:40 -05:00
Jeffrey Czyz
572fab7591
Correct comments in avoids_saturating_channels 2024-10-18 18:28:40 -05:00
Jeffrey Czyz
7fa6770a7a
Correct base_penalty_amount_multiplier_msat docs
Commit df52da7b31 modified
ProbabilisticScorer to apply some penalty amount multipliers to the
total amount flowing over the channel. However, the commit updated the
docs for base_penalty_amount_multiplier_msat even though that behavior
didn't change. This commit reverts those docs.
2024-10-18 18:28:40 -05:00
Jeffrey Czyz
866588c20f
Don't over-penalize channels with inflight HTLCs
Commit df52da7b31 modified
ProbabilisticScorer to apply some penalty amount multipliers (e.g.,
liquidity_penalty_amount_multiplier_msat) to the total amount flowing
over the channel (i.e., including inflight HTLCs), not just the payment
in question. This led to over-penalizing in-use channels. Instead, only
apply the total amount when calculating success probability.
2024-10-18 18:28:40 -05:00
Gursharan Singh
608209ef19
Merge pull request #3359 from TheBlueMatt/2024-10-less-types-re-export
Remove deprecated re-exports
2024-10-18 14:35:49 -07:00
Matt Corallo
c5be7aa285
Merge pull request #3297 from TheBlueMatt/2024-09-cleanup-package
Cleanup `PackageTemplate`a bit
2024-10-18 17:44:29 +00:00