Skip to content

Commit 7785360

Browse files
authored
Merge pull request #4320 from TheBlueMatt/2026-01-live-holding-cells
Free holding cells immediately rather than in message sending
2 parents e9ce486 + cad88af commit 7785360

File tree

2 files changed

+159
-106
lines changed

2 files changed

+159
-106
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,17 +2784,13 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
27842784
}
27852785

27862786
// If we finish updating the monitor, we should free the holding cell right away (this did
2787-
// not occur prior to #756).
2787+
// not occur prior to #756). This should result in a new monitor update.
27882788
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
27892789
let (mon_id, _) = get_latest_mon_update_id(&nodes[0], chan_id);
27902790
nodes[0].chain_monitor.chain_monitor.force_channel_monitor_updated(chan_id, mon_id);
27912791
expect_payment_claimed!(nodes[0], payment_hash_0, 100_000);
2792-
2793-
// New outbound messages should be generated immediately upon a call to
2794-
// get_and_clear_pending_msg_events (but not before).
2795-
check_added_monitors(&nodes[0], 0);
2796-
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
27972792
check_added_monitors(&nodes[0], 1);
2793+
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
27982794
assert_eq!(events.len(), 1);
27992795

28002796
// Deliver the pending in-flight CS
@@ -3556,12 +3552,10 @@ fn do_test_blocked_chan_preimage_release(completion_mode: BlockedUpdateComplMode
35563552
}
35573553

35583554
// The event processing should release the last RAA update.
3559-
check_added_monitors(&nodes[1], 1);
3560-
3561-
// When we fetch the next update the message getter will generate the next update for nodes[2],
3562-
// generating a further monitor update.
3555+
// It should also generate the next update for nodes[2].
3556+
check_added_monitors(&nodes[1], 2);
35633557
let mut bs_htlc_fulfill = get_htlc_update_msgs(&nodes[1], &node_c_id);
3564-
check_added_monitors(&nodes[1], 1);
3558+
check_added_monitors(&nodes[1], 0);
35653559

35663560
nodes[2]
35673561
.node
@@ -5142,13 +5136,12 @@ fn test_mpp_claim_to_holding_cell() {
51425136
nodes[3].chain_monitor.chain_monitor.channel_monitor_updated(chan_4_id, latest_id).unwrap();
51435137
// Once we process monitor events (in this case by checking for the `PaymentClaimed` event, the
51445138
// RAA monitor update blocked above will be released.
5139+
// At the same time, the RAA monitor update completion will allow the C <-> D channel to
5140+
// generate its fulfill update.
51455141
expect_payment_claimed!(nodes[3], paymnt_hash_1, 500_000);
5146-
check_added_monitors(&nodes[3], 1);
5147-
5148-
// After the RAA monitor update completes, the C <-> D channel will be able to generate its
5149-
// fulfill updates as well.
5142+
check_added_monitors(&nodes[3], 2);
51505143
let mut c_claim = get_htlc_update_msgs(&nodes[3], &node_c_id);
5151-
check_added_monitors(&nodes[3], 1);
5144+
check_added_monitors(&nodes[3], 0);
51525145

51535146
// Finally, clear all the pending payments.
51545147
let path = [&[&nodes[1], &nodes[3]][..], &[&nodes[2], &nodes[3]][..]];

0 commit comments

Comments
 (0)