@@ -3341,93 +3341,6 @@ fn test_durable_preimages_on_closed_channel() {
3341
3341
do_test_durable_preimages_on_closed_channel ( false , false , false ) ;
3342
3342
}
3343
3343
3344
- #[ test]
3345
- fn test_sync_async_persist_doesnt_hang ( ) {
3346
- // Previously, we checked if a channel was a candidate for making forward progress based on if
3347
- // the `MonitorEvent::Completed` matched the channel's latest monitor update id. However, this
3348
- // could lead to a rare race when `ChannelMonitor`s were being persisted both synchronously and
3349
- // asynchronously leading to channel hangs.
3350
- //
3351
- // To hit this case, we need to generate a `MonitorEvent::Completed` prior to a new channel
3352
- // update, but which is only processed after the channel update.
3353
- let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
3354
- let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
3355
- let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
3356
- let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
3357
-
3358
- let chan_id_ab = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) . 2 ;
3359
-
3360
- // Send two payments from A to B, then claim the first, marking the very last
3361
- // ChannelMonitorUpdate as InProgress...
3362
- let ( payment_preimage_1, payment_hash_1, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
3363
- let ( payment_preimage_2, payment_hash_2, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
3364
-
3365
- nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
3366
- check_added_monitors ( & nodes[ 1 ] , 1 ) ;
3367
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
3368
-
3369
- let bs_updates = get_htlc_update_msgs ( & nodes[ 1 ] , & nodes[ 0 ] . node . get_our_node_id ( ) ) ;
3370
- nodes[ 0 ] . node . handle_update_fulfill_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & bs_updates. update_fulfill_htlcs [ 0 ] ) ;
3371
- expect_payment_sent ( & nodes[ 0 ] , payment_preimage_1, None , false , false ) ;
3372
- nodes[ 0 ] . node . handle_commitment_signed_batch_test ( nodes[ 1 ] . node . get_our_node_id ( ) , & bs_updates. commitment_signed ) ;
3373
- check_added_monitors ( & nodes[ 0 ] , 1 ) ;
3374
- let ( as_raa, as_cs) = get_revoke_commit_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
3375
-
3376
- nodes[ 1 ] . node . handle_revoke_and_ack ( nodes[ 0 ] . node . get_our_node_id ( ) , & as_raa) ;
3377
- check_added_monitors ( & nodes[ 1 ] , 1 ) ;
3378
- nodes[ 1 ] . node . handle_commitment_signed_batch_test ( nodes[ 0 ] . node . get_our_node_id ( ) , & as_cs) ;
3379
- check_added_monitors ( & nodes[ 1 ] , 1 ) ;
3380
-
3381
- let bs_final_raa = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendRevokeAndACK , nodes[ 0 ] . node. get_our_node_id( ) ) ;
3382
- chanmon_cfgs[ 0 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
3383
- nodes[ 0 ] . node . handle_revoke_and_ack ( nodes[ 1 ] . node . get_our_node_id ( ) , & bs_final_raa) ;
3384
- check_added_monitors ( & nodes[ 0 ] , 1 ) ;
3385
-
3386
- // Immediately complete the monitor update, but before the ChannelManager has a chance to see
3387
- // the MonitorEvent::Completed, create a channel update by receiving a claim on the second
3388
- // payment.
3389
- let ( _, ab_update_id) = nodes[ 0 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & chan_id_ab) . unwrap ( ) . clone ( ) ;
3390
- nodes[ 0 ] . chain_monitor . chain_monitor . channel_monitor_updated ( chan_id_ab, ab_update_id) . unwrap ( ) ;
3391
-
3392
- nodes[ 1 ] . node . claim_funds ( payment_preimage_2) ;
3393
- check_added_monitors ( & nodes[ 1 ] , 1 ) ;
3394
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_2, 1_000_000 ) ;
3395
-
3396
- let bs_updates = get_htlc_update_msgs ( & nodes[ 1 ] , & nodes[ 0 ] . node . get_our_node_id ( ) ) ;
3397
- nodes[ 0 ] . node . handle_update_fulfill_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & bs_updates. update_fulfill_htlcs [ 0 ] ) ;
3398
- nodes[ 0 ] . node . handle_commitment_signed_batch_test ( nodes[ 1 ] . node . get_our_node_id ( ) , & bs_updates. commitment_signed ) ;
3399
- check_added_monitors ( & nodes[ 0 ] , 1 ) ;
3400
-
3401
- // At this point, we have completed an extra `ChannelMonitorUpdate` but the `ChannelManager`
3402
- // hasn't yet seen our `MonitorEvent::Completed`. When we call
3403
- // `get_and_clear_pending_msg_events` here, the `ChannelManager` finally sees that event and
3404
- // should return the channel to normal operation.
3405
- let ( as_raa, as_cs) = get_revoke_commit_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
3406
-
3407
- // Now that we've completed our test, process the events we have queued up (which we were not
3408
- // able to check until now as they would have caused the `ChannelManager` to look at the
3409
- // pending `MonitorEvent`s).
3410
- let pending_events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
3411
- assert_eq ! ( pending_events. len( ) , 2 ) ;
3412
- if let Event :: PaymentPathSuccessful { ref payment_hash, ..} = pending_events[ 1 ] {
3413
- assert_eq ! ( payment_hash. unwrap( ) , payment_hash_1) ;
3414
- } else { panic ! ( ) ; }
3415
- if let Event :: PaymentSent { ref payment_hash, ..} = pending_events[ 0 ] {
3416
- assert_eq ! ( * payment_hash, payment_hash_2) ;
3417
- } else { panic ! ( ) ; }
3418
-
3419
- // Finally, complete the claiming of the second payment
3420
- nodes[ 1 ] . node . handle_revoke_and_ack ( nodes[ 0 ] . node . get_our_node_id ( ) , & as_raa) ;
3421
- check_added_monitors ( & nodes[ 1 ] , 1 ) ;
3422
- nodes[ 1 ] . node . handle_commitment_signed_batch_test ( nodes[ 0 ] . node . get_our_node_id ( ) , & as_cs) ;
3423
- check_added_monitors ( & nodes[ 1 ] , 1 ) ;
3424
-
3425
- let bs_final_raa = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendRevokeAndACK , nodes[ 0 ] . node. get_our_node_id( ) ) ;
3426
- nodes[ 0 ] . node . handle_revoke_and_ack ( nodes[ 1 ] . node . get_our_node_id ( ) , & bs_final_raa) ;
3427
- check_added_monitors ( & nodes[ 0 ] , 1 ) ;
3428
- expect_payment_path_successful ! ( nodes[ 0 ] ) ;
3429
- }
3430
-
3431
3344
fn do_test_reload_mon_update_completion_actions ( close_during_reload : bool ) {
3432
3345
// Test that if a `ChannelMonitorUpdate` completes but a `ChannelManager` isn't serialized
3433
3346
// before restart we run the monitor update completion action on startup.
0 commit comments