Commit ba1207a
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 e13ff10 commit ba1207a
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 | |
|---|---|---|---|
| |||
1373 | 1373 | | |
1374 | 1374 | | |
1375 | 1375 | | |
1376 | | - | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
1390 | | - | |
1391 | | - | |
| 1376 | + | |
1392 | 1377 | | |
1393 | 1378 | | |
1394 | 1379 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
494 | 499 | | |
495 | 500 | | |
496 | 501 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
3223 | 3223 | | |
3224 | 3224 | | |
3225 | 3225 | | |
3226 | | - | |
| 3226 | + | |
3227 | 3227 | | |
3228 | 3228 | | |
3229 | 3229 | | |
| |||
3404 | 3404 | | |
3405 | 3405 | | |
3406 | 3406 | | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
3407 | 3423 | | |
3408 | 3424 | | |
3409 | 3425 | | |
| |||
3422 | 3438 | | |
3423 | 3439 | | |
3424 | 3440 | | |
3425 | | - | |
| 3441 | + | |
3426 | 3442 | | |
3427 | 3443 | | |
3428 | 3444 | | |
| |||
3432 | 3448 | | |
3433 | 3449 | | |
3434 | 3450 | | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
3435 | 3454 | | |
3436 | | - | |
| 3455 | + | |
3437 | 3456 | | |
3438 | 3457 | | |
3439 | 3458 | | |
| |||
3444 | 3463 | | |
3445 | 3464 | | |
3446 | 3465 | | |
3447 | | - | |
3448 | | - | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
3449 | 3471 | | |
3450 | | - | |
| 3472 | + | |
3451 | 3473 | | |
3452 | | - | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
3453 | 3477 | | |
3454 | | - | |
| 3478 | + | |
3455 | 3479 | | |
3456 | 3480 | | |
3457 | 3481 | | |
| |||
0 commit comments