Commit f809e6c
committed
Re-fail perm-failed HTLCs on startup in case of
`MonitorEvent`s aren't delivered to the `ChannelManager` in a
durable fashion - 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 a previous commit we handled the case of claimed HTLCs by
replaying payment preimages on startup to avoid `MonitorEvent` loss
causing us to miss an HTLC claim. Here we handle the HTLC-failed
case similarly.
Unlike with HTLC claims via preimage, we don't already have replay
logic in `ChannelManager` startup, but its easy enough to add one.
Luckily, we already track when an HTLC reaches permanently-failed
state in `ChannelMonitor` (i.e. it has `ANTI_REORG_DELAY`
confirmations on-chain on the failing transaction), so all we need
to do is add the ability to query for that and fail them on
`ChannelManager` startup.MonitorEvent loss1 parent 9186900 commit f809e6c
File tree
3 files changed
+384
-9
lines changed- lightning/src
- chain
- ln
3 files changed
+384
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3034 | 3034 | | |
3035 | 3035 | | |
3036 | 3036 | | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
| 3072 | + | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
3037 | 3151 | | |
3038 | 3152 | | |
3039 | 3153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15804 | 15804 | | |
15805 | 15805 | | |
15806 | 15806 | | |
15807 | | - | |
| 15807 | + | |
15808 | 15808 | | |
15809 | 15809 | | |
15810 | 15810 | | |
| |||
15836 | 15836 | | |
15837 | 15837 | | |
15838 | 15838 | | |
15839 | | - | |
| 15839 | + | |
| 15840 | + | |
| 15841 | + | |
| 15842 | + | |
15840 | 15843 | | |
15841 | 15844 | | |
15842 | 15845 | | |
| |||
15878 | 15881 | | |
15879 | 15882 | | |
15880 | 15883 | | |
| 15884 | + | |
15881 | 15885 | | |
15882 | 15886 | | |
15883 | 15887 | | |
| |||
16601 | 16605 | | |
16602 | 16606 | | |
16603 | 16607 | | |
| 16608 | + | |
| 16609 | + | |
| 16610 | + | |
| 16611 | + | |
| 16612 | + | |
| 16613 | + | |
| 16614 | + | |
| 16615 | + | |
| 16616 | + | |
| 16617 | + | |
| 16618 | + | |
| 16619 | + | |
| 16620 | + | |
| 16621 | + | |
16604 | 16622 | | |
16605 | 16623 | | |
16606 | 16624 | | |
| |||
17281 | 17299 | | |
17282 | 17300 | | |
17283 | 17301 | | |
17284 | | - | |
17285 | | - | |
17286 | | - | |
17287 | | - | |
17288 | | - | |
17289 | | - | |
17290 | | - | |
| 17302 | + | |
| 17303 | + | |
| 17304 | + | |
| 17305 | + | |
17291 | 17306 | | |
17292 | 17307 | | |
17293 | 17308 | | |
| |||
0 commit comments