Skip to content

Commit 6494cd4

Browse files
committed
Update ChannelMonitorUpdateStatus documentation with async support
Since we now (almost) support async monitor update persistence, the documentation on `ChannelMonitorUpdateStatus` can be updated to no longer suggest users must keep a local copy that persists before returning. However, because there are still a few remaining issues, we note that async support is currently beta and explicily warn of potential for funds-loss. Fixes #1684
1 parent 2b121df commit 6494cd4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lightning/src/chain/mod.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ pub trait Confirm {
176176
}
177177

178178
/// An enum representing the status of a channel monitor update persistence.
179+
///
180+
/// Note that there is no error variant - any failure to persist a [`ChannelMonitor`] should be
181+
/// retried indefinitely, the node shut down (as if we cannot update stored data we can't do much
182+
/// of anything useful), or the channel force-close using
183+
/// [`ChannelManager::force_close_broadcasting_latest_txn`].
184+
///
185+
/// Note that in the last case, force-closing with the latest [`ChannelMonitorUpdate`] applied may
186+
/// result in a transaction which can only be spent by the latest [`ChannelMonitor`]. Thus, if the
187+
/// latest [`ChannelMonitor`] is not durably persisted anywhere, naively calling
188+
/// [`ChannelManager::force_close_broadcasting_latest_txn`] *may result in loss of funds*!
179189
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
180190
pub enum ChannelMonitorUpdateStatus {
181191
/// The update has been durably persisted and all copies of the relevant [`ChannelMonitor`]
@@ -204,6 +214,10 @@ pub enum ChannelMonitorUpdateStatus {
204214
/// remote location (with local copies persisted immediately), it is anticipated that all
205215
/// updates will return [`InProgress`] until the remote copies could be updated.
206216
///
217+
/// Note that while fully asynchronous persistence of [`ChannelMonitor`] data is generally
218+
/// reliable, this feature is considered beta, and a handful of edge-cases remain. Until the
219+
/// remaining cases are fixed, in rare cases, *using this feature may lead to funds loss*.
220+
///
207221
/// [`InProgress`]: ChannelMonitorUpdateStatus::InProgress
208222
InProgress,
209223
}
@@ -216,14 +230,10 @@ pub enum ChannelMonitorUpdateStatus {
216230
/// channel state changes and HTLCs are resolved. See method documentation for specific
217231
/// requirements.
218232
///
219-
/// Implementations **must** ensure that updates are successfully applied and persisted upon method
220-
/// completion. If an update will not succeed, then it must immediately shut down.
221-
///
222233
/// If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
223234
/// backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
224235
/// could result in a revoked transaction being broadcast, allowing the counterparty to claim all
225-
/// funds in the channel. See [`ChannelMonitorUpdateStatus`] for more details about how to handle
226-
/// multiple instances.
236+
/// funds in the channel.
227237
pub trait Watch<ChannelSigner: WriteableEcdsaChannelSigner> {
228238
/// Watches a channel identified by `funding_txo` using `monitor`.
229239
///

0 commit comments

Comments
 (0)