perf: optimizing parameters sizing

This commit is contained in:
Adam Uhlíř 2025-01-08 14:58:51 +01:00
parent dfab6102e7
commit 7e69a3be3e
No known key found for this signature in database
GPG Key ID: 1D17A9E81F76155B
3 changed files with 10 additions and 11 deletions

View File

@ -10,7 +10,7 @@ insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[{*.js, *.sol}]
[{*.js,*.sol}]
charset = utf-8
indent_style = space
indent_size = 2

View File

@ -8,17 +8,17 @@ struct Request {
address client;
Ask ask;
Content content;
uint256 expiry; // amount of seconds since start of the request at which this request expires
uint64 expiry; // amount of seconds since start of the request at which this request expires
bytes32 nonce; // random nonce to differentiate between similar requests
}
struct Ask {
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
uint256 collateral; // amount of tokens required to be deposited by the hosts in order to fill the slot
uint64 slots; // the number of requested slots
uint64 slotSize; // amount of storage per slot (in number of bytes)
uint64 duration; // how long content should be stored (in seconds)
uint64 maxSlotLoss; // Max slots that can be lost without data considered to be lost
}

View File

@ -2,21 +2,20 @@ const { ethers } = require("hardhat")
const { keccak256, defaultAbiCoder } = ethers.utils
function requestId(request) {
const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, int64)"
const Ask = "tuple(uint256, uint256, uint256, int64, int64, int64, int64)"
const Content = "tuple(string, bytes32)"
const Request =
"tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)"
const Request = "tuple(address, " + Ask + ", " + Content + ", int64, bytes32)"
return keccak256(defaultAbiCoder.encode([Request], requestToArray(request)))
}
function askToArray(ask) {
return [
ask.slots,
ask.slotSize,
ask.duration,
ask.proofProbability,
ask.reward,
ask.collateral,
ask.slots,
ask.slotSize,
ask.duration,
ask.maxSlotLoss,
]
}