Commit graph

8257 commits

Author SHA1 Message Date
Elias Rohrer
91ae8b87ca
Define MigratableKVStore trait with list_all_keys method
.. which will be used for generic `KVStore`-to-`KVStore` migration
logic.
2024-12-12 13:31:47 +01:00
Jeffrey Czyz
fe1cf69b58
Merge pull request #3449 from TheBlueMatt/2024-12-event-processing-logging
Log before and after `Event` processing calls
2024-12-08 21:59:41 -06:00
Matt Corallo
e2b964e793 Log before and after Event processing calls
At various points we've had issues where `Event` processing for a
user possibly is taking a long time, causing other things to stall.
However, due to lack of logging during `Event` processing itself
this can be rather difficult to debug. In
85eb8145fb we attempted to add
logging for this, but in doing so ended up with more verbose
logging than we were comfortable with.

Instead, here, we log only when we actually process an `Event`,
directly in the callsite passing the `Event` to the user.

Fixes #3331
2024-12-08 00:34:44 +00:00
Matt Corallo
020be440b6
Merge pull request #3442 from arik-so/archive-monitor-persistence-trigger
Persist unresolved ChannelMonitors on empty height change
2024-12-06 19:23:15 +00:00
Matt Corallo
b96b19a65d
Merge pull request #3413 from TheBlueMatt/2024-11-async-persist-claiming-from-closed-chan-1
Misc updates to tee up async `ChannelMonitorUpdate` persist for claims against closed channels
2024-12-06 19:13:53 +00:00
Arik Sosman
6f9300f115
Persist unresolved ChannelMonitors on empty height change 2024-12-06 08:27:37 -08:00
Gursharan Singh
8a54da6527
Merge pull request #3390 from arik-so/gossip-filtration-fix
Gossip filtration fix
2024-12-05 18:48:03 -08:00
Matt Corallo
b50354dc48 Check in-flight updates before completing events on closed chans
When we handle a `ChannelMonitorUpdate` completion we always
complete everything that was waiting on any updates to the same
channel all at once. Thus, we need to skip all updates if there's
pending updates besides the one that was just completed.

We handled this correctly for open channels, but the shortcut for
closed channels ignored any other pending updates entirely.

Here we fix this, which is ultimately required for tests which are
added in a few commits to pass.
2024-12-06 01:03:44 +00:00
Matt Corallo
4766e99e6f Properly enforce that all ChannelMonitorUpdates are ordered
c99d3d785d updated
`ChannelMonitorUpdate::update_id` to continue counting up even
after the channel is closed. It, however, accidentally updated the
`ChannelMonitorUpdate` application logic to skip testing that
`ChannelMonitorUpdate`s are well-ordered after the channel has been
closed (in an attempt to ensure other checks in the same
conditional block were applied).

This fixes that oversight.
2024-12-06 01:03:44 +00:00
Matt Corallo
70a375151e Add monitor update handling to update_maps_on_chan_removal
Closing channels requires a two step process - first
`update_maps_on_chan_removal` is called while holding the same
per-peer lock under which the channel reached the terminal state,
then after dropping the same lock(s), `finish_close_channel` is
called.

Because the channel is closed and thus no further
`ChannelMonitorUpdate`s are generated for the off-chain state, we'd
previously applied the `ChannelMonitorUpdate` in
`finish_close_channel`. This was tweaked somewhat in
c99d3d785d when we stopped using
`u64::MAX` for any updates after closure. However, we worked around
the races that implied by setting the `update_id` only when we go
to apply the `ChannelMonitorUpdate`, rather than when we create it.

In a coming commit, we'll need to have an `update_id` immediately
upon creation (to track in-flight updates that haven't reached
application yet). This implies that we can no longer apply closure
`ChannelMonitorUpdate`s after dropping the per-peer lock(s), as the
updates must be well-ordered with any later updates to the same
channel, even after it has been closed.

Thus, here, we add `ChannelMonitorUpdate` handling to
`update_maps_on_chan_removal`, renaming it `locked_close_channel`
to better capture its new purpose.
2024-12-06 01:03:44 +00:00
Matt Corallo
d1c340a0e1 Add additional variants to handle_new_monitor_update!
In the coming commits we'll start handling `ChannelMonitorUpdate`s
during channel closure in-line rather than after dropping locks via
`finish_close_channel`. In order to make that easy, here we add a
new `REMAIN_LOCKED_UPDATE_ACTIONS_PROCESSED_LATER` variant to
`handle_new_monitor_update!` which can attempt to apply an update
without dropping the locks and processing
`MonitorUpdateCompletionAction`s immediately.
2024-12-06 01:02:58 +00:00
Matt Corallo
385799f604 Handle events immediately if we are running during block connection
During block connection, we cannot apply `ChannelMonitorUpdate`s if
we're running during the startup sequence (i.e. before the user has
called any methods outside of block connection). We previously
handled this by simply always pushing any `ChannelMonitorUpdate`s
generated during block connection into the
`pending_background_events` queue.

