mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-02-05 19:25:28 +00:00
Move expansion from Ask to Request
This commit is contained in:
parent
3d5fa4708b
commit
0dabfd16d3
@ -102,7 +102,7 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
|||||||
"maxSlotLoss exceeds slots"
|
"maxSlotLoss exceeds slots"
|
||||||
);
|
);
|
||||||
require(
|
require(
|
||||||
request.ask.expansion > 0 && request.ask.expansion <= 100,
|
request.expansion > 0 && request.expansion <= 100,
|
||||||
"expansion must be [1, 100]"
|
"expansion must be [1, 100]"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ struct Request {
|
|||||||
Content content;
|
Content content;
|
||||||
uint256 expiry; // amount of seconds since start of the request at which this request expires
|
uint256 expiry; // amount of seconds since start of the request at which this request expires
|
||||||
bytes32 nonce; // random nonce to differentiate between similar requests
|
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 {
|
struct Ask {
|
||||||
@ -20,7 +21,6 @@ struct Ask {
|
|||||||
uint256 reward; // amount of tokens paid per second per slot to hosts
|
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
|
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
|
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 {
|
struct Content {
|
||||||
|
@ -226,12 +226,12 @@ describe("Marketplace", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("is rejected when expansion is out of bounds", async 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(
|
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
|
||||||
"expansion must be [1, 100]"
|
"expansion must be [1, 100]"
|
||||||
)
|
)
|
||||||
|
|
||||||
request.ask.expansion = 101
|
request.expansion = 101
|
||||||
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
|
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
|
||||||
"expansion must be [1, 100]"
|
"expansion must be [1, 100]"
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,6 @@ const exampleRequest = async () => {
|
|||||||
reward: 84,
|
reward: 84,
|
||||||
maxSlotLoss: 2,
|
maxSlotLoss: 2,
|
||||||
collateral: 200,
|
collateral: 200,
|
||||||
expansion: 60,
|
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",
|
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",
|
||||||
@ -37,6 +36,7 @@ const exampleRequest = async () => {
|
|||||||
},
|
},
|
||||||
expiry: hours(1),
|
expiry: hours(1),
|
||||||
nonce: hexlify(randomBytes(32)),
|
nonce: hexlify(randomBytes(32)),
|
||||||
|
expansion: 60, // 60% of nodes are eligible halfway to when all addresses eligible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ const { ethers } = require("hardhat")
|
|||||||
const { keccak256, defaultAbiCoder } = ethers.utils
|
const { keccak256, defaultAbiCoder } = ethers.utils
|
||||||
|
|
||||||
function requestId(request) {
|
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 Content = "tuple(string, bytes32)"
|
||||||
const Request =
|
const Request =
|
||||||
"tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)"
|
"tuple(address, " + Ask + ", " + Content + ", uint256, bytes32, uint8)"
|
||||||
return keccak256(defaultAbiCoder.encode([Request], requestToArray(request)))
|
return keccak256(defaultAbiCoder.encode([Request], requestToArray(request)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +18,6 @@ function askToArray(ask) {
|
|||||||
ask.reward,
|
ask.reward,
|
||||||
ask.collateral,
|
ask.collateral,
|
||||||
ask.maxSlotLoss,
|
ask.maxSlotLoss,
|
||||||
ask.expansion,
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +33,7 @@ function requestToArray(request) {
|
|||||||
contentToArray(request.content),
|
contentToArray(request.content),
|
||||||
request.expiry,
|
request.expiry,
|
||||||
request.nonce,
|
request.nonce,
|
||||||
|
request.expansion
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user