diff --git a/contracts/Marketplace.sol b/contracts/Marketplace.sol index 6ea64b3..43bcad8 100644 --- a/contracts/Marketplace.sol +++ b/contracts/Marketplace.sol @@ -102,7 +102,7 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian { "maxSlotLoss exceeds slots" ); require( - request.ask.expansion > 0 && request.ask.expansion <= 100, + request.expansion > 0 && request.expansion <= 100, "expansion must be [1, 100]" ); diff --git a/contracts/Requests.sol b/contracts/Requests.sol index 46be82b..2a79235 100644 --- a/contracts/Requests.sol +++ b/contracts/Requests.sol @@ -10,6 +10,7 @@ struct Request { Content content; uint256 expiry; // amount of seconds since start of the request at which this request expires bytes32 nonce; // random nonce to differentiate between similar requests + uint8 expansion; // Percentage of addresses eligible to reserve a slot halfway between request creation and when all network addresses are eligible to participate. [1-100]. } struct Ask { @@ -20,7 +21,6 @@ struct Ask { uint256 reward; // amount of tokens paid per second per slot to hosts uint256 collateral; // amount of tokens required to be deposited by the hosts in order to fill the slot uint64 maxSlotLoss; // Max slots that can be lost without data considered to be lost - uint8 expansion; // Percentage of addresses eligible to reserve a slot halfway between request creation and when all network addresses are eligible to participate. [1-100]. } struct Content { diff --git a/test/Marketplace.test.js b/test/Marketplace.test.js index 5911609..f45511d 100644 --- a/test/Marketplace.test.js +++ b/test/Marketplace.test.js @@ -226,12 +226,12 @@ describe("Marketplace", function () { }) it("is rejected when expansion is out of bounds", async function () { - request.ask.expansion = 0 + request.expansion = 0 await expect(marketplace.requestStorage(request)).to.be.revertedWith( "expansion must be [1, 100]" ) - request.ask.expansion = 101 + request.expansion = 101 await expect(marketplace.requestStorage(request)).to.be.revertedWith( "expansion must be [1, 100]" ) diff --git a/test/examples.js b/test/examples.js index 4f750a2..78960ca 100644 --- a/test/examples.js +++ b/test/examples.js @@ -29,7 +29,6 @@ const exampleRequest = async () => { reward: 84, maxSlotLoss: 2, collateral: 200, - expansion: 60, }, content: { cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob", @@ -37,6 +36,7 @@ const exampleRequest = async () => { }, expiry: hours(1), nonce: hexlify(randomBytes(32)), + expansion: 60, // 60% of nodes are eligible halfway to when all addresses eligible } } diff --git a/test/ids.js b/test/ids.js index b1a3be3..c1efcac 100644 --- a/test/ids.js +++ b/test/ids.js @@ -2,10 +2,10 @@ const { ethers } = require("hardhat") const { keccak256, defaultAbiCoder } = ethers.utils function requestId(request) { - const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, uint64, uint8)" + const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, uint64)" const Content = "tuple(string, bytes32)" const Request = - "tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)" + "tuple(address, " + Ask + ", " + Content + ", uint256, bytes32, uint8)" return keccak256(defaultAbiCoder.encode([Request], requestToArray(request))) } @@ -18,7 +18,6 @@ function askToArray(ask) { ask.reward, ask.collateral, ask.maxSlotLoss, - ask.expansion, ] } @@ -34,6 +33,7 @@ function requestToArray(request) { contentToArray(request.content), request.expiry, request.nonce, + request.expansion ], ] }