delta
delta copied to clipboard
CID for /deals/content endpoint might be incorrect
For users who have already calculated commP and are passing it in to /deals/content endpoint, the payload cid we are calculating could be incorrect depending on whether the file being passed through is a car file or not (side note: I wasn't quite able to figure out if we check that anywhere in the code)
Assuming it is a car file being passed through, then we are adding it to the local ipfs node and calculating the payload cid for the car file, as opposed to the original file.
At the end of the day I don't think it matters because payload cid is not really relevant for storage deals, but it does look like we are calculating it and passing it in the deal proposal.
@anjor if you already have the commp (piece, padded size and size), you can add a metadata as part of the form request.
https://github.com/application-research/delta#upload-a-file
curl --location --request POST 'http://localhost:1414/api/v1/deal/content' \
--header 'Authorization: Bearer [ESTUARY_API_KEY]' \
--form 'data=@"/Users/alvinreyes/Downloads/baga6ea4seaqhfvwbdypebhffobtxjyp4gunwgwy2ydanlvbe6uizm5hlccxqmeq.car"' \
-form 'metadata="{\"miner\":\"f01963614\",
\"piece_commitment\": {
\"piece_cid\": \"baga6ea4seaqhfvwbdypebhffobtxjyp4gunwgwy2ydanlvbe6uizm5hlccxqmeq\",
\"padded_piece_size\": 4294967296
},
\"connection_mode\": \"e2e\",
\"size\": 2500366291
}"'
yeah that's fine. But in the code you still recalculate payload cid by pinning the uploaded car file: https://github.com/application-research/delta/blob/7b13079ea950981f445cb682490d17d512230aca/api/deal.go#L602
which will now be the payload cid for the car file, and not for the original file.
the recalculation here is ok since we want to make sure that the payload cid complies with how delta prepare deals.
What we can do is add a new endpoint that accepts a pre-computed CID. I'll add to the next release.
Will this payload cid be reported back to the user? Because that might make for weird UX, where the user will get back a car instead of the data they expect.