Commit graph

8075 commits

Author SHA1 Message Date
Elias Rohrer
468588f2ff
Drop dead code from provide_latest_counterparty_commitment_tx
We drop some dead code that unnecessarily allocates a `Vec` but does
nothing else.
2024-11-01 10:26:46 +01: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
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
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
Matt Corallo
20db790c53 Add a test for the fee-bump rate of timeout HTLC claims on cp txn
In a previous commit we updated the fee-bump-rate of claims against
HTLC timeouts on counterparty commitment transactions so that
instead of immediately attempting to bump every block we consider
the fact that we actually have at least `MIN_CLTV_EXPIRY_DELTA`
blocks to do so, and bumping at the appropriate rate given that.

Here we test that by adding an extra check to an existing test
that we do not bump in the very next block after the HTLC timeout
claim was initially broadcasted.
2024-10-18 16:23:27 +00:00
Matt Corallo
6ae33dc1e0 Set correct counterparty_spendable_height for outb local HTLCs
For outbound HTLCs, the counterparty can spend the output
immediately. This fixes the `counterparty_spendable_height` in the
`PackageTemplate` claiming outbound HTLCs on local commitment
transactions, which was previously spuriously set to the HTLC
timeout (at which point *we* can claim the HTLC).
2024-10-18 16:23:27 +00:00
Matt Corallo
b5b38603fd Stop exporting lightning::ln::features
Now that the module only contains some implementations of
serialization for the `lightning_types::features` structs, there's
no reason for it to be public.
2024-10-17 19:39:12 +00:00
Matt Corallo
f4b23115f6 Add a test of gossip message buffer limiting in PeerManager
This adds a simple test that the gossip message buffer in
`PeerManager` is limited, including the new behavior of bypassing
the limit when the broadcast comes from the
`ChannelMessageHandler`.
2024-10-17 19:09:15 +00:00
Matt Corallo
21904ffcb5 Add a constructor for the test SocketDescriptor and hang_writes
In testing, its useful to be able to tell the `SocketDescriptor` to
pretend the system network buffer is full, which we add here by
creating a new `hang_writes` flag. In order to simplify
constructing, we also add a new constructor which existing tests
are moved to.
2024-10-17 19:09:15 +00:00
Matt Corallo
bcad2571ac Fix the establish_connection utility method for a 2nd connection
The `establish_connection` method should work for more than one
connection per `PeerManager`, which we fix here.
2024-10-17 19:09:15 +00:00
Matt Corallo
1b711ed15f Reliably deliver gossip messages from our ChannelMessageHandler
When our `ChannelMessageHandler` creates gossip broadcast
`MessageSendEvent`s, we generally want these to be reliably
delivered to all our peers, even if there's not much buffer space
available.

Here we do this by passing an extra flag to `forward_broadcast_msg`
which indicates where the message came from, then ignoring the
buffer-full criteria when the flag is set.
2024-10-17 19:09:15 +00:00