Skip to content

Further decouple ChannelManager from Channel state somewhat #3539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 28, 2025

Conversation

TheBlueMatt
Copy link
Collaborator

Just a few tiny followups to #3513 to keep moving towards ChannelManager caring less about the specific state the channel is in.

@jkczyz jkczyz self-requested a review January 15, 2025 17:34
/// Should be called when the peer is disconnected. Returns true if the channel can be resumed
/// when the peer reconnects (via [`Self::peer_connected_get_handshake`]). If not, the channel
/// must be immediately closed.
pub fn peer_disconnected_is_resumable<L: Deref>(&mut self, logger: &L) -> bool where L::Target: Logger {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about naming this is_disconnected_peer_resumable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not stateless, though, I wanted to communicate that its a "this peer has disconnected" notification, plus "should i discard the channel". Not sure how best to communicate it, this name is a bit awkward.

@wpaulino
Copy link
Contributor

LGTM once the logging context is restored

@TheBlueMatt TheBlueMatt force-pushed the 2025-01-3513-followups branch from e25da14 to 2abe846 Compare January 24, 2025 22:09
@TheBlueMatt
Copy link
Collaborator Author

Sorry for the delay, fixed the logger issue:

$ git diff-tree -U2 e25da1455 2abe8469b
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index fcc11ca05..16599f126 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -9455,6 +9455,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
 		// Returns whether we should remove this channel as it's just been closed.
 		let unblock_chan = |phase: &mut Channel<SP>, pending_msg_events: &mut Vec<MessageSendEvent>| -> Option<ShutdownResult> {
+			let logger = WithChannelContext::from(&self.logger, &phase.context(), None);
 			let node_id = phase.context().get_counterparty_node_id();
-			if let Some(msgs) = phase.signer_maybe_unblocked(self.chain_hash, &self.logger) {
+			if let Some(msgs) = phase.signer_maybe_unblocked(self.chain_hash, &&logger) {
 				if let Some(msg) = msgs.open_channel {
 					pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
@@ -9513,7 +9514,4 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
 					}
 					if let Some(broadcast_tx) = msgs.signed_closing_tx {
-						let channel_id = chan.context.channel_id();
-						let counterparty_node_id = chan.context.get_counterparty_node_id();
-						let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), None);
 						log_info!(logger, "Broadcasting closing tx {}", log_tx!(broadcast_tx));
 						self.tx_broadcaster.broadcast_transactions(&[&broadcast_tx]);

@jkczyz
Copy link
Contributor

jkczyz commented Jan 27, 2025

FYI, this will conflict with #3550. May be easier to get that in first, but either way is fine by me.

After lightningdevkit#3513 we have a bit more encapsulation of channel logic in
channel.rs with channelmanager.rs needing a bit less knowledge of
which specific state a channel is in.

This continues that trend slightly when unblocking the signer.
@TheBlueMatt
Copy link
Collaborator Author

Rebased.

@TheBlueMatt TheBlueMatt force-pushed the 2025-01-3513-followups branch from 2abe846 to 6852e8a Compare January 27, 2025 21:44
After lightningdevkit#3513 we have a bit more encapsulation of channel logic in
channel.rs with channelmanager.rs needing a bit less knowledge of
which specific state a channel is in.

This continues that trend slightly when a peer disconnects.
After lightningdevkit#3513 we have a bit more encapsulation of channel logic in
channel.rs with channelmanager.rs needing a bit less knowledge of
which specific state a channel is in.

This continues that trend slightly when a peer reconnects.
@TheBlueMatt TheBlueMatt force-pushed the 2025-01-3513-followups branch from 6852e8a to bece44c Compare January 28, 2025 14:49
@TheBlueMatt
Copy link
Collaborator Author

Ugh, fixed the dangling link after the third commit.

@wpaulino wpaulino merged commit 569f906 into lightningdevkit:main Jan 28, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants