@@ -176,6 +176,16 @@ 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*!
179
189
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
180
190
pub enum ChannelMonitorUpdateStatus {
181
191
/// The update has been durably persisted and all copies of the relevant [`ChannelMonitor`]
@@ -184,13 +194,13 @@ pub enum ChannelMonitorUpdateStatus {
184
194
/// This includes performing any `fsync()` calls required to ensure the update is guaranteed to
185
195
/// be available on restart even if the application crashes.
186
196
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) .
197
+ /// Used to indicate that the update will happen asynchronously in the background or that a
198
+ /// transient failure occurred which will be retried in the background and eventually complete .
189
199
///
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.
200
+ /// This will "freeze" a channel, preventing us from revoking old states or submitting a new
201
+ /// commitment transaction to the counterparty. Once the update(s) which are `InProgress` have
202
+ /// been completed , a [`MonitorEvent::Completed`] can be used to restore the channel to an
203
+ /// operational state.
194
204
///
195
205
/// Even when a channel has been "frozen", updates to the [`ChannelMonitor`] can continue to
196
206
/// occur (e.g. if an inbound HTLC which we forwarded was claimed upstream, resulting in us
@@ -204,6 +214,10 @@ pub enum ChannelMonitorUpdateStatus {
204
214
/// remote location (with local copies persisted immediately), it is anticipated that all
205
215
/// updates will return [`InProgress`] until the remote copies could be updated.
206
216
///
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
+ ///
207
221
/// [`InProgress`]: ChannelMonitorUpdateStatus::InProgress
208
222
InProgress ,
209
223
}
@@ -212,18 +226,12 @@ pub enum ChannelMonitorUpdateStatus {
212
226
/// blocks are connected and disconnected.
213
227
///
214
228
/// 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.
229
+ /// responsible for maintaining a set of monitors such that they can be updated as channel state
230
+ /// changes. On each update, *all copies* of a [`ChannelMonitor`] must be updated and the update
231
+ /// persisted to disk to ensure that the latest [`ChannelMonitor`] state can be reloaded if the
232
+ /// application crashes.
221
233
///
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.
234
+ /// See method documentation and [`ChannelMonitorUpdateStatus`] for specific requirements.
227
235
pub trait Watch < ChannelSigner : WriteableEcdsaChannelSigner > {
228
236
/// Watches a channel identified by `funding_txo` using `monitor`.
229
237
///
0 commit comments