From 9ab65ae5a61a09a6849cc4adbd8ef58fb89c037e Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 2 Aug 2022 11:41:49 +0200 Subject: [PATCH] [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. --- contracts/Marketplace.sol | 4 ++-- test/examples.js | 4 ++-- test/ids.js | 10 ++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/contracts/Marketplace.sol b/contracts/Marketplace.sol index c778581..cbd7b6e 100644 --- a/contracts/Marketplace.sol +++ b/contracts/Marketplace.sol @@ -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 { diff --git a/test/examples.js b/test/examples.js index 1399294..b6302a8 100644 --- a/test/examples.js +++ b/test/examples.js @@ -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", diff --git a/test/ids.js b/test/ids.js index 5c59823..6f9ca95 100644 --- a/test/ids.js +++ b/test/ids.js @@ -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) {