Move expansion from Ask to Request

This commit is contained in:
Eric 2024-09-19 16:55:47 +10:00
parent 3d5fa4708b
commit 0dabfd16d3
No known key found for this signature in database
5 changed files with 8 additions and 8 deletions

View File

@ -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]"
);

View File

@ -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 {

View File

@ -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]"
)

View File

@ -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
}
}

View File

@ -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
],
]
}