ipfs / boxo

A set of reference libraries for building IPFS applications and implementations in Go.
https://github.com/ipfs/boxo#readme
Other
181 stars 82 forks source link

gateway: rollback IPNS #397

Open Jorropo opened 1 year ago

Jorropo commented 1 year ago

Currently IPNS over the DHT is very fast to find a record but it then waits for a while trying to contact various nodes trying to ensure this record is updated until a timeout is reached. (see ipfs name resolve -s $SOME_IPNS_NAME)

We should start the gateway serving process as soon as the first record is found, but hold onto serving response. If an other better record is found we can cancel the first request and make a new one, "rolling back". Given reaching consensus on IPNS is often the longest thing before first byte, it would make the TTFB === IPNS resolution time, since initial data resolution (traversing path and ranges in the file until we find the first piece of data), provider record resolution and bitswap session building would be pipelined into quorum process.

Given bitswap sessions and the block cache it's also likely doing an outdated request first will accelerate the real request later. For example if I found you host an old version of some IPNS name, I think it's reasonable to optimistically ask you for the newer one when I learn about it even tho I didn't finished my provider record step yet.

Winterhuman commented 1 year ago

As an additional consideration: https://github.com/ipfs/specs/issues/274