However, this results in `ChannelMonitorUpdate`s going through the
queue when we could just push them immediately. Here we explicitly
check `background_events_processed_since_startup` and use that to
decide whether to push updates through the background queue
instead.
2024-12-06 01:02:58 +00:00
Matt Corallo
d33687dbef Don't generate dup force-close ChannelMonitorUpdates on startup
On startup, if we have a channel which was closed immediately
before shutdown such that the `ChannelMonitorUpdate` marking the
channel as closed is still in-flight, it doesn't make sense to
generate a fresh `ChannelMonitorUpdate` marking the channel as
closed immediately after the existing in-flight one.

Here we detect this case and drop the extra update, though its not
all that harmful it does avoid some test changes in the coming
commits.
2024-12-06 01:02:58 +00:00
Matt Corallo
f9374b8377 When removing PeerState check for in-flight mon updates deeply
When deciding if we should remove a `PeerState` entry we want to
ensure we don't remove if there are pending updates in
`in_flight_monitor_updates`. Previously this was done with a simple
`in_flight_monitor_updates.is_empty()`, however this can prevent
removal of `PeerState` entries if a channel had an update at some
point (leaving an entry in the map) but the update was ultimately
completed.

Instead, we need to iterate over the entries in
`in_flight_monitor_updates` and decline to remove `PeerState`s only
if there is an entry for a pending update still in-flight.
2024-12-06 01:02:58 +00:00
Matt Corallo
10f9123420
Merge pull request #3447 from valentinewallace/2024-12-fix-fuzz
Fix `full_stack` fuzz target
2024-12-05 22:15:34 +00:00
Valentine Wallace
2286191239
Fix full_stack fuzz target
2e685ffb24 removed a field from UserConfig, which
broke this fuzz target. The hardcoded strings needed to be updated to remove
this field from them too.
2024-12-05 16:17:03 -05:00
Matt Corallo
239d10ab2e
Merge pull request #3432 from tnull/2024-11-take-verifier-by-arc
Take circular `GossipVerifier` reference by `Arc`
2024-12-05 19:04:18 +00:00
Arik Sosman
145e1aba38
Trigger full sync only on old GossipTimestampFilters
Previously, upon receipt of a GossipTimestampFilter message, we would
immediately start unloading the entire network graph on our
unsuspecting peer.

This commit modifies our behavior to only do so if the timestamp of
the filter message is at least six hour old. Otherwise, we only send
updated sync data as it comes in.
2024-12-05 10:06:39 -08:00
Matt Corallo
529cbed9c7
Merge pull request #3445 from elsirion/2024-12-copy-description
chore: make `Bolt11InvoiceDescriptionRef` copy
2024-12-05 16:06:22 +00:00
elsirion
64a3bd6856
chore: make Bolt11InvoiceDescriptionRef copy 2024-12-05 16:46:51 +01:00
Matt Corallo
f33738d6cd
Merge pull request #3439 from valentinewallace/2024-12-remove-mpp-keysend-cfg
Remove `UserConfig::accept_mpp_keysend`
2024-12-05 15:31:14 +00:00
Elias Rohrer
797993c65d
Merge pull request #3441 from arik-so/2024-12-lint-fixes 2024-12-05 10:37:31 +01:00
Arik Sosman
b4f21d16f4
Explicitly specify elided lifetime for LockTestExt 2024-12-05 00:48:35 -08:00
Arik Sosman
340ef29032
Remove blank lines following doc comments 2024-12-05 00:48:35 -08:00
Arik Sosman
1ff77aef60
Allow manual_div_ceil
Until our MSRV reaches 1.73.0, we're gonna need
to keep allowing it.
2024-12-05 00:48:35 -08:00
Valentine Wallace
2e685ffb24
Remove UserConfig::accept_mpp_keysend
This option was added to force users to opt into breaking compat with
< 0.0.116, so it should be fine to remove for the 0.1 release. Otherwise,
receiving to static invoices would always require flipping this on.
2024-12-04 15:57:20 -05:00
Matt Corallo
726dd5cad3
Merge pull request #3429 from andrei-21/feature/channelmonitor-goodies
Clean channelmonitor.rs code
2024-12-04 14:58:05 +00:00
Matt Corallo
1386bef048
Merge pull request #3431 from tnull/2024-11-drop-logging-features
Drop log-limiting features
2024-12-03 17:54:20 +00:00
Elias Rohrer
f6af8e346e
Drop log-limiting features
Previously, LDK offered two ways to limit log outputs:
filtering during runtime client-side by matching on any given `Record`'s `Level` value,
as well as at compile time through the `max_level_*` feature flags.

