]> 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>
Wed, 13 Nov 2024 01:24:06 +0000 (01:24 +0000)
commit6f023f8f0896545fdac3aa30eb9e0003a58897fe
tree6247d0f8abf6eb4758ff688064aed72ba340d8ec
parentebf1de5bc79097e03f1099b009098bb380fbc81f
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]