Commit 36b5385
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 87bcf91 commit 36b5385
File tree
14 files changed
+324
-104
lines changed- lightning-invoice/src
- lightning/src
- chain
- events
- ln
- pending_changelog
14 files changed
+324
-104
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1160 | 1160 | | |
1161 | 1161 | | |
1162 | 1162 | | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
| 1163 | + | |
1179 | 1164 | | |
1180 | 1165 | | |
1181 | 1166 | | |
| |||
| 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 | | |
| |||
992 | 992 | | |
993 | 993 | | |
994 | 994 | | |
995 | | - | |
| 995 | + | |
996 | 996 | | |
997 | 997 | | |
998 | 998 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
467 | 472 | | |
468 | 473 | | |
469 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1390 | 1390 | | |
1391 | 1391 | | |
1392 | 1392 | | |
| 1393 | + | |
1393 | 1394 | | |
1394 | 1395 | | |
1395 | 1396 | | |
| |||
1427 | 1428 | | |
1428 | 1429 | | |
1429 | 1430 | | |
1430 | | - | |
| 1431 | + | |
1431 | 1432 | | |
1432 | 1433 | | |
1433 | 1434 | | |
| |||
2173 | 2174 | | |
2174 | 2175 | | |
2175 | 2176 | | |
2176 | | - | |
| 2177 | + | |
2177 | 2178 | | |
2178 | 2179 | | |
2179 | 2180 | | |
| |||
2411 | 2412 | | |
2412 | 2413 | | |
2413 | 2414 | | |
2414 | | - | |
| 2415 | + | |
2415 | 2416 | | |
2416 | 2417 | | |
2417 | 2418 | | |
| |||
2428 | 2429 | | |
2429 | 2430 | | |
2430 | 2431 | | |
2431 | | - | |
| 2432 | + | |
2432 | 2433 | | |
2433 | 2434 | | |
2434 | 2435 | | |
| |||
2529 | 2530 | | |
2530 | 2531 | | |
2531 | 2532 | | |
2532 | | - | |
| 2533 | + | |
2533 | 2534 | | |
2534 | 2535 | | |
2535 | 2536 | | |
| |||
2556 | 2557 | | |
2557 | 2558 | | |
2558 | 2559 | | |
2559 | | - | |
| 2560 | + | |
2560 | 2561 | | |
2561 | 2562 | | |
2562 | 2563 | | |
| |||
2753 | 2754 | | |
2754 | 2755 | | |
2755 | 2756 | | |
2756 | | - | |
| 2757 | + | |
2757 | 2758 | | |
2758 | 2759 | | |
2759 | 2760 | | |
| |||
2978 | 2979 | | |
2979 | 2980 | | |
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 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3449 | 3449 | | |
3450 | 3450 | | |
3451 | 3451 | | |
3452 | | - | |
| 3452 | + | |
| 3453 | + | |
3453 | 3454 | | |
3454 | 3455 | | |
3455 | 3456 | | |
| |||
3628 | 3629 | | |
3629 | 3630 | | |
3630 | 3631 | | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
3631 | 3636 | | |
3632 | 3637 | | |
3633 | 3638 | | |
| |||
3646 | 3651 | | |
3647 | 3652 | | |
3648 | 3653 | | |
3649 | | - | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
3650 | 3659 | | |
3651 | 3660 | | |
3652 | 3661 | | |
| |||
3657 | 3666 | | |
3658 | 3667 | | |
3659 | 3668 | | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
3660 | 3672 | | |
3661 | | - | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
3662 | 3678 | | |
3663 | 3679 | | |
3664 | 3680 | | |
| |||
3669 | 3685 | | |
3670 | 3686 | | |
3671 | 3687 | | |
3672 | | - | |
3673 | | - | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
3674 | 3693 | | |
3675 | | - | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
3676 | 3699 | | |
3677 | | - | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
3678 | 3703 | | |
3679 | | - | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
3680 | 3709 | | |
3681 | 3710 | | |
3682 | 3711 | | |
| |||
0 commit comments