Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

raw block response fails hash verification #98

Closed
Arqu opened this issue Nov 2, 2022 · 3 comments · Fixed by n0-computer/iroh#644
Closed

raw block response fails hash verification #98

Arqu opened this issue Nov 2, 2022 · 3 comments · Fixed by n0-computer/iroh#644
Assignees
Labels
bug Something isn't working

Comments

@Arqu
Copy link
Collaborator

Arqu commented Nov 2, 2022

When running as a racing gateway iroh fails the the block hash verification for raw.
bafybeifffvqarrkavsdg664bluuci3ojmmda6st73icfjgzqbb7ffhlkwi

@Arqu Arqu added the bug Something isn't working label Nov 2, 2022
@b5 b5 assigned Arqu Nov 2, 2022
@Arqu
Copy link
Collaborator Author

Arqu commented Dec 16, 2022

@b5 think I got to this. To confirm, can you possibly recall or share the exact http_resolvers address you passed in?

@Arqu
Copy link
Collaborator Author

Arqu commented Dec 19, 2022

So, this is fun.
When fetching from an iroh gateway, you always get the data and just the data.
On ipfs.io for example if you do a ?format=raw which we use for racing gateways, the data seems prefixed with:

  • \n\xcb\x08\x08\x02\x12\xc3\x08 for QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB in stringy form
  • 0A, CB, 08, 08, 02, 12, C3, 08 for QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB
  • 0A, 8A, 80, 10, 08, 02, 12, 80, 80, 10 for bafybeifffvqarrkavsdg664bluuci3ojmmda6st73icfjgzqbb7ffhlkwi

@lidel
Copy link

lidel commented Dec 19, 2022

Unable to reproduce, gateway returns exactly the same bytes as getting raw block:

$ ipfs block get bafybeifffvqarrkavsdg664bluuci3ojmmda6st73icfjgzqbb7ffhlkwi > expected
$ curl "http://127.0.0.1:8080/ipfs/bafybeifffvqarrkavsdg664bluuci3ojmmda6st73icfjgzqbb7ffhlkwi?format=raw" > local_curl
$ curl "https://ipfs.io/ipfs/bafybeifffvqarrkavsdg664bluuci3ojmmda6st73icfjgzqbb7ffhlkwi?format=raw" > ipfs.io_curl

$ diff -s expected local_curl
Files expected and local_curl are identical
$ diff -s expected ipfs.io_curl
Files expected and ipfs.io_curl are identical

@Arqu perhaps you are comparing different things, such as dag-pb[Data].Data field with the entire dag-pb block? ?format=raw will return the entire block as opaque bytes, and for dag-pb block it means entire outer protobuf.

ps. You may want to look at ipfs/specs#331 which explains internals of dag-pb blocks, but ?format=raw does not care about codec, it does not parse the block, it only return bytes that will hash to the multihash in the requested CID and that is all.

@dignifiedquire dignifiedquire transferred this issue from n0-computer/iroh Feb 17, 2023
@ramfox ramfox removed this from iroh Feb 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants