Commit 31049ed
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 495c38c commit 31049ed
File tree
13 files changed
+316
-98
lines changed- lightning-invoice/src
- lightning/src
- chain
- events
- ln
13 files changed
+316
-98
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 | |
|---|---|---|---|
| |||
805 | 805 | | |
806 | 806 | | |
807 | 807 | | |
808 | | - | |
| 808 | + | |
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
| |||
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
891 | | - | |
| 891 | + | |
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
| |||
901 | 901 | | |
902 | 902 | | |
903 | 903 | | |
904 | | - | |
| 904 | + | |
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
| |||
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
988 | | - | |
| 988 | + | |
989 | 989 | | |
990 | 990 | | |
991 | 991 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
510 | 515 | | |
511 | 516 | | |
512 | 517 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1403 | 1403 | | |
1404 | 1404 | | |
1405 | 1405 | | |
| 1406 | + | |
1406 | 1407 | | |
1407 | 1408 | | |
1408 | 1409 | | |
| |||
1440 | 1441 | | |
1441 | 1442 | | |
1442 | 1443 | | |
1443 | | - | |
| 1444 | + | |
1444 | 1445 | | |
1445 | 1446 | | |
1446 | 1447 | | |
| |||
2196 | 2197 | | |
2197 | 2198 | | |
2198 | 2199 | | |
2199 | | - | |
| 2200 | + | |
2200 | 2201 | | |
2201 | 2202 | | |
2202 | 2203 | | |
| |||
2449 | 2450 | | |
2450 | 2451 | | |
2451 | 2452 | | |
2452 | | - | |
| 2453 | + | |
2453 | 2454 | | |
2454 | 2455 | | |
2455 | 2456 | | |
| |||
2466 | 2467 | | |
2467 | 2468 | | |
2468 | 2469 | | |
2469 | | - | |
| 2470 | + | |
2470 | 2471 | | |
2471 | 2472 | | |
2472 | 2473 | | |
| |||
2567 | 2568 | | |
2568 | 2569 | | |
2569 | 2570 | | |
2570 | | - | |
| 2571 | + | |
2571 | 2572 | | |
2572 | 2573 | | |
2573 | 2574 | | |
| |||
2598 | 2599 | | |
2599 | 2600 | | |
2600 | 2601 | | |
2601 | | - | |
| 2602 | + | |
2602 | 2603 | | |
2603 | 2604 | | |
2604 | 2605 | | |
| |||
2797 | 2798 | | |
2798 | 2799 | | |
2799 | 2800 | | |
2800 | | - | |
| 2801 | + | |
2801 | 2802 | | |
2802 | 2803 | | |
2803 | 2804 | | |
| |||
3024 | 3025 | | |
3025 | 3026 | | |
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 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3201 | 3201 | | |
3202 | 3202 | | |
3203 | 3203 | | |
3204 | | - | |
| 3204 | + | |
3205 | 3205 | | |
3206 | 3206 | | |
3207 | 3207 | | |
| |||
3382 | 3382 | | |
3383 | 3383 | | |
3384 | 3384 | | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
3385 | 3401 | | |
3386 | 3402 | | |
3387 | 3403 | | |
| |||
3400 | 3416 | | |
3401 | 3417 | | |
3402 | 3418 | | |
3403 | | - | |
| 3419 | + | |
3404 | 3420 | | |
3405 | 3421 | | |
3406 | 3422 | | |
| |||
3410 | 3426 | | |
3411 | 3427 | | |
3412 | 3428 | | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
3413 | 3432 | | |
3414 | | - | |
| 3433 | + | |
3415 | 3434 | | |
3416 | 3435 | | |
3417 | 3436 | | |
| |||
3422 | 3441 | | |
3423 | 3442 | | |
3424 | 3443 | | |
3425 | | - | |
3426 | | - | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
3427 | 3449 | | |
3428 | | - | |
| 3450 | + | |
3429 | 3451 | | |
3430 | | - | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
3431 | 3455 | | |
3432 | | - | |
| 3456 | + | |
3433 | 3457 | | |
3434 | 3458 | | |
3435 | 3459 | | |
| |||
0 commit comments