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

network/litep2p: Publishes empty addresses at startup #5147

Closed
alexggh opened this issue Jul 25, 2024 · 4 comments · Fixed by #5176
Closed

network/litep2p: Publishes empty addresses at startup #5147

alexggh opened this issue Jul 25, 2024 · 4 comments · Fixed by #5176

Comments

@alexggh
Copy link
Contributor

alexggh commented Jul 25, 2024

https://grafana.teleport.parity.io/goto/V-MQGUXSR?orgId=1

When starting a node with litep2p enabled I see in the logs that it publishes on the DHT addresses which are not valid

Publishing authority DHT record peer_id='12D3KooWSogJN9vDNkkpNFMAdDAB5XGUGaM5T8tDsB1F4x8vV2de' addresses='[]'
Publishing authority DHT record peer_id='12D3KooWKKotwpDtVqi7rZyKEovpVdDqiV9LuwVu1b3KTZgbXZw4' addresses='[]'

Nodes publish a few seconds later valid addresses, so this errors might be harmless, but they still need to be investigated.

cc: @paritytech/networking

@lexnv
Copy link
Contributor

lexnv commented Jul 25, 2024

It looks like we rely on the Identify protocol to obtain the observed address.

When we receive a response via the identify info, we get the observed address and populate the external_addresses:

Some(DiscoveryEvent::ExternalAddressDiscovered { address }) => {
let mut addresses = self.external_addresses.write();
if addresses.insert(address.clone()) {
log::info!(target: LOG_TARGET, "discovered new external address for our node: {address}");
}

We only report back addresses that have been confirmed at least 5 times, although I believe the confirmation can come from the same peer multiple times:

match self.address_confirmations.get(address) {
Some(confirmations) => {
*confirmations += 1usize;
if *confirmations >= MIN_ADDRESS_CONFIRMATIONS {
return true
}
},
None => {
self.address_confirmations.insert(address.clone(), 1usize);
},
}
false

Definetly something to look into, this might be the reason why some validators are failing to connect.
I've also observed that libp2p can discover addresses much faster than litep2p, I think it relies on other mechanisms that we can look into.

@dmitry-markin
Copy link
Contributor

I've also observed that libp2p can discover addresses much faster than litep2p, I think it relies on other mechanisms that we can look into.

libp2p uses address translation to "discover" external addresses, that boils down to replacing the port in the discovered external address by the port used in the listen address. While being one-shot procedure and working for simple 1:1 port forwarding cases, I think it's incorrect in the general case and inferior than heuristic of comparing addresses returned by different peers.

May be we can decrease the number of confirmations to 3, ensuring they are coming from different peers.

As for authority-discovery, would deferring publishing until we have at least one external address detected fix the issue?

@lexnv
Copy link
Contributor

lexnv commented Jul 29, 2024

Yep, it sounds good to me, exactly my plan (although I picked 2 confirmations instead of 3) :D

@alexggh
Copy link
Contributor Author

alexggh commented Jul 29, 2024

Whatever solution we come up with, can we also make sure it fixes this case as well ?

github-merge-queue bot pushed a commit that referenced this issue Jul 31, 2024
…only (#5176)

This PR reduces the occurrences for identified observed addresses.

Litep2p discovers its external addresses by inspecting the
`IdentifyInfo::ObservedAddress` field reported by other peers.
After we get 5 confirmations of the same external observed address (the
address the peer dialed to reach us), the address is reported through
the network layer.

The PR effectively changes this from 5 to 2.
This has a subtle implication on freshly started nodes for the
authority-discovery discussed below.

The PR also makes the authority discovery a bit more robust by not
publishing records if the node doesn't have addresses yet to report.
This aims to fix a scenario where:
- the litep2p node has started, it has some pending observed addresses
but less than 5
- the authorit-discovery publishes a record, but at this time the node
doesn't have any addresses discovered and the record is published
without addresses -> this means other nodes will not be able to reach us

Next Steps
- [ ] versi testing

Closes: #5147

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this issue Aug 2, 2024
…only (paritytech#5176)

This PR reduces the occurrences for identified observed addresses.

Litep2p discovers its external addresses by inspecting the
`IdentifyInfo::ObservedAddress` field reported by other peers.
After we get 5 confirmations of the same external observed address (the
address the peer dialed to reach us), the address is reported through
the network layer.

The PR effectively changes this from 5 to 2.
This has a subtle implication on freshly started nodes for the
authority-discovery discussed below.

The PR also makes the authority discovery a bit more robust by not
publishing records if the node doesn't have addresses yet to report.
This aims to fix a scenario where:
- the litep2p node has started, it has some pending observed addresses
but less than 5
- the authorit-discovery publishes a record, but at this time the node
doesn't have any addresses discovered and the record is published
without addresses -> this means other nodes will not be able to reach us

Next Steps
- [ ] versi testing

Closes: paritytech#5147

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
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 a pull request may close this issue.

3 participants