Commit 6789818
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 92fd015 commit 6789818
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 | |
|---|---|---|---|
| |||
3409 | 3409 | | |
3410 | 3410 | | |
3411 | 3411 | | |
3412 | | - | |
| 3412 | + | |
| 3413 | + | |
3413 | 3414 | | |
3414 | 3415 | | |
3415 | 3416 | | |
| |||
3606 | 3607 | | |
3607 | 3608 | | |
3608 | 3609 | | |
3609 | | - | |
| 3610 | + | |
3610 | 3611 | | |
3611 | 3612 | | |
3612 | 3613 | | |
| |||
3623 | 3624 | | |
3624 | 3625 | | |
3625 | 3626 | | |
3626 | | - | |
| 3627 | + | |
3627 | 3628 | | |
3628 | 3629 | | |
3629 | 3630 | | |
| |||
3642 | 3643 | | |
3643 | 3644 | | |
3644 | 3645 | | |
3645 | | - | |
| 3646 | + | |
3646 | 3647 | | |
3647 | 3648 | | |
3648 | 3649 | | |
| |||
3651 | 3652 | | |
3652 | 3653 | | |
3653 | 3654 | | |
3654 | | - | |
| 3655 | + | |
3655 | 3656 | | |
3656 | 3657 | | |
3657 | 3658 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
| 866 | + | |
866 | 867 | | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
867 | 871 | | |
868 | 872 | | |
869 | 873 | | |
| |||
4121 | 4125 | | |
4122 | 4126 | | |
4123 | 4127 | | |
4124 | | - | |
| 4128 | + | |
4125 | 4129 | | |
4126 | 4130 | | |
4127 | | - | |
| 4131 | + | |
| 4132 | + | |
| 4133 | + | |
| 4134 | + | |
| 4135 | + | |
| 4136 | + | |
| 4137 | + | |
4128 | 4138 | | |
4129 | 4139 | | |
4130 | 4140 | | |
| |||
4135 | 4145 | | |
4136 | 4146 | | |
4137 | 4147 | | |
4138 | | - | |
4139 | | - | |
4140 | | - | |
4141 | 4148 | | |
4142 | 4149 | | |
4143 | 4150 | | |
4144 | | - | |
4145 | | - | |
| 4151 | + | |
| 4152 | + | |
4146 | 4153 | | |
4147 | 4154 | | |
4148 | 4155 | | |
| |||
4830 | 4837 | | |
4831 | 4838 | | |
4832 | 4839 | | |
| 4840 | + | |
4833 | 4841 | | |
4834 | 4842 | | |
4835 | 4843 | | |
| |||
4841 | 4849 | | |
4842 | 4850 | | |
4843 | 4851 | | |
4844 | | - | |
| 4852 | + | |
| 4853 | + | |
| 4854 | + | |
4845 | 4855 | | |
4846 | 4856 | | |
4847 | 4857 | | |
4848 | 4858 | | |
4849 | | - | |
| 4859 | + | |
4850 | 4860 | | |
4851 | 4861 | | |
4852 | 4862 | | |
| |||
5023 | 5033 | | |
5024 | 5034 | | |
5025 | 5035 | | |
5026 | | - | |
| 5036 | + | |
| 5037 | + | |
| 5038 | + | |
| 5039 | + | |
| 5040 | + | |
| 5041 | + | |
| 5042 | + | |
| 5043 | + | |
5027 | 5044 | | |
5028 | 5045 | | |
5029 | 5046 | | |
| |||
5202 | 5219 | | |
5203 | 5220 | | |
5204 | 5221 | | |
5205 | | - | |
| 5222 | + | |
5206 | 5223 | | |
5207 | 5224 | | |
5208 | 5225 | | |
| |||
7777 | 7794 | | |
7778 | 7795 | | |
7779 | 7796 | | |
7780 | | - | |
| 7797 | + | |
| 7798 | + | |
| 7799 | + | |
| 7800 | + | |
| 7801 | + | |
| 7802 | + | |
| 7803 | + | |
7781 | 7804 | | |
7782 | 7805 | | |
7783 | 7806 | | |
| |||
8172 | 8195 | | |
8173 | 8196 | | |
8174 | 8197 | | |
| 8198 | + | |
8175 | 8199 | | |
8176 | 8200 | | |
8177 | 8201 | | |
| |||
8199 | 8223 | | |
8200 | 8224 | | |
8201 | 8225 | | |
8202 | | - | |
| 8226 | + | |
8203 | 8227 | | |
8204 | | - | |
8205 | | - | |
8206 | | - | |
8207 | | - | |
8208 | | - | |
8209 | | - | |
8210 | | - | |
8211 | | - | |
8212 | 8228 | | |
8213 | 8229 | | |
8214 | 8230 | | |
8215 | 8231 | | |
8216 | 8232 | | |
8217 | 8233 | | |
8218 | 8234 | | |
8219 | | - | |
| 8235 | + | |
8220 | 8236 | | |
8221 | 8237 | | |
8222 | 8238 | | |
| |||
0 commit comments