Handle async initial ChannelMonitor persistence failing on restart
authorMatt Corallo <git@bluematt.me>
Sat, 20 Aug 2022 01:03:27 +0000 (01:03 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 19 Oct 2022 14:41:30 +0000 (14:41 +0000)
commitbee42b1659c5989516e5d76501b85b9ff970c647
tree11d1828bca5b3ce9d11443e9d9b56a5bc79ae089
parent7544030bb63fee6484fc178bb2ac8f382fe3b5b1
Handle async initial ChannelMonitor persistence failing on restart

If the initial ChannelMonitor persistence is done asynchronously
but does not complete before the node restarts (with a
ChannelManager persistence), we'll start back up with a channel
present but no corresponding ChannelMonitor.

Because the Channel is pending-monitor-update and has not yet
broadcasted its initial funding transaction or sent channel_ready,
this is not a violation of our API contract nor a safety violation.
However, the previous code would refuse to deserialize the
ChannelManager treating it as an API contract violation.

The solution is to test for this case explicitly and drop the
channel entirely as if the peer disconnected before we received
the funding_signed for outbound channels or before sending the
channel_ready for inbound channels.
lightning/src/ln/chanmon_update_fail_tests.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/util/events.rs