-
Notifications
You must be signed in to change notification settings - Fork 798
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
[net/libp2p] Use raw Identify
observed addresses to discover external addresses
#7338
base: master
Are you sure you want to change the base?
Conversation
/cmd prdoc --audience node_dev --bump patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic looks good to me!
Err(address) | ||
} | ||
} else { | ||
Ok(address.with(Protocol::P2p(self.local_peer_id))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too familiar with this, is it a common scenario to receive an identify report without PeerId? Or more exceptional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They typically don't include the peer ID, but it is not stated in libp2p spec whether they are allowed to include the peer ID. Unfortunately, it's a real nightmare in libp2p & litep2p, as it's always not clear whether a multiaddress in some specific place includes or does not include the peer ID.
const MIN_ADDRESS_CONFIRMATIONS: usize = 2; | ||
/// Number of times observed address is received from different peers before it is confirmed as | ||
/// external. | ||
const MIN_ADDRESS_CONFIRMATIONS: usize = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are now waiting for 3 confirmations in an LRU of 32 addresses. Are we losing precision somehow with this setup? Should we bump MAX_EXTERNAL_ADDRESSES
to a higher value, or are we able to discover addresses just like before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a bug, and when we received the address for the first time we inserted an empty hash map, and only after that counted confirmations. So it was always 3 confirmations, just the information about the first peer ID we got the address from was lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice job here 🙏
let oldest = (self.address_confirmations.len() >= | ||
self.address_confirmations.limiter().max_length() as usize) | ||
.then(|| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks slightly horrible :D (Some upstream change that also returns the removed item on insert would be nice)
Instead of using libp2p-provided external address candidates, susceptible to address translation issues, use litep2p-backend approach based on confirming addresses observed by multiple peers as external.
Fixes #7207.