Skip to content

Commit 82e9cdd

Browse files
committed
Attempt queued splice after existing pending splice becomes locked
Since we don't yet support contributing to an incoming splice, we need to make sure we attempt our splice negotiation eventually if the counterparty was also attempting a splice at the same time but they won the quiescence tie-breaker. Since only one pending splice (without RBF) is allowed at a time, we do this after the existing splice becomes locked.
1 parent 2d9ed03 commit 82e9cdd

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

lightning/src/ln/async_signer_tests.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ fn do_test_async_raa_peer_disconnect(
600600
}
601601

602602
// Expect the RAA
603-
let (_, revoke_and_ack, commitment_signed, resend_order, _, _) =
603+
let (_, revoke_and_ack, commitment_signed, resend_order, _, _, _) =
604604
handle_chan_reestablish_msgs!(dst, src);
605605
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
606606
assert!(revoke_and_ack.is_none());
@@ -616,14 +616,14 @@ fn do_test_async_raa_peer_disconnect(
616616
dst.node.signer_unblocked(Some((src_node_id, chan_id)));
617617

618618
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
619-
let (_, revoke_and_ack, commitment_signed, resend_order, _, _) =
619+
let (_, revoke_and_ack, commitment_signed, resend_order, _, _, _) =
620620
handle_chan_reestablish_msgs!(dst, src);
621621
assert!(revoke_and_ack.is_some());
622622
assert!(commitment_signed.is_some());
623623
assert!(resend_order == RAACommitmentOrder::RevokeAndACKFirst);
624624
} else {
625625
// Make sure we don't double send the RAA.
626-
let (_, revoke_and_ack, commitment_signed, _, _, _) =
626+
let (_, revoke_and_ack, commitment_signed, _, _, _, _) =
627627
handle_chan_reestablish_msgs!(dst, src);
628628
assert!(revoke_and_ack.is_none());
629629
assert!(commitment_signed.is_none());
@@ -750,7 +750,8 @@ fn do_test_async_commitment_signature_peer_disconnect(
750750
}
751751

752752
// Expect the RAA
753-
let (_, revoke_and_ack, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
753+
let (_, revoke_and_ack, commitment_signed, _, _, _, _) =
754+
handle_chan_reestablish_msgs!(dst, src);
754755
assert!(revoke_and_ack.is_some());
755756
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
756757
assert!(commitment_signed.is_none());
@@ -763,11 +764,11 @@ fn do_test_async_commitment_signature_peer_disconnect(
763764
dst.node.signer_unblocked(Some((src_node_id, chan_id)));
764765

765766
if test_case == UnblockSignerAcrossDisconnectCase::AtEnd {
766-
let (_, _, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
767+
let (_, _, commitment_signed, _, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
767768
assert!(commitment_signed.is_some());
768769
} else {
769770
// Make sure we don't double send the CS.
770-
let (_, _, commitment_signed, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
771+
let (_, _, commitment_signed, _, _, _, _) = handle_chan_reestablish_msgs!(dst, src);
771772
assert!(commitment_signed.is_none());
772773
}
773774
}
@@ -884,6 +885,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
884885
assert!(as_resp.2.is_none());
885886
assert!(as_resp.4.is_none());
886887
assert!(as_resp.5.is_none());
888+
assert!(as_resp.6.is_none());
887889

888890
if monitor_update_failure {
889891
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
@@ -905,6 +907,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
905907
assert!(as_resp.2.is_none());
906908
assert!(as_resp.4.is_none());
907909
assert!(as_resp.5.is_none());
910+
assert!(as_resp.6.is_none());
908911

909912
nodes[0].enable_channel_signer_op(&node_b_id, &chan_id, SignerOp::SignCounterpartyCommitment);
910913
nodes[0].node.signer_unblocked(Some((node_b_id, chan_id)));
@@ -927,6 +930,9 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
927930
assert!(as_resp.5.is_none());
928931
assert!(bs_resp.5.is_none());
929932

933+
assert!(as_resp.6.is_none());
934+
assert!(bs_resp.6.is_none());
935+
930936
// Now that everything is restored, get the CS + RAA and handle them.
931937
nodes[1]
932938
.node

lightning/src/ln/channel.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10837,6 +10837,12 @@ where
1083710837
let announcement_sigs =
1083810838
self.get_announcement_sigs(node_signer, chain_hash, user_config, block_height, logger);
1083910839

10840+
if let Some(quiescent_action) = self.quiescent_action.as_ref() {
10841+
if matches!(quiescent_action, QuiescentAction::Splice(_)) {
10842+
self.context.channel_state.set_awaiting_quiescence();
10843+
}
10844+
}
10845+
1084010846
Some(SpliceFundingPromotion {
1084110847
funding_txo,
1084210848
monitor_update,

lightning/src/ln/functional_test_utils.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4789,6 +4789,13 @@ macro_rules! handle_chan_reestablish_msgs {
47894789
had_channel_update = true;
47904790
}
47914791

4792+
let mut stfu = None;
4793+
if let Some(&MessageSendEvent::SendStfu { ref node_id, ref msg }) = msg_events.get(idx) {
4794+
idx += 1;
4795+
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
4796+
stfu = Some(msg.clone());
4797+
}
4798+
47924799
let mut revoke_and_ack = None;
47934800
let mut commitment_update = None;
47944801
let order = if let Some(ev) = msg_events.get(idx) {
@@ -4864,7 +4871,15 @@ macro_rules! handle_chan_reestablish_msgs {
48644871

48654872
assert_eq!(msg_events.len(), idx, "{msg_events:?}");
48664873

4867-
(channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs, tx_signatures)
4874+
(
4875+
channel_ready,
4876+
revoke_and_ack,
4877+
commitment_update,
4878+
order,
4879+
announcement_sigs,
4880+
tx_signatures,
4881+
stfu,
4882+
)
48684883
}};
48694884
}
48704885

@@ -4873,6 +4888,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
48734888
pub node_b: &'a Node<'b, 'c, 'd>,
48744889
pub send_channel_ready: (bool, bool),
48754890
pub send_announcement_sigs: (bool, bool),
4891+
pub send_stfu: (bool, bool),
48764892
pub send_interactive_tx_commit_sig: (bool, bool),
48774893
pub send_interactive_tx_sigs: (bool, bool),
48784894
pub expect_renegotiated_funding_locked_monitor_update: (bool, bool),
@@ -4895,6 +4911,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
48954911
node_b,
48964912
send_channel_ready: (false, false),
48974913
send_announcement_sigs: (false, false),
4914+
send_stfu: (false, false),
48984915
send_interactive_tx_commit_sig: (false, false),
48994916
send_interactive_tx_sigs: (false, false),
49004917
expect_renegotiated_funding_locked_monitor_update: (false, false),
@@ -4918,6 +4935,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
49184935
node_b,
49194936
send_channel_ready,
49204937
send_announcement_sigs,
4938+
send_stfu,
49214939
send_interactive_tx_commit_sig,
49224940
send_interactive_tx_sigs,
49234941
expect_renegotiated_funding_locked_monitor_update,
@@ -5036,6 +5054,12 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
50365054
} else {
50375055
assert!(chan_msgs.4.is_none());
50385056
}
5057+
if send_stfu.0 {
5058+
let stfu = chan_msgs.6.take().unwrap();
5059+
node_a.node.handle_stfu(node_b_id, &stfu);
5060+
} else {
5061+
assert!(chan_msgs.6.is_none());
5062+
}
50395063
if send_interactive_tx_commit_sig.0 {
50405064
assert!(chan_msgs.1.is_none());
50415065
let commitment_update = chan_msgs.2.take().unwrap();
@@ -5142,6 +5166,12 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
51425166
} else {
51435167
assert!(chan_msgs.4.is_none());
51445168
}
5169+
if send_stfu.1 {
5170+
let stfu = chan_msgs.6.take().unwrap();
5171+
node_b.node.handle_stfu(node_a_id, &stfu);
5172+
} else {
5173+
assert!(chan_msgs.6.is_none());
5174+
}
51455175
if send_interactive_tx_commit_sig.1 {
51465176
assert!(chan_msgs.1.is_none());
51475177
let commitment_update = chan_msgs.2.take().unwrap();

0 commit comments

Comments
 (0)