Different configurations for different networks
By default we have a proof period of 2 minutes, but on hardhat it's 1 minute.
This commit is contained in:
parent
1ce3d10fa2
commit
11ccefd720
|
@ -0,0 +1,33 @@
|
|||
const fs = require("fs")
|
||||
|
||||
const BASE_PATH = __dirname + "/networks"
|
||||
|
||||
const DEFAULT_CONFIGURATION = {
|
||||
collateral: {
|
||||
repairRewardPercentage: 10,
|
||||
maxNumberOfSlashes: 2,
|
||||
slashCriterion: 2,
|
||||
slashPercentage: 20,
|
||||
},
|
||||
proofs: {
|
||||
// period has to be less than downtime * blocktime
|
||||
period: 120, // seconds
|
||||
timeout: 30, // seconds
|
||||
downtime: 64, // number of blocks
|
||||
downtimeProduct: 67 // number of blocks
|
||||
},
|
||||
reservations: {
|
||||
maxReservations: 3
|
||||
}
|
||||
}
|
||||
|
||||
function loadConfiguration(name) {
|
||||
const path = `${BASE_PATH}/${name}/configuration.js`
|
||||
if(fs.existsSync(path)) {
|
||||
return require(path)
|
||||
} else {
|
||||
return DEFAULT_CONFIGURATION
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { loadConfiguration }
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
collateral: {
|
||||
repairRewardPercentage: 10,
|
||||
maxNumberOfSlashes: 2,
|
||||
slashCriterion: 2,
|
||||
slashPercentage: 20,
|
||||
},
|
||||
proofs: {
|
||||
// period has to be less than downtime * blocktime
|
||||
// blocktime can be 1 second with hardhat in automine mode
|
||||
period: 60, // seconds
|
||||
timeout: 30, // seconds
|
||||
downtime: 64, // number of blocks
|
||||
downtimeProduct: 67 // number of blocks
|
||||
},
|
||||
reservations: {
|
||||
maxReservations: 3
|
||||
}
|
||||
}
|
|
@ -1,25 +1,5 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
const { loadConfiguration } = require("../configuration/configuration.js")
|
||||
|
||||
async function mine256blocks({ network, ethers }) {
|
||||
if (network.tags.local) {
|
||||
|
@ -32,7 +12,7 @@ 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
|
||||
let configuration = loadConfiguration(network.name)
|
||||
configuration.proofs.zkeyHash = zkeyHash
|
||||
const args = [configuration, token.address, verifier.address]
|
||||
const { deployer: from } = await getNamedAccounts()
|
||||
|
@ -52,7 +32,7 @@ async function deployTestMarketplace({
|
|||
const token = await deployments.get("TestToken")
|
||||
const verifier = await deployments.get("TestVerifier")
|
||||
const zkeyHash = loadZkeyHash(network.name)
|
||||
let configuration = CONFIGURATION
|
||||
let configuration = loadConfiguration(network.name)
|
||||
configuration.proofs.zkeyHash = zkeyHash
|
||||
const args = [configuration, token.address, verifier.address]
|
||||
const { deployer: from } = await getNamedAccounts()
|
||||
|
|
Loading…
Reference in New Issue