Commit 86849e4
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 9f5b70e commit 86849e4
File tree
14 files changed
+326
-105
lines changed- lightning-invoice/src
- lightning/src
- chain
- events
- ln
- pending_changelog
14 files changed
+326
-105
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1365 | 1365 | | |
1366 | 1366 | | |
1367 | 1367 | | |
1368 | | - | |
1369 | | - | |
1370 | | - | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
1375 | | - | |
1376 | | - | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
| 1368 | + | |
1384 | 1369 | | |
1385 | 1370 | | |
1386 | 1371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
809 | | - | |
| 809 | + | |
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
| |||
889 | 889 | | |
890 | 890 | | |
891 | 891 | | |
892 | | - | |
| 892 | + | |
893 | 893 | | |
894 | 894 | | |
895 | 895 | | |
| |||
902 | 902 | | |
903 | 903 | | |
904 | 904 | | |
905 | | - | |
| 905 | + | |
906 | 906 | | |
907 | 907 | | |
908 | 908 | | |
| |||
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
988 | | - | |
| 988 | + | |
989 | 989 | | |
990 | 990 | | |
991 | 991 | | |
| |||
| 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 | | |
| |||
2444 | 2445 | | |
2445 | 2446 | | |
2446 | 2447 | | |
2447 | | - | |
| 2448 | + | |
2448 | 2449 | | |
2449 | 2450 | | |
2450 | 2451 | | |
| |||
2461 | 2462 | | |
2462 | 2463 | | |
2463 | 2464 | | |
2464 | | - | |
| 2465 | + | |
2465 | 2466 | | |
2466 | 2467 | | |
2467 | 2468 | | |
| |||
2562 | 2563 | | |
2563 | 2564 | | |
2564 | 2565 | | |
2565 | | - | |
| 2566 | + | |
2566 | 2567 | | |
2567 | 2568 | | |
2568 | 2569 | | |
| |||
2589 | 2590 | | |
2590 | 2591 | | |
2591 | 2592 | | |
2592 | | - | |
| 2593 | + | |
2593 | 2594 | | |
2594 | 2595 | | |
2595 | 2596 | | |
| |||
2786 | 2787 | | |
2787 | 2788 | | |
2788 | 2789 | | |
2789 | | - | |
| 2790 | + | |
2790 | 2791 | | |
2791 | 2792 | | |
2792 | 2793 | | |
| |||
3011 | 3012 | | |
3012 | 3013 | | |
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 | + | |
| 3078 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3181 | 3181 | | |
3182 | 3182 | | |
3183 | 3183 | | |
3184 | | - | |
| 3184 | + | |
3185 | 3185 | | |
3186 | 3186 | | |
3187 | 3187 | | |
| |||
3362 | 3362 | | |
3363 | 3363 | | |
3364 | 3364 | | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
3365 | 3381 | | |
3366 | 3382 | | |
3367 | 3383 | | |
| |||
3380 | 3396 | | |
3381 | 3397 | | |
3382 | 3398 | | |
3383 | | - | |
| 3399 | + | |
3384 | 3400 | | |
3385 | 3401 | | |
3386 | 3402 | | |
| |||
3390 | 3406 | | |
3391 | 3407 | | |
3392 | 3408 | | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
3393 | 3412 | | |
3394 | | - | |
| 3413 | + | |
3395 | 3414 | | |
3396 | 3415 | | |
3397 | 3416 | | |
| |||
3402 | 3421 | | |
3403 | 3422 | | |
3404 | 3423 | | |
3405 | | - | |
3406 | | - | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
3407 | 3429 | | |
3408 | | - | |
| 3430 | + | |
3409 | 3431 | | |
3410 | | - | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
3411 | 3435 | | |
3412 | | - | |
| 3436 | + | |
3413 | 3437 | | |
3414 | 3438 | | |
3415 | 3439 | | |
| |||
0 commit comments