2025-06-26 11:28:58 +02:00

48 lines
1.2 KiB
JavaScript

const fs = require("fs")
const { loadZkeyHash } = require("../verifier/verifier.js")
const BASE_PATH = __dirname + "/networks"
const DEFAULT_CONFIGURATION = {
collateral: {
repairRewardPercentage: 10,
maxNumberOfSlashes: 2,
slashPercentage: 20,
validatorRewardPercentage: 20, // percentage of the slashed amount going to the validators
},
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
zkeyHash: "",
},
reservations: {
maxReservations: 3,
},
requestDurationLimit: 60*60*24*30 // 30 days
}
function getDefaultConfig(networkName) {
if (networkName === undefined) {
throw new TypeError("Network name needs to be specified!")
}
const zkeyHash = loadZkeyHash(networkName)
const config = loadConfiguration(networkName)
config.proofs.zkeyHash = zkeyHash
return config
}
function loadConfiguration(name) {
const path = `${BASE_PATH}/${name}/configuration.js`
if (fs.existsSync(path)) {
return require(path)
} else {
return DEFAULT_CONFIGURATION
}
}
module.exports = { loadConfiguration, getDefaultConfig }