Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Mortem: invalid CID for big images #11115

Open
vikiival opened this issue Oct 17, 2024 · 0 comments
Open

Post Mortem: invalid CID for big images #11115

vikiival opened this issue Oct 17, 2024 · 0 comments
Labels
bug Something isn't working post-mortem Bug bug

Comments

@vikiival
Copy link
Member

vikiival commented Oct 17, 2024

What happened?

@filippoweb3 reached to me that images from WUD collection are not loading on the wallets.
As a result external teams have opened issues/PRs:

He assured me in the DMs that content was uploaded via KodaDot > Create > Single NFT

The root issue was however in the pinning service.

[
  {
    "requestid": "Z2lkOi8vZmlsZWJhc2UvQXNzZXQvMTUyMTQ0MzE3OA",
    "status": "pinned",
    "created": "2024-10-16T10:15:00.000-04:00",
    "pin": {
      "cid": "QmfZchkQpaS8wSF3FCEefwmmnEjRwjZSBs3JFnEJWDiDfP",
      "name": "1 Bronze.png",
      "origins": [],
      "meta": {}
    },
    "info": {
      "size": "13189961"
    }
  },
  {
    "requestid": "Z2lkOi8vZmlsZWJhc2UvQXNzZXQvMTUyMTQ0MjY0Nw",
    "status": "pinned",
    "created": "2024-10-16T10:07:23.000-04:00",
    "pin": {
      "cid": "QmfZchkQpaS8wSF3FCEefwmmnEjRwjZSBs3JFnEJWDiDfP",
      "name": "QmdVRnnxfwxYQhvkUFT5YbEnBHa89ztBrmCBHnhczqkyud",
      "origins": [],
      "meta": {}
    },
    "info": {
      "size": "13189961"
    }
  }
]

To calculate CID we use a popular npm library called ipfs-only-hash this library exports a Hash object that does the calculation

import { CID } from 'multiformats'
import Hash from 'ipfs-only-hash'

export async function hashOf(content: ImportContent | string): Promise<CID> {
	// note: generating the hash.of
	// from cid v1 and then converting it to cid v0
	// generates a wrong cid with big file sizes
	return CID.parse(await Hash.of(content, { onlyHash: true, cidVersion: 1 }))
}

// toV0() is a conversion that broke the CID on big file
const cid = (await hashOf(content)).toV0().toString()

As you may observe there is nothing wrong on the snippet above, however when we were trying to convert v1 CID (starting baf) to the v0 (Qm), the library made a wrong calculation.

The fix

As @hassnian was the original author of pinning worker (ipos) he took the challenge and made a fix

Both of us have tested the PR to ensure the that CID mismatch is not happening again. Fix was deployed on production.

Who was affected

The IPOS worker was added in the 03333e1

Therefore users who minted files bigger than 9 MB in the dates between 17/07/2024 - 17/10/2024 could be affected

If you artwork is not loading correctly on Talisman/ Nova wallet please reach to us on the telegram channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working post-mortem Bug bug
Projects
None yet
Development

No branches or pull requests

1 participant