Skip to content

Commit a2df43d

Browse files
committed
Remove check which makes us sometimes never send closing_signed
This is the case pointed out by nayuta-gondo at lightning/bolts#499 (comment) though this doesn't actually solve the issue of ensuring we have a consistent fee view when we start shutdown processing. There isn't a clear solution to that however without adding additional state tracking in Channel. This also removes an associated test that tests for the correct behavior (but didn't consider the bug) as we no longer behave correctly. This should be fine as we'll be removing all the update_fee garbage with option_simplified_commitment anyway.
1 parent dfbc6c6 commit a2df43d

File tree

2 files changed

+1
-48
lines changed

2 files changed

+1
-48
lines changed

src/ln/channel.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,8 +2406,7 @@ impl Channel {
24062406
fn maybe_propose_first_closing_signed(&mut self, fee_estimator: &FeeEstimator) -> Option<msgs::ClosingSigned> {
24072407
if !self.channel_outbound || !self.pending_inbound_htlcs.is_empty() || !self.pending_outbound_htlcs.is_empty() ||
24082408
self.channel_state & (BOTH_SIDES_SHUTDOWN_MASK | ChannelState::AwaitingRemoteRevoke as u32) != BOTH_SIDES_SHUTDOWN_MASK ||
2409-
self.last_sent_closing_fee.is_some() ||
2410-
self.cur_remote_commitment_transaction_number != self.cur_local_commitment_transaction_number{
2409+
self.last_sent_closing_fee.is_some() || self.pending_update_fee.is_some() {
24112410
return None;
24122411
}
24132412

src/ln/channelmanager.rs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4921,52 +4921,6 @@ mod tests {
49214921
assert!(nodes[2].node.list_channels().is_empty());
49224922
}
49234923

4924-
#[test]
4925-
fn update_fee_async_shutdown() {
4926-
// Test update_fee works after shutdown start if messages are delivered out-of-order
4927-
let nodes = create_network(2);
4928-
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
4929-
4930-
let starting_feerate = nodes[0].node.channel_state.lock().unwrap().by_id.get(&chan_1.2).unwrap().get_feerate();
4931-
nodes[0].node.update_fee(chan_1.2.clone(), starting_feerate + 20).unwrap();
4932-
check_added_monitors!(nodes[0], 1);
4933-
let updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
4934-
assert!(updates.update_add_htlcs.is_empty());
4935-
assert!(updates.update_fulfill_htlcs.is_empty());
4936-
assert!(updates.update_fail_htlcs.is_empty());
4937-
assert!(updates.update_fail_malformed_htlcs.is_empty());
4938-
assert!(updates.update_fee.is_some());
4939-
4940-
nodes[1].node.close_channel(&chan_1.2).unwrap();
4941-
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
4942-
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_1_shutdown).unwrap();
4943-
// Note that we don't actually test normative behavior here. The spec indicates we could
4944-
// actually send a closing_signed here, but is kinda unclear and could possibly be amended
4945-
// to require waiting on the full commitment dance before doing so (see
4946-
// https://github.com/lightningnetwork/lightning-rfc/issues/499). In any case, to avoid
4947-
// ambiguity, we should wait until after the full commitment dance to send closing_signed.
4948-
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
4949-
4950-
nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), &updates.update_fee.unwrap()).unwrap();
4951-
nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &updates.commitment_signed).unwrap();
4952-
check_added_monitors!(nodes[1], 1);
4953-
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_0_shutdown).unwrap();
4954-
let node_0_closing_signed = commitment_signed_dance!(nodes[1], nodes[0], (), false, true, true);
4955-
4956-
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
4957-
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), match node_0_closing_signed.unwrap() {
4958-
MessageSendEvent::SendClosingSigned { ref node_id, ref msg } => {
4959-
assert_eq!(*node_id, nodes[1].node.get_our_node_id());
4960-
msg
4961-
},
4962-
_ => panic!("Unexpected event"),
4963-
}).unwrap();
4964-
let (_, node_1_closing_signed) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
4965-
nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed.unwrap()).unwrap();
4966-
let (_, node_0_none) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
4967-
assert!(node_0_none.is_none());
4968-
}
4969-
49704924
fn do_test_shutdown_rebroadcast(recv_count: u8) {
49714925
// Test that shutdown/closing_signed is re-sent on reconnect with a variable number of
49724926
// messages delivered prior to disconnect

0 commit comments

Comments
 (0)