Uh oh!
There was an error while loading. Please reload this page.
Move ChannelMonitorUpdateStatus mode check from ChannelManager to ChainMonitor - #4435
Closed
joostjager wants to merge 1 commit into
Closed
Move ChannelMonitorUpdateStatus mode check from ChannelManager to ChainMonitor#4435joostjager wants to merge 1 commit into
joostjager wants to merge 1 commit into
Conversation
ldk-reviews-bot
commented
Feb 23, 2026
👋 Hi! I see this is a draft PR. |
joostjagerforce-pushed
the
fix-chainmonitor-mode-violation
branch
from
February 23, 2026 11:39
79be78c to
abe9d13Compare…inMonitor When `ChannelMonitor::update_monitor` fails (e.g. a counterparty `commitment_signed` arrives after funding was spent), `ChainMonitor` persists the full monitor successfully but overrides the return value to `InProgress`. If the user's `Persist` impl only returns `Completed`, this causes `ChannelManager::handle_monitor_update_res` to panic on the mode mismatch. The root cause is that the mode check lived in `ChannelManager`, which sees the *post-override* status. By moving the check to `ChainMonitor` and running it against the *raw* `Persist` result (before the `update_res.is_err()` override), we validate only the user's persister behavior. ChainMonitor's internal override to `InProgress` for failed monitor updates no longer triggers a false mode violation. Also fix the `chanmon_consistency` fuzzer's `reload_node`, which hardcoded the persister to `Completed` before calling `watch_channel`, then switched to the node's actual mode afterward. With the mode check now in `ChainMonitor`, this caused a false violation. Set the persister to the correct mode before calling `watch_channel` so `ChainMonitor` sees a consistent persist mode from the start. Additionally, mirror pending monitor updates into `TestChainMonitor.latest_monitors` after `watch_channel` returns `InProgress`. The real `ChainMonitor` tracks the initial `update_id` as pending, but `TestChainMonitor` was unaware of it since `watch_channel` is called on the real `ChainMonitor` directly (bypassing `TestChainMonitor`). Without this, `complete_all_monitor_updates` could never drain and complete the update, leaving reloaded node channels permanently stuck. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
joostjagerforce-pushed
the
fix-chainmonitor-mode-violation
branch
from
February 23, 2026 14:00
abe9d13 to
7e0a4dcCompareCodecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #4435 +/- ##
==========================================
- Coverage 85.86% 85.86% -0.01%
==========================================
Files 159 159 Lines 104302 104308 +6 Branches 104302 104308 +6 ==========================================
+ Hits 89558 89563 +5 + Misses 12246 12242 -4 - Partials 2498 2503 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
joostjager
commented
Feb 24, 2026
ContributorAuthor
Closing in favor of alternative fix: #4436 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
ChannelMonitor::update_monitorfails (e.g. a counterpartycommitment_signedarrives after funding was spent),ChainMonitorpersists the full monitor successfully but overrides the return value toInProgress. If the user'sPersistimpl only returnsCompleted, this causesChannelManager::handle_monitor_update_resto panic on the mode mismatch.The root cause is that the mode check lived in
ChannelManager, which sees the post-override status. By moving the check toChainMonitorand running it against the rawPersistresult (before theupdate_res.is_err()override), we validate only the user's persister behavior. ChainMonitor's internal override toInProgressfor failed monitor updates no longer triggers a false mode violation.