Commit cd2e169
committed
Only generate a post-close lock ChannelMonitorUpdate if we need one
If a channel is closed on startup, but we find that the
`ChannelMonitor` isn't aware of this, we generate a
`ChannelMonitorUpdate` containing a
`ChannelMonitorUpdateStep::ChannelForceClosed`. This ensures that
the `ChannelMonitor` will not accept any future updates in case we
somehow load up a previous `ChannelManager` (though that really
shouldn't happen).
Previously, we'd apply this update only if we detected that the
`ChannelManager` had not yet informed the `ChannelMonitor` about
the channel's closure, even if the `ChannelMonitor` would already
refuse any other updates because it detected a channel closure
on chain.
This doesn't accomplish anything but an extra I/O write, so we
remove it here.
Further, a user reported that, in regtest, they could:
(a) coop close a channel (not generating a `ChannelMonitorUpdate`)
(b) wait just under 4032 blocks (on regtest, taking only a day)
(c) restart the `ChannelManager`, generating the above update
(d) connect a block or two (during the startup sequence), making
the `ChannelMonitor` eligible for archival,
(d) restart the `ChannelManager` again (without applying the
update from (c), but after having archived the
`ChannelMonitor`, leading to a failure to deserialize as we
have a pending `ChannelMonitorUpdate` for a `ChannelMonitor`
that has been archived.
Though it seems very unlikely this would happen on mainnet, it is
theoretically possible.1 parent 489d70a commit cd2e169
2 files changed
+16
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1774 | 1774 | | |
1775 | 1775 | | |
1776 | 1776 | | |
1777 | | - | |
1778 | | - | |
1779 | | - | |
1780 | | - | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
1781 | 1785 | | |
1782 | 1786 | | |
1783 | 1787 | | |
| |||
3315 | 3319 | | |
3316 | 3320 | | |
3317 | 3321 | | |
3318 | | - | |
| 3322 | + | |
3319 | 3323 | | |
3320 | 3324 | | |
3321 | 3325 | | |
3322 | 3326 | | |
3323 | 3327 | | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
3324 | 3332 | | |
3325 | 3333 | | |
3326 | 3334 | | |
| |||
4268 | 4276 | | |
4269 | 4277 | | |
4270 | 4278 | | |
4271 | | - | |
| 4279 | + | |
4272 | 4280 | | |
4273 | 4281 | | |
4274 | 4282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13781 | 13781 | | |
13782 | 13782 | | |
13783 | 13783 | | |
13784 | | - | |
13785 | | - | |
| 13784 | + | |
| 13785 | + | |
13786 | 13786 | | |
13787 | 13787 | | |
13788 | 13788 | | |
| |||
0 commit comments