It turns out the latter approach was always broken when used outside of
the `lightning` crate. Here, we therefore simply drop the feature-based
filtering.
2024-12-03 17:26:49 +01:00
Matt Corallo
a92084b4dc
Merge pull request #3437 from tnull/2024-12-drop-elided-lifetime-name
Drop elided lifetime name from `get_best_block`
2024-12-03 16:23:18 +00:00
Matt Corallo
e1e8ce00c8
Merge pull request #3420 from TheBlueMatt/2024-11-live-success-prob
Add the ability to fetch a probability from live liquidity bounds
2024-12-03 16:10:22 +00:00
Elias Rohrer
2ca1d8fadf
Drop unnecessary elided lifetime name from get_best_block
.. which recently started to yield a warning on the `beta` channel of
rustc.
2024-12-03 11:22:42 +01:00
Matt Corallo
7cfcb14846
Merge pull request #3434 from tnull/2024-12-fix-indexmap-pin
Fix `indexmap` pin as 2.7.0 was just released
2024-12-02 16:47:24 +00:00
Matt Corallo
d3efe5cbb7 Add a fallback-allowed param to historical success prob estimator
`historical_estimated_payment_success_probability` exposes the
historical success probability estimator publicly, but only allows
fetching data from channels where we have sufficient information.

In the previous commit,
`live_estimated_payment_success_probability` was added to enable
querying the live bounds success probability estimator.

Sadly, while the historical success probability estimator falls
back to the live probability estimator, it does so with a different
final parameter to `success_probability`, making
`live_estimated_payment_success_probability` not useful for
calculating the actual historical model output when we have
insufficient data.

Instead, here, we add a new parameter to
`historical_estimated_payment_success_probability` which
determines whether it will return fallback data from the live
model instead.
2024-12-02 16:45:50 +00:00
Matt Corallo
b1770ba8f6 Add the ability to fetch a probability from live liquidity bounds
We already expose the estimated success probability from the
historical liquidity bounds from
`historical_estimated_payment_success_probability`, but we don't
do that for the live liquidity bounds.

Here we add a `live_estimated_payment_success_probability` which
exposes the probability result from the live liquidity bounds as
well.
2024-12-02 16:45:50 +00:00
Elias Rohrer
d80d1dd1ff
Fix indexmap pin as 2.7.0 was just released
I heard you like pins, so I pinned you pin so you can pin while you pin.
2024-12-02 16:20:06 +01:00
Andrei
8ebda06c4e Turn IrrevocablyResolvedHTLC comment into a Rust comment 2024-12-02 00:00:00 +00:00
Jeffrey Czyz
846342eec1
Merge pull request #3433 from andrei-21/fix/iso-typo
Fix `ISO 4712` typo to `ISO 4217`
2024-11-29 16:03:30 -06:00
Elias Rohrer
aca3979a9e
Take circular GossipVerifier reference by Arc
Our current architecture requires `GossipVerifier`'s type signature to
include a circular reference to itself. Previously, we directly gave
that as `Self`, which however did not work when setting it dynamically
under all circumstances. Here we take `Self` by `Arc` mitigate this
issue.
2024-11-28 12:03:10 +01:00
Andrei
fa731ae832 Fix ISO 4712 typo to ISO 4217 2024-11-28 00:00:00 +00:00
Andrei
553e6c7ec6 Clean channelmonitor.rs code
* Replace deprecated `u64::max_value()`
* Use `Option::is_some()`
* Use `Iterator::any()` instead of `Iterator::find()`
2024-11-27 00:00:00 +00:00
Matt Corallo
12920d8ca4
Merge pull request #3417 from dunxen/2024-11-removenextfundingtxidpersist
Remove `next_funding_txid` tlv from `Channel` read/write
2024-11-26 22:32:40 +00:00
valentinewallace
70ace8184c
Merge pull request #3345 from tankyleo/onion-channel-updates
Stop sending `channel_update` in onion failures
2024-11-26 14:24:10 -05:00
Matt Corallo
ff36405609
Merge pull request #3426 from morehouse/correct_return_value
Correct return value for `apply_post_close_monitor_update`
2024-11-26 17:01:01 +00:00
Matt Morehouse
857d36344d
Correct return value for apply_post_close_monitor_update
A recent change accidentally inverted the returned monitor update for
the case where an update is applied after the channel has been closed.
This commit corrects that mistake.
2024-11-26 10:35:44 -06:00
Matt Corallo
ba3d4ff957
Merge pull request #3421 from arik-so/rgs-cache-doc
Expand on RGS caching requirements
2024-11-25 14:37:07 +00:00
Duncan Dean
7177acb576
Remove next_funding_txid tlv from channel read/write
We want to remove this before release so that we can work on a way to
not persist this but rather get it from other persisted data and just
free up the TLV.

Note that the "added in 0.0.124" comment was incorrect as it was
actually added in #3137 but the comment was stale so it's safe to remove.
2024-11-25 09:19:05 +02:00
Matt Corallo
aba57bbc07 Make test_durable_preimages_on_closed_channel more robust
Makes `test_durable_preimages_on_closed_channel` more robust
against changes to the order in which transactions are broadcast.
2024-11-24 13:56:07 +00:00
Arik Sosman
144340bf0f
Expand on RGS caching requirements 2024-11-23 11:33:16 -05:00
Jeffrey Czyz
2d6720e7e2
Merge pull request #3419 from arik-so/rgs-timestamp-docs
Document RGS timestamp usage
2024-11-22 15:08:33 -06:00