Change the cid from string to bytes (#214)

* Change the cid from string to bytes

* Fix content definition

* Fix cid invalid test
This commit is contained in:
Arnaud 2025-02-13 14:03:45 +01:00 committed by GitHub
parent 875e4d53ec
commit 0f2012b144
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 4 deletions

View File

@ -3,6 +3,7 @@ module.exports = {
repairRewardPercentage: 10, repairRewardPercentage: 10,
maxNumberOfSlashes: 2, maxNumberOfSlashes: 2,
slashPercentage: 20, slashPercentage: 20,
validatorRewardPercentage: 20, // percentage of the slashed amount going to the validators
}, },
proofs: { proofs: {
// period has to be less than downtime * blocktime // period has to be less than downtime * blocktime

View File

@ -23,7 +23,7 @@ struct Ask {
} }
struct Content { struct Content {
string cid; // content id, used to download the dataset bytes cid; // content id, used to download the dataset
bytes32 merkleRoot; // merkle root of the dataset, used to verify storage proofs bytes32 merkleRoot; // merkle root of the dataset, used to verify storage proofs
} }

View File

@ -279,7 +279,7 @@ describe("Marketplace", function () {
}) })
it("is rejected when cid is missing", async function () { it("is rejected when cid is missing", async function () {
request.content.cid = "" request.content.cid = []
await expect(marketplace.requestStorage(request)).to.be.revertedWith( await expect(marketplace.requestStorage(request)).to.be.revertedWith(
"Marketplace_InvalidCid" "Marketplace_InvalidCid"
) )

View File

@ -34,7 +34,7 @@ const exampleRequest = async () => {
collateralPerByte: 1, collateralPerByte: 1,
}, },
content: { content: {
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob", cid: Buffer.from("zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob"),
merkleRoot: Array.from(randomBytes(32)), merkleRoot: Array.from(randomBytes(32)),
}, },
expiry: hours(1), expiry: hours(1),

View File

@ -3,7 +3,7 @@ const { keccak256, defaultAbiCoder } = ethers.utils
function requestId(request) { function requestId(request) {
const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, int64)" const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, int64)"
const Content = "tuple(string, bytes32)" const Content = "tuple(bytes, bytes32)"
const Request = const Request =
"tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)" "tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)"
return keccak256(defaultAbiCoder.encode([Request], requestToArray(request))) return keccak256(defaultAbiCoder.encode([Request], requestToArray(request)))