Skip to content

Commit 46c6fb7

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 9802afa commit 46c6fb7

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
@@ -558,6 +558,11 @@ pub(super) struct Channel<Signer: ChannelSigner> {
558558
monitor_pending_channel_ready: bool,
559559
monitor_pending_revoke_and_ack: bool,
560560
monitor_pending_commitment_signed: bool,
561+
562+
// TODO: If a channel is drop'd, we don't know whether the `ChannelMonitor` is ultimately
563+
// responsible for some of the HTLCs here or not - we don't know whether the update in question
564+
// completed or not. We currently ignore these fields entirely when force-closing a channel,
565+
// but need to handle this somehow or we run the risk of losing HTLCs!
561566
monitor_pending_forwards: Vec<(PendingHTLCInfo, u64)>,
562567
monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
563568
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
@@ -1374,15 +1374,6 @@ macro_rules! handle_monitor_update_res {
13741374
ChannelMonitorUpdateStatus::PermanentFailure => {
13751375
log_error!($self.logger, "Closing channel {} due to monitor update ChannelMonitorUpdateStatus::PermanentFailure", log_bytes!($chan_id[..]));
13761376
update_maps_on_chan_removal!($self, $chan);
1377-
// TODO: $failed_fails is dropped here, which will cause other channels to hit the
1378-
// chain in a confused state! We need to move them into the ChannelMonitor which
1379-
// will be responsible for failing backwards once things confirm on-chain.
1380-
// It's ok that we drop $failed_forwards here - at this point we'd rather they
1381-
// broadcast HTLC-Timeout and pay the associated fees to get their funds back than
1382-
// us bother trying to claim it just to forward on to another peer. If we're
1383-
// splitting hairs we'd prefer to claim payments that were to us, but we haven't
1384-
// given up the preimage yet, so might as well just wait until the payment is
1385-
// retried, avoiding the on-chain fees.
13861377
let res: Result<(), _> = Err(MsgHandleErrInternal::from_finish_shutdown("ChannelMonitor storage failure".to_owned(), *$chan_id, $chan.get_user_id(),
13871378
$chan.force_shutdown(false), $self.get_channel_update_for_broadcast(&$chan).ok() ));
13881379
(res, true)

0 commit comments

Comments
 (0)