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

Default IP and onion P2P ports conflict with each other, and with Bitcoin Core default onion P2P port #545

Open
JeremyRand opened this issue Aug 14, 2024 · 6 comments
Labels

Comments

@JeremyRand
Copy link
Member

Upstream Bitcoin Core listens on two P2P ports: port 8333 (for IP connections) and port 8334 (for Tor onion service connections), as per this log from Bitcoin Core:

2024-08-14T19:52:08Z Bound to 127.0.0.1:8334
2024-08-14T19:52:08Z Bound to [::]:8333
2024-08-14T19:52:08Z Bound to 0.0.0.0:8333

Meanwhile, Namecoin Core listens on port 8334 for both IP and onion P2P connections, as per this log (tested with b3b7c95):

2024-08-14T19:57:15Z Bound to 127.0.0.1:8334
2024-08-14T19:57:15Z Bound to [::]:8334
2024-08-14T19:57:15Z [net:error] Unable to bind to 0.0.0.0:8334 on this computer. Namecoin Core is probably already running.

This results in three problems:

  1. Namecoin Core cannot accept any incoming IPv4 or onion connections if Bitcoin Core is also running (unless either Bitcoin Core or Namecoin Core has been manually configured to use different ports).
  2. Namecoin Core cannot accept any incoming IPv4 connections because it conflicts with itself (unless Namecoin Core has been manually configured to use different ports).
  3. Latest Bitcoin Core master (and Namecoin Core with it) makes both of the above problems a fatal error that prevents launching at all.

Open questions on how to fix it:

  1. What ports should we switch to for IP and onion?
  2. Does our RPC port conflict with anything in Bitcoin Core?
  3. How should we do the transition so that we don't accidentally partition the network?

I have ideas on fix strategy which I will post in a bit, but curious what Daniel thinks.

(Thanks to @tfreedman from Cyphrs for reporting the launch failure.)

@JeremyRand JeremyRand added the bug label Aug 14, 2024
@JeremyRand
Copy link
Member Author

We should presumably check the P2P IP, P2P onion, and RPC ports for testnet and regtest for conflicts as well.

@JeremyRand
Copy link
Member Author

Latest Bitcoin Core master (and Namecoin Core with it) makes both of the above problems a fatal error that prevents launching at all.

This symptom is probably a blocker for the 28.0 release.

@JeremyRand
Copy link
Member Author

Suggested mitigation strategy:

  1. v28.0: Switch the incoming onion port. This resolves the immediate v28.0 blocker. It shouldn't cause a partition since virtually no one is exclusively connecting to onion peers.
  2. v28.1: Make outgoing IPv6 connections based on DNS seed results try both a new port and the existing port.
  3. v28.2: Add a new default incoming IPv6 port (leave the old one there too).
  4. v28.3: Add a DNS seed that returns IPv6 peers with the new port.
  5. v28.4: Make outgoing IPv4 connections based on DNS seed results try both a new port and the existing port.
  6. v28.5: Add a new default incoming IPv4 port (leave the old one there too).
  7. v28.6: Add a DNS seed that returns IPv4 peers with the new port.
  8. v28.7: Disable old default incoming IPv6 port.
  9. v28.8: Disable old IPv6 DNS seed.
  10. v28.9: Disable old outgoing IPv6 port.
  11. v28.10: Disable old default incoming IPv4 port.
  12. v28.11: Disable old IPv4 DNS seed.
  13. v28.12: Disable old outgoing IPv4 port.

The intent of doing this gradually is to minimize the amount of network disruption at any given time (this will cause some network disruption). Each change will not be committed to Git until DNS seed metrics show that the previous change is reasonably widespread on the P2P network. If v29.0 is tagged prior to some of the above being committed, then we will apply them to the 29.x series rather than 28.x, etc.

@domob1812
Copy link

Plan sounds good to me. Changing the onion port is most likely not an issue at all, and something we can do immediately. Changing the other ports based on how the network upgrades seems like a good idea. My guess is that it will update very slowly, though.

@JeremyRand
Copy link
Member Author

OK, so my suggestion is that we use port 8534 as the new RPC port, port 8535 as the new P2P port, and 8536 as the new onion port. Rationale:

  • It's a contiguous port range, like what Bitcoin does.
  • It's in the same order as Bitcoin's range.
  • None of these ports are widely used by existing applications. The only mention of any of these ports I can find in any of the port databases is that port 8536 is used by an obscure malware program that I doubt has been active for quite a while. (And if we cause a user-visible conflict with a malware program, that doesn't seem like a bad thing. Poor-man's antivirus?)
  • The two ports below this range, and the five ports above this range, also seem to be unused by common applications, which reduces the risk that future conflicts will arise.

Does this plan sound good? Should I submit a PR for changing the onion port?

@domob1812
Copy link

No objections from my side. And yes, if you could submit a PR for changing the onion port and unblock this for now, that would be very appreciated.

JeremyRand pushed a commit to JeremyRand/namecoin-core that referenced this issue Nov 3, 2024
JeremyRand pushed a commit to JeremyRand/namecoin-core that referenced this issue Nov 3, 2024
domob1812 added a commit that referenced this issue Nov 3, 2024
4dc3fc4 Avoid onion listen port collision (Jeremy Rand)

Pull request description:

  Refs #545

ACKs for top commit:
  domob1812:
    ACK 4dc3fc4.

Tree-SHA512: 05c3eaa572b236b1d3239313fc26089f40621eb6616915fc182975dfd030625f0963b35251f6d2334e2427366d5673c2ec610f7b056586fbbc8e994f739b4d4d
domob1812 pushed a commit to domob1812/namecoin-core that referenced this issue Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants