Skip to content

Use MonitorUpdatingPersister for ChainMonitor#11

Merged
amackillop merged 2 commits into
amackillop/probingfrom
amackillop/blt-380/use-mup
Oct 17, 2025
Merged

Use MonitorUpdatingPersister for ChainMonitor#11
amackillop merged 2 commits into
amackillop/probingfrom
amackillop/blt-380/use-mup

Conversation

@amackillop

Copy link
Copy Markdown

Replace direct KVStore usage with MonitorUpdatingPersister to enable incremental channel monitor updates instead of rewriting the entire monitor on each update. This improves I/O efficiency by writing only differential updates (typically hundreds of bytes) rather than rewriting the full monitor (potentially tens of megabytes) for each state change. The existing behaviour tends to make channel updates very slow after a few thousand updates.

The persister is configured with a maximum of 100 pending updates before consolidating to a full monitor write. This balances I/O bandwidth savings against storage complexity.

Note: MonitorUpdatingPersister format is not backward-compatible with the standard persister due to the sentinel byte sequence prepended to monitors.

Replace direct KVStore usage with MonitorUpdatingPersister to enable
incremental channel monitor updates instead of rewriting the entire
monitor on each update. This improves I/O efficiency by writing only
differential updates (typically hundreds of bytes) rather than
rewriting the full monitor (potentially tens of megabytes) for each
state change. The existing behaviour tends to make channel updates
very slow after a few thousand updates.

The persister is configured with a maximum of 100 pending updates
before consolidating to a full monitor write. This balances I/O
bandwidth savings against storage complexity.

Note: MonitorUpdatingPersister format is not backward-compatible
with the standard persister due to the sentinel byte sequence
prepended to monitors.
Use MonitorUpdatingPersister's read_all_channel_monitors_with_updates()
method instead of the standard read_channel_monitors() function.

The MonitorUpdatingPersister writes monitors with a special sentinel
byte sequence (MONITOR_UPDATING_PERSISTER_PREPEND_SENTINEL) that makes
them incompatible with the standard reading function. Only the
persister's own reading method can properly deserialize monitors that
may have unapplied updates.

This fixes the "Failed to read ChannelMonitor" InvalidData error that
occurs when attempting to load existing channel state.

@wvanlint wvanlint left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You might also need to call cleanup_stale_updates sometimes on startup to avoid accumulating abandoned updates. We're running with a maximum_pending_updates of 1000 in production now, but 100 sounds good to me as well.

Interestingly, I was looking for the previous lazy delete KVStore interface, but it looks like those changed to new async interfaces in LDK 0.2.

Is it also possible for CI to succeed here?

@amackillop

amackillop commented Oct 16, 2025

Copy link
Copy Markdown
Author

Is it also possible for CI to succeed here?

CI got borked a long time ago when we did the custom logging thing but I would like to get it working again. For now I rely on the Prober CI.

I did just take a look since the custom logging stuff was reverted once it was available natively in LDK node. Looks like it is complaining about the intentional unreachable code should be easy to fix. I left it unreachable instead of deleting or commenting out to minimize conflicts

@amackillop amackillop merged commit c590c4d into amackillop/probing Oct 17, 2025
0 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants