mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-12 15:25:00 +00:00
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
33
configuration/configuration.js
Normal file
33
configuration/configuration.js
Normal file
@ -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 }
|
19
configuration/networks/hardhat/configuration.js
Normal file
19
configuration/networks/hardhat/configuration.js
Normal file
@ -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")
|
const { loadZkeyHash } = require("../verifier/verifier.js")
|
||||||
|
const { loadConfiguration } = require("../configuration/configuration.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 }) {
|
async function mine256blocks({ network, ethers }) {
|
||||||
if (network.tags.local) {
|
if (network.tags.local) {
|
||||||
@ -32,7 +12,7 @@ async function deployMarketplace({ deployments, getNamedAccounts }) {
|
|||||||
const token = await deployments.get("TestToken")
|
const token = await deployments.get("TestToken")
|
||||||
const verifier = await deployments.get("Groth16Verifier")
|
const verifier = await deployments.get("Groth16Verifier")
|
||||||
const zkeyHash = loadZkeyHash(network.name)
|
const zkeyHash = loadZkeyHash(network.name)
|
||||||
let configuration = CONFIGURATION
|
let configuration = loadConfiguration(network.name)
|
||||||
configuration.proofs.zkeyHash = zkeyHash
|
configuration.proofs.zkeyHash = zkeyHash
|
||||||
const args = [configuration, token.address, verifier.address]
|
const args = [configuration, token.address, verifier.address]
|
||||||
const { deployer: from } = await getNamedAccounts()
|
const { deployer: from } = await getNamedAccounts()
|
||||||
@ -52,7 +32,7 @@ async function deployTestMarketplace({
|
|||||||
const token = await deployments.get("TestToken")
|
const token = await deployments.get("TestToken")
|
||||||
const verifier = await deployments.get("TestVerifier")
|
const verifier = await deployments.get("TestVerifier")
|
||||||
const zkeyHash = loadZkeyHash(network.name)
|
const zkeyHash = loadZkeyHash(network.name)
|
||||||
let configuration = CONFIGURATION
|
let configuration = loadConfiguration(network.name)
|
||||||
configuration.proofs.zkeyHash = zkeyHash
|
configuration.proofs.zkeyHash = zkeyHash
|
||||||
const args = [configuration, token.address, verifier.address]
|
const args = [configuration, token.address, verifier.address]
|
||||||
const { deployer: from } = await getNamedAccounts()
|
const { deployer: from } = await getNamedAccounts()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user