]> git.bitcoin.ninja Git - rust-lightning/commit
Drop completed blocked `ChannelMonitorUpdate`s on startup 2024-04-drop-blocked-completed-updates
authorMatt Corallo <git@bluematt.me>
Thu, 25 Apr 2024 14:30:05 +0000 (14:30 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 25 Apr 2024 15:13:56 +0000 (15:13 +0000)
commitc40504a0fc1f651f79c046b50e20f54746851ae0
tree857a91ab87f41bb7a06a9d8dbadfb9c966b7082f
parent4bab9c8393345805ef36367cdb10a3a569f365fc
Drop completed blocked `ChannelMonitorUpdate`s on startup

If a user receives a payment preimage for an outbound payment, the
`PaymentSent` event will block any eventual RAA
`ChannelMonitorUpdate` from the same channel, assuming it comes in
before the event can be processed. If this blocking kicks in, but
the flow eventually completes with the RAA `ChannelMonitorUpdate`
being persisted, but the `ChannelManager` is only persisted prior
to the event being handled, on startup we'll have a fully
up-to-date `ChannelMonitor` but a pending, blocked
`ChannelMonitorUpdate`. When the `PaymentSent` event is replayed
we'll end up trying to apply a redundant `ChannelMonitorUpdate`
which will panic.

See the test added in this commit for an implementation of this
situation.

In this commit we fix this issue by simply dropping blocked
`ChannelMonitorUpdate`s the same as we do pending ones.
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/monitor_tests.rs