mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-30 00:05:01 +00:00
33010bd20c
* feat(slot-reservations): Allow slots to be reserved Closes #175. Allows reservation of slots, without an implementation of the expanding window. - Add a function called `reserveSlot(address, SlotId)`, that allows three unique addresses per slot to be reserved, that returns bool if successful. - Use `mapping(SlotId => EnumerableSet.AddressSet)` - Return false if the address could not be added to the set (if `EnumerableSet.add` returns false) - Add `canReserveSlot(address, SlotId)` - Return `true` if set of reservations is less than 3 and the set doesn't already contain the address - Return `true` otherwise (for now, later add in logic for checking the address is inside the expanding window) - Call `canReserveSlot` from `reserveSlot` as a `require` or invariant - Add `SlotReservations` configuration struct to the network-level config, with `maxReservations`
74 lines
2.3 KiB
JavaScript
74 lines
2.3 KiB
JavaScript
const { loadZkeyHash } = require("../verifier/verifier.js")
|
|
|
|
// marketplace configuration
|
|
const CONFIGURATION = {
|
|
collateral: {
|
|
repairRewardPercentage: 10,
|
|
maxNumberOfSlashes: 2,
|
|
slashCriterion: 2,
|
|
slashPercentage: 20,
|
|
},
|
|
proofs: {
|
|
period: 60,
|
|
timeout: 30,
|
|
// `downtime` needs to be larger than `period` when running hardhat
|
|
// in automine mode, because it can produce a block every second
|
|
downtime: 64,
|
|
downtimeProduct: 67
|
|
},
|
|
reservations: {
|
|
maxReservations: 3
|
|
}
|
|
}
|
|
|
|
async function mine256blocks({ network, ethers }) {
|
|
if (network.tags.local) {
|
|
await ethers.provider.send("hardhat_mine", ["0x100"])
|
|
}
|
|
}
|
|
|
|
// deploys a marketplace with a real Groth16 verifier
|
|
async function deployMarketplace({ deployments, getNamedAccounts }) {
|
|
const token = await deployments.get("TestToken")
|
|
const verifier = await deployments.get("Groth16Verifier")
|
|
const zkeyHash = loadZkeyHash(network.name)
|
|
let configuration = CONFIGURATION
|
|
configuration.proofs.zkeyHash = zkeyHash
|
|
const args = [configuration, token.address, verifier.address]
|
|
const { deployer: from } = await getNamedAccounts()
|
|
const marketplace = await deployments.deploy("Marketplace", { args, from })
|
|
console.log("Deployed Marketplace with Groth16 Verifier at:")
|
|
console.log(marketplace.address)
|
|
console.log()
|
|
}
|
|
|
|
// deploys a marketplace with a testing verifier
|
|
async function deployTestMarketplace({
|
|
network,
|
|
deployments,
|
|
getNamedAccounts,
|
|
}) {
|
|
if (network.tags.local) {
|
|
const token = await deployments.get("TestToken")
|
|
const verifier = await deployments.get("TestVerifier")
|
|
const zkeyHash = loadZkeyHash(network.name)
|
|
let configuration = CONFIGURATION
|
|
configuration.proofs.zkeyHash = zkeyHash
|
|
const args = [configuration, token.address, verifier.address]
|
|
const { deployer: from } = await getNamedAccounts()
|
|
const marketplace = await deployments.deploy("Marketplace", { args, from })
|
|
console.log("Deployed Marketplace with Test Verifier at:")
|
|
console.log(marketplace.address)
|
|
console.log()
|
|
}
|
|
}
|
|
|
|
module.exports = async (environment) => {
|
|
await mine256blocks(environment)
|
|
await deployMarketplace(environment)
|
|
await deployTestMarketplace(environment)
|
|
}
|
|
|
|
module.exports.tags = ["Marketplace"]
|
|
module.exports.dependencies = ["TestToken", "Verifier"]
|