Commit ef0e1a6
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 d97a168 commit ef0e1a6
File tree
14 files changed
+323
-103
lines changed- lightning-invoice/src
- lightning/src
- chain
- events
- ln
- pending_changelog
14 files changed
+323
-103
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 | |
|---|---|---|---|
| |||
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
812 | | - | |
| 812 | + | |
813 | 813 | | |
814 | 814 | | |
815 | 815 | | |
| |||
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
895 | | - | |
| 895 | + | |
896 | 896 | | |
897 | 897 | | |
898 | 898 | | |
| |||
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
908 | | - | |
| 908 | + | |
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
991 | | - | |
| 991 | + | |
992 | 992 | | |
993 | 993 | | |
994 | 994 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
489 | 494 | | |
490 | 495 | | |
491 | 496 | | |
| |||
| 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 | | |
| |||
2443 | 2444 | | |
2444 | 2445 | | |
2445 | 2446 | | |
2446 | | - | |
| 2447 | + | |
2447 | 2448 | | |
2448 | 2449 | | |
2449 | 2450 | | |
| |||
2460 | 2461 | | |
2461 | 2462 | | |
2462 | 2463 | | |
2463 | | - | |
| 2464 | + | |
2464 | 2465 | | |
2465 | 2466 | | |
2466 | 2467 | | |
| |||
2561 | 2562 | | |
2562 | 2563 | | |
2563 | 2564 | | |
2564 | | - | |
| 2565 | + | |
2565 | 2566 | | |
2566 | 2567 | | |
2567 | 2568 | | |
| |||
2588 | 2589 | | |
2589 | 2590 | | |
2590 | 2591 | | |
2591 | | - | |
| 2592 | + | |
2592 | 2593 | | |
2593 | 2594 | | |
2594 | 2595 | | |
| |||
2785 | 2786 | | |
2786 | 2787 | | |
2787 | 2788 | | |
2788 | | - | |
| 2789 | + | |
2789 | 2790 | | |
2790 | 2791 | | |
2791 | 2792 | | |
| |||
3010 | 3011 | | |
3011 | 3012 | | |
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 | + | |
| 3072 | + | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 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