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

Increased ProviderAddrTTL from RFM17.1 isn't applied #868

Closed
dennis-tra opened this issue Aug 22, 2023 · 1 comment · Fixed by #870
Closed

Increased ProviderAddrTTL from RFM17.1 isn't applied #868

dennis-tra opened this issue Aug 22, 2023 · 1 comment · Fixed by #870

Comments

@dennis-tra
Copy link
Contributor

dennis-tra commented Aug 22, 2023

Looking through the code, I believe that the increased ProviderAddrTTL doesn’t have any effect. We increased that value as a result of RFM 17.1.

In this line we pass the new provider of a certain key to the ProviderManager:

dht.providerStore.AddProvider(ctx, key, peer.AddrInfo{ID: p})

The value that we're passing is just peer.AddrInfo{ID: p}, so there are no addresses attached to it. In the ProviderManger this value gets handled here:

if provInfo.ID != pm.self {
  pm.pstore.AddAddrs(provInfo.ID, provInfo.Addrs, ProviderAddrTTL)
}

provInfo is the peer.AddrInfo{ID: p} from above. This means the Addrs field will be always empty, so, I believe, ProviderAddrTTL won't have any effect.

However, we're still keeping the addresses around for a bit because the peer that stores the records with us gets added to the peerstore just because it connected to us - the TTL of their addresses will just be different. I think the values are ConnectedAddrTTL while we're connected to that peer (basically infinite TTL) and TempAddrTTL after we have disconnected. The latter value is set to 2 minutes.

cc @cortze

@dennis-tra
Copy link
Contributor Author

This is how it worked initially: 3b37c43

	for _, pi := range pinfos {
		if pi.ID != p {
			// we should ignore this provider reccord! not from originator.
			// (we chould sign them and check signature later...)
			log.Errorf("handleAddProvider received provider %s from %s. Ignore.", pi.ID, p)
			continue
		}

		if len(pi.Addrs) < 1 {
			log.Errorf("got no valid addresses for provider %s. Ignore.", p)
			continue
		}

		log.Infof("received provider %s for %s (addrs: %s)", p, key, pi.Addrs)
		for _, maddr := range pi.Addrs {
			// add the received addresses to our peerstore.
			dht.peerstore.AddAddress(p, maddr)
		}
		dht.providers.AddProvider(key, p)
	}

That's where it capsized: 7724838

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.

1 participant