-
Notifications
You must be signed in to change notification settings - Fork 42
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
Rust peer is announcing wrong multiaddrs #131
Comments
I've deployed this branch of the rust-peer and so far it seems to have solved the problem:
Also true from the perspective of the delegated routing endpoint |
This looks to me like you are running this application over the internet. It may establish a new port per connection and so the external peer is witnessing this new port and reporting it back to you. I would try setting up a port forward on your router to avoid this kind of NATing and see if that helps. |
I also originally thought it was a NAT issue. But there may be something else going on When I tried this briefly I'm seeing most peers report my correct port and only a few others don't. I then tried to identify those peers directly with vole (go-libp2p), thinking they may be giving weird/wrong responses. But they return the correct response there. I'll try to dig a little deeper. The core issue of course is that we are seeing weird/wrong observed address after Identifying. In general it should be safe to only announce our observed addr after we see the same addr a handful of times (in go-libp2p we set this to 4). |
Yes
I have the Rust peer deployed to a VM with a dedicated public IPv4. No NAT.
Right, is that generally something that is abstracted by libp2p or done in user space? So what's the root problem?We see that other peers observe the Rust peer to have the same IP however with a different port to the one it's explicitly listening on (9091 and 9090). I'm not intimately familiar with how connections are initiated in rust libp2p and the underlying OS network stack, but it seems reasonable that outgoing connections from the rust peer have a dynamic allocated source port that is different the one the rust peer is explicitly listening on This kind of begs the question –if nothing else but for my own curiosity– of how this problem is avoided generally in the identify protocol? Is convention to follow a certain "threshold consensus" of 4 (or more) peers reporting the same observed address to verify your observed address? |
@2color can you try an experiment for me? Run the rust-peer and save the output to a file (e.g.
Here's my output: https://gist.github.com/MarcoPolo/1eb35eddd9bda917cd052fc7bb7b108e I'm running this on a forwarded port on a home server. There should be no NAT involved. This is also interesting:
This makes me think that what we might be seeing is the NAT on our remote peer's end. |
@MarcoPolo Here's the output for both commands: https://gist.github.com/2color/f9cd261d13d994ebd5abb918f972e5fe |
I did a similar experiment on the Go peer in this repo (using this patch) and here are the addrs I see reported back:
So the go peer does see random ports reported back as well. Another interesting thing is that the rust-peer seems to be go through a lot more connections in the same period of time. Here the Go peer connected to about 1500 peers. The Rust one in the same time connected to about 15k peers! That's probably a bug? @2color do you also see the rust one connecting to ~10x the number of peers in the same period of time? Unrelated to the many conns bug. I think this experiment shows that the weird multiaddrs we see in the observed addrs are coming from remote peers and not something due to rust-libp2p (probably) since we see the same thing in go-libp2p. |
Interesting. What's your explanation for these random ports then?
Off the cuff, yes, but I haven't tested it enough to say.
Yeah. I wonder why the |
I think it's a NAT on their end. Their router maps the port differently, maybe for "security".
It's to learn about your public IP Addresses if you don't know it. On EC2 your machine doesn't know its public address. The correct logic is complicated and subtle. But a first order approximation is probably something like:
|
Problem
The Rust bootstrap peer (
12D3KooWGahRw3ZnM4gAyd9FK75v4Bp5keFYTvkcAwhpEm28wbV3
) that is deployed on a machine with a public IP (/ip4/147.28.186.157
) has been announcing many multiaddrs with the same IP and a different port.For example, sending an identify request to the peer we get the following response
Even though the node is only listening on
147.28.186.157
port9091
for QUIC connections.Potential cause
The rust peer may be announcing/responding to peer routing requests with wrong multiaddrs.
When the rust peer receives an Identify protocol event, it takes the observed address from the event and calls
swarm.add_external_address
:universal-connectivity/rust-peer/src/main.rs
Lines 207 to 220 in 0d235e7
When looking at the looks, there were cases when
observed_addr
was a different port, e.g./ip4/147.28.186.157/udp/5272/quic-v1
.I suspect that the observed port in this example is wrongly
5272
instead of9001
due to connections that were initiated (outgoing) by the bootstrap rust-peer where this in fact the outgoing port, but not the one that is publicly dialable.Open questions
swarm.add_external_address
call? According to the code docs:/// Add a confirmed external address for the local node.
///
/// This function should only be called with addresses that are guaranteed to be reachable.
/// The address is broadcast to all [
NetworkBehaviour
]s via [FromSwarm::ExternalAddrConfirmed
].The text was updated successfully, but these errors were encountered: