ipfs-sync icon indicating copy to clipboard operation
ipfs-sync copied to clipboard

Source IPFS Hash is not respected

Open mtahon opened this issue 5 years ago • 0 comments

Hello,

When using a non-default hash mechanism for IPFS CIDs, the files are transferred to the destination IPFS node overriding the hash algorithm, making the upload fail.

Example:

$ ./node_modules/\@graphprotocol/ipfs-sync/bin/ipfs-sync sync-files --from http://server.local:8080 --to https://api.thegraph.com/ipfs/ --file-list ./cid.txt 
Syncing files
Source node (--from): http://server.local:8080
Target node (--to): https://api.thegraph.com/ipfs/
20 files need to be synced
---
0/20 (bafkrwifoa6frs5wqw5auhbh7royk6hkfnziowoatwbllz564nms2z6xeoy): Syncing
0/20 (bafkrwifoa6frs5wqw5auhbh7royk6hkfnziowoatwbllz564nms2z6xeoy): Retrieving file
1/20 (bafkrwigwmspxwf6zar7krv3qxlthykbvtoiqgqoycr6c3ztllqz7mm22d4): Syncing
1/20 (bafkrwigwmspxwf6zar7krv3qxlthykbvtoiqgqoycr6c3ztllqz7mm22d4): Retrieving file
2/20 (bafkrwihl2nedu2xjc7tk4a6dif2x47423ccaledews3zp57o52ygxcc7uy): Syncing
2/20 (bafkrwihl2nedu2xjc7tk4a6dif2x47423ccaledews3zp57o52ygxcc7uy): Retrieving file
3/20 (bafkrwifbwtqeetqlpesoxytvvkeodfm2u7qifojralv6ijwoqyrlsjg3sa): Syncing
3/20 (bafkrwifbwtqeetqlpesoxytvvkeodfm2u7qifojralv6ijwoqyrlsjg3sa): Retrieving file
4/20 (bafkrwieb56ke3vul5o7ob2s3qqelxmtuhvckrdocbjln5tjdcjkgvf42zi): Syncing
4/20 (bafkrwieb56ke3vul5o7ob2s3qqelxmtuhvckrdocbjln5tjdcjkgvf42zi): Retrieving file
5/20 (bafkrwib3d67yenzpwygk6ronvxnzygsnoyafdicaupomnqmqjkvqbvkaai): Syncing
5/20 (bafkrwib3d67yenzpwygk6ronvxnzygsnoyafdicaupomnqmqjkvqbvkaai): Retrieving file
6/20 (bafkrwiheesfaeiq4lbk5v4taj7pr4gtjthgk673ij7dfyz3bzuelnszlvy): Syncing
6/20 (bafkrwiheesfaeiq4lbk5v4taj7pr4gtjthgk673ij7dfyz3bzuelnszlvy): Retrieving file
7/20 (bafkrwie2rlcgerupwqadju4rkl6s7aov2oxqvcishi6dv3fv55e7eee3sq): Syncing
7/20 (bafkrwie2rlcgerupwqadju4rkl6s7aov2oxqvcishi6dv3fv55e7eee3sq): Retrieving file
8/20 (bafkrwieywydmmikwroblwiskjbfmbaya54n6s3qa2hlpqu5fagcizgwlfa): Syncing
8/20 (bafkrwieywydmmikwroblwiskjbfmbaya54n6s3qa2hlpqu5fagcizgwlfa): Retrieving file
9/20 (bafkrwid74dlqi7ne7kxu27bhlq3fj5z2oul7fmihzzd5er6sbtznraftn4): Syncing
9/20 (bafkrwid74dlqi7ne7kxu27bhlq3fj5z2oul7fmihzzd5er6sbtznraftn4): Retrieving file
0/20 (bafkrwifoa6frs5wqw5auhbh7royk6hkfnziowoatwbllz564nms2z6xeoy): Uploading file
2/20 (bafkrwihl2nedu2xjc7tk4a6dif2x47423ccaledews3zp57o52ygxcc7uy): Uploading file
5/20 (bafkrwib3d67yenzpwygk6ronvxnzygsnoyafdicaupomnqmqjkvqbvkaai): Uploading file
6/20 (bafkrwiheesfaeiq4lbk5v4taj7pr4gtjthgk673ij7dfyz3bzuelnszlvy): Uploading file
3/20 (bafkrwifbwtqeetqlpesoxytvvkeodfm2u7qifojralv6ijwoqyrlsjg3sa): Uploading file
4/20 (bafkrwieb56ke3vul5o7ob2s3qqelxmtuhvckrdocbjln5tjdcjkgvf42zi): Uploading file
1/20 (bafkrwigwmspxwf6zar7krv3qxlthykbvtoiqgqoycr6c3ztllqz7mm22d4): Uploading file
9/20 (bafkrwid74dlqi7ne7kxu27bhlq3fj5z2oul7fmihzzd5er6sbtznraftn4): Uploading file
8/20 (bafkrwieywydmmikwroblwiskjbfmbaya54n6s3qa2hlpqu5fagcizgwlfa): Uploading file
7/20 (bafkrwie2rlcgerupwqadju4rkl6s7aov2oxqvcishi6dv3fv55e7eee3sq): Uploading file
/node_modules/gluegun/build/index.js:13
    throw up;
    ^

Error: 3/20 (bafkrwifbwtqeetqlpesoxytvvkeodfm2u7qifojralv6ijwoqyrlsjg3sa): Failed to sync file: Uploaded file hash differs: QmRsnvqTxFNPU5fM7bMPCBNYt7GREMxtnjnz4PHPEqC7KK
    at /node_modules/@graphprotocol/ipfs-sync/src/commands/sync-files.js:134:17
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async Promise.all (index 3)
    at async Command.run (/node_modules/@graphprotocol/ipfs-sync/src/commands/sync-files.js:89:5)

So apparently ipfs-sync is creating the hash QmRsnvqTxFNPU5fM7bMPCBNYt7GREMxtnjnz4PHPEqC7KK (CID with sha-2 hash algorithm) instead of the hash bafkrwifbwtqeetqlpesoxytvvkeodfm2u7qifojralv6ijwoqyrlsjg3sa (CID with keccak-256 hash algorithm)

The CID and hash algorithm should be respected when syncing the file to the destination node.

Best regards, Mathieu

mtahon avatar Oct 22 '20 10:10 mtahon