Skip to content

Commit 51058bf

Browse files
WIP always use persistent monitor events
1 parent 555e614 commit 51058bf

14 files changed

Lines changed: 168 additions & 3054 deletions

lightning/src/chain/channelmonitor.rs

Lines changed: 26 additions & 278 deletions
Large diffs are not rendered by default.

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 26 additions & 930 deletions
Large diffs are not rendered by default.

lightning/src/ln/channel.rs

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,6 @@ pub(super) struct MonitorRestoreUpdates {
12271227
pub commitment_update: Option<msgs::CommitmentUpdate>,
12281228
pub commitment_order: RAACommitmentOrder,
12291229
pub accepted_htlcs: Vec<(PendingHTLCInfo, u64)>,
1230-
pub failed_htlcs: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
12311230
pub finalized_claimed_htlcs: Vec<(HTLCSource, Option<AttributionData>)>,
12321231
/// Inbound update_adds that are now irrevocably committed to this channel and are ready for the
12331232
/// onion to be processed in order to forward or receive the HTLC.
@@ -8137,65 +8136,6 @@ where
81378136
})
81388137
}
81398138

8140-
/// Returns committed inbound HTLCs that have been forwarded but not yet fully resolved. Useful
8141-
/// when reconstructing the set of pending HTLCs when deserializing the `ChannelManager`.
8142-
pub(super) fn inbound_forwarded_htlcs(
8143-
&self,
8144-
) -> impl Iterator<Item = (PaymentHash, HTLCPreviousHopData, OutboundHop)> + '_ {
8145-
// We don't want to return an HTLC as needing processing if it already has a resolution that's
8146-
// pending in the holding cell.
8147-
let htlc_resolution_in_holding_cell = |id: u64| -> bool {
8148-
self.context.holding_cell_htlc_updates.iter().any(|holding_cell_htlc| {
8149-
match holding_cell_htlc {
8150-
HTLCUpdateAwaitingACK::ClaimHTLC { htlc_id, .. } => *htlc_id == id,
8151-
HTLCUpdateAwaitingACK::FailHTLC { htlc_id, .. } => *htlc_id == id,
8152-
HTLCUpdateAwaitingACK::FailMalformedHTLC { htlc_id, .. } => *htlc_id == id,
8153-
HTLCUpdateAwaitingACK::AddHTLC { .. } => false,
8154-
}
8155-
})
8156-
};
8157-
8158-
let prev_outbound_scid_alias = self.context.outbound_scid_alias();
8159-
let user_channel_id = self.context.get_user_id();
8160-
let channel_id = self.context.channel_id();
8161-
let outpoint = self.funding_outpoint();
8162-
let counterparty_node_id = self.context.get_counterparty_node_id();
8163-
8164-
self.context.pending_inbound_htlcs.iter().filter_map(move |htlc| match &htlc.state {
8165-
InboundHTLCState::Committed {
8166-
update_add_htlc:
8167-
InboundUpdateAdd::Forwarded {
8168-
incoming_packet_shared_secret,
8169-
phantom_shared_secret,
8170-
trampoline_shared_secret,
8171-
blinded_failure,
8172-
outbound_hop,
8173-
},
8174-
} => {
8175-
if htlc_resolution_in_holding_cell(htlc.htlc_id) {
8176-
return None;
8177-
}
8178-
// The reconstructed `HTLCPreviousHopData` is used to fail or claim the HTLC backwards
8179-
// post-restart, if it is missing in the outbound edge.
8180-
let prev_hop_data = HTLCPreviousHopData {
8181-
prev_outbound_scid_alias,
8182-
user_channel_id: Some(user_channel_id),
8183-
htlc_id: htlc.htlc_id,
8184-
incoming_packet_shared_secret: *incoming_packet_shared_secret,
8185-
phantom_shared_secret: *phantom_shared_secret,
8186-
trampoline_shared_secret: *trampoline_shared_secret,
8187-
blinded_failure: *blinded_failure,
8188-
channel_id,
8189-
outpoint,
8190-
counterparty_node_id: Some(counterparty_node_id),
8191-
cltv_expiry: Some(htlc.cltv_expiry),
8192-
};
8193-
Some((htlc.payment_hash, prev_hop_data, *outbound_hop))
8194-
},
8195-
_ => None,
8196-
})
8197-
}
8198-
81998139
/// Useful when reconstructing the set of pending HTLC forwards when deserializing the
82008140
/// `ChannelManager`. We don't want to cache an HTLC as needing to be forwarded if it's already
82018141
/// present in the outbound edge, or else we'll double-forward.
@@ -10034,7 +9974,7 @@ where
100349974
self.context.monitor_pending_commitment_signed = false;
100359975
return MonitorRestoreUpdates {
100369976
raa: None, commitment_update: None, commitment_order: RAACommitmentOrder::RevokeAndACKFirst,
10037-
accepted_htlcs, failed_htlcs, finalized_claimed_htlcs, pending_update_adds,
9977+
accepted_htlcs, finalized_claimed_htlcs, pending_update_adds,
100389978
funding_broadcastable, channel_ready, announcement_sigs, funding_tx_signed,
100399979
channel_ready_order, committed_outbound_htlc_sources
100409980
};
@@ -10065,7 +10005,7 @@ where
1006510005
if commitment_update.is_some() { "a" } else { "no" }, if raa.is_some() { "an" } else { "no" },
1006610006
match commitment_order { RAACommitmentOrder::CommitmentFirst => "commitment", RAACommitmentOrder::RevokeAndACKFirst => "RAA"});
1006710007
MonitorRestoreUpdates {
10068-
raa, commitment_update, commitment_order, accepted_htlcs, failed_htlcs, finalized_claimed_htlcs,
10008+
raa, commitment_update, commitment_order, accepted_htlcs, finalized_claimed_htlcs,
1006910009
pending_update_adds, funding_broadcastable, channel_ready, announcement_sigs, funding_tx_signed,
1007010010
channel_ready_order, committed_outbound_htlc_sources
1007110011
}

0 commit comments

Comments
 (0)