Log info about HTLC failures when we fail them back
authorMatt Corallo <git@bluematt.me>
Tue, 20 Apr 2021 21:35:11 +0000 (21:35 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 21 May 2021 15:10:45 +0000 (15:10 +0000)
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs

index 8db346a9e3fa46782c54cb5becbb531d8fa75657..639ac84495e08f06171f3bfec7f2ed0e83d144cd 100644 (file)
@@ -1332,7 +1332,7 @@ impl<Signer: Sign> Channel<Signer> {
        ///
        /// Note that it is still possible to hit these assertions in case we find a preimage on-chain
        /// but then have a reorg which settles on an HTLC-failure on chain.
-       pub fn get_update_fail_htlc(&mut self, htlc_id_arg: u64, err_packet: msgs::OnionErrorPacket) -> Result<Option<msgs::UpdateFailHTLC>, ChannelError> {
+       pub fn get_update_fail_htlc<L: Deref>(&mut self, htlc_id_arg: u64, err_packet: msgs::OnionErrorPacket, logger: &L) -> Result<Option<msgs::UpdateFailHTLC>, ChannelError> where L::Target: Logger {
                if (self.channel_state & (ChannelState::ChannelFunded as u32)) != (ChannelState::ChannelFunded as u32) {
                        panic!("Was asked to fail an HTLC when channel was not in an operational state");
                }
@@ -1382,6 +1382,7 @@ impl<Signer: Sign> Channel<Signer> {
                                        _ => {}
                                }
                        }
+                       log_trace!(logger, "Placing failure for HTLC ID {} in holding cell", htlc_id_arg);
                        self.holding_cell_htlc_updates.push(HTLCUpdateAwaitingACK::FailHTLC {
                                htlc_id: htlc_id_arg,
                                err_packet,
@@ -1389,6 +1390,7 @@ impl<Signer: Sign> Channel<Signer> {
                        return Ok(None);
                }
 
+               log_trace!(logger, "Failing HTLC ID {} back with a update_fail_htlc message", htlc_id_arg);
                {
                        let htlc = &mut self.pending_inbound_htlcs[pending_idx];
                        htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(err_packet.clone()));
@@ -2382,7 +2384,7 @@ impl<Signer: Sign> Channel<Signer> {
                                                }
                                        },
                                        &HTLCUpdateAwaitingACK::FailHTLC { htlc_id, ref err_packet } => {
-                                               match self.get_update_fail_htlc(htlc_id, err_packet.clone()) {
+                                               match self.get_update_fail_htlc(htlc_id, err_packet.clone(), logger) {
                                                        Ok(update_fail_msg_option) => update_fail_htlcs.push(update_fail_msg_option.unwrap()),
                                                        Err(e) => {
                                                                if let ChannelError::Ignore(_) = e {}
index 9445f518c54a7d82e6d83e09b6c45f19cc3c37fb..9f9820c1dbc083218c66efce32348f7f3c1da075 100644 (file)
@@ -2069,7 +2069,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
                                                                },
                                                                HTLCForwardInfo::FailHTLC { htlc_id, err_packet } => {
                                                                        log_trace!(self.logger, "Failing HTLC back to channel with short id {} after delay", short_chan_id);
-                                                                       match chan.get_mut().get_update_fail_htlc(htlc_id, err_packet) {
+                                                                       match chan.get_mut().get_update_fail_htlc(htlc_id, err_packet, &self.logger) {
                                                                                Err(e) => {
                                                                                        if let ChannelError::Ignore(msg) = e {
                                                                                                log_trace!(self.logger, "Failed to fail backwards to short_id {}: {}", short_chan_id, msg);