-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrelay_to_event.js
51 lines (38 loc) · 1.52 KB
/
relay_to_event.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const ethers = require('ethers');
const KeepRandomBeaconOperator = require("@keep-network/keep-core/artifacts/KeepRandomBeaconOperator.json")
const config = require('./config')
const infura = config.infura_secret || process.env.INFURA_API;
const network = config.network || 'homestead'
async function main() {
let wallet
try {
const ip = new ethers.providers.InfuraProvider(network, infura);
const randomOpContract = new ethers.Contract(KeepRandomBeaconOperator.networks["1"].address, KeepRandomBeaconOperator.abi, ip);
const events = await randomOpContract.queryFilter(randomOpContract.filters.RelayEntryTimeoutReported(null));
console.log(events.length);
console.log(await randomOpContract.hasMinimumStake("0x49b73ef45A462bcAf968b3ba34918080584c4191"))
let slashEvents = new Map();
for (event of events) {
let idx = event.args[0];
console.log(`group index: ${idx}`);
let pk = await randomOpContract.getGroupPublicKey(idx);
//console.log(`group pk: ${pk}`);
let members = await randomOpContract.getGroupMembers(pk);
let mset = new Set();
for (member of members) {
if (slashEvents.has(member)) { slashEvents.set(member, slashEvents.get(member) + 1); }
else { slashEvents.set(member, 1); }
mset.add(member);
}
console.log(`members.length ${members.length} vs mset.size ${mset.size}`);
}
console.log(slashEvents);
console.log(slashEvents.size);
} catch(err) {
console.error(`Could not authorize: ${err.message}`)
process.exit(1)
}
}
main().catch(err => {
console.error(err);
})