Commit d1986df
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 08ae599 commit d1986df
File tree
14 files changed
+293
-101
lines changed- lightning-invoice/src
- lightning/src
- chain
- events
- ln
- pending_changelog
14 files changed
+293
-101
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1175 | 1175 | | |
1176 | 1176 | | |
1177 | 1177 | | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
| 1178 | + | |
1194 | 1179 | | |
1195 | 1180 | | |
1196 | 1181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
810 | | - | |
| 810 | + | |
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
| |||
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
893 | | - | |
| 893 | + | |
894 | 894 | | |
895 | 895 | | |
896 | 896 | | |
| |||
903 | 903 | | |
904 | 904 | | |
905 | 905 | | |
906 | | - | |
| 906 | + | |
907 | 907 | | |
908 | 908 | | |
909 | 909 | | |
| |||
991 | 991 | | |
992 | 992 | | |
993 | 993 | | |
994 | | - | |
| 994 | + | |
995 | 995 | | |
996 | 996 | | |
997 | 997 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
420 | 425 | | |
421 | 426 | | |
422 | 427 | | |
| |||
| 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 | | |
| |||
2144 | 2145 | | |
2145 | 2146 | | |
2146 | 2147 | | |
2147 | | - | |
| 2148 | + | |
2148 | 2149 | | |
2149 | 2150 | | |
2150 | 2151 | | |
| |||
2380 | 2381 | | |
2381 | 2382 | | |
2382 | 2383 | | |
2383 | | - | |
| 2384 | + | |
2384 | 2385 | | |
2385 | 2386 | | |
2386 | 2387 | | |
| |||
2397 | 2398 | | |
2398 | 2399 | | |
2399 | 2400 | | |
2400 | | - | |
| 2401 | + | |
2401 | 2402 | | |
2402 | 2403 | | |
2403 | 2404 | | |
| |||
2497 | 2498 | | |
2498 | 2499 | | |
2499 | 2500 | | |
2500 | | - | |
| 2501 | + | |
2501 | 2502 | | |
2502 | 2503 | | |
2503 | 2504 | | |
| |||
2524 | 2525 | | |
2525 | 2526 | | |
2526 | 2527 | | |
2527 | | - | |
| 2528 | + | |
2528 | 2529 | | |
2529 | 2530 | | |
2530 | 2531 | | |
| |||
2721 | 2722 | | |
2722 | 2723 | | |
2723 | 2724 | | |
2724 | | - | |
| 2725 | + | |
2725 | 2726 | | |
2726 | 2727 | | |
2727 | 2728 | | |
| |||
2946 | 2947 | | |
2947 | 2948 | | |
2948 | 2949 | | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3438 | 3438 | | |
3439 | 3439 | | |
3440 | 3440 | | |
3441 | | - | |
| 3441 | + | |
| 3442 | + | |
3442 | 3443 | | |
3443 | 3444 | | |
3444 | 3445 | | |
| |||
3635 | 3636 | | |
3636 | 3637 | | |
3637 | 3638 | | |
3638 | | - | |
| 3639 | + | |
3639 | 3640 | | |
3640 | 3641 | | |
3641 | 3642 | | |
| |||
3652 | 3653 | | |
3653 | 3654 | | |
3654 | 3655 | | |
3655 | | - | |
| 3656 | + | |
3656 | 3657 | | |
3657 | 3658 | | |
3658 | 3659 | | |
| |||
3671 | 3672 | | |
3672 | 3673 | | |
3673 | 3674 | | |
3674 | | - | |
| 3675 | + | |
3675 | 3676 | | |
3676 | 3677 | | |
3677 | 3678 | | |
| |||
3680 | 3681 | | |
3681 | 3682 | | |
3682 | 3683 | | |
3683 | | - | |
| 3684 | + | |
3684 | 3685 | | |
3685 | 3686 | | |
3686 | 3687 | | |
| |||
0 commit comments