Skip to content

Commit be5d67e

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 1815edc commit be5d67e

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
@@ -542,6 +542,11 @@ pub(super) struct Channel<Signer: Sign> {
542542
monitor_pending_channel_ready: bool,
543543
monitor_pending_revoke_and_ack: bool,
544544
monitor_pending_commitment_signed: bool,
545+
546+
// TODO: If a channel is drop'd, we don't know whether the `ChannelMonitor` is ultimately
547+
// responsible for some of the HTLCs here or not - we don't know whether the update in question
548+
// completed or not. We currently ignore these fields entirely when force-closing a channel,
549+
// but need to handle this somehow or we run the risk of losing HTLCs!
545550
monitor_pending_forwards: Vec<(PendingHTLCInfo, u64)>,
546551
monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
547552
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
@@ -1483,15 +1483,6 @@ macro_rules! handle_monitor_update_res {
14831483
ChannelMonitorUpdateStatus::PermanentFailure => {
14841484
log_error!($self.logger, "Closing channel {} due to monitor update ChannelMonitorUpdateStatus::PermanentFailure", log_bytes!($chan_id[..]));
14851485
update_maps_on_chan_removal!($self, $chan);
1486-
// TODO: $failed_fails is dropped here, which will cause other channels to hit the
1487-
// chain in a confused state! We need to move them into the ChannelMonitor which
1488-
// will be responsible for failing backwards once things confirm on-chain.
1489-
// It's ok that we drop $failed_forwards here - at this point we'd rather they
1490-
// broadcast HTLC-Timeout and pay the associated fees to get their funds back than
1491-
// us bother trying to claim it just to forward on to another peer. If we're
1492-
// splitting hairs we'd prefer to claim payments that were to us, but we haven't
1493-
// given up the preimage yet, so might as well just wait until the payment is
1494-
// retried, avoiding the on-chain fees.
14951486
let res: Result<(), _> = Err(MsgHandleErrInternal::from_finish_shutdown("ChannelMonitor storage failure".to_owned(), *$chan_id, $chan.get_user_id(),
14961487
$chan.force_shutdown(false), $self.get_channel_update_for_broadcast(&$chan).ok() ));
14971488
(res, true)

0 commit comments

Comments
 (0)