Commit 66ad55f
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 5dbb35e commit 66ad55f
File tree
14 files changed
+324
-100
lines changed- lightning-invoice/src
- lightning/src
- chain
- events
- ln
- pending_changelog
14 files changed
+324
-100
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1336 | 1336 | | |
1337 | 1337 | | |
1338 | 1338 | | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
1343 | | - | |
1344 | | - | |
1345 | | - | |
1346 | | - | |
1347 | | - | |
1348 | | - | |
1349 | | - | |
1350 | | - | |
1351 | | - | |
1352 | | - | |
1353 | | - | |
1354 | | - | |
| 1339 | + | |
1355 | 1340 | | |
1356 | 1341 | | |
1357 | 1342 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
829 | | - | |
| 829 | + | |
830 | 830 | | |
831 | 831 | | |
832 | 832 | | |
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
912 | | - | |
| 912 | + | |
913 | 913 | | |
914 | 914 | | |
915 | 915 | | |
| |||
922 | 922 | | |
923 | 923 | | |
924 | 924 | | |
925 | | - | |
| 925 | + | |
926 | 926 | | |
927 | 927 | | |
928 | 928 | | |
| |||
1005 | 1005 | | |
1006 | 1006 | | |
1007 | 1007 | | |
1008 | | - | |
| 1008 | + | |
1009 | 1009 | | |
1010 | 1010 | | |
1011 | 1011 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
475 | 480 | | |
476 | 481 | | |
477 | 482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1380 | 1380 | | |
1381 | 1381 | | |
1382 | 1382 | | |
| 1383 | + | |
1383 | 1384 | | |
1384 | 1385 | | |
1385 | 1386 | | |
| |||
1417 | 1418 | | |
1418 | 1419 | | |
1419 | 1420 | | |
1420 | | - | |
| 1421 | + | |
1421 | 1422 | | |
1422 | 1423 | | |
1423 | 1424 | | |
| |||
2163 | 2164 | | |
2164 | 2165 | | |
2165 | 2166 | | |
2166 | | - | |
| 2167 | + | |
2167 | 2168 | | |
2168 | 2169 | | |
2169 | 2170 | | |
| |||
2401 | 2402 | | |
2402 | 2403 | | |
2403 | 2404 | | |
2404 | | - | |
| 2405 | + | |
2405 | 2406 | | |
2406 | 2407 | | |
2407 | 2408 | | |
| |||
2418 | 2419 | | |
2419 | 2420 | | |
2420 | 2421 | | |
2421 | | - | |
| 2422 | + | |
2422 | 2423 | | |
2423 | 2424 | | |
2424 | 2425 | | |
| |||
2519 | 2520 | | |
2520 | 2521 | | |
2521 | 2522 | | |
2522 | | - | |
| 2523 | + | |
2523 | 2524 | | |
2524 | 2525 | | |
2525 | 2526 | | |
| |||
2546 | 2547 | | |
2547 | 2548 | | |
2548 | 2549 | | |
2549 | | - | |
| 2550 | + | |
2550 | 2551 | | |
2551 | 2552 | | |
2552 | 2553 | | |
| |||
2743 | 2744 | | |
2744 | 2745 | | |
2745 | 2746 | | |
2746 | | - | |
| 2747 | + | |
2747 | 2748 | | |
2748 | 2749 | | |
2749 | 2750 | | |
| |||
2968 | 2969 | | |
2969 | 2970 | | |
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 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3499 | 3499 | | |
3500 | 3500 | | |
3501 | 3501 | | |
3502 | | - | |
| 3502 | + | |
| 3503 | + | |
3503 | 3504 | | |
3504 | 3505 | | |
3505 | 3506 | | |
| |||
3679 | 3680 | | |
3680 | 3681 | | |
3681 | 3682 | | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
3682 | 3687 | | |
3683 | 3688 | | |
3684 | 3689 | | |
| |||
3697 | 3702 | | |
3698 | 3703 | | |
3699 | 3704 | | |
3700 | | - | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
3701 | 3710 | | |
3702 | 3711 | | |
3703 | 3712 | | |
| |||
3708 | 3717 | | |
3709 | 3718 | | |
3710 | 3719 | | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
3711 | 3723 | | |
3712 | | - | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
3713 | 3729 | | |
3714 | 3730 | | |
3715 | 3731 | | |
| |||
3720 | 3736 | | |
3721 | 3737 | | |
3722 | 3738 | | |
3723 | | - | |
3724 | | - | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
3725 | 3744 | | |
3726 | | - | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
3727 | 3750 | | |
3728 | | - | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
3729 | 3754 | | |
3730 | | - | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
3731 | 3760 | | |
3732 | 3761 | | |
3733 | 3762 | | |
| |||
0 commit comments