Skip to content

Conversation

TheBlueMatt
Copy link
Collaborator

In 601bf4b we started refusing to load ChannelMonitors which were created prior to LDK 0.0.110 and which were last updated prior to LDK 0.0.116. While this is likely fine for nearly all of our users, there's some risk that some (like me) have ancient un-archived ChannelMonitors.

We do need to start auto-archiving ChannelMonitors but for now we need some way for such users to at least not fail on startup. Sadly, ancient ChannelMonitors often don't contain some of the data we need to accurately calculate Balances, but in cases where they do, and where there are no claimable Balances, we can be confident we don't need the ChannelMonitors.

Thus, here, we adapt the ChannelMonitor Readable implementation used in the persistence wrappers to detect this case and simply skip loading such ChannelMonitors. Its not clear if this is sufficient, but its at least better than the current state of affairs after 601bf4b.

@TheBlueMatt TheBlueMatt added this to the 0.2 milestone Oct 7, 2025
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Oct 7, 2025

I've assigned @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot ldk-reviews-bot requested a review from jkczyz October 7, 2025 23:24
@TheBlueMatt TheBlueMatt force-pushed the 2025-10-less-panicy-reads branch 2 times, most recently from 58ad915 to 2b29c85 Compare October 8, 2025 10:51
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 57.14286% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.73%. Comparing base (2efb009) to head (b1fc759).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/util/persist.rs 53.33% 16 Missing and 5 partials ⚠️
lightning/src/chain/channelmonitor.rs 66.66% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4146      +/-   ##
==========================================
+ Coverage   88.63%   88.73%   +0.09%     
==========================================
  Files         180      180              
  Lines      135241   135568     +327     
  Branches   135241   135568     +327     
==========================================
+ Hits       119869   120294     +425     
+ Misses      12607    12506     -101     
- Partials     2765     2768       +3     
Flag Coverage Δ
fuzzing 21.71% <6.34%> (-0.05%) ⬇️
tests 88.57% <55.55%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt TheBlueMatt force-pushed the 2025-10-less-panicy-reads branch from 2b29c85 to 696e213 Compare October 8, 2025 13:19
} else {
panic!("Found monitor for channel {channel_id} with no updates since v0.0.118. \
These monitors are no longer supported. \
To continue, run a v0.1 release, send/route a payment over the channel or close it.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, so what if the monitor is already closed and you still have balances to claim? Is there any way you can realistically start up? I guess this would be pretty unlikely, unless you have an outbound payment you still need to time out on chain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you can't without manually deleting the monitor from your store. It really sucks and I'm not really happy with the state of things but it seems a bit late to walk this back :/

// return Ok(None) to allow it to be skipped and not loaded.
return Ok(None);
} else {
panic!("Found monitor for channel {channel_id} with no updates since v0.0.118. \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mentions 0.0.118 but the commit mentions 0.0.116

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that is from 601bf4b. I'll fix but looks like it was actually in 0.0.119

});

if counterparty_node_id.is_none() {
if (holder_tx_signed || lockdown_from_offchain) && monitor.get_claimable_balances().is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need to bother checking for (holder_tx_signed || lockdown_from_offchain)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not but it seemed like a nice additional check to include cause I'm not at all confident in the balance set for really old monitors.

@TheBlueMatt TheBlueMatt force-pushed the 2025-10-less-panicy-reads branch from 696e213 to 74ec7a6 Compare October 9, 2025 17:23
@TheBlueMatt
Copy link
Collaborator Author

Tweaked the commit message to refer to the correct version number and also pushed a small fixup.

@wpaulino
Copy link
Contributor

wpaulino commented Oct 9, 2025

LGTM after squash

In 601bf4b we started refusing to
load `ChannelMonitor`s which were created prior to LDK 0.0.110 and
which were last updated prior to LDK 0.0.119. While this is likely
fine for nearly all of our users, there's some risk that some (like
me) have ancient un-archived `ChannelMonitor`s.

We do need to start auto-archiving `ChannelMonitor`s but for now we
need some way for such users to at least not fail on startup.
Sadly, ancient `ChannelMonitor`s often don't contain some of the
data we need to accurately calculate `Balance`s, but in cases where
they do, and where there are no claimable `Balance`s, we can be
confident we don't need the `ChannelMonitor`s.

Thus, here, we adapt the `ChannelMonitor` `Readable` implementation
used in the persistence wrappers to detect this case and simply
skip loading such `ChannelMonitor`s. Its not clear if this is
sufficient, but its at least better than the current state of
affairs after 601bf4b.
@TheBlueMatt TheBlueMatt force-pushed the 2025-10-less-panicy-reads branch from 74ec7a6 to b1fc759 Compare October 9, 2025 18:23
@TheBlueMatt
Copy link
Collaborator Author

Squashed without further changes.

@TheBlueMatt
Copy link
Collaborator Author

This is a trivial patch, at least if you take get_claimable_balances at face value. I'm not 100% confident in it for ancient monitors, but presumably ancient monitors don't have any funds remaining to claim. I'm also not sure that this is enough for all our users, but its better than the current state of things. Gonna go ahead and land because its straightforward, but @jkczyz can take a look at it later if he wants.

@TheBlueMatt TheBlueMatt merged commit 3e79de2 into lightningdevkit:main Oct 9, 2025
22 checks passed
Comment on lines +934 to +936
"ChannelMonitor was stale, with no updates since LDK 0.0.118. \
It cannot be read by modern versions of LDK, though also does not contain any funds left to sweep. \
You should manually delete it instead",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth including the monitor_key given this is called indirectly from read_all_channel_monitors_with_updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants