Skip to content

Commit 65d518b

Browse files
authored
Merge pull request #3942 from TheBlueMatt/2025-07-misc-followups
Misc Followups
2 parents c4f94e0 + 15a70f1 commit 65d518b

23 files changed

+272
-242
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,9 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
11381138
dest.handle_update_add_htlc(nodes[$node].get_our_node_id(), &new_msg);
11391139
}
11401140
}
1141-
for update_fulfill in update_fulfill_htlcs.iter() {
1141+
let processed_change = !update_add_htlcs.is_empty() || !update_fulfill_htlcs.is_empty() ||
1142+
!update_fail_htlcs.is_empty() || !update_fail_malformed_htlcs.is_empty();
1143+
for update_fulfill in update_fulfill_htlcs {
11421144
out.locked_write(format!("Delivering update_fulfill_htlc from node {} to node {}.\n", $node, idx).as_bytes());
11431145
dest.handle_update_fulfill_htlc(nodes[$node].get_our_node_id(), update_fulfill);
11441146
}
@@ -1154,8 +1156,6 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
11541156
out.locked_write(format!("Delivering update_fee from node {} to node {}.\n", $node, idx).as_bytes());
11551157
dest.handle_update_fee(nodes[$node].get_our_node_id(), &msg);
11561158
}
1157-
let processed_change = !update_add_htlcs.is_empty() || !update_fulfill_htlcs.is_empty() ||
1158-
!update_fail_htlcs.is_empty() || !update_fail_malformed_htlcs.is_empty();
11591159
if $limit_events != ProcessMessages::AllMessages && processed_change {
11601160
// If we only want to process some messages, don't deliver the CS until later.
11611161
extra_ev = Some(MessageSendEvent::UpdateHTLCs { node_id, channel_id, updates: CommitmentUpdate {

lightning-dns-resolver/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ mod test {
455455
}
456456

457457
check_added_monitors(&nodes[1], 1);
458-
let updates = get_htlc_update_msgs!(nodes[1], payer_id);
459-
nodes[0].node.handle_update_fulfill_htlc(payee_id, &updates.update_fulfill_htlcs[0]);
458+
let mut updates = get_htlc_update_msgs!(nodes[1], payer_id);
459+
nodes[0].node.handle_update_fulfill_htlc(payee_id, updates.update_fulfill_htlcs.remove(0));
460460
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, false);
461461

462462
expect_payment_sent(&nodes[0], our_payment_preimage, None, true, true);

lightning-net-tokio/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ mod tests {
721721
#[cfg(simple_close)]
722722
fn handle_closing_sig(&self, _their_node_id: PublicKey, _msg: ClosingSig) {}
723723
fn handle_update_add_htlc(&self, _their_node_id: PublicKey, _msg: &UpdateAddHTLC) {}
724-
fn handle_update_fulfill_htlc(&self, _their_node_id: PublicKey, _msg: &UpdateFulfillHTLC) {}
724+
fn handle_update_fulfill_htlc(&self, _their_node_id: PublicKey, _msg: UpdateFulfillHTLC) {}
725725
fn handle_update_fail_htlc(&self, _their_node_id: PublicKey, _msg: &UpdateFailHTLC) {}
726726
fn handle_update_fail_malformed_htlc(
727727
&self, _their_node_id: PublicKey, _msg: &UpdateFailMalformedHTLC,

lightning/src/chain/chainmonitor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,27 +1394,27 @@ mod tests {
13941394
// Now manually walk the commitment signed dance - because we claimed two payments
13951395
// back-to-back it doesn't fit into the neat walk commitment_signed_dance does.
13961396

1397-
let updates = get_htlc_update_msgs!(nodes[1], node_a_id);
1398-
nodes[0].node.handle_update_fulfill_htlc(node_b_id, &updates.update_fulfill_htlcs[0]);
1397+
let mut updates = get_htlc_update_msgs!(nodes[1], node_a_id);
1398+
nodes[0].node.handle_update_fulfill_htlc(node_b_id, updates.update_fulfill_htlcs.remove(0));
13991399
expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false);
14001400
nodes[0].node.handle_commitment_signed_batch_test(node_b_id, &updates.commitment_signed);
14011401
check_added_monitors!(nodes[0], 1);
14021402
let (as_first_raa, as_first_update) = get_revoke_commit_msgs!(nodes[0], node_b_id);
14031403

14041404
nodes[1].node.handle_revoke_and_ack(node_a_id, &as_first_raa);
14051405
check_added_monitors!(nodes[1], 1);
1406-
let bs_second_updates = get_htlc_update_msgs!(nodes[1], node_a_id);
1406+
let mut bs_2nd_updates = get_htlc_update_msgs!(nodes[1], node_a_id);
14071407
nodes[1].node.handle_commitment_signed_batch_test(node_a_id, &as_first_update);
14081408
check_added_monitors!(nodes[1], 1);
14091409
let bs_first_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, node_a_id);
14101410

14111411
nodes[0]
14121412
.node
1413-
.handle_update_fulfill_htlc(node_b_id, &bs_second_updates.update_fulfill_htlcs[0]);
1413+
.handle_update_fulfill_htlc(node_b_id, bs_2nd_updates.update_fulfill_htlcs.remove(0));
14141414
expect_payment_sent(&nodes[0], payment_preimage_2, None, false, false);
14151415
nodes[0]
14161416
.node
1417-
.handle_commitment_signed_batch_test(node_b_id, &bs_second_updates.commitment_signed);
1417+
.handle_commitment_signed_batch_test(node_b_id, &bs_2nd_updates.commitment_signed);
14181418
check_added_monitors!(nodes[0], 1);
14191419
nodes[0].node.handle_revoke_and_ack(node_b_id, &bs_first_raa);
14201420
expect_payment_path_successful!(nodes[0]);

lightning/src/events/mod.rs

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,11 +1101,22 @@ pub enum Event {
11011101
///
11021102
/// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
11031103
path: Path,
1104-
/// The hold times as reported by each hop. The unit in which the hold times are expressed are 100's of
1105-
/// milliseconds. So a hop reporting 2 is a hold time that corresponds to roughly 200 milliseconds. As earlier
1106-
/// hops hold on to an HTLC for longer, the hold times in the list are expected to decrease. When our peer
1107-
/// didn't provide attribution data, the list is empty. The same applies to HTLCs that were resolved onchain.
1108-
/// Because of unavailability of hold times, the list may be shorter than the number of hops in the path.
1104+
/// The time that each hop indicated it held the HTLC.
1105+
///
1106+
/// The unit in which the hold times are expressed are 100's of milliseconds. So a hop
1107+
/// reporting 2 is a hold time that corresponds to between 200 and 299 milliseconds.
1108+
///
1109+
/// We expect that at each hop the actual hold time will be strictly greater than the hold
1110+
/// time of the following hops, as a node along the path shouldn't have completed the HTLC
1111+
/// until the next node has completed it. Note that because hold times are in 100's of ms,
1112+
/// hold times as reported are likely to often be equal across hops.
1113+
///
1114+
/// If our peer didn't provide attribution data or the HTLC resolved on chain, the list
1115+
/// will be empty.
1116+
///
1117+
/// Each entry will correspond with one entry in [`Path::hops`], or, thereafter, the
1118+
/// [`BlindedTail::trampoline_hops`] in [`Path::blinded_tail`]. Because not all nodes
1119+
/// support hold times, the list may be shorter than the number of hops in the path.
11091120
hold_times: Vec<u32>,
11101121
},
11111122
/// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
@@ -1158,11 +1169,22 @@ pub enum Event {
11581169
error_code: Option<u16>,
11591170
#[cfg(any(test, feature = "_test_utils"))]
11601171
error_data: Option<Vec<u8>>,
1161-
/// The hold times as reported by each hop. The unit in which the hold times are expressed are 100's of
1162-
/// milliseconds. So a hop reporting 2 is a hold time that corresponds to roughly 200 milliseconds. As earlier
1163-
/// hops hold on to an HTLC for longer, the hold times in the list are expected to decrease. When our peer
1164-
/// didn't provide attribution data, the list is empty. The same applies to HTLCs that were resolved onchain.
1165-
/// Because of unavailability of hold times, the list may be shorter than the number of hops in the path.
1172+
/// The time that each hop indicated it held the HTLC.
1173+
///
1174+
/// The unit in which the hold times are expressed are 100's of milliseconds. So a hop
1175+
/// reporting 2 is a hold time that corresponds to between 200 and 299 milliseconds.
1176+
///
1177+
/// We expect that at each hop the actual hold time will be strictly greater than the hold
1178+
/// time of the following hops, as a node along the path shouldn't have completed the HTLC
1179+
/// until the next node has completed it. Note that because hold times are in 100's of ms,
1180+
/// hold times as reported are likely to often be equal across hops.
1181+
///
1182+
/// If our peer didn't provide attribution data or the HTLC resolved on chain, the list
1183+
/// will be empty.
1184+
///
1185+
/// Each entry will correspond with one entry in [`Path::hops`], or, thereafter, the
1186+
/// [`BlindedTail::trampoline_hops`] in [`Path::blinded_tail`]. Because not all nodes
1187+
/// support hold times, the list may be shorter than the number of hops in the path.
11661188
hold_times: Vec<u32>,
11671189
},
11681190
/// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.

lightning/src/ln/async_signer_tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -825,20 +825,20 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
825825

826826
// Handle the update_fulfill_htlc, but fail to persist the monitor update when handling the
827827
// commitment_signed.
828-
let events_2 = nodes[1].node.get_and_clear_pending_msg_events();
828+
let mut events_2 = nodes[1].node.get_and_clear_pending_msg_events();
829829
assert_eq!(events_2.len(), 1);
830-
match events_2[0] {
830+
match events_2.remove(0) {
831831
MessageSendEvent::UpdateHTLCs {
832832
node_id: _,
833833
channel_id: _,
834-
updates: msgs::CommitmentUpdate { ref update_fulfill_htlcs, ref commitment_signed, .. },
834+
updates: msgs::CommitmentUpdate { mut update_fulfill_htlcs, commitment_signed, .. },
835835
} => {
836-
nodes[0].node.handle_update_fulfill_htlc(node_b_id, &update_fulfill_htlcs[0]);
836+
nodes[0].node.handle_update_fulfill_htlc(node_b_id, update_fulfill_htlcs.remove(0));
837837
expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false);
838838
if monitor_update_failure {
839839
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
840840
}
841-
nodes[0].node.handle_commitment_signed_batch_test(node_b_id, commitment_signed);
841+
nodes[0].node.handle_commitment_signed_batch_test(node_b_id, &commitment_signed);
842842
if monitor_update_failure {
843843
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
844844
} else {
@@ -1401,8 +1401,8 @@ fn test_no_disconnect_while_async_commitment_signed_expecting_remote_revoke_and_
14011401

14021402
// After processing the `update_fulfill`, they'll only be able to send `revoke_and_ack` until
14031403
// the `commitment_signed` is no longer pending.
1404-
let update = get_htlc_update_msgs!(&nodes[1], node_a_id);
1405-
nodes[0].node.handle_update_fulfill_htlc(node_b_id, &update.update_fulfill_htlcs[0]);
1404+
let mut update = get_htlc_update_msgs!(&nodes[1], node_a_id);
1405+
nodes[0].node.handle_update_fulfill_htlc(node_b_id, update.update_fulfill_htlcs.remove(0));
14061406
nodes[0].node.handle_commitment_signed_batch_test(node_b_id, &update.commitment_signed);
14071407
check_added_monitors(&nodes[0], 1);
14081408

0 commit comments

Comments
 (0)