Skip to content

Commit b0c312d

Browse files
Matt CoralloTheBlueMatt
authored andcommitted
Attempt to unblock blocked monitor updates on startup
When we make an MPP claim we push RAA blockers for each chanel to ensure we don't allow any single channel to make too much progress until all channels have the preimage durably on disk. We don't have to store those RAA blockers on disk in the ChannelManager as there's no point - if the ChannelManager gets to disk with the RAA blockers it also brought with it the pending ChannelMonitorUpdates that contain the preimages and will now be replayed, ensuring the preimage makes it to all ChannelMonitors. However, just because those RAA blockers dissapear on reload doesn't mean the implications of them does too - if a later ChannelMonitorUpdate was blocked in the channel we don't have logic to unblock it on startup. Here we add such logic, simply attempting to unblock all blocked `ChannelMonitorUpdate`s that existed on startup. Code written by Claude. Fixes #4518
1 parent 416dfad commit b0c312d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

lightning/src/ln/channelmanager.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,11 @@ enum BackgroundEvent {
14731473
channel_id: ChannelId,
14741474
highest_update_id_completed: u64,
14751475
},
1476+
/// A channel had blocked monitor updates waiting on startup. If the updates were blocked on
1477+
/// an MPP claim blocker not written to disk, we may be able to unblock them now.
1478+
///
1479+
/// This event is never written to disk.
1480+
AttemptUnblockMonitorUpdates { counterparty_node_id: PublicKey, channel_id: ChannelId },
14761481
}
14771482

14781483
/// A pointer to a channel that is unblocked when an event is surfaced
@@ -8795,6 +8800,12 @@ impl<
87958800
&counterparty_node_id,
87968801
);
87978802
},
8803+
BackgroundEvent::AttemptUnblockMonitorUpdates {
8804+
counterparty_node_id,
8805+
channel_id,
8806+
} => {
8807+
self.handle_monitor_update_release(counterparty_node_id, channel_id, None);
8808+
},
87988809
}
87998810
}
88008811
NotifyOption::DoPersist
@@ -9751,6 +9762,7 @@ impl<
97519762
BackgroundEvent::MonitorUpdatesComplete {
97529763
channel_id, ..
97539764
} => *channel_id == _prev_channel_id,
9765+
BackgroundEvent::AttemptUnblockMonitorUpdates { .. } => false,
97549766
}
97559767
});
97569768
assert!(channel_closed || matching_bg_event, "{:?}", *background_events);
@@ -19456,6 +19468,14 @@ impl<
1945619468
log_error!(logger, " Please ensure the chain::Watch API requirements are met and file a bug report at https://github.com/lightningdevkit/rust-lightning");
1945719469
return Err(DecodeError::DangerousValue);
1945819470
}
19471+
if funded_chan.blocked_monitor_updates_pending() > 0 {
19472+
pending_background_events.push(
19473+
BackgroundEvent::AttemptUnblockMonitorUpdates {
19474+
counterparty_node_id: *counterparty_id,
19475+
channel_id: *chan_id,
19476+
},
19477+
);
19478+
}
1945919479
} else {
1946019480
// We shouldn't have persisted (or read) any unfunded channel types so none should have been
1946119481
// created in this `channel_by_id` map.

0 commit comments

Comments
 (0)