Skip to content
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

gossipd: Turn off IP discovery when we already have useable addresses. #5344

Merged
merged 5 commits into from
Jul 12, 2022

Conversation

m-schmoock
Copy link
Collaborator

@m-schmoock m-schmoock commented Jun 25, 2022

Currently, IP discovery will be active (unless turned off) also when users configure announced addresses manually.
When the manual configuration uses a non-default port, this will lead to the strange behavior of announcing the same address twice. One with the correct and one with the guessed default port.

The idea is that we turn off IP discovery when a usable announcement has been defined via commandline, config or autobind.
Also this PR sets the 'guessed' port depending on what network (Mainnet, Testnet, ...) we are on.

Followup

  • Make the switch --disable-ip-discovery obsolete it and maybe add a --ip-discovery true/false(/auto) switch to force it on or off or keeping it automatically, if not defined.

Note:

We could/should also enable IP discovery when we only have a working TOR address (but without --always-use-proxy ofc). This will give nodes an option to have a bootstrap way to be reachable until IP discovery can do the job in a more stable way.
Keep in mind its easier for most users to punch a hole in a NAT router than to setup TOR correctly.
If/Once we have a --ip-discovery=true switch the user can also do that manually if he wants to.

Addresses #5305

gossipd/gossipd.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Concept ACK

@m-schmoock m-schmoock changed the title gossipd: Turn off IP discovery when manual configuration is used. gossipd: Turn off IP discovery when we already have useable addresses. Jun 27, 2022
@rustyrussell
Copy link
Contributor

This will make the switch '--disable-ip-discovery' more or less pointless (except for edge cases). We can think about adding a '--enable-ip-discovery' switch instead or also.

This is why --enable/disable flags are generally poor design: --ip-discovery= is better, since it can be overridden later in commandline too.

@rustyrussell rustyrussell added this to the v0.12 milestone Jun 30, 2022
@niftynei
Copy link
Collaborator

@m-schmoock we're looking to cut an RC this week, and I'd love to get this added. It looks like this just needs a rebase.

@m-schmoock
Copy link
Collaborator Author

@m-schmoock we're looking to cut an RC this week, and I'd love to get this added. It looks like this just needs a rebase.

Ok, I'll try to finish it. It's a little bit more though because we also need to depreciate the '--disable-ip-discovery' flag, update docs and tests etc.

This commit got reduced to just changing a comment because
the stuff it initially did was already merged in before by
commit 7ff62b4

So I just kept the changed comment as its more precise.

Changelog-None
This will only add the discovered `remote_addr` IPs if no other
addresses would be announced. Meaning whenever a public address was
found by autobind or an address was specified via commandline or config,
IP discovery will be disabled.

Addresses: ElementsProject#5305

Note from the author: We could/should also enable IP discovery when we only
have a TOR address (but without --always-use-proxy ofc). This will give
nodes an option to have a bootstrap way to be reached until IP discovery
can do the job in a more stable way.

Changelog-Changed: Only use IP discovery as fallback when no addresses would be announced
I just increased the version byte. Didn't recreate and dump a new store.
The test still works so I assume no imcompatibilities.

Changelog-None
@m-schmoock
Copy link
Collaborator Author

Note: Needed to fix some outdated gossmap tests that broke CI

@m-schmoock
Copy link
Collaborator Author

m-schmoock commented Jul 11, 2022

@rustyrussell
So now IP discovery is only active if no other addresses are defined (or usable). I would like the option to have a TOR address announced but also IP discovery enabled. How can we achieve that?

  1. TODO anyway: Deprecate --disable-ip-discovery. Whats the proper way of deprecating a paramter? Just remove it or raise a warning/error?
  2. Add a --ip-discovery=true/false(/auto) switch. But this can't be a strict bool, because we want IP discovery to kick in as a fallback when no addresses are defined. Therefore we don't want to default to true nor do we want to default to false but 'auto'. Whats the proper way to do that? For example in lightningd/lightningd.h:
enum config_autobool {
    AUTOBOOL_AUTO,
    AUTOBOOL_ON,
    AUTOBOOL_OFF
};

// ... plus the corresponding helpers to register this as an arg...
  1. Alternatively to 2. we can have it as a string arg with value checking. But that's ugly too for something that's more like an optional<boolean>.
  2. Alternatively to 2. and 3. we can enable annoucement of discovered IPs when there are only non-IP addresses announced (e.g. just a TOR address).

@m-schmoock m-schmoock requested a review from niftynei July 11, 2022 16:18
@rustyrussell
Copy link
Contributor

Number 2 is correct. And default to AUTO.

@m-schmoock
Copy link
Collaborator Author

m-schmoock commented Jul 11, 2022

Number 2 is correct. And default to AUTO.

@rustyrussell
Okay will add that.
And how about the deprecation of the --disable-ip-discovery flag? just drop it or fail/warn?

@rustyrussell
Copy link
Contributor

Number 2 is correct. And default to AUTO.

@rustyrussell Okay will add that. And how about the deprecation of the --disable-ip-discovery flag? just drop it or fail/warn?

You need to deprecate it: accept it if deprecated_apis is false with a log_unusual() warning, put it in Changelog, remove it from documentation...

Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

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

Ack f02e510

Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

ACK f02e510

@niftynei niftynei merged commit f67ab2a into ElementsProject:master Jul 12, 2022
@m-schmoock m-schmoock deleted the feat/auto_ipdiscovery branch July 17, 2022 10:59
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.

4 participants