-
Notifications
You must be signed in to change notification settings - Fork 636
p2p: Switch
dial excludes peers from same machine (IP)
#4494
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
Comments
I don't think the reported scenario can be observed when Actually, we always use this configuration when running unit tests: Lines 32 to 36 in fc4e719
Exactly because all nodes end up having the same IP (e.g., |
This flag was introduced, with a different name, by this commit: 5796e87. It works like this from 2018. This comment is also useful: tendermint/tendermint#1634 (comment). |
The reason for the default being |
Hmmm so interesting! By the way I have hit this also Yes, while testing I think that the best solution is to get rid of the flag and makes a default behavior not do anything special if it's the same IP address because really what we should be looking for anyway is the node ID and not the IP address so much. |
Uh oh!
There was an error while loading. Please reload this page.
Bug Report / Question
Description
The current implementation of the p2p
Switch
keeps track of peers using their verified IDs.However, if a peer connection originates / is directed towards a machine whose IP is already stored in the peer store (from a different peer), regardless of the port, the potential peer dial is ignored:
cometbft/p2p/switch.go
Lines 571 to 575 in c6fa225
Example:
Peer A has peers:
cosmos123@127.0.0.1:3000
cosmos456@187.155.80.202:2525
If a new peer, originating either from
127.0.0.1
or187.155.80.202
, but from a different port (ex.3001
/2526
) is considered for a dial onPeer A
, they are ignored because a peer with the same IP is already present -- even though they can be 2 completely separate peers (clients) running on the same machine (but on different ports).Edit:
My bigger question here is -- why does
AllowDuplicateIP
exist, why not do this by default? What is the benefit of excluding peers from the same machine?I can only assume it's some kind of security measure to block specific endpoints from initiating connections, but IPs are easily spoofed.
cc @melekes
How to reproduce it
Craft a unit test that creates 3
Switch
instances, withTransport
s running on different ports (same IP of course), and haveSwitch 0
connect toSwitch 1
andSwitch 2
. (Switch 0
is the only dialer in this scenario, turn off discovery)If
Switch 0
connects toSwitch 1
first, the dial toSwitch 2
should be ignored, becauseSwitch 1
andSwitch 2
share the same IP, but run on different ports -- this shouldn't be the case in reality, since different client processes can originate from the same machine.The text was updated successfully, but these errors were encountered: