orbitdb: Head hash didn't match the contents errors
Several users are reporting this warning
console.warn node_modules/orbit-db-store/src/Store.js:258
"WARNING! Head hash didn't match the contents
While this seems alarming, it’s much more likely a bug in OrbitDB than anything else. We will investigate.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 26 (17 by maintainers)
This was happening before because JSON.stringify wasn’t deterministic, so I thought this had been fixed. There’s likely another culprit not being serialized correctly, or something similar. Retrograding seems to have helped @ptoner which is why I closed it.
Reopened 😃
getting this with ipfs-js “0.55.3”, orbit-db “0.26.1”
The order of
Object.keysis not deterministic. If there’s a part of the code that relies on that, we should change that. There are libraries like https://github.com/substack/json-stable-stringify that could be used, if necessary.Are you able to point me to the code in question, @oed?
We are on version
0.21.3and are still seeing this (a lot). @thiagodelgado111 was working on a fix, maybe he knows more.So got to the bottom of it:
The problem occurs when there is a
nullvalue inside the payload. Makes sense.Ehm, why was this closed? We are still experiencing this issue with
js-ipfs@0.36.4. Don’t think this is related to the ipfs version actually.Seems to both be z ones.
I’ve narrowed it down to this: It happens with entries I receive from another node on the network. The reason it happens is because of the keys being in the wrong order. Here is the output from the two hashes that don’t match:
For some reason it seems like the
sigandkeyproperty in the object received from another node are swapped. The objects are the same otherwise. If I only load the db locally I don’t see this issue.There might of course be other causes for the issue, but atleast this one is confirmed.
I’m on orbitdb
0.21.4.not sure though that it’s the case but do you have only one db per instance? I think i had this warning because i created few bases per one instance.