]> git.bitcoin.ninja Git - rust-lightning/commit
Req the counterparty node id when claiming against a closed chan
authorMatt Corallo <git@bluematt.me>
Wed, 9 Oct 2024 19:05:18 +0000 (19:05 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 10 Oct 2024 14:32:00 +0000 (14:32 +0000)
commite4ca3ee667818910c3a3e21b69b56a45aa321bd6
treee458016d085bce3082b9bcaf0f125d0d07b9b43f
parentc7b12ffbdcb6d0f8ddfeccf37ec07e4174263d60
Req the counterparty node id when claiming against a closed chan

Currently we store in-flight `ChannelMonitorUpdate`s in the
per-peer structure in `ChannelManager`. This is nice and simple as
we're generally updating it when we're updating other per-peer
data, so we already have the relevant lock(s) and map entries.

Sadly, when we're claiming an HTLC against a closed channel, we
didn't have the `counterparty_node_id` available until it was
added in 0.0.124 (and now we only have it for HTLCs which were
forwarded in 0.0.124). This means we can't look up the per-peer
structure when claiming old HTLCs, making it difficult to track the
new `ChannelMonitorUpdate` as in-flight.

While we could transition the in-flight `ChannelMonitorUpdate`
tracking to a new global map indexed by `OutPoint`, doing so would
result in a major lock which would be highly contended across
channels with different peers.

Instead, as we move towards tracking in-flight
`ChannelMonitorUpdate`s for closed channels we'll keep our existing
storage, leaving only the `counterparty_node_id` issue to contend
with.

Here we simply accept the issue, requiring that
`counterparty_node_id` be available when claiming HTLCs against a
closed channel. On startup, we explicitly check for any forwarded
HTLCs which came from a closed channel where the forward happened
prior to 0.0.124, failing to deserialize, or logging an warning if
the channel is still open (implying things may work out, but panics
may occur if the channel closes prior to HTLC resolution).

While this is a somewhat dissapointing resolution, LDK nodes which
forward HTLCs are generally fairly well-upgraded, so it is not
anticipated to be an issue in practice.
lightning/src/ln/channelmanager.rs
pending_changelog/matt-no-upgrade-skip.txt [new file with mode: 0644]