Skip to content

Commit f7f3a48

Browse files
committed
fix: Make keyper threshold fraction configurable
1 parent a942821 commit f7f3a48

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

contracts/deploy/500_configure_keypers.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ const { configure_keypers } = require("../lib/configure-keypers.js");
22

33
module.exports = async function (hre) {
44
var keyperAddrs = await hre.getKeyperAddresses();
5-
await configure_keypers(keyperAddrs, hre.deployConf.activationBlockOffset);
5+
await configure_keypers(
6+
keyperAddrs,
7+
hre.deployConf.activationBlockOffset,
8+
hre.deployConf.thresholdRatio
9+
);
610
};

contracts/hardhat.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extendEnvironment((hre) => {
8484
collator: null,
8585
fundValue: "",
8686
activationBlockOffset: 30,
87+
thresholdRatio: 2 / 3,
8788
};
8889
}
8990

contracts/lib/configure-keypers.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ const { ethers } = require("hardhat");
99
//TODO since we want to call this for new keypers
1010
// this should also check and eventually fund the
1111
// keypers if they are below the target funding.
12-
async function configure_keypers(keyperAddrs, blockOffset = 15) {
12+
async function configure_keypers(
13+
keyperAddrs,
14+
blockOffset = 15,
15+
threshold_ratio = 2 / 3
16+
) {
1317
if (keyperAddrs.length == 0) {
1418
console.log("WARNING: cannot configure keypers: no keyper addresses given");
1519
return;
@@ -54,10 +58,11 @@ async function configure_keypers(keyperAddrs, blockOffset = 15) {
5458
return;
5559
}
5660

61+
const threshold = Math.ceil(keyperAddrs.length * threshold_ratio);
5762
const tx = await cfg.addNewCfg({
5863
activationBlockNumber: activationBlockNumber,
5964
setIndex: configSetIndex,
60-
threshold: Math.ceil((keyperAddrs.length / 3) * 2),
65+
threshold: threshold,
6166
});
6267
await tx.wait();
6368
console.log(

0 commit comments

Comments
 (0)