Repository navigation
Add disable_lightning_connections config flag - #1064
Conversation
|
👋 Thanks for assigning @tnull as a reviewer! |
|
Curious your thoughts Elias, I understand this may be a hacky use case. See this issue for context: lightningdevkit/ldk-server#257 |
|
If the node reconnects to the peer with a stale database, we get a panic, which I think is the correct course of action here; that's been the core motivation for this offline flag. |
Hmm, I honestly would prefer to directly go for the full recovery mode we planned for a bit. Do you think this is time critical, or can we add it for v0.9? |
Yes let's go for the full recovery mode (do you have an issue describing this?) I think this can wait for 0.9, feel free to close this PR and we can re-open a separate proper recovery PR. |
No issue so far, but what we discussed was to have a special mode on builder or a separate utility that you'd give all the information you have (seed, list of known prior peers, etc) and it would try to claw all funds back that are possible, i.e., do force-close recovery but also retrieve Actually, let me see if i can do a quick draft. |
18dff83 to
adff576
Compare
disable_peer_networking flagdisable_outbound_lightning_connections flag
| /// |----------------------------------------|--------------------------------------| | ||
| /// | `storage_dir_path` | /tmp/ldk_node/ | | ||
| /// | `network` | Bitcoin | | ||
| /// |`disable_outbound_lightning_connections`| false | |
There was a problem hiding this comment.
nit: This has missing whitespace (before, after).
There was a problem hiding this comment.
I renamed the field to disable_lightning_connections see the rationale in the commit message below.
| async fn do_connect_peer_internal( | ||
| &self, node_id: PublicKey, addr: SocketAddress, | ||
| ) -> Result<(), Error> { | ||
| if self.disable_outbound_lightning_connections { |
There was a problem hiding this comment.
Should we add a test for this, i.e., one that sets up some nodes and then restarts with the flag enabled, ensuring that they they don't reconnect?
| /// If `persist` is set to `true`, we'll remember the peer and reconnect to it on restart. | ||
| /// Outbound connection attempts fail with [`Error::ConnectionFailed`] if | ||
| /// [`Config::disable_outbound_lightning_connections`] is set. | ||
| pub fn connect( |
There was a problem hiding this comment.
Hmm, wouldn't we still want to allow manual overrides? I.e. allow the user to selectively connect peers, e.g., to trigger the channel-reestablish recovery flow?
There was a problem hiding this comment.
the node that reconnects to peers to trigger the force-closes must not have the stale database, it must be launched from the seed alone. That node will be launched with outbound connections enabled.
If the node with the stale database tries to reconnect with the peers, the channel-reestablish flow causes the node to panic in rust-lightning. That is why we would like to add this disable_outbound_lightning_connections flag here, and also disable manual overrides.
See the full procedure I have in mind here: lightningdevkit/ldk-server#257 (comment)
There was a problem hiding this comment.
Actually I went further and now enforce that inbound connections are disabled as well, see the rationale in the commit message below.
| /// Inbound connections are controlled separately by | ||
| /// [`Config::listening_addresses`]; set it to `None` to prevent inbound connections as well. | ||
| /// Other networking, including chain synchronization, is unaffected. | ||
| pub disable_outbound_lightning_connections: bool, |
There was a problem hiding this comment.
Hmm, maybe this would be better on the builder, rather than a Config field?
There was a problem hiding this comment.
Hmm I went back and forth on that one, I don't have a strong opinion, I went with what is consistent with the rest of the existing networking config options: a field on Config, and methods on the builder to modify this field before building the node.
adff576 to
fca1cd8
Compare
disable_outbound_lightning_connections flagdisable_lightning_connections config flag
fca1cd8 to
d4982c0
Compare
|
Sorry tnull for the delay here I completely missed your responses. I've addressed your comments, and also now require listening addresses to be empty if It is rebased against the latest main. |
| &self, node_id: PublicKey, addr: SocketAddress, | ||
| ) -> Result<(), Error> { | ||
| if self.disable_lightning_connections { | ||
| log_warn!(self.logger, "Lightning peer connections are disabled."); |
There was a problem hiding this comment.
Rather than logging indefinitely, should we just disable the reconnection loop when the flag is enabled?
There was a problem hiding this comment.
Thanks done below, the goal is to remove sources of infinite logs, feel free to use --ignore--all-space for this commit.
|
Let me know if I should squash. |
| self.config.network | ||
| ); | ||
|
|
||
| if self.config.disable_lightning_connections { |
There was a problem hiding this comment.
nit: Maybe print this in the if below? Not sure its' worth adding clutter here just for this?
There was a problem hiding this comment.
Done below thank you
| /// attempts are disabled for the built node. Inbound listening must also be disabled by | ||
| /// setting [`Config::listening_addresses`] to `None` or an empty list; | ||
| /// otherwise building fails with [`BuildError::InvalidListeningAddresses`]. | ||
| pub fn set_disable_lightning_connections(&self, disable: bool) { |
There was a problem hiding this comment.
This probably also needs to be exposed in the Uniffi UDL file?
There was a problem hiding this comment.
Not needed because of these lines further above:
Lines 1224 to 1226 in 3bc8309
There was a problem hiding this comment.
Ah, nvm, I forgot that we switched the builder over to macros a while ago 😆
This flag may be useful to launch a node with a stale database with the goal of recovering funds from the `to_remote` outputs on the confirmed commitment of the node's channel peers. In this mode, it is very important for no connections to be made, outbound or inbound, manual or automatic. Otherwise, the node may accept a connection from a channel peer, receive an `error` message from the peer, and broadcast a stale commitment. Hence, we enforce that the listening addresses field is empty if `disable_lightning_connections` field is true.
efbc208 to
85f1204
Compare
|
Squashed with the diff below: diff --git a/src/lib.rs b/src/lib.rs
index 4ec878b5..850d1704 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -329,13 +329,6 @@ impl Node {
self.config.network
);
- if self.config.disable_lightning_connections {
- log_info!(
- self.logger,
- "Lightning peer networking is disabled for both inbound and outbound connections."
- );
- }
-
self.runtime.allow_cancellable_background_task_spawns();
// Start up any runtime-dependant chain sources (e.g. Electrum)
@@ -603,6 +596,11 @@ impl Node {
}
}
});
+ } else {
+ log_info!(
+ self.logger,
+ "Lightning peer networking is disabled for both inbound and outbound connections."
+ );
}
// Regularly broadcast node announcements. |
There was a problem hiding this comment.
ACK, but still want to note that this is a temporary stop gap that we should revert once we have a 'real' recovery mode, esp. given it doesn't cover all potential ways in which we could end up broadcasting a stale commitment, AFAIU.
@tankyleo Mind opening a tracking issue that describes that a) we need a recovery mode / what should be part of it and b) we shoudl revert this PR then?
Uh oh!
There was an error while loading. Please reload this page.