[marketplace] Specify size per slot, instead of total size

Reasoning: it was unclear exactly how much storage a
host should have available for a slot. The division
size/slots can have a non-integer value.
This commit is contained in:
Mark Spanbroek 2022-08-02 11:41:49 +02:00 committed by markspanbroek
parent 3e9fffb526
commit 9ab65ae5a6
3 changed files with 12 additions and 6 deletions

View File

@ -129,11 +129,11 @@ contract Marketplace is Collateral, Proofs {
}
struct Ask {
uint256 size; // size of requested storage in number of bytes
uint64 slots; // the number of requested slots
uint256 slotSize; // amount of storage per slot (in number of bytes)
uint256 duration; // how long content should be stored (in seconds)
uint256 proofProbability; // how often storage proofs are required
uint256 reward; // amount of tokens paid per second per slot to hosts
uint64 slots; // the total number of hosts that store the data set
}
struct Content {

View File

@ -5,11 +5,11 @@ const { hexlify, randomBytes } = ethers.utils
const exampleRequest = () => ({
client: hexlify(randomBytes(20)),
ask: {
size: 1 * 1024 * 1024 * 1024, // 1 Gigabyte
slots: 4,
slotSize: 1 * 1024 * 1024 * 1024, // 1 Gigabyte
duration: hours(10),
proofProbability: 4, // require a proof roughly once every 4 periods
reward: 84,
slots: 4,
},
content: {
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",

View File

@ -2,7 +2,7 @@ const { ethers } = require("hardhat")
const { keccak256, defaultAbiCoder } = ethers.utils
function requestId(request) {
const Ask = "tuple(uint256, uint256, uint256, uint256, int64)"
const Ask = "tuple(int64, uint256, uint256, uint256, uint256)"
const Erasure = "tuple(uint64)"
const PoR = "tuple(bytes, bytes, bytes)"
const Content = "tuple(string, " + Erasure + ", " + PoR + ")"
@ -12,7 +12,13 @@ function requestId(request) {
}
function askToArray(ask) {
return [ask.size, ask.duration, ask.proofProbability, ask.reward, ask.slots]
return [
ask.slots,
ask.slotSize,
ask.duration,
ask.proofProbability,
ask.reward,
]
}
function erasureToArray(erasure) {