Commit 71a364c
committed
Generate new
`MonitorEvent`s aren't delivered to the `ChannelManager` in a
durable fasion - if the `ChannelManager` fetches the pending
`MonitorEvent`s, then the `ChannelMonitor` gets persisted (i.e. due
to a block update) then the node crashes, prior to persisting the
`ChannelManager` again, the `MonitorEvent` and its effects on the
`ChannelManger` will be lost. This isn't likely in a sync persist
environment, but in an async one this could be an issue.
Note that this is only an issue for closed channels -
`MonitorEvent`s only inform the `ChannelManager` that a channel is
closed (which the `ChannelManager` will learn on startup or when it
next tries to advance the channel state), that
`ChannelMonitorUpdate` writes completed (which the `ChannelManager`
will detect on startup), or that HTLCs resolved on-chain post
closure. Of the three, only the last is problematic to lose prior
to a reload.
In previous commits we ensured that HTLC resolutions which came to
`ChannelManager` via a `MonitorEvent` were replayed on startup if
the `MonitorEvent` was lost. However, in cases where the
`ChannelManager` was so stale that it didn't have the payment state
for an HTLC at all, we only re-add it in cases where
`ChannelMonitor::get_pending_or_resolved_outbound_htlcs` includes
it.
Because constantly re-adding a payment state and then failing it
would generate lots of noise for users on startup (not to mention
risk of confusing stale payment events for the latest state of a
payment when the `PaymentId` has been reused to retry a payment).
Thus, `get_pending_or_resolved_outbound_htlcs` does not include
state for HTLCs which were resolved on chain with a preimage or
HTLCs which were resolved on chain with a timeout after
`ANTI_REORG_DELAY` confirmations.
This critera matches the critera for generating a `MonitorEvent`,
and works great under the assumption that `MonitorEvent`s are
reliably delivered. However, if they are not, and our
`ChannelManager` is lost or substantially old (or, in a future
where we do not persist `ChannelManager` at all), we will not end
up seeing payment resolution events for an HTLC.
Instead, we really want to tell our `ChannelMonitor`s when the
resolution of an HTLC is complete. Note that we don't particularly
care about non-payment HTLCs, as there is no re-hydration of state
to do there - `ChannelManager` load ignores forwarded HTLCs coming
back from `get_pending_or_resolved_outbound_htlcs` as there's
nothing to do - we always attempt to replay the success/failure and
figure out if it mattered based on whether there was still an HTLC
to claim/fail.
Here we begin generating the new
`ChannelMonitorUpdateStep::ReleasePaymentComplete` updates,
updating functional tests for the new `ChannelMonitorUpdate`s where
required.ReleasePaymentComplete monitor updates1 parent 8b637cc commit 71a364c
File tree
9 files changed
+282
-55
lines changed- lightning/src
- chain
- ln
9 files changed
+282
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4119 | 4119 | | |
4120 | 4120 | | |
4121 | 4121 | | |
| 4122 | + | |
4122 | 4123 | | |
4123 | 4124 | | |
4124 | 4125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3870 | 3870 | | |
3871 | 3871 | | |
3872 | 3872 | | |
| 3873 | + | |
3873 | 3874 | | |
3874 | 3875 | | |
3875 | 3876 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1267 | 1267 | | |
1268 | 1268 | | |
1269 | 1269 | | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
1270 | 1276 | | |
1271 | 1277 | | |
1272 | 1278 | | |
| |||
1279 | 1285 | | |
1280 | 1286 | | |
1281 | 1287 | | |
| 1288 | + | |
1282 | 1289 | | |
1283 | 1290 | | |
1284 | 1291 | | |
| |||
8009 | 8016 | | |
8010 | 8017 | | |
8011 | 8018 | | |
8012 | | - | |
8013 | | - | |
8014 | | - | |
8015 | | - | |
8016 | | - | |
| 8019 | + | |
| 8020 | + | |
| 8021 | + | |
| 8022 | + | |
| 8023 | + | |
| 8024 | + | |
| 8025 | + | |
| 8026 | + | |
| 8027 | + | |
| 8028 | + | |
| 8029 | + | |
| 8030 | + | |
| 8031 | + | |
| 8032 | + | |
8017 | 8033 | | |
8018 | 8034 | | |
8019 | 8035 | | |
| |||
8642 | 8658 | | |
8643 | 8659 | | |
8644 | 8660 | | |
| 8661 | + | |
| 8662 | + | |
| 8663 | + | |
| 8664 | + | |
| 8665 | + | |
8645 | 8666 | | |
8646 | 8667 | | |
8647 | 8668 | | |
8648 | 8669 | | |
8649 | | - | |
| 8670 | + | |
8650 | 8671 | | |
8651 | 8672 | | |
8652 | | - | |
| 8673 | + | |
| 8674 | + | |
| 8675 | + | |
| 8676 | + | |
| 8677 | + | |
| 8678 | + | |
| 8679 | + | |
| 8680 | + | |
| 8681 | + | |
| 8682 | + | |
8653 | 8683 | | |
8654 | 8684 | | |
8655 | 8685 | | |
8656 | 8686 | | |
8657 | | - | |
| 8687 | + | |
| 8688 | + | |
8658 | 8689 | | |
8659 | 8690 | | |
8660 | 8691 | | |
| |||
11372 | 11403 | | |
11373 | 11404 | | |
11374 | 11405 | | |
| 11406 | + | |
| 11407 | + | |
| 11408 | + | |
| 11409 | + | |
| 11410 | + | |
| 11411 | + | |
11375 | 11412 | | |
11376 | 11413 | | |
11377 | 11414 | | |
11378 | 11415 | | |
11379 | 11416 | | |
11380 | | - | |
| 11417 | + | |
11381 | 11418 | | |
11382 | 11419 | | |
11383 | 11420 | | |
| |||
12864 | 12901 | | |
12865 | 12902 | | |
12866 | 12903 | | |
| 12904 | + | |
| 12905 | + | |
| 12906 | + | |
12867 | 12907 | | |
12868 | 12908 | | |
| 12909 | + | |
| 12910 | + | |
| 12911 | + | |
| 12912 | + | |
| 12913 | + | |
| 12914 | + | |
| 12915 | + | |
| 12916 | + | |
| 12917 | + | |
| 12918 | + | |
| 12919 | + | |
| 12920 | + | |
| 12921 | + | |
| 12922 | + | |
| 12923 | + | |
| 12924 | + | |
| 12925 | + | |
| 12926 | + | |
| 12927 | + | |
| 12928 | + | |
| 12929 | + | |
| 12930 | + | |
| 12931 | + | |
| 12932 | + | |
| 12933 | + | |
| 12934 | + | |
| 12935 | + | |
| 12936 | + | |
| 12937 | + | |
| 12938 | + | |
| 12939 | + | |
| 12940 | + | |
| 12941 | + | |
| 12942 | + | |
| 12943 | + | |
| 12944 | + | |
| 12945 | + | |
| 12946 | + | |
| 12947 | + | |
| 12948 | + | |
| 12949 | + | |
| 12950 | + | |
| 12951 | + | |
| 12952 | + | |
| 12953 | + | |
| 12954 | + | |
| 12955 | + | |
| 12956 | + | |
| 12957 | + | |
| 12958 | + | |
| 12959 | + | |
12869 | 12960 | | |
12870 | 12961 | | |
12871 | 12962 | | |
| |||
16557 | 16648 | | |
16558 | 16649 | | |
16559 | 16650 | | |
| 16651 | + | |
16560 | 16652 | | |
16561 | 16653 | | |
16562 | 16654 | | |
| |||
16614 | 16706 | | |
16615 | 16707 | | |
16616 | 16708 | | |
| 16709 | + | |
| 16710 | + | |
| 16711 | + | |
| 16712 | + | |
| 16713 | + | |
| 16714 | + | |
| 16715 | + | |
| 16716 | + | |
| 16717 | + | |
16617 | 16718 | | |
16618 | 16719 | | |
16619 | 16720 | | |
| |||
16622 | 16723 | | |
16623 | 16724 | | |
16624 | 16725 | | |
16625 | | - | |
16626 | | - | |
16627 | | - | |
16628 | | - | |
16629 | | - | |
16630 | | - | |
16631 | | - | |
16632 | | - | |
16633 | | - | |
16634 | 16726 | | |
16635 | 16727 | | |
16636 | 16728 | | |
| |||
16642 | 16734 | | |
16643 | 16735 | | |
16644 | 16736 | | |
| 16737 | + | |
| 16738 | + | |
| 16739 | + | |
| 16740 | + | |
| 16741 | + | |
| 16742 | + | |
| 16743 | + | |
| 16744 | + | |
| 16745 | + | |
| 16746 | + | |
| 16747 | + | |
| 16748 | + | |
| 16749 | + | |
| 16750 | + | |
| 16751 | + | |
| 16752 | + | |
| 16753 | + | |
| 16754 | + | |
| 16755 | + | |
| 16756 | + | |
| 16757 | + | |
| 16758 | + | |
| 16759 | + | |
| 16760 | + | |
| 16761 | + | |
| 16762 | + | |
| 16763 | + | |
| 16764 | + | |
| 16765 | + | |
| 16766 | + | |
| 16767 | + | |
| 16768 | + | |
| 16769 | + | |
| 16770 | + | |
| 16771 | + | |
16645 | 16772 | | |
16646 | 16773 | | |
16647 | 16774 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2803 | 2803 | | |
2804 | 2804 | | |
2805 | 2805 | | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
2806 | 2809 | | |
2807 | 2810 | | |
2808 | 2811 | | |
| |||
3052 | 3055 | | |
3053 | 3056 | | |
3054 | 3057 | | |
| 3058 | + | |
3055 | 3059 | | |
3056 | 3060 | | |
3057 | 3061 | | |
| |||
3062 | 3066 | | |
3063 | 3067 | | |
3064 | 3068 | | |
| 3069 | + | |
3065 | 3070 | | |
3066 | 3071 | | |
3067 | 3072 | | |
| |||
3086 | 3091 | | |
3087 | 3092 | | |
3088 | 3093 | | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
3089 | 3098 | | |
3090 | 3099 | | |
3091 | 3100 | | |
| |||
3195 | 3204 | | |
3196 | 3205 | | |
3197 | 3206 | | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
3198 | 3210 | | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
3199 | 3214 | | |
3200 | 3215 | | |
3201 | 3216 | | |
| |||
0 commit comments