@maci-protocol/coordinator 0.0.0-ci.fc91dc9 → 0.0.0-ci.fdc9104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -11
- package/build/hardhat.config.cjs +14 -9
- package/build/hardhat.config.cjs.map +1 -1
- package/build/hardhat.config.d.cts +12 -12
- package/build/hardhat.config.d.cts.map +1 -1
- package/build/scripts/generateKeypair.js +2 -2
- package/build/scripts/generateKeypair.js.map +1 -1
- package/build/tests/constants.d.ts +3 -3
- package/build/tests/constants.d.ts.map +1 -1
- package/build/tests/constants.js +5 -3
- package/build/tests/constants.js.map +1 -1
- package/build/tests/e2e.deploy.test.js +48 -66
- package/build/tests/e2e.deploy.test.js.map +1 -1
- package/build/tests/e2e.redis.test.d.ts +2 -0
- package/build/tests/e2e.redis.test.d.ts.map +1 -0
- package/build/tests/e2e.redis.test.js +118 -0
- package/build/tests/e2e.redis.test.js.map +1 -0
- package/build/tests/utils.d.ts +1 -1
- package/build/tests/utils.d.ts.map +1 -1
- package/build/tests/utils.js +5 -3
- package/build/tests/utils.js.map +1 -1
- package/build/ts/app.module.d.ts.map +1 -1
- package/build/ts/app.module.js +6 -0
- package/build/ts/app.module.js.map +1 -1
- package/build/ts/common/__tests__/common.test.js +43 -41
- package/build/ts/common/__tests__/common.test.js.map +1 -1
- package/build/ts/common/accountAbstraction.d.ts +5 -5
- package/build/ts/common/accountAbstraction.d.ts.map +1 -1
- package/build/ts/common/accountAbstraction.js +11 -9
- package/build/ts/common/accountAbstraction.js.map +1 -1
- package/build/ts/common/chain.d.ts +12 -6
- package/build/ts/common/chain.d.ts.map +1 -1
- package/build/ts/common/chain.js +19 -17
- package/build/ts/common/chain.js.map +1 -1
- package/build/ts/common/coordinatorKeypair.d.ts +7 -0
- package/build/ts/common/coordinatorKeypair.d.ts.map +1 -0
- package/build/ts/common/coordinatorKeypair.js +14 -0
- package/build/ts/common/coordinatorKeypair.js.map +1 -0
- package/build/ts/common/errors.d.ts +16 -12
- package/build/ts/common/errors.d.ts.map +1 -1
- package/build/ts/common/errors.js +16 -12
- package/build/ts/common/errors.js.map +1 -1
- package/build/ts/common/http.d.ts +6 -0
- package/build/ts/common/http.d.ts.map +1 -0
- package/build/ts/common/http.js +49 -0
- package/build/ts/common/http.js.map +1 -0
- package/build/ts/common/index.d.ts +1 -1
- package/build/ts/common/index.d.ts.map +1 -1
- package/build/ts/common/index.js +1 -1
- package/build/ts/common/index.js.map +1 -1
- package/build/ts/common/networks.d.ts +2 -21
- package/build/ts/common/networks.d.ts.map +1 -1
- package/build/ts/common/networks.js +39 -48
- package/build/ts/common/networks.js.map +1 -1
- package/build/ts/common/types.d.ts +2 -2
- package/build/ts/common/types.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/deployer.controller.test.js +23 -25
- package/build/ts/deployer/__tests__/deployer.controller.test.js.map +1 -1
- package/build/ts/deployer/__tests__/deployer.service.test.js +186 -80
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -1
- package/build/ts/deployer/__tests__/utils.d.ts +10 -14
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/utils.js +16 -25
- package/build/ts/deployer/__tests__/utils.js.map +1 -1
- package/build/ts/deployer/deployer.controller.d.ts.map +1 -1
- package/build/ts/deployer/deployer.controller.js +19 -6
- package/build/ts/deployer/deployer.controller.js.map +1 -1
- package/build/ts/deployer/deployer.service.d.ts +17 -8
- package/build/ts/deployer/deployer.service.d.ts.map +1 -1
- package/build/ts/deployer/deployer.service.js +232 -68
- package/build/ts/deployer/deployer.service.js.map +1 -1
- package/build/ts/deployer/dto.d.ts +3 -3
- package/build/ts/deployer/dto.d.ts.map +1 -1
- package/build/ts/deployer/dto.js +5 -5
- package/build/ts/deployer/dto.js.map +1 -1
- package/build/ts/deployer/types.d.ts +42 -35
- package/build/ts/deployer/types.d.ts.map +1 -1
- package/build/ts/file/__tests__/file.service.test.js +12 -11
- package/build/ts/file/__tests__/file.service.test.js.map +1 -1
- package/build/ts/file/file.service.d.ts +4 -3
- package/build/ts/file/file.service.d.ts.map +1 -1
- package/build/ts/file/file.service.js +16 -10
- package/build/ts/file/file.service.js.map +1 -1
- package/build/ts/file/types.d.ts +2 -2
- package/build/ts/file/types.d.ts.map +1 -1
- package/build/ts/health/__tests__/health.controller.test.d.ts +2 -0
- package/build/ts/health/__tests__/health.controller.test.d.ts.map +1 -0
- package/build/ts/health/__tests__/health.controller.test.js +52 -0
- package/build/ts/health/__tests__/health.controller.test.js.map +1 -0
- package/build/ts/health/__tests__/health.service.test.d.ts +2 -0
- package/build/ts/health/__tests__/health.service.test.d.ts.map +1 -0
- package/build/ts/health/__tests__/health.service.test.js +101 -0
- package/build/ts/health/__tests__/health.service.test.js.map +1 -0
- package/build/ts/health/health.controller.d.ts +16 -0
- package/build/ts/health/health.controller.d.ts.map +1 -0
- package/build/ts/health/health.controller.js +43 -0
- package/build/ts/health/health.controller.js.map +1 -0
- package/build/ts/health/health.module.d.ts +3 -0
- package/build/ts/health/health.module.d.ts.map +1 -0
- package/build/ts/health/health.module.js +22 -0
- package/build/ts/health/health.module.js.map +1 -0
- package/build/ts/health/health.service.d.ts +42 -0
- package/build/ts/health/health.service.d.ts.map +1 -0
- package/build/ts/health/health.service.js +176 -0
- package/build/ts/health/health.service.js.map +1 -0
- package/build/ts/health/types.d.ts +87 -0
- package/build/ts/health/types.d.ts.map +1 -0
- package/build/ts/health/types.js +2 -0
- package/build/ts/health/types.js.map +1 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.d.ts +11 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.d.ts.map +1 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.js +12 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.js.map +1 -0
- package/build/ts/main.js +1 -1
- package/build/ts/proof/__tests__/proof.controller.test.js +6 -7
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.gateway.test.js +3 -4
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.service.test.js +28 -74
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
- package/build/ts/proof/dto.d.ts +6 -10
- package/build/ts/proof/dto.d.ts.map +1 -1
- package/build/ts/proof/dto.js +15 -30
- package/build/ts/proof/dto.js.map +1 -1
- package/build/ts/proof/proof.controller.d.ts.map +1 -1
- package/build/ts/proof/proof.controller.js +38 -15
- package/build/ts/proof/proof.controller.js.map +1 -1
- package/build/ts/proof/proof.module.d.ts.map +1 -1
- package/build/ts/proof/proof.module.js +1 -0
- package/build/ts/proof/proof.module.js.map +1 -1
- package/build/ts/proof/proof.service.d.ts +2 -4
- package/build/ts/proof/proof.service.d.ts.map +1 -1
- package/build/ts/proof/proof.service.js +26 -27
- package/build/ts/proof/proof.service.js.map +1 -1
- package/build/ts/proof/types.d.ts +6 -10
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/proof/types.js.map +1 -1
- package/build/ts/redis/__tests__/redis.service.test.d.ts +2 -0
- package/build/ts/redis/__tests__/redis.service.test.d.ts.map +1 -0
- package/build/ts/redis/__tests__/redis.service.test.js +148 -0
- package/build/ts/redis/__tests__/redis.service.test.js.map +1 -0
- package/build/ts/redis/redis.module.d.ts +3 -0
- package/build/ts/redis/redis.module.d.ts.map +1 -0
- package/build/ts/redis/redis.module.js +18 -0
- package/build/ts/redis/redis.module.js.map +1 -0
- package/build/ts/redis/redis.service.d.ts +53 -0
- package/build/ts/redis/redis.service.d.ts.map +1 -0
- package/build/ts/redis/redis.service.js +99 -0
- package/build/ts/redis/redis.service.js.map +1 -0
- package/build/ts/redis/types.d.ts +66 -0
- package/build/ts/redis/types.d.ts.map +1 -0
- package/build/ts/redis/types.js +2 -0
- package/build/ts/redis/types.js.map +1 -0
- package/build/ts/redis/utils.d.ts +20 -0
- package/build/ts/redis/utils.d.ts.map +1 -0
- package/build/ts/redis/utils.js +27 -0
- package/build/ts/redis/utils.js.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.d.ts +2 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.d.ts.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.js +62 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.js.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.d.ts +2 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.d.ts.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js +369 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js.map +1 -0
- package/build/ts/scheduler/dto.d.ts +41 -0
- package/build/ts/scheduler/dto.d.ts.map +1 -0
- package/build/ts/scheduler/dto.js +115 -0
- package/build/ts/scheduler/dto.js.map +1 -0
- package/build/ts/scheduler/scheduler.controller.d.ts +32 -0
- package/build/ts/scheduler/scheduler.controller.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.controller.js +118 -0
- package/build/ts/scheduler/scheduler.controller.js.map +1 -0
- package/build/ts/scheduler/scheduler.module.d.ts +3 -0
- package/build/ts/scheduler/scheduler.module.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.module.js +24 -0
- package/build/ts/scheduler/scheduler.module.js.map +1 -0
- package/build/ts/scheduler/scheduler.service.d.ts +71 -0
- package/build/ts/scheduler/scheduler.service.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.service.js +297 -0
- package/build/ts/scheduler/scheduler.service.js.map +1 -0
- package/build/ts/scheduler/types.d.ts +65 -0
- package/build/ts/scheduler/types.d.ts.map +1 -0
- package/build/ts/scheduler/types.js +2 -0
- package/build/ts/scheduler/types.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js +2 -2
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js.map +1 -1
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js +34 -19
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js.map +1 -1
- package/build/ts/sessionKeys/__tests__/utils.d.ts +1 -1
- package/build/ts/sessionKeys/__tests__/utils.d.ts.map +1 -1
- package/build/ts/sessionKeys/__tests__/utils.js +7 -6
- package/build/ts/sessionKeys/__tests__/utils.js.map +1 -1
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts +1 -1
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts.map +1 -1
- package/build/ts/sessionKeys/sessionKeys.service.d.ts +4 -3
- package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -1
- package/build/ts/sessionKeys/sessionKeys.service.js +1 -2
- package/build/ts/sessionKeys/sessionKeys.service.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js +3 -3
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js +2 -2
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.service.test.js +5 -5
- package/build/ts/subgraph/__tests__/subgraph.service.test.js.map +1 -1
- package/build/ts/subgraph/dto.d.ts +2 -2
- package/build/ts/subgraph/dto.d.ts.map +1 -1
- package/build/ts/subgraph/dto.js +3 -3
- package/build/ts/subgraph/dto.js.map +1 -1
- package/build/ts/subgraph/subgraph.controller.d.ts.map +1 -1
- package/build/ts/subgraph/subgraph.controller.js +8 -3
- package/build/ts/subgraph/subgraph.controller.js.map +1 -1
- package/build/ts/subgraph/subgraph.service.d.ts +4 -0
- package/build/ts/subgraph/subgraph.service.d.ts.map +1 -1
- package/build/ts/subgraph/subgraph.service.js +23 -10
- package/build/ts/subgraph/subgraph.service.js.map +1 -1
- package/build/ts/subgraph/types.d.ts +2 -2
- package/build/ts/subgraph/types.d.ts.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +46 -40
- package/build/tests/e2e.aa.test.d.ts +0 -2
- package/build/tests/e2e.aa.test.d.ts.map +0 -1
- package/build/tests/e2e.aa.test.js +0 -106
- package/build/tests/e2e.aa.test.js.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { EMode } from "@maci-protocol/contracts";
|
|
2
|
+
import dotenv from "dotenv";
|
|
3
|
+
import { zeroAddress } from "viem";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { FileService } from "../../file/file.service";
|
|
6
|
+
import { HealthService } from "../health.service";
|
|
7
|
+
dotenv.config();
|
|
8
|
+
describe("HealthService", () => {
|
|
9
|
+
const fileService = new FileService();
|
|
10
|
+
const mockRedisService = {
|
|
11
|
+
isOpen: jest.fn().mockReturnValue(true),
|
|
12
|
+
};
|
|
13
|
+
const healthService = new HealthService(fileService, mockRedisService);
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
});
|
|
17
|
+
describe("checkRapidsnark", () => {
|
|
18
|
+
test("should return rapidsnark path and executability status", async () => {
|
|
19
|
+
jest.spyOn(fs.promises, "access").mockImplementation(() => Promise.resolve());
|
|
20
|
+
jest
|
|
21
|
+
.spyOn(fs.promises, "stat")
|
|
22
|
+
.mockImplementation(() => Promise.resolve({ isFile: () => true }));
|
|
23
|
+
const response = await healthService.checkRapidsnark();
|
|
24
|
+
expect(response.rapidsnarkExecutablePath).toBe(process.env.COORDINATOR_RAPIDSNARK_EXE);
|
|
25
|
+
expect(response.rapidsnarkIsAccessible).toBe(true);
|
|
26
|
+
expect(response.rapidsnarkIsExecutable).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
test("should return false when rapidsnark path is not set", async () => {
|
|
29
|
+
jest.spyOn(fs.promises, "access").mockImplementation(() => Promise.reject(new Error()));
|
|
30
|
+
jest.spyOn(fs.promises, "stat").mockImplementation(() => Promise.reject(new Error()));
|
|
31
|
+
process.env.COORDINATOR_RAPIDSNARK_EXE = "/incorrect/path/to/rapidsnark";
|
|
32
|
+
const response = await healthService.checkRapidsnark();
|
|
33
|
+
expect(response.rapidsnarkIsAccessible).toBe(false);
|
|
34
|
+
expect(response.rapidsnarkIsExecutable).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe("checkZkeysDirectory", () => {
|
|
38
|
+
test("should return if zkeys directory exists and the available zkeys paths", async () => {
|
|
39
|
+
jest
|
|
40
|
+
.spyOn(fs.promises, "stat")
|
|
41
|
+
.mockImplementation(() => Promise.resolve({ isDirectory: () => true }));
|
|
42
|
+
const { zkeysDirectoryExists, availableZkeys } = await healthService.checkZkeysDirectory();
|
|
43
|
+
const numberofZkeys = Object.keys(availableZkeys).length;
|
|
44
|
+
const expectedNumberOfZkeys = 1 + // poll joining zkey
|
|
45
|
+
1 + // poll joined zkey
|
|
46
|
+
3 + // message process zkey for modes (QV, NON_QV, FULL)
|
|
47
|
+
2; // vote tally zkey for modes (only QV and NON_QV)
|
|
48
|
+
expect(zkeysDirectoryExists).toBe(true);
|
|
49
|
+
expect(numberofZkeys).toBe(expectedNumberOfZkeys);
|
|
50
|
+
});
|
|
51
|
+
test("should return less available zkeys when COORDINATOR_POLL_JOINING_ZKEY_NAME is not set in the env file", async () => {
|
|
52
|
+
process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME = "/incorrect/path/to/poll_joining";
|
|
53
|
+
const { availableZkeys } = await healthService.checkZkeysDirectory();
|
|
54
|
+
expect(availableZkeys[process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME]).toBe(undefined);
|
|
55
|
+
});
|
|
56
|
+
test("should return less available zkeys when COORDINATOR_POLL_JOINED_ZKEY_NAME is not set in the env file", async () => {
|
|
57
|
+
process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME = "/incorrect/path/to/poll_joined";
|
|
58
|
+
const { availableZkeys } = await healthService.checkZkeysDirectory();
|
|
59
|
+
expect(availableZkeys[process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME]).toBe(undefined);
|
|
60
|
+
});
|
|
61
|
+
test("should return less available zkeys when COORDINATOR_TALLY_ZKEY_NAME is not set in the env file", async () => {
|
|
62
|
+
process.env.COORDINATOR_TALLY_ZKEY_NAME = "/incorrect/path/to/tally_zkey";
|
|
63
|
+
const { availableZkeys } = await healthService.checkZkeysDirectory();
|
|
64
|
+
expect(availableZkeys[`${process.env.COORDINATOR_TALLY_ZKEY_NAME}_Mode_${String(EMode.NON_QV)}`]).toBe(undefined);
|
|
65
|
+
expect(availableZkeys[`${process.env.COORDINATOR_TALLY_ZKEY_NAME}_Mode_${String(EMode.QV)}`]).toBe(undefined);
|
|
66
|
+
});
|
|
67
|
+
test("should return less available zkeys when COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME is not set in the env file", async () => {
|
|
68
|
+
process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME = "/incorrect/path/to/message_process_zkey";
|
|
69
|
+
const { availableZkeys } = await healthService.checkZkeysDirectory();
|
|
70
|
+
expect(availableZkeys[`${process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME}_Mode_${String(EMode.NON_QV)}`]).toBe(undefined);
|
|
71
|
+
expect(availableZkeys[`${process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME}_Mode_${String(EMode.QV)}`]).toBe(undefined);
|
|
72
|
+
expect(availableZkeys[`${process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME}_Mode_${String(EMode.FULL)}`]).toBe(undefined);
|
|
73
|
+
});
|
|
74
|
+
test("should return false when zkeys directory is not set", async () => {
|
|
75
|
+
jest.spyOn(fs.promises, "stat").mockImplementation(() => Promise.reject(new Error()));
|
|
76
|
+
process.env.COORDINATOR_ZKEY_PATH = "/incorrect/path/to/zkeys";
|
|
77
|
+
const { zkeysDirectoryExists } = await healthService.checkZkeysDirectory();
|
|
78
|
+
expect(zkeysDirectoryExists).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe("checkWalletFunds", () => {
|
|
82
|
+
test("should return the wallet address", async () => {
|
|
83
|
+
const { fundsInNetworks } = await healthService.checkWalletFunds();
|
|
84
|
+
expect(fundsInNetworks[0].address).toBeDefined();
|
|
85
|
+
expect(fundsInNetworks[0].address).not.toBe(zeroAddress);
|
|
86
|
+
});
|
|
87
|
+
test("should return 0x if coordinator private key is not set", async () => {
|
|
88
|
+
process.env.PRIVATE_KEY = "";
|
|
89
|
+
process.env.MNEMONIC = "";
|
|
90
|
+
const { fundsInNetworks } = await healthService.checkWalletFunds();
|
|
91
|
+
expect(fundsInNetworks[0].address).toBe(zeroAddress);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe("checkRedisConnection", () => {
|
|
95
|
+
test("should return true if Redis connection is open", () => {
|
|
96
|
+
const isRedisOpen = healthService.checkRedisConnection();
|
|
97
|
+
expect(isRedisOpen).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=health.service.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.service.test.js","sourceRoot":"","sources":["../../../../ts/health/__tests__/health.service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAkB,MAAM,IAAI,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IACtC,MAAM,gBAAgB,GAAG;QACvB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;KACb,CAAC;IAE7B,MAAM,a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Aa,CAAC,gBAAgB,EAAE,CAAC;YAEnE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;YACjD,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;YACxE,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;YAC1B,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,aAAa,CAAC,gBAAgB,EAAE,CAAC;YAEnE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,IAAI,CAAC,gDAAgD,EAAE,GAAG,EAAE;YAC1D,MAAM,WAAW,GAAG,aAAa,CAAC,oBAAoB,EAAE,CAAC;YAEzD,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HealthService } from "./health.service";
|
|
2
|
+
import { IHealthCheckResponse } from "./types";
|
|
3
|
+
export declare class HealthController {
|
|
4
|
+
private readonly healthService;
|
|
5
|
+
/**
|
|
6
|
+
* Initialize HealthController
|
|
7
|
+
*/
|
|
8
|
+
constructor(healthService: HealthService);
|
|
9
|
+
/**
|
|
10
|
+
* Health check api method.
|
|
11
|
+
*
|
|
12
|
+
* @returns true if the service is running
|
|
13
|
+
*/
|
|
14
|
+
check(): Promise<IHealthCheckResponse>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=health.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.controller.d.ts","sourceRoot":"","sources":["../../../ts/health/health.controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,qBAEa,gBAAgB;IAIf,OAAO,CAAC,QAAQ,CAAC,aAAa;IAH1C;;OAEG;gBAC0B,aAAa,EAAE,aAAa;IAEzD;;;;OAIG;IAGH,KAAK,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAGvC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Controller, Get, HttpStatus } from "@nestjs/common";
|
|
11
|
+
import { ApiResponse, ApiTags } from "@nestjs/swagger";
|
|
12
|
+
import { HealthService } from "./health.service";
|
|
13
|
+
let HealthController = class HealthController {
|
|
14
|
+
healthService;
|
|
15
|
+
/**
|
|
16
|
+
* Initialize HealthController
|
|
17
|
+
*/
|
|
18
|
+
constructor(healthService) {
|
|
19
|
+
this.healthService = healthService;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Health check api method.
|
|
23
|
+
*
|
|
24
|
+
* @returns true if the service is running
|
|
25
|
+
*/
|
|
26
|
+
check() {
|
|
27
|
+
return this.healthService.checkCoordinatorHealth();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
__decorate([
|
|
31
|
+
ApiResponse({ status: HttpStatus.OK, description: "The service is running" }),
|
|
32
|
+
Get("check"),
|
|
33
|
+
__metadata("design:type", Function),
|
|
34
|
+
__metadata("design:paramtypes", []),
|
|
35
|
+
__metadata("design:returntype", Promise)
|
|
36
|
+
], HealthController.prototype, "check", null);
|
|
37
|
+
HealthController = __decorate([
|
|
38
|
+
ApiTags("v1/health"),
|
|
39
|
+
Controller("v1/health"),
|
|
40
|
+
__metadata("design:paramtypes", [HealthService])
|
|
41
|
+
], HealthController);
|
|
42
|
+
export { HealthController };
|
|
43
|
+
//# sourceMappingURL=health.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.controller.js","sourceRoot":"","sources":["../../../ts/health/health.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAK1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAIE;IAH7B;;OAEG;IACH,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D;;;;OAIG;IAGH,KAAK;QACH,OAAO,IAAI,CAAC,aAAa,CAAC,sBAAsB,EAAE,CAAC;IACrD,CAAC;CACF,CAAA;AAHC;IAFC,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;IAC7E,GAAG,CAAC,OAAO,CAAC;;;;6CAGZ;AAfU,gBAAgB;IAF5B,OAAO,CAAC,WAAW,CAAC;IACpB,UAAU,CAAC,WAAW,CAAC;qCAKsB,aAAa;GAJ9C,gBAAgB,CAgB5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.module.d.ts","sourceRoot":"","sources":["../../../ts/health/health.module.ts"],"names":[],"mappings":"AAQA,qBAKa,YAAY;CAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from "@nestjs/common";
|
|
8
|
+
import { FileModule } from "../file/file.module";
|
|
9
|
+
import { RedisModule } from "../redis/redis.module";
|
|
10
|
+
import { HealthController } from "./health.controller";
|
|
11
|
+
import { HealthService } from "./health.service";
|
|
12
|
+
let HealthModule = class HealthModule {
|
|
13
|
+
};
|
|
14
|
+
HealthModule = __decorate([
|
|
15
|
+
Module({
|
|
16
|
+
imports: [FileModule, RedisModule],
|
|
17
|
+
controllers: [HealthController],
|
|
18
|
+
providers: [HealthService],
|
|
19
|
+
})
|
|
20
|
+
], HealthModule);
|
|
21
|
+
export { HealthModule };
|
|
22
|
+
//# sourceMappingURL=health.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.module.js","sourceRoot":"","sources":["../../../ts/health/health.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAO1C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,YAAY;IALxB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;QAClC,WAAW,EAAE,CAAC,gBAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,aAAa,CAAC;KAC3B,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ICheckRapidsnark, ICheckWalletFunds, ICheckZkeysDirectory, IHealthCheckResponse } from "./types";
|
|
2
|
+
import { FileService } from "../file/file.service";
|
|
3
|
+
import { RedisService } from "../redis/redis.service";
|
|
4
|
+
/**
|
|
5
|
+
* Health service functions to check the status of the coordinator service.
|
|
6
|
+
*/
|
|
7
|
+
export declare class HealthService {
|
|
8
|
+
private readonly fileService;
|
|
9
|
+
private readonly redisService;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new instance of the HealthService.
|
|
12
|
+
*
|
|
13
|
+
* @param fileService - file service
|
|
14
|
+
*/
|
|
15
|
+
constructor(fileService: FileService, redisService: RedisService);
|
|
16
|
+
/**
|
|
17
|
+
* Check if rapidsnark is available and executable.
|
|
18
|
+
* @returns the rapidsnark executable path and its executability status
|
|
19
|
+
*/
|
|
20
|
+
checkRapidsnark(): Promise<ICheckRapidsnark>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if zkeys directory exists
|
|
23
|
+
* @returns the existence of the zkeys directory and the required zkeys
|
|
24
|
+
*/
|
|
25
|
+
checkZkeysDirectory(): Promise<ICheckZkeysDirectory>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if coordinator wallet has funds
|
|
28
|
+
* @returns the address and its funds in all networks
|
|
29
|
+
*/
|
|
30
|
+
checkWalletFunds(): Promise<ICheckWalletFunds>;
|
|
31
|
+
/**
|
|
32
|
+
* Check redis client is connected and open
|
|
33
|
+
* @return true if the redis client is connected and open, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
checkRedisConnection(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Check coordinator service health
|
|
38
|
+
* @returns an object containing the results of all the health checks
|
|
39
|
+
*/
|
|
40
|
+
checkCoordinatorHealth(): Promise<IHealthCheckResponse>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=health.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.service.d.ts","sourceRoot":"","sources":["../../../ts/health/health.service.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/G,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;GAEG;AACH,qBACa,aAAa;IAOtB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAP/B;;;;OAIG;gBAEgB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY;IAG7C;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAuBlD;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,oBAAoB,CAAC;IA0D1D;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAgCpD;;;OAGG;IACH,oBAAoB,IAAI,OAAO;IAI/B;;;OAGG;IACG,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAe9D"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { EMode, ESupportedChains } from "@maci-protocol/sdk";
|
|
11
|
+
import { Injectable } from "@nestjs/common";
|
|
12
|
+
import { formatEther } from "ethers";
|
|
13
|
+
import { zeroAddress } from "viem";
|
|
14
|
+
import fs from "fs";
|
|
15
|
+
import path from "path";
|
|
16
|
+
import { getSigner } from "../common";
|
|
17
|
+
import { FileService } from "../file/file.service";
|
|
18
|
+
import { RedisService } from "../redis/redis.service";
|
|
19
|
+
/**
|
|
20
|
+
* Health service functions to check the status of the coordinator service.
|
|
21
|
+
*/
|
|
22
|
+
let HealthService = class HealthService {
|
|
23
|
+
fileService;
|
|
24
|
+
redisService;
|
|
25
|
+
/**
|
|
26
|
+
* Create a new instance of the HealthService.
|
|
27
|
+
*
|
|
28
|
+
* @param fileService - file service
|
|
29
|
+
*/
|
|
30
|
+
constructor(fileService, redisService) {
|
|
31
|
+
this.fileService = fileService;
|
|
32
|
+
this.redisService = redisService;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check if rapidsnark is available and executable.
|
|
36
|
+
* @returns the rapidsnark executable path and its executability status
|
|
37
|
+
*/
|
|
38
|
+
async checkRapidsnark() {
|
|
39
|
+
const rapidsnarkExecutablePath = process.env.COORDINATOR_RAPIDSNARK_EXE || "";
|
|
40
|
+
const [rapidsnarkIsAccessible, rapidsnarkIsExecutable] = await Promise.all([
|
|
41
|
+
fs.promises
|
|
42
|
+
// eslint-disable-next-line no-bitwise
|
|
43
|
+
.access(rapidsnarkExecutablePath, fs.constants.F_OK | fs.constants.X_OK)
|
|
44
|
+
.then(() => true)
|
|
45
|
+
.catch(() => false),
|
|
46
|
+
fs.promises
|
|
47
|
+
// eslint-disable-next-line no-bitwise
|
|
48
|
+
.stat(rapidsnarkExecutablePath)
|
|
49
|
+
.then((stats) => stats.isFile())
|
|
50
|
+
.catch(() => false),
|
|
51
|
+
]);
|
|
52
|
+
return {
|
|
53
|
+
rapidsnarkExecutablePath,
|
|
54
|
+
rapidsnarkIsAccessible,
|
|
55
|
+
rapidsnarkIsExecutable,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if zkeys directory exists
|
|
60
|
+
* @returns the existence of the zkeys directory and the required zkeys
|
|
61
|
+
*/
|
|
62
|
+
async checkZkeysDirectory() {
|
|
63
|
+
const zkeysDirectoryPath = path.resolve(process.env.COORDINATOR_ZKEY_PATH);
|
|
64
|
+
const requiredZkeyNames = [
|
|
65
|
+
{
|
|
66
|
+
name: process.env.COORDINATOR_TALLY_ZKEY_NAME,
|
|
67
|
+
modes: [EMode.QV, EMode.NON_QV],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME,
|
|
71
|
+
modes: [EMode.QV, EMode.NON_QV, EMode.FULL],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME,
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
const zkeysDirectoryExists = await fs.promises
|
|
81
|
+
.stat(zkeysDirectoryPath)
|
|
82
|
+
.then((stats) => stats.isDirectory())
|
|
83
|
+
.catch(() => false);
|
|
84
|
+
const availableZkeys = requiredZkeyNames.reduce((acc, { name, modes }) => {
|
|
85
|
+
if (!modes) {
|
|
86
|
+
try {
|
|
87
|
+
acc[name] = this.fileService.getZkeyFilePaths(name);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
acc[name] = undefined;
|
|
91
|
+
}
|
|
92
|
+
return acc;
|
|
93
|
+
}
|
|
94
|
+
const modeEntries = modes.reduce((modeAcc, mode) => {
|
|
95
|
+
const pathname = `${name}_Mode_${String(mode)}`;
|
|
96
|
+
try {
|
|
97
|
+
// eslint-disable-next-line no-param-reassign
|
|
98
|
+
modeAcc[pathname] = this.fileService.getZkeyFilePaths(name, mode);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
// eslint-disable-next-line no-param-reassign
|
|
102
|
+
modeAcc[pathname] = undefined;
|
|
103
|
+
}
|
|
104
|
+
return modeAcc;
|
|
105
|
+
}, {});
|
|
106
|
+
return { ...acc, ...modeEntries };
|
|
107
|
+
}, {});
|
|
108
|
+
return {
|
|
109
|
+
zkeysDirectoryExists,
|
|
110
|
+
availableZkeys,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if coordinator wallet has funds
|
|
115
|
+
* @returns the address and its funds in all networks
|
|
116
|
+
*/
|
|
117
|
+
async checkWalletFunds() {
|
|
118
|
+
const networks = Object.values(ESupportedChains);
|
|
119
|
+
const fundsInNetworks = await Promise.all(networks.map(async (network) => {
|
|
120
|
+
try {
|
|
121
|
+
const signer = await getSigner(network);
|
|
122
|
+
const address = await signer.getAddress();
|
|
123
|
+
return signer.provider?.getBalance(signer).then((balance) => ({
|
|
124
|
+
address,
|
|
125
|
+
network,
|
|
126
|
+
balance: formatEther(balance),
|
|
127
|
+
status: true,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
return {
|
|
132
|
+
address: zeroAddress,
|
|
133
|
+
network,
|
|
134
|
+
balance: formatEther(0n),
|
|
135
|
+
status: false,
|
|
136
|
+
error: error.message,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
return {
|
|
141
|
+
fundsInNetworks: fundsInNetworks.filter(Boolean).map((x) => x),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Check redis client is connected and open
|
|
146
|
+
* @return true if the redis client is connected and open, false otherwise
|
|
147
|
+
*/
|
|
148
|
+
checkRedisConnection() {
|
|
149
|
+
return this.redisService.isOpen();
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Check coordinator service health
|
|
153
|
+
* @returns an object containing the results of all the health checks
|
|
154
|
+
*/
|
|
155
|
+
async checkCoordinatorHealth() {
|
|
156
|
+
const [rapidsnark, zkeysDirectory, coordinatorWalletFunds] = await Promise.all([
|
|
157
|
+
this.checkRapidsnark(),
|
|
158
|
+
this.checkZkeysDirectory(),
|
|
159
|
+
this.checkWalletFunds(),
|
|
160
|
+
]);
|
|
161
|
+
const isRedisOpen = this.checkRedisConnection();
|
|
162
|
+
return {
|
|
163
|
+
rapidsnark,
|
|
164
|
+
zkeysDirectory,
|
|
165
|
+
coordinatorWalletFunds,
|
|
166
|
+
isRedisOpen,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
HealthService = __decorate([
|
|
171
|
+
Injectable(),
|
|
172
|
+
__metadata("design:paramtypes", [FileService,
|
|
173
|
+
RedisService])
|
|
174
|
+
], HealthService);
|
|
175
|
+
export { HealthService };
|
|
176
|
+
//# sourceMappingURL=health.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.service.js","sourceRoot":"","sources":["../../../ts/health/health.service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king the rapidsnark setup
|
|
4
|
+
*/
|
|
5
|
+
export interface ICheckRapidsnark {
|
|
6
|
+
/**
|
|
7
|
+
* Rapidsnark executable path
|
|
8
|
+
*/
|
|
9
|
+
rapidsnarkExecutablePath: string;
|
|
10
|
+
/**
|
|
11
|
+
* Is rapidsnark accessible
|
|
12
|
+
*/
|
|
13
|
+
rapidsnarkIsAccessible: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Is rapidsnark executable
|
|
16
|
+
*/
|
|
17
|
+
rapidsnarkIsExecutable: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for checking the zkeys directory
|
|
21
|
+
*/
|
|
22
|
+
export interface ICheckZkeysDirectory {
|
|
23
|
+
/**
|
|
24
|
+
* Does zkeys directory exist
|
|
25
|
+
*/
|
|
26
|
+
zkeysDirectoryExists: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Available zkeys
|
|
29
|
+
*/
|
|
30
|
+
availableZkeys: Record<string, IGetZkeyFilePathsData | undefined>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Interface for network info (balance and status)
|
|
34
|
+
*/
|
|
35
|
+
export interface INetworkInfo {
|
|
36
|
+
/**
|
|
37
|
+
* Signer address
|
|
38
|
+
*/
|
|
39
|
+
address: string;
|
|
40
|
+
/**
|
|
41
|
+
* Network name
|
|
42
|
+
*/
|
|
43
|
+
network: string;
|
|
44
|
+
/**
|
|
45
|
+
* Balance in the network
|
|
46
|
+
*/
|
|
47
|
+
balance: string;
|
|
48
|
+
/**
|
|
49
|
+
* Is the network accessible
|
|
50
|
+
*/
|
|
51
|
+
status: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Network error
|
|
54
|
+
*/
|
|
55
|
+
error?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Interface for checking the coordinator wallet funds
|
|
59
|
+
*/
|
|
60
|
+
export interface ICheckWalletFunds {
|
|
61
|
+
/**
|
|
62
|
+
* Funds in all networks
|
|
63
|
+
*/
|
|
64
|
+
fundsInNetworks: INetworkInfo[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Interface for the health check response
|
|
68
|
+
*/
|
|
69
|
+
export interface IHealthCheckResponse {
|
|
70
|
+
/**
|
|
71
|
+
* Rapidsnark check result
|
|
72
|
+
*/
|
|
73
|
+
rapidsnark: ICheckRapidsnark;
|
|
74
|
+
/**
|
|
75
|
+
* Zkeys directory check result
|
|
76
|
+
*/
|
|
77
|
+
zkeysDirectory: ICheckZkeysDirectory;
|
|
78
|
+
/**
|
|
79
|
+
* Coordinator wallet funds check result
|
|
80
|
+
*/
|
|
81
|
+
coordinatorWalletFunds: ICheckWalletFunds;
|
|
82
|
+
/**
|
|
83
|
+
* Redis connection is open
|
|
84
|
+
*/
|
|
85
|
+
isRedisOpen: boolean;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/health/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAAC,CAAC;CACnE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,eAAe,EAAE,YAAY,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,UAAU,EAAE,gBAAgB,CAAC;IAE7B;;OAEG;IACH,cAAc,EAAE,oBAAoB,CAAC;IAErC;;OAEG;IACH,sBAAsB,EAAE,iBAAiB,CAAC;IAE1C;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ts/health/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class StandardMerkleTree {
|
|
2
|
+
static of: jest.Mock<any, any, any>;
|
|
3
|
+
static from: jest.Mock<any, any, any>;
|
|
4
|
+
static verify: jest.Mock<any, any, any>;
|
|
5
|
+
static load: jest.Mock<any, any, any>;
|
|
6
|
+
getProof: jest.Mock<any, any, any>;
|
|
7
|
+
verify: jest.Mock<any, any, any>;
|
|
8
|
+
render: jest.Mock<any, any, any>;
|
|
9
|
+
dump: jest.Mock<any, any, any>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=merkle-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merkle-tree.d.ts","sourceRoot":"","sources":["../../../../../ts/jest/__mocks__/@openzeppelin/merkle-tree.ts"],"names":[],"mappings":"AACA,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,EAAE,2BAAa;IAEtB,MAAM,CAAC,IAAI,2BAAa;IAExB,MAAM,CAAC,MAAM,2BAAa;IAE1B,MAAM,CAAC,IAAI,2BAAa;IAExB,QAAQ,2BAAa;IAErB,MAAM,2BAAa;IAEnB,MAAM,2BAAa;IAEnB,IAAI,2BAAa;CAClB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Mock for @openzeppelin/merkle-tree to avoid util.deprecate issues in tests
|
|
2
|
+
export class StandardMerkleTree {
|
|
3
|
+
static of = jest.fn();
|
|
4
|
+
static from = jest.fn();
|
|
5
|
+
static verify = jest.fn();
|
|
6
|
+
static load = jest.fn();
|
|
7
|
+
getProof = jest.fn();
|
|
8
|
+
verify = jest.fn();
|
|
9
|
+
render = jest.fn();
|
|
10
|
+
dump = jest.fn();
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=merkle-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merkle-tree.js","sourceRoot":"","sources":["../../../../../ts/jest/__mocks__/@openzeppelin/merkle-tree.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,OAAO,kBAAkB;IAC7B,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAEtB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAExB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAE1B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAExB,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAErB,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAEnB,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAEnB,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC"}
|
package/build/ts/main.js
CHANGED
|
@@ -40,7 +40,7 @@ async function bootstrap() {
|
|
|
40
40
|
.build();
|
|
41
41
|
const document = SwaggerModule.createDocument(app, config);
|
|
42
42
|
SwaggerModule.setup("api", app, document);
|
|
43
|
-
await app.listen(process.env.COORDINATOR_PORT ||
|
|
43
|
+
await app.listen(process.env.COORDINATOR_PORT || 3001);
|
|
44
44
|
}
|
|
45
45
|
bootstrap();
|
|
46
46
|
//# sourceMappingURL=main.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { EMode, ESupportedChains } from "@maci-protocol/sdk";
|
|
1
2
|
import { HttpException, HttpStatus } from "@nestjs/common";
|
|
2
3
|
import { Test } from "@nestjs/testing";
|
|
3
|
-
import { ESupportedNetworks } from "../../common";
|
|
4
4
|
import { FileService } from "../../file/file.service";
|
|
5
5
|
import { ProofController } from "../proof.controller";
|
|
6
6
|
import { ProofGeneratorService } from "../proof.service";
|
|
@@ -9,18 +9,17 @@ describe("ProofController", () => {
|
|
|
9
9
|
const defaultProofGeneratorArgs = {
|
|
10
10
|
poll: 0,
|
|
11
11
|
maciContractAddress: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
12
|
-
|
|
13
|
-
encryptedCoordinatorPrivateKey: "siO9W/g7jNVXs9tOUv/pffrcqYdMlgdXw7nSSlqM1q1UvHGSSbhtLJpeT+nJKW7/+xrBTgI0wB866DSkg8Rgr8zD+POUMiKPrGqAO/XhrcmRDL+COURFNDRh9WGeAua6hdiNoufQYvXPl1iWyIYidSDbfmC2wR6F9vVkhg/6KDZyw8Wlr6LUh0RYT+hUHEwwGbz7MeqZJcJQSTpECPF5pnk8NTHL2W/XThaewB4n4HYqjDUbYLmBDLYWsDDMgoPo709a309rTq3uEe0YBgVF8g9aGxucTDhz+/LYYzqaeSxclUwen9Z4BGZjiDSPBZfooOEQEEwIJlViQ2kl1VeOKAmkiWEUVfItivmNbC/PNZchklmfFsGpiu4DT9UU9YVBN2OTcFYHHsslcaqrR7SuesqjluaGjG46oYEmfQlkZ4gXhavdWXw2ant+Tv6HRo4trqjoD1e3jUkN6gJMWomxOeRBTg0czBZlz/IwUtTpBHcKhi3EqGQo8OuQtWww+Ts7ySmeoONuovYUsIAppNuOubfUxvFJoTr2vKbWNAiYetw09kddkjmBe+S8A5PUiFOi262mfc7g5wJwPPP7wpTBY0Fya+2BCPzXqRLMOtNI+1tW3/UQLZYvEY8J0TxmhoAGZaRn8FKaosatRxDZTQS6QUNmKxpmUspkRKzTXN5lznM=",
|
|
12
|
+
mode: EMode.NON_QV,
|
|
14
13
|
sessionKeyAddress: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
15
14
|
approval: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
16
|
-
chain:
|
|
15
|
+
chain: ESupportedChains.Localhost,
|
|
17
16
|
};
|
|
18
17
|
const defaultMergeArgs = {
|
|
19
18
|
maciContractAddress: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
20
19
|
pollId: 0,
|
|
21
20
|
sessionKeyAddress: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
22
21
|
approval: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
23
|
-
chain:
|
|
22
|
+
chain: ESupportedChains.Localhost,
|
|
24
23
|
};
|
|
25
24
|
const defaultProofGeneratorData = {
|
|
26
25
|
tallyProofs: [],
|
|
@@ -67,7 +66,7 @@ describe("ProofController", () => {
|
|
|
67
66
|
test("should throw an error if proof generation is failed", async () => {
|
|
68
67
|
const error = new Error("error");
|
|
69
68
|
mockGeneratorService.generate.mockRejectedValue(error);
|
|
70
|
-
await expect(proofController.generate(defaultProofGeneratorArgs)).rejects.toThrow(new HttpException(error.message, HttpStatus.
|
|
69
|
+
await expect(proofController.generate(defaultProofGeneratorArgs)).rejects.toThrow(new HttpException(error.message, HttpStatus.INTERNAL_SERVER_ERROR));
|
|
71
70
|
});
|
|
72
71
|
});
|
|
73
72
|
describe("v1/proof/merge", () => {
|
|
@@ -84,7 +83,7 @@ describe("ProofController", () => {
|
|
|
84
83
|
test("should throw an error if file service throws an error", async () => {
|
|
85
84
|
const error = new Error("error");
|
|
86
85
|
mockFileService.getPublicKey.mockRejectedValue(error);
|
|
87
|
-
await expect(proofController.getPublicKey()).rejects.toThrow(new HttpException(error.message, HttpStatus.
|
|
86
|
+
await expect(proofController.getPublicKey()).rejects.toThrow(new HttpException(error.message, HttpStatus.INTERNAL_SERVER_ERROR));
|
|
88
87
|
});
|
|
89
88
|
});
|
|
90
89
|
});
|