IPNS Record Owner Optimisation
Here's the current situation when fetching the latest IPNS record:
- Peer
12D3KooWownercreates an IPNS recordk51key...and distributes it through the network. - Peer
12D3KooWresolverwants to find the latest version ofk51key.... 12D3KooWresolversearches the network and findsnpeers who advertisek51key..., they then fetch the record fromnnumber of peers and check which record has the highest sequence value.
The problem with this system is that it's very slow needing multiple peers to verify that you've fetched the latest record, however, there is an optimisation for speeding this up for when one of the n peers happens to be the record owner. Here's how it might work:
- Peer
12D3KooWownercreates an IPNS recordk51key...and distributes it through the network. - Peer
12D3KooWresolverwants to find the latest version ofk51key.... 12D3KooWresolversearches the network and findsnpeers who advertisek51key.... Instead of trying to fetchnnumber of records, they start by fetching a few at random (let's say three for this example).12D3KooWresolverreads the record to find PeerID12D3KooWowner, they then check to see if any of thenpeers they found have PeerID12D3KooWowner.- If one of the 3 random peers was the record owner, the search can immediately stop since the record owner's copy of
k51key...is guaranteed to be the latest and has already been fetched. - If one of the
n-3peers is the record holder,12D3KooWresolvercan attempt to fetchk51key...directly from them. If it succeeds, the search can immediately stop since the record owner's copy ofk51key...is guaranteed to be the latest. - If
12D3KooWownerisn't any of thenpeers, or the attempt to fetchk51key...from12D3KooWownerfailed,12D3KooWresolverwill continue to fetch all remaining records to compare them as before.
Because IPNS records expire, record owners are likely to be online most of the time in order to ensure the record doesn't disappear from the network, this means the chance of finding the record holder amongst the n peers will be relatively high in the current environment.
Yeah, this would be really nice. Basically, IPNS records could contain "canonical" sources for finding the latest version.
Turns out you actually mentioned something very similar to this about 4 years ago: https://github.com/libp2p/go-libp2p-kad-dht/issues/145#issuecomment-410831110
Having an optional IpnsEntry.data[trust] field for defining an array of PeerIDs to trust (with the owner's PeerID being implicitly trusted) seems like a possible way forward, what do you think? @Stebalien @lidel
Context: https://github.com/ipfs/specs/pull/319
I've created https://github.com/ipfs/specs/pull/350 to close this issue