@@ -176,6 +176,18 @@ pub trait Confirm {
176
176
}
177
177
178
178
/// 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).
183
+ ///
184
+ /// Note that channels should generally *not* be force-closed after a persistence failure.
185
+ /// Force-closing with the latest [`ChannelMonitorUpdate`] applied may result in a transaction
186
+ /// being broadcast which can only be spent by the latest [`ChannelMonitor`]! Thus, if the
187
+ /// latest [`ChannelMonitor`] is not durably persisted anywhere and exists only in memory, naively
188
+ /// calling [`ChannelManager::force_close_broadcasting_latest_txn`] *may result in loss of funds*!
189
+ ///
190
+ /// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn
179
191
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
180
192
pub enum ChannelMonitorUpdateStatus {
181
193
/// The update has been durably persisted and all copies of the relevant [`ChannelMonitor`]
@@ -184,13 +196,13 @@ pub enum ChannelMonitorUpdateStatus {
184
196
/// This includes performing any `fsync()` calls required to ensure the update is guaranteed to
185
197
/// be available on restart even if the application crashes.
186
198
Completed ,
187
- /// Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
188
- /// our state failed, but is expected to succeed at some point in the future) .
199
+ /// Indicates that the update will happen asynchronously in the background or that a transient
200
+ /// failure occurred which is being retried in the background and will eventually complete .
189
201
///
190
- /// Such a failure will "freeze" a channel, preventing us from revoking old states or
191
- /// submitting new commitment transactions to the counterparty. Once the update(s) which failed
192
- /// have been successfully applied , a [`MonitorEvent::Completed`] can be used to restore the
193
- /// channel to an operational state.
202
+ /// This will "freeze" a channel, preventing us from revoking old states or submitting a new
203
+ /// commitment transaction to the counterparty. Once the update(s) which are `InProgress` have
204
+ /// been completed , a [`MonitorEvent::Completed`] can be used to restore the channel to an
205
+ /// operational state.
194
206
///
195
207
/// Even when a channel has been "frozen", updates to the [`ChannelMonitor`] can continue to
196
208
/// occur (e.g. if an inbound HTLC which we forwarded was claimed upstream, resulting in us
@@ -204,6 +216,10 @@ pub enum ChannelMonitorUpdateStatus {
204
216
/// remote location (with local copies persisted immediately), it is anticipated that all
205
217
/// updates will return [`InProgress`] until the remote copies could be updated.
206
218
///
219
+ /// Note that while fully asynchronous persistence of [`ChannelMonitor`] data is generally
220
+ /// reliable, this feature is considered beta, and a handful of edge-cases remain. Until the
221
+ /// remaining cases are fixed, in rare cases, *using this feature may lead to funds loss*.
222
+ ///
207
223
/// [`InProgress`]: ChannelMonitorUpdateStatus::InProgress
208
224
InProgress ,
209
225
}
@@ -212,18 +228,12 @@ pub enum ChannelMonitorUpdateStatus {
212
228
/// blocks are connected and disconnected.
213
229
///
214
230
/// Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
215
- /// responsible for maintaining a set of monitors such that they can be updated accordingly as
216
- /// channel state changes and HTLCs are resolved. See method documentation for specific
217
- /// requirements.
218
- ///
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.
231
+ /// responsible for maintaining a set of monitors such that they can be updated as channel state
232
+ /// changes. On each update, *all copies* of a [`ChannelMonitor`] must be updated and the update
233
+ /// persisted to disk to ensure that the latest [`ChannelMonitor`] state can be reloaded if the
234
+ /// application crashes.
221
235
///
222
- /// If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
223
- /// backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
224
- /// 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
+ /// See method documentation and [`ChannelMonitorUpdateStatus`] for specific requirements.
227
237
pub trait Watch < ChannelSigner : WriteableEcdsaChannelSigner > {
228
238
/// Watches a channel identified by `funding_txo` using `monitor`.
229
239
///
0 commit comments