Commit c7e8f27
committed
Delay RAA-after-next processing until PaymentSent is are handled
In 0ad1f4c we fixed a nasty bug
where a failure to persist a `ChannelManager` faster than a
`ChannelMonitor` could result in the loss of a `PaymentSent` event,
eventually resulting in a `PaymentFailed` instead!
As noted in that commit, there's still some risk, though its been
substantially reduced - if we receive an `update_fulfill_htlc`
message for an outbound payment, and persist the initial removal
`ChannelMonitorUpdate`, then respond with our own
`commitment_signed` + `revoke_and_ack`, followed by receiving our
peer's final `revoke_and_ack`, and then persist the
`ChannelMonitorUpdate` generated from that, all prior to completing
a `ChannelManager` persistence, we'll still forget the HTLC and
eventually trigger a `PaymentFailed` rather than the correct
`PaymentSent`.
Here we fully fix the issue by delaying the final
`ChannelMonitorUpdate` persistence until the `PaymentSent` event
has been processed and document the fact that a spurious
`PaymentFailed` event can still be generated for a sent payment.
The original fix in 0ad1f4c is
still incredibly useful here, allowing us to avoid blocking the
first `ChannelMonitorUpdate` until the event processing completes,
as this would cause us to add event-processing delay in our general
commitment update latency. Instead, we ultimately race the user
handling the `PaymentSent` event with how long it takes our
`revoke_and_ack` + `commitment_signed` to make it to our
counterparty and receive the response `revoke_and_ack`. This should
give the user plenty of time to handle the event before we need to
make progress.
Sadly, because we change our `ChannelMonitorUpdate` semantics, this
change requires a number of test changes, avoiding checking for a
post-RAA `ChannelMonitorUpdate` until after we process a
`PaymentSent` event. Note that this does not apply to payments we
learned the preimage for on-chain - ensuring `PaymentSent` events
from such resolutions will be addressed in a future PR. Thus, tests
which resolve payments on-chain switch to a direct call to the
`expect_payment_sent` function with the claim-expected flag unset.1 parent 57bebe7 commit c7e8f27
File tree
14 files changed
+229
-101
lines changed- lightning-invoice/src
- lightning/src
- chain
- ln
- util
- pending_changelog
14 files changed
+229
-101
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
1104 | | - | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
| 1094 | + | |
1110 | 1095 | | |
1111 | 1096 | | |
1112 | 1097 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
| 791 | + | |
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
| |||
871 | 871 | | |
872 | 872 | | |
873 | 873 | | |
874 | | - | |
| 874 | + | |
875 | 875 | | |
876 | 876 | | |
877 | 877 | | |
| |||
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
887 | | - | |
| 887 | + | |
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
| |||
972 | 972 | | |
973 | 973 | | |
974 | 974 | | |
975 | | - | |
| 975 | + | |
976 | 976 | | |
977 | 977 | | |
978 | 978 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1371 | 1371 | | |
1372 | 1372 | | |
1373 | 1373 | | |
| 1374 | + | |
1374 | 1375 | | |
1375 | 1376 | | |
1376 | 1377 | | |
| |||
1408 | 1409 | | |
1409 | 1410 | | |
1410 | 1411 | | |
1411 | | - | |
| 1412 | + | |
1412 | 1413 | | |
1413 | 1414 | | |
1414 | 1415 | | |
| |||
2140 | 2141 | | |
2141 | 2142 | | |
2142 | 2143 | | |
2143 | | - | |
| 2144 | + | |
2144 | 2145 | | |
2145 | 2146 | | |
2146 | 2147 | | |
| |||
2376 | 2377 | | |
2377 | 2378 | | |
2378 | 2379 | | |
2379 | | - | |
| 2380 | + | |
2380 | 2381 | | |
2381 | 2382 | | |
2382 | 2383 | | |
| |||
2393 | 2394 | | |
2394 | 2395 | | |
2395 | 2396 | | |
2396 | | - | |
| 2397 | + | |
2397 | 2398 | | |
2398 | 2399 | | |
2399 | 2400 | | |
| |||
2493 | 2494 | | |
2494 | 2495 | | |
2495 | 2496 | | |
2496 | | - | |
| 2497 | + | |
2497 | 2498 | | |
2498 | 2499 | | |
2499 | 2500 | | |
| |||
2520 | 2521 | | |
2521 | 2522 | | |
2522 | 2523 | | |
2523 | | - | |
| 2524 | + | |
2524 | 2525 | | |
2525 | 2526 | | |
2526 | 2527 | | |
| |||
2717 | 2718 | | |
2718 | 2719 | | |
2719 | 2720 | | |
2720 | | - | |
| 2721 | + | |
2721 | 2722 | | |
2722 | 2723 | | |
2723 | 2724 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3421 | 3421 | | |
3422 | 3422 | | |
3423 | 3423 | | |
3424 | | - | |
| 3424 | + | |
| 3425 | + | |
3425 | 3426 | | |
3426 | 3427 | | |
3427 | 3428 | | |
| |||
3618 | 3619 | | |
3619 | 3620 | | |
3620 | 3621 | | |
3621 | | - | |
| 3622 | + | |
3622 | 3623 | | |
3623 | 3624 | | |
3624 | 3625 | | |
| |||
3635 | 3636 | | |
3636 | 3637 | | |
3637 | 3638 | | |
3638 | | - | |
| 3639 | + | |
3639 | 3640 | | |
3640 | 3641 | | |
3641 | 3642 | | |
| |||
3654 | 3655 | | |
3655 | 3656 | | |
3656 | 3657 | | |
3657 | | - | |
| 3658 | + | |
3658 | 3659 | | |
3659 | 3660 | | |
3660 | 3661 | | |
| |||
3663 | 3664 | | |
3664 | 3665 | | |
3665 | 3666 | | |
3666 | | - | |
| 3667 | + | |
3667 | 3668 | | |
3668 | 3669 | | |
3669 | 3670 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
918 | 918 | | |
919 | 919 | | |
920 | 920 | | |
| 921 | + | |
921 | 922 | | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
922 | 926 | | |
923 | 927 | | |
924 | 928 | | |
| |||
4180 | 4184 | | |
4181 | 4185 | | |
4182 | 4186 | | |
4183 | | - | |
| 4187 | + | |
4184 | 4188 | | |
4185 | 4189 | | |
4186 | | - | |
| 4190 | + | |
| 4191 | + | |
| 4192 | + | |
| 4193 | + | |
| 4194 | + | |
| 4195 | + | |
| 4196 | + | |
4187 | 4197 | | |
4188 | 4198 | | |
4189 | 4199 | | |
| |||
4194 | 4204 | | |
4195 | 4205 | | |
4196 | 4206 | | |
4197 | | - | |
4198 | | - | |
4199 | | - | |
4200 | 4207 | | |
4201 | 4208 | | |
4202 | 4209 | | |
4203 | | - | |
4204 | | - | |
| 4210 | + | |
| 4211 | + | |
4205 | 4212 | | |
4206 | 4213 | | |
4207 | 4214 | | |
| |||
4889 | 4896 | | |
4890 | 4897 | | |
4891 | 4898 | | |
| 4899 | + | |
4892 | 4900 | | |
4893 | 4901 | | |
4894 | 4902 | | |
| |||
4900 | 4908 | | |
4901 | 4909 | | |
4902 | 4910 | | |
4903 | | - | |
| 4911 | + | |
| 4912 | + | |
| 4913 | + | |
4904 | 4914 | | |
4905 | 4915 | | |
4906 | 4916 | | |
4907 | 4917 | | |
4908 | | - | |
| 4918 | + | |
4909 | 4919 | | |
4910 | 4920 | | |
4911 | 4921 | | |
| |||
5082 | 5092 | | |
5083 | 5093 | | |
5084 | 5094 | | |
5085 | | - | |
| 5095 | + | |
| 5096 | + | |
| 5097 | + | |
| 5098 | + | |
| 5099 | + | |
| 5100 | + | |
| 5101 | + | |
| 5102 | + | |
5086 | 5103 | | |
5087 | 5104 | | |
5088 | 5105 | | |
| |||
5261 | 5278 | | |
5262 | 5279 | | |
5263 | 5280 | | |
5264 | | - | |
| 5281 | + | |
5265 | 5282 | | |
5266 | 5283 | | |
5267 | 5284 | | |
| |||
7842 | 7859 | | |
7843 | 7860 | | |
7844 | 7861 | | |
7845 | | - | |
| 7862 | + | |
| 7863 | + | |
| 7864 | + | |
| 7865 | + | |
| 7866 | + | |
| 7867 | + | |
| 7868 | + | |
7846 | 7869 | | |
7847 | 7870 | | |
7848 | 7871 | | |
| |||
8237 | 8260 | | |
8238 | 8261 | | |
8239 | 8262 | | |
| 8263 | + | |
8240 | 8264 | | |
8241 | 8265 | | |
8242 | 8266 | | |
| |||
8264 | 8288 | | |
8265 | 8289 | | |
8266 | 8290 | | |
8267 | | - | |
| 8291 | + | |
8268 | 8292 | | |
8269 | | - | |
8270 | | - | |
8271 | | - | |
8272 | | - | |
8273 | | - | |
8274 | | - | |
8275 | | - | |
8276 | | - | |
8277 | 8293 | | |
8278 | 8294 | | |
8279 | 8295 | | |
8280 | 8296 | | |
8281 | 8297 | | |
8282 | 8298 | | |
8283 | 8299 | | |
8284 | | - | |
| 8300 | + | |
8285 | 8301 | | |
8286 | 8302 | | |
8287 | 8303 | | |
| |||
0 commit comments