AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 44 Bitcoin

Replace dual-sync-async persistence panic with Watch contract

Public commit record

What the developer wrote

Authored by Joost Jager

95/100 · Strong
Replace dual-sync-async persistence panic with Watch contract

Commit 0760f99 ("Disallow dual-sync-async persistence without
restarting") added a panic in non-test builds when a Persist
implementation returns both Completed and InProgress from the same
ChannelManager instance. However, this check runs against the status
that ChainMonitor returns to ChannelManager, not the raw Persist
result. When ChannelMonitor::update_monitor fails (e.g. a
counterparty commitment_signed arrives after a funding spend
confirms), ChainMonitor persists the full monitor successfully but
overrides the return value to InProgress. If the user's Persist impl
only ever returns Completed, this override triggers a false
mode-mismatch panic.

This replaces the panic with a per-channel contract at the Watch
trait level: a Watch implementation must not return Completed for a
channel update while prior InProgress updates are still pending.
Switching from Completed to InProgress is always allowed, but
switching back is impractical because the Watch implementation cannot
observe when ChannelManager has finished processing a
MonitorEvent::Completed. The documentation on
ChannelMonitorUpdateStatus is updated to describe these rules.

The mode tracking and panic checks from 0760f99 are removed and
replaced with a panic that validates the new contract directly on
the in-flight update state. Legacy tests that switch the persister
between modes mid-flight can opt out via
Node::disable_monitor_completeness_assertion().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a bug where the Lightning Dev Kit (LDK) node software could crash with a false alarm panic. The panic was meant to catch incorrect use of two persistence modes, but it could also fire in legitimate situations because it checked an overridden status value rather than the raw result from the user's persistence code. The fix replaces the broad panic with a more precise rule at the Watch trait level and adds a test-only opt-out for legacy tests that intentionally switch modes mid-flight.

Recommended action

This is a defensive bug-fix commit. Users running LDK nodes should upgrade to avoid spurious panics. Developers implementing custom Watch/Persist traits should review the updated ChannelMonitorUpdateStatus documentation to ensure they do not return Completed while prior InProgress updates for the same channel are still pending.

Security signals we found

01

Removal of a non-test panic that could be triggered by legitimate runtime conditions

02

Introduction of a per-channel Watch contract to enforce async persistence correctness

03

Test-only opt-out added for legacy tests that violate the new contract

04

Documentation updated on ChannelMonitorUpdateStatus to clarify allowed mode transitions

Risk score

Why this scored 44/100

Our methodology →
Potential impact 12/30
Exploitability 5/25
Stealth signal 8/15
Affected reach 7/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.