Commit efde36c
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 880d88e commit efde36c
File tree
14 files changed
+326
-104
lines changed- lightning-invoice/src
- lightning/src
- chain
- events
- ln
- pending_changelog
14 files changed
+326
-104
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 | |
|---|---|---|---|
| |||
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
831 | | - | |
| 831 | + | |
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
| |||
911 | 911 | | |
912 | 912 | | |
913 | 913 | | |
914 | | - | |
| 914 | + | |
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
| |||
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
927 | | - | |
| 927 | + | |
928 | 928 | | |
929 | 929 | | |
930 | 930 | | |
| |||
1013 | 1013 | | |
1014 | 1014 | | |
1015 | 1015 | | |
1016 | | - | |
| 1016 | + | |
1017 | 1017 | | |
1018 | 1018 | | |
1019 | 1019 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
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 | |
|---|---|---|---|
| |||
3451 | 3451 | | |
3452 | 3452 | | |
3453 | 3453 | | |
3454 | | - | |
| 3454 | + | |
| 3455 | + | |
3455 | 3456 | | |
3456 | 3457 | | |
3457 | 3458 | | |
| |||
3630 | 3631 | | |
3631 | 3632 | | |
3632 | 3633 | | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
3633 | 3638 | | |
3634 | 3639 | | |
3635 | 3640 | | |
| |||
3648 | 3653 | | |
3649 | 3654 | | |
3650 | 3655 | | |
3651 | | - | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
3652 | 3661 | | |
3653 | 3662 | | |
3654 | 3663 | | |
| |||
3659 | 3668 | | |
3660 | 3669 | | |
3661 | 3670 | | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
3662 | 3674 | | |
3663 | | - | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
3664 | 3680 | | |
3665 | 3681 | | |
3666 | 3682 | | |
| |||
3671 | 3687 | | |
3672 | 3688 | | |
3673 | 3689 | | |
3674 | | - | |
3675 | | - | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
3676 | 3695 | | |
3677 | | - | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
3678 | 3701 | | |
3679 | | - | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
3680 | 3705 | | |
3681 | | - | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
3682 | 3711 | | |
3683 | 3712 | | |
3684 | 3713 | | |
| |||
0 commit comments