Publish IPNS from multiple nodes simultaneously?

Hello, I wanted to know if it was possible to publish an IPNS entry from multiple hosts at the same time?

I.e what we want to do is generate an IPNS key. Then copy that same key to multiple nodes. Then do an “ipns name publish --key=mykey $HASH” on multiple active nodes at the same time. Doable?

Ideally they would be publishing the same destination multihash, but I can envision timing problems/race conditions between getting them completely synchronized. Is there a problem if two different nodes publish a different hash to the network under the same IPNS at the same time? Thanks!

Doable. Check the other thead:

I read that thread but it wasn’t clear whether you could publish from two different nodes simultaneously. I am aware you can publish the same key from two different nodes at different times (e.g. the blog update example that was given in the thread) but I’m talking about for resiliency reasons publishing IPNS from two different hosts to the same Cid at the same time simultaneously.

I had to try something like this before — and I can say that…

  • value that published later usually just «overwrites» the earlier ones even when publishing from different nodes. As you said, it’s pretty difficult to publish two names at the exactly same time!

  • But sometimes resolving this name (especially immediately after publishing) returns both values discordantly — probably because the «actual» (published later) value has not yet spread across the all available nodes, and some of them can return the «outdated» (published earlier) value. (AFAIK, all DHT-connected IPFS nodes work as a mechanism for storing and resolving published IPNS entries… is this correct, IPFS developers?)

And it’s possible to make an slightly related experiment:

  1. Publish some hash with long lifetime — e.g. ipfs name publish --key=test.key --lifetime=48h /ipfs/Qm[value1]

  2. Try to resolve this IPNS name from any network-connected node: returned value obviously should be /ipfs/Qm[value1], no unexpected here.

  3. Then publish another hash under the same key, but with short lifetime — e.g. ipfs name publish --key=test.key --lifetime=9m /ipfs/Qm[value2].

  4. Try to resolve this name again. (Returned value should be /ipfs/Qm[value2], still no unexpected.)

  5. Wait 9 or more minutes — accordingly to lifetime from step 3. And try to resolve this key one more time. (Returned value should be /ipfs/Qm[value1] again — and this is quite unexpected! Seems like «obsolete» value actually not disappears immediately from IPFS swarm after publishing new one.)

Hope it will be useful.

Hey Jesse,

I don’t think it makes sense to publish the same Cid simultaneously from two hosts. Each publish operation gets broadcast, so doing it twice doesn’t really add anything. And even if one publish operation gets lost, you could just repeat it later from the same host.

So: Unless the network is entirely split in two, it doesn’t make sense to attempt redundant “publish” operations. (They technically won’t even really be redundant, because the published packet includes a sequence number; so unless you really publish exactly simultaneously, it’s quite likely that node 2 will already see the publish from node 1, and then increment the sequence number when it does its own publish.)