Commit b479969
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 5259cd5 commit b479969
File tree
14 files changed
+322
-102
lines changed- lightning-invoice/src
- lightning/src
- chain
- events
- ln
- pending_changelog
14 files changed
+322
-102
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1364 | 1364 | | |
1365 | 1365 | | |
1366 | 1366 | | |
1367 | | - | |
1368 | | - | |
1369 | | - | |
1370 | | - | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
1375 | | - | |
1376 | | - | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
| 1367 | + | |
1383 | 1368 | | |
1384 | 1369 | | |
1385 | 1370 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
473 | 478 | | |
474 | 479 | | |
475 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1400 | 1400 | | |
1401 | 1401 | | |
1402 | 1402 | | |
| 1403 | + | |
1403 | 1404 | | |
1404 | 1405 | | |
1405 | 1406 | | |
| |||
1437 | 1438 | | |
1438 | 1439 | | |
1439 | 1440 | | |
1440 | | - | |
| 1441 | + | |
1441 | 1442 | | |
1442 | 1443 | | |
1443 | 1444 | | |
| |||
2191 | 2192 | | |
2192 | 2193 | | |
2193 | 2194 | | |
2194 | | - | |
| 2195 | + | |
2195 | 2196 | | |
2196 | 2197 | | |
2197 | 2198 | | |
| |||
2437 | 2438 | | |
2438 | 2439 | | |
2439 | 2440 | | |
2440 | | - | |
| 2441 | + | |
2441 | 2442 | | |
2442 | 2443 | | |
2443 | 2444 | | |
| |||
2454 | 2455 | | |
2455 | 2456 | | |
2456 | 2457 | | |
2457 | | - | |
| 2458 | + | |
2458 | 2459 | | |
2459 | 2460 | | |
2460 | 2461 | | |
| |||
2555 | 2556 | | |
2556 | 2557 | | |
2557 | 2558 | | |
2558 | | - | |
| 2559 | + | |
2559 | 2560 | | |
2560 | 2561 | | |
2561 | 2562 | | |
| |||
2582 | 2583 | | |
2583 | 2584 | | |
2584 | 2585 | | |
2585 | | - | |
| 2586 | + | |
2586 | 2587 | | |
2587 | 2588 | | |
2588 | 2589 | | |
| |||
2779 | 2780 | | |
2780 | 2781 | | |
2781 | 2782 | | |
2782 | | - | |
| 2783 | + | |
2783 | 2784 | | |
2784 | 2785 | | |
2785 | 2786 | | |
| |||
3004 | 3005 | | |
3005 | 3006 | | |
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 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3124 | 3124 | | |
3125 | 3125 | | |
3126 | 3126 | | |
3127 | | - | |
| 3127 | + | |
| 3128 | + | |
3128 | 3129 | | |
3129 | 3130 | | |
3130 | 3131 | | |
| |||
3304 | 3305 | | |
3305 | 3306 | | |
3306 | 3307 | | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
3307 | 3324 | | |
3308 | 3325 | | |
3309 | 3326 | | |
| |||
3322 | 3339 | | |
3323 | 3340 | | |
3324 | 3341 | | |
3325 | | - | |
| 3342 | + | |
3326 | 3343 | | |
3327 | 3344 | | |
3328 | 3345 | | |
| |||
3332 | 3349 | | |
3333 | 3350 | | |
3334 | 3351 | | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
3335 | 3355 | | |
3336 | | - | |
| 3356 | + | |
3337 | 3357 | | |
3338 | 3358 | | |
3339 | 3359 | | |
| |||
3344 | 3364 | | |
3345 | 3365 | | |
3346 | 3366 | | |
3347 | | - | |
3348 | | - | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
3349 | 3372 | | |
3350 | | - | |
| 3373 | + | |
3351 | 3374 | | |
3352 | | - | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
3353 | 3378 | | |
3354 | | - | |
| 3379 | + | |
3355 | 3380 | | |
3356 | 3381 | | |
3357 | 3382 | | |
| |||
0 commit comments