-
Notifications
You must be signed in to change notification settings - Fork 1.2k
wrong IPNS DHT record selection algorithm #2183
Comments
I might extend that whomever answers this, wondering if you could kindly also touch on when the DHT is expected to by out of alpha and ready for production deployments? I looked at the weekly team call logs which seemingly stopped (?) being documented in 2018. Gracias. |
@vasco-santos can you speak to this? The implementation suggested by @Qmstream looks good to me. Is there another reason this was implemented like this? Does the selector function always receive 2 records? Note, we'd have to change the implementation here as well as |
Hey! thanks for reaching out @Mapiac Something is incorrect here in fact! I believe this is valid for the selection when a peer is syncing its value back, but not for getting the record from the DHT. In this way, I would expect that we call the select function from ipfs/js-ipfs/src/core/ipns/routing/utils.js#L15 Other option, that seems the most correct to me, would be to change the @Mapiac would you like to PR |
The So either this function needs to change to call the selector multiple times, reducing the records down to 1, or the selector needs to change to accept multiple records (as @Qmstream suggests). |
I also noticed the dht's Is it really necessary to keep these empty/errored values? Why not simply: if (rec && rec.value) {
pathVals.push({
val: rec.value,
from: peer
})
} [edit:] Oh, maybe you are keeping track of peers with bad records to later send them correction values? In that case perhaps it would be better to filter this list before sending them to How about changing to const recs = vals.map((v) => v.val).filter(Boolean) [edit again:] It's also necessary to change to if (v.val && v.val.equals(best)) { |
@Qmstream thank you reporting this - would you mind opening an issue for this on https://github.com/libp2p/js-libp2p-kad-dht ? 🙏 |
Should I submit a PR in And then submit another PR in js-ipfs/src/core/ipns/routing/utils.js Line 15 in 0287a6c
|
@vasco-santos @alanshaw looks like the At the moment IPNS seems to be broken both on DHT and pubsub when it comes to getting the latest records. |
js-ipfs is being deprecated in favor of Helia. You can #4336 and read the migration guide. This should have been fixed in https://github.com/ipfs/helia-ipns - if it's not please open an issue on that repo. |
I'm not sure how to to deal with this as two modules are involved:
But the current IPNS record selection algorithm is wrong: it receives an array of records from the DHT but compares only the two first entries (and throws if only one entry is present):
js-ipfs/src/core/ipns/routing/utils.js
Line 15 in 0287a6c
An alternative, correct implementation would be this:
But it's necessary to change the interface of
ipns.validator.select
:https://github.com/ipfs/js-ipns/blob/ccc41788705e4bc4043a47af0aee86a29b2159a3/src/index.js#L310
(For reference: the records come from: https://github.com/libp2p/js-libp2p-kad-dht/blob/master/src/private.js#L294)
The text was updated successfully, but these errors were encountered: