Commit 6749a07
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 653c482 commit 6749a07
2 files changed
+16
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1737 | 1737 | | |
1738 | 1738 | | |
1739 | 1739 | | |
1740 | | - | |
1741 | | - | |
1742 | | - | |
1743 | | - | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
1744 | 1748 | | |
1745 | 1749 | | |
1746 | 1750 | | |
| |||
3278 | 3282 | | |
3279 | 3283 | | |
3280 | 3284 | | |
3281 | | - | |
| 3285 | + | |
3282 | 3286 | | |
3283 | 3287 | | |
3284 | 3288 | | |
3285 | 3289 | | |
3286 | 3290 | | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
3287 | 3295 | | |
3288 | 3296 | | |
3289 | 3297 | | |
| |||
4227 | 4235 | | |
4228 | 4236 | | |
4229 | 4237 | | |
4230 | | - | |
| 4238 | + | |
4231 | 4239 | | |
4232 | 4240 | | |
4233 | 4241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13364 | 13364 | | |
13365 | 13365 | | |
13366 | 13366 | | |
13367 | | - | |
13368 | | - | |
| 13367 | + | |
| 13368 | + | |
13369 | 13369 | | |
13370 | 13370 | | |
13371 | 13371 | | |
| |||
0 commit comments