Skip to content

Commit a68f9fe

Browse files
committed
Move TODO from handle_monitor_update_res into Channel
The TODO mentioned in `handle_monitor_update_res` about how we might forget about HTLCs in case of permanent monitor update failure still applies in spite of all our changes. If a channel is drop'd in general, monitor-pending updates may be lost if the monitor update failed to persist. This was always the case, and is ultimately the general form of the the specific TODO, so we simply leave comments there
1 parent 0266a4c commit a68f9fe

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lightning/src/ln/channel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,11 @@ pub(super) struct Channel<Signer: Sign> {
543543
monitor_pending_channel_ready: bool,
544544
monitor_pending_revoke_and_ack: bool,
545545
monitor_pending_commitment_signed: bool,
546+
547+
// TODO: If a channel is drop'd, we don't know whether the `ChannelMonitor` is ultimately
548+
// responsible for some of the HTLCs here or not - we don't know whether the update in question
549+
// completed or not. We currently ignore these fields entirely when force-closing a channel,
550+
// but need to handle this somehow or we run the risk of losing HTLCs!
546551
monitor_pending_forwards: Vec<(PendingHTLCInfo, u64)>,
547552
monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
548553
monitor_pending_finalized_fulfills: Vec<HTLCSource>,

lightning/src/ln/channelmanager.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,15 +1309,6 @@ macro_rules! handle_monitor_update_res {
13091309
ChannelMonitorUpdateStatus::PermanentFailure => {
13101310
log_error!($self.logger, "Closing channel {} due to monitor update ChannelMonitorUpdateStatus::PermanentFailure", log_bytes!($chan_id[..]));
13111311
update_maps_on_chan_removal!($self, $chan);
1312-
// TODO: $failed_fails is dropped here, which will cause other channels to hit the
1313-
// chain in a confused state! We need to move them into the ChannelMonitor which
1314-
// will be responsible for failing backwards once things confirm on-chain.
1315-
// It's ok that we drop $failed_forwards here - at this point we'd rather they
1316-
// broadcast HTLC-Timeout and pay the associated fees to get their funds back than
1317-
// us bother trying to claim it just to forward on to another peer. If we're
1318-
// splitting hairs we'd prefer to claim payments that were to us, but we haven't
1319-
// given up the preimage yet, so might as well just wait until the payment is
1320-
// retried, avoiding the on-chain fees.
13211312
let res: Result<(), _> = Err(MsgHandleErrInternal::from_finish_shutdown("ChannelMonitor storage failure".to_owned(), *$chan_id, $chan.get_user_id(),
13221313
$chan.force_shutdown(false), $self.get_channel_update_for_broadcast(&$chan).ok() ));
13231314
(res, true)

0 commit comments

Comments
 (0)