Skip to content

Commit 70a6c55

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 3333677 commit 70a6c55

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lightning/src/ln/channel.rs

+5
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

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

0 commit comments

Comments
 (0)