@maci-protocol/coordinator 0.0.0-ci.40d164d → 0.0.0-ci.4450fd6
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/LICENSE +1 -2
- package/README.md +71 -10
- package/build/hardhat.config.cjs +17 -9
- package/build/hardhat.config.cjs.map +1 -1
- package/build/hardhat.config.d.cts +15 -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 -4
- package/build/tests/constants.d.ts.map +1 -1
- package/build/tests/constants.js +5 -4
- package/build/tests/constants.js.map +1 -1
- package/build/tests/e2e.deploy.test.js +129 -101
- 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 +7 -1
- package/build/tests/utils.d.ts.map +1 -1
- package/build/tests/utils.js +17 -6
- 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 +44 -46
- package/build/ts/common/__tests__/common.test.js.map +1 -1
- package/build/ts/common/accountAbstraction.d.ts +7 -24
- package/build/ts/common/accountAbstraction.d.ts.map +1 -1
- package/build/ts/common/accountAbstraction.js +22 -49
- package/build/ts/common/accountAbstraction.js.map +1 -1
- package/build/ts/common/chain.d.ts +22 -0
- package/build/ts/common/chain.d.ts.map +1 -0
- package/build/ts/common/chain.js +37 -0
- package/build/ts/common/chain.js.map +1 -0
- 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 +11 -8
- package/build/ts/common/errors.d.ts.map +1 -1
- package/build/ts/common/errors.js +10 -7
- 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 +3 -1
- package/build/ts/common/index.d.ts.map +1 -1
- package/build/ts/common/index.js +3 -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 +3 -4
- 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 +183 -336
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -1
- package/build/ts/deployer/__tests__/utils.d.ts +31 -6
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/utils.js +47 -23
- 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 +24 -51
- package/build/ts/deployer/deployer.service.d.ts.map +1 -1
- package/build/ts/deployer/deployer.service.js +335 -470
- package/build/ts/deployer/deployer.service.js.map +1 -1
- package/build/ts/deployer/dto.d.ts +7 -7
- package/build/ts/deployer/dto.d.ts.map +1 -1
- package/build/ts/deployer/dto.js +14 -6
- package/build/ts/deployer/dto.js.map +1 -1
- package/build/ts/deployer/types.d.ts +79 -42
- 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 +8 -7
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.gateway.test.js +5 -3
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.service.test.js +27 -71
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
- package/build/ts/proof/dto.d.ts +15 -18
- package/build/ts/proof/dto.d.ts.map +1 -1
- package/build/ts/proof/dto.js +55 -49
- package/build/ts/proof/dto.js.map +1 -1
- package/build/ts/proof/proof.controller.d.ts +3 -2
- 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 +4 -6
- package/build/ts/proof/proof.service.d.ts.map +1 -1
- package/build/ts/proof/proof.service.js +48 -130
- package/build/ts/proof/proof.service.js.map +1 -1
- package/build/ts/proof/types.d.ts +21 -17
- 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 +53 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts.map +1 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js +105 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.service.d.ts +16 -4
- package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -1
- package/build/ts/sessionKeys/sessionKeys.service.js +23 -6
- 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 -39
- 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 -103
- package/build/tests/e2e.aa.test.js.map +0 -1
- package/build/ts/deployer/utils.d.ts +0 -8
- package/build/ts/deployer/utils.d.ts.map +0 -1
- package/build/ts/deployer/utils.js +0 -9
- package/build/ts/deployer/utils.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
4
|
-
Cory Dickson, Han Jian, Chih-Cheng Liang, and Koh Wei Jie
|
|
3
|
+
Copyright (c) 2025 Ethereum Foundation
|
|
5
4
|
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -2,16 +2,77 @@
|
|
|
2
2
|
|
|
3
3
|
Please refer to [Offchain relayer service documentation](https://maci.pse.dev/docs/category/offchain-relayer) for more information.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
1.
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
10
|
-
4.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
1. [Node.js](https://nodejs.org/en) version 20.0.0.
|
|
8
|
+
2. [pnpm](https://pnpm.io/installation) package manager.
|
|
9
|
+
3. [rapidsnark](https://github.com/iden3/rapidsnark) program.
|
|
10
|
+
4. (Optional) [Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/) database if you want to use the scheduler module.
|
|
11
|
+
|
|
12
|
+
- Please note that the build process might fail in a Windows environment. If you are using Windows, it is recommended to use Windows Subsystem for Linux (WSL) or a virtual machine with a Linux distribution.
|
|
13
|
+
|
|
14
|
+
## Install and build it from source
|
|
15
|
+
|
|
16
|
+
1. Install dependencies and build the project
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm install
|
|
20
|
+
pnpm run build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. Install Redis database (if the scheduler module is going to be used) using [the official guide](https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/)
|
|
24
|
+
|
|
25
|
+
3. Download the zkeys
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm run download-zkeys:test
|
|
29
|
+
# for production zkeys
|
|
30
|
+
# pnpm run download-zkeys:ceremony
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
4. Move to the coordinator service directory
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cd apps/coordinator
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
5. Generate the RSA key pair to encrypt values throughout the communication workflow
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pnpm run generate-keypair
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
6. Setup .env file (see `.env.example` for reference)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
cp .env.example .env
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
7. Run the NestJS application
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pnpm run start
|
|
55
|
+
# or
|
|
56
|
+
pnpm run start:prod
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Docker
|
|
60
|
+
|
|
61
|
+
Remember to run it from the monorepo root directory.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Build docker
|
|
65
|
+
docker compose -f apps/coordinator/docker-compose.yml build
|
|
66
|
+
|
|
67
|
+
# Run container detached
|
|
68
|
+
docker compose -f apps/coordinator/docker-compose.yml up -d
|
|
69
|
+
|
|
70
|
+
# Enter the container
|
|
71
|
+
docker compose -f apps/coordinator/docker-compose.yml exec coordinator-service /bin/sh
|
|
72
|
+
|
|
73
|
+
# Stop container
|
|
74
|
+
docker compose -f apps/coordinator/docker-compose.yml down
|
|
75
|
+
```
|
|
15
76
|
|
|
16
77
|
## Subgraph deployment
|
|
17
78
|
|
package/build/hardhat.config.cjs
CHANGED
|
@@ -7,22 +7,30 @@ dotenv.config();
|
|
|
7
7
|
const parentDir = __dirname.includes("build") ? ".." : "";
|
|
8
8
|
const TEST_MNEMONIC = "test test test test test test test test test test test junk";
|
|
9
9
|
module.exports = {
|
|
10
|
-
defaultNetwork: "
|
|
10
|
+
defaultNetwork: "localhost",
|
|
11
11
|
networks: {
|
|
12
|
-
|
|
12
|
+
localhost: {
|
|
13
13
|
url: process.env.COORDINATOR_RPC_URL || "http://localhost:8545",
|
|
14
|
-
accounts:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
accounts: process.env.PRIVATE_KEY
|
|
15
|
+
? [process.env.PRIVATE_KEY]
|
|
16
|
+
: {
|
|
17
|
+
mnemonic: process.env.MNEMONIC || TEST_MNEMONIC,
|
|
18
|
+
path: "m/44'/60'/0'/0",
|
|
19
|
+
initialIndex: process.env.INITIAL_INDEX ? Number(process.env.INITIAL_INDEX) : 0,
|
|
20
|
+
count: 20,
|
|
21
|
+
},
|
|
21
22
|
},
|
|
22
23
|
hardhat: {
|
|
23
24
|
loggingEnabled: false,
|
|
25
|
+
mining: {
|
|
26
|
+
auto: false,
|
|
27
|
+
interval: 5000,
|
|
28
|
+
},
|
|
24
29
|
},
|
|
25
30
|
},
|
|
31
|
+
solidity: {
|
|
32
|
+
version: "0.8.28",
|
|
33
|
+
},
|
|
26
34
|
paths: {
|
|
27
35
|
sources: path.resolve(__dirname, parentDir, "./node_modules/@maci-protocol/sdk/node_modules/@maci-protocol/contracts/contracts"),
|
|
28
36
|
artifacts: path.resolve(__dirname, parentDir, "./node_modules/@maci-protocol/sdk/node_modules/@maci-protocol/contracts/artifacts"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hardhat.config.cjs","sourceRoot":"","sources":["../hardhat.config.cjs"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEjC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,MAAM,aAAa,GAAG,6DAA6D,CAAC;AAEpF,MAAM,CAAC,OAAO,GAAG;IACf,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"hardhat.config.cjs","sourceRoot":"","sources":["../hardhat.config.cjs"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEjC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,MAAM,aAAa,GAAG,6DAA6D,CAAC;AAEpF,MAAM,CAAC,OAAO,GAAG;IACf,cAAc,EAAE,WAAW;IAC3B,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,uBAAuB;YAC/D,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;gBAC/B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;gBAC3B,CAAC,CAAC;oBACE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa;oBAC/C,IAAI,EAAE,gBAAgB;oBACtB,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC/E,KAAK,EAAE,EAAE;iBACV;SACN;QACD,OAAO,EAAE;YACP,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE;gBACN,IAAI,EAAE,KAAK;gBACX,QAAQ,EAAE,IAAI;aACf;SACF;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,QAAQ;KAClB;IACD,KAAK,EAAE;QACL,OAAO,EAAE,IAAI,CAAC,OAAO,CACnB,SAAS,EACT,SAAS,EACT,mFAAmF,CACpF;QACD,SAAS,EAAE,IAAI,CAAC,OAAO,CACrB,SAAS,EACT,SAAS,EACT,mFAAmF,CACpF;KACF;CACF,CAAC"}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
declare const TEST_MNEMONIC: "test test test test test test test test test test test junk";
|
|
2
1
|
export let defaultNetwork: string;
|
|
3
2
|
export namespace networks {
|
|
4
|
-
namespace
|
|
3
|
+
namespace localhost {
|
|
5
4
|
let url: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
let loggingEnabled: boolean;
|
|
5
|
+
let accounts: string[] | {
|
|
6
|
+
mnemonic: string;
|
|
7
|
+
path: string;
|
|
8
|
+
initialIndex: number;
|
|
9
|
+
count: number;
|
|
10
|
+
};
|
|
13
11
|
}
|
|
14
12
|
namespace hardhat {
|
|
15
|
-
let
|
|
16
|
-
|
|
13
|
+
let loggingEnabled: boolean;
|
|
14
|
+
namespace mining {
|
|
15
|
+
let auto: boolean;
|
|
16
|
+
let interval: number;
|
|
17
|
+
}
|
|
17
18
|
}
|
|
18
19
|
}
|
|
20
|
+
export namespace solidity {
|
|
21
|
+
let version: string;
|
|
22
|
+
}
|
|
19
23
|
export namespace paths {
|
|
20
24
|
let sources: string;
|
|
21
25
|
let artifacts: string;
|
|
22
26
|
}
|
|
23
|
-
export {};
|
|
24
27
|
//# sourceMappingURL=hardhat.config.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hardhat.config.d.cts","sourceRoot":"","sources":["../hardhat.config.cjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hardhat.config.d.cts","sourceRoot":"","sources":["../hardhat.config.cjs"],"names":[],"mappings":""}
|
|
@@ -17,8 +17,8 @@ export async function generateRsaKeypair() {
|
|
|
17
17
|
const publicKey = keypair.publicKey.export({ type: "pkcs1", format: "pem" });
|
|
18
18
|
const privateKey = keypair.privateKey.export({ type: "pkcs1", format: "pem" });
|
|
19
19
|
await Promise.all([
|
|
20
|
-
fs.promises.writeFile(path.resolve(process.env.COORDINATOR_PUBLIC_KEY_PATH), publicKey),
|
|
21
|
-
fs.promises.writeFile(path.resolve(process.env.COORDINATOR_PRIVATE_KEY_PATH), privateKey),
|
|
20
|
+
fs.promises.writeFile(path.resolve(process.env.COORDINATOR_PUBLIC_KEY_PATH || "./public.key"), publicKey),
|
|
21
|
+
fs.promises.writeFile(path.resolve(process.env.COORDINATOR_PRIVATE_KEY_PATH || "./private.key"), privateKey),
|
|
22
22
|
]);
|
|
23
23
|
}
|
|
24
24
|
generateRsaKeypair();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateKeypair.js","sourceRoot":"","sources":["../../scripts/generateKeypair.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,yCAAyC;AACzC,iDAAiD;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACnE,wCAAwC;AACxC,gDAAgD;AAEhD,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC;AAE1G,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,EAAE;QACzC,aAAa,EAAE,cAAc;KAC9B,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAE/E,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"generateKeypair.js","sourceRoot":"","sources":["../../scripts/generateKeypair.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,yCAAyC;AACzC,iDAAiD;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACnE,wCAAwC;AACxC,gDAAgD;AAEhD,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC;AAE1G,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,EAAE;QACzC,aAAa,EAAE,cAAc;KAC9B,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAE/E,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,cAAc,CAAC,EAAE,SAAS,CAAC;QACzG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,eAAe,CAAC,EAAE,UAAU,CAAC;KAC7G,CAAC,CAAC;AACL,CAAC;AAED,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export declare const pollJoiningTestZkeyPath
|
|
2
|
-
export declare const testPollJoiningWasmPath
|
|
3
|
-
export declare const testPollJoiningWitnessPath
|
|
1
|
+
export declare const pollJoiningTestZkeyPath: string;
|
|
2
|
+
export declare const testPollJoiningWasmPath: string;
|
|
3
|
+
export declare const testPollJoiningWitnessPath: string;
|
|
4
4
|
export declare const testRapidsnarkPath: string;
|
|
5
5
|
export declare const zeroUint256Encoded: string;
|
|
6
6
|
export declare const oneUint256Encoded: string;
|
|
7
|
-
export declare const pollDuration = 10;
|
|
8
7
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../tests/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../tests/constants.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,uBAAuB,QAA+E,CAAC;AACpH,eAAO,MAAM,uBAAuB,QAGnC,CAAC;AACF,eAAO,MAAM,0BAA0B,QAGtC,CAAC;AACF,eAAO,MAAM,kBAAkB,QAAyC,CAAC;AAEzE,eAAO,MAAM,kBAAkB,QAAsD,CAAC;AACtF,eAAO,MAAM,iBAAiB,QAAsD,CAAC"}
|
package/build/tests/constants.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AbiCoder } from "ethers";
|
|
2
2
|
import { homedir } from "os";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const
|
|
3
|
+
import path from "path";
|
|
4
|
+
const root = path.resolve(__dirname, "../../..");
|
|
5
|
+
export const pollJoiningTestZkeyPath = path.resolve(root, "./zkeys/PollJoining_10_test/PollJoining_10_test.0.zkey");
|
|
6
|
+
export const testPollJoiningWasmPath = path.resolve(root, "./zkeys/PollJoining_10_test/PollJoining_10_test_js/PollJoining_10_test.wasm");
|
|
7
|
+
export const testPollJoiningWitnessPath = path.resolve(root, "./zkeys/PollJoining_10_test/PollJoining_10_test_cpp/PollJoining_10_test");
|
|
6
8
|
export const testRapidsnarkPath = `${homedir()}/rapidsnark/build/prover`;
|
|
7
9
|
export const zeroUint256Encoded = AbiCoder.defaultAbiCoder().encode(["uint256"], [0]);
|
|
8
10
|
export const oneUint256Encoded = AbiCoder.defaultAbiCoder().encode(["uint256"], [1]);
|
|
9
|
-
export const pollDuration = 10; // 100 seconds (added to unix timestamp of start date)
|
|
10
11
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../tests/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../tests/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,wDAAwD,CAAC,CAAC;AACpH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,OAAO,CACjD,IAAI,EACJ,6EAA6E,CAC9E,CAAC;AACF,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC,OAAO,CACpD,IAAI,EACJ,yEAAyE,CAC1E,CAAC;AACF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,OAAO,EAAE,0BAA0B,CAAC;AAEzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,59 +1,57 @@
|
|
|
1
|
-
// To only run this file: pnpm exec jest --testPathPattern=tests/e2e.deploy.test.ts
|
|
2
|
-
import { generateRandomSalt } from "@maci-protocol/crypto";
|
|
3
1
|
import { Keypair } from "@maci-protocol/domainobjs";
|
|
4
|
-
import {
|
|
2
|
+
import { isArm, joinPoll, signup, sleepUntil, ESupportedChains, ContractStorage } from "@maci-protocol/sdk";
|
|
5
3
|
import { ValidationPipe } from "@nestjs/common";
|
|
6
4
|
import { Test } from "@nestjs/testing";
|
|
7
5
|
import dotenv from "dotenv";
|
|
8
|
-
import hardhat from "hardhat";
|
|
9
6
|
import { io } from "socket.io-client";
|
|
10
7
|
import { zeroAddress } from "viem";
|
|
8
|
+
import path from "path";
|
|
11
9
|
import { AppModule } from "../ts/app.module";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import { getSigner } from "../ts/common";
|
|
11
|
+
import { pollDuration, pollStartDateExtraSeconds, testMaciDeploymentConfig, testPollDeploymentConfig, } from "../ts/deployer/__tests__/utils";
|
|
12
|
+
import { DeployerModule } from "../ts/deployer/deployer.module";
|
|
15
13
|
import { FileModule } from "../ts/file/file.module";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
14
|
+
import { ProofModule } from "../ts/proof/proof.module";
|
|
15
|
+
import { SessionKeysModule } from "../ts/sessionKeys/sessionKeys.module";
|
|
16
|
+
import { pollJoiningTestZkeyPath, testPollJoiningWasmPath, testPollJoiningWitnessPath, testRapidsnarkPath, zeroUint256Encoded, } from "./constants";
|
|
17
|
+
import { getAuthorizationHeader } from "./utils";
|
|
19
18
|
dotenv.config();
|
|
20
|
-
|
|
19
|
+
jest.setTimeout(700000); // Sets timeout to 700 seconds
|
|
20
|
+
const PORT = process.env.COORDINATOR_PORT || 3001;
|
|
21
|
+
const TEST_URL = `http://localhost:${PORT}/v1`;
|
|
22
|
+
const CHAIN = ESupportedChains.Localhost;
|
|
23
|
+
const REGEX_SUBGRAPH = /^https:\/\/api\.studio\.thegraph\.com\/query\/\d+\/maci-subgraph\/v0\.0\.\d+$/;
|
|
21
24
|
const NUM_USERS = 1;
|
|
22
|
-
const
|
|
25
|
+
const VOTE_OPTIONS = {
|
|
23
26
|
"0": 0,
|
|
24
27
|
"1": 0,
|
|
25
28
|
};
|
|
29
|
+
const useWasm = isArm();
|
|
26
30
|
describe("E2E Deployment Tests", () => {
|
|
27
31
|
let signer;
|
|
28
32
|
let encryptedHeader;
|
|
29
|
-
let coordinatorKeypair;
|
|
30
|
-
let sessionKeyAddress;
|
|
31
|
-
let approval;
|
|
32
33
|
let app;
|
|
33
34
|
let socket;
|
|
34
|
-
const publicClient = getPublicClient(ESupportedNetworks.OPTIMISM_SEPOLIA);
|
|
35
35
|
let maciAddress;
|
|
36
|
+
let maciCreatedAt;
|
|
36
37
|
let pollId;
|
|
37
38
|
// set up coordinator address
|
|
38
39
|
beforeAll(async () => {
|
|
39
|
-
|
|
40
|
+
signer = await getSigner(CHAIN);
|
|
40
41
|
encryptedHeader = await getAuthorizationHeader(signer);
|
|
41
|
-
coordinatorKeypair = new Keypair();
|
|
42
42
|
process.env.COORDINATOR_ADDRESSES = await signer.getAddress();
|
|
43
|
-
await rechargeGasIfNeeded(process.env.COORDINATOR_ADDRESSES, "0.007", "0.007");
|
|
44
|
-
});
|
|
45
|
-
// set up NestJS app
|
|
46
|
-
beforeAll(async () => {
|
|
47
43
|
const moduleFixture = await Test.createTestingModule({
|
|
48
|
-
imports: [AppModule, FileModule],
|
|
44
|
+
imports: [AppModule, FileModule, DeployerModule, ProofModule, SessionKeysModule],
|
|
49
45
|
}).compile();
|
|
50
46
|
app = moduleFixture.createNestApplication();
|
|
51
47
|
app.useGlobalPipes(new ValidationPipe({ transform: true }));
|
|
52
48
|
await app.init();
|
|
53
|
-
await app.listen(
|
|
49
|
+
await app.listen(PORT);
|
|
54
50
|
});
|
|
55
51
|
afterAll(async () => {
|
|
56
52
|
await app.close();
|
|
53
|
+
const storageInstance = ContractStorage.getInstance(path.join(process.cwd(), "deployed-contracts.json"));
|
|
54
|
+
storageInstance.cleanup(CHAIN);
|
|
57
55
|
});
|
|
58
56
|
// set up auth header in WS connection
|
|
59
57
|
beforeEach(async () => {
|
|
@@ -74,9 +72,24 @@ describe("E2E Deployment Tests", () => {
|
|
|
74
72
|
afterEach(() => {
|
|
75
73
|
socket.disconnect();
|
|
76
74
|
});
|
|
77
|
-
|
|
75
|
+
test("should return true in the health check", async () => {
|
|
76
|
+
const response = await fetch(`${TEST_URL}/health/check`, { method: "GET" });
|
|
77
|
+
const body = (await response.json());
|
|
78
|
+
expect(response.status).toBe(200);
|
|
79
|
+
expect(body.rapidsnark.rapidsnarkIsExecutable).toBe(true);
|
|
80
|
+
expect(body.zkeysDirectory.zkeysDirectoryExists).toBe(true);
|
|
81
|
+
expect(body.coordinatorWalletFunds.fundsInNetworks[0].address).not.toBe(zeroAddress);
|
|
82
|
+
});
|
|
83
|
+
test("should retrieve RSA public key", async () => {
|
|
84
|
+
const response = await fetch(`${TEST_URL}/proof/publicKey`, {
|
|
85
|
+
method: "GET",
|
|
86
|
+
});
|
|
87
|
+
const body = (await response.json());
|
|
88
|
+
expect(response.status).toBe(200);
|
|
89
|
+
expect(body.publicKey).toBeDefined();
|
|
90
|
+
});
|
|
78
91
|
test("should retrieve the session key address", async () => {
|
|
79
|
-
const response = await fetch(`${
|
|
92
|
+
const response = await fetch(`${TEST_URL}/session-keys/generate`, {
|
|
80
93
|
method: "GET",
|
|
81
94
|
headers: {
|
|
82
95
|
Authorization: encryptedHeader,
|
|
@@ -85,56 +98,41 @@ describe("E2E Deployment Tests", () => {
|
|
|
85
98
|
const body = (await response.json());
|
|
86
99
|
expect(response.status).toBe(200);
|
|
87
100
|
expect(body.sessionKeyAddress).not.toBe(zeroAddress);
|
|
88
|
-
// save them for next tests
|
|
89
|
-
sessionKeyAddress = body.sessionKeyAddress;
|
|
90
|
-
approval = await generateApproval(sessionKeyAddress);
|
|
91
|
-
const sessionKeyAccount = await getKernelAccount(sessionKeyAddress);
|
|
92
|
-
await rechargeGasIfNeeded(sessionKeyAccount.address, "0.03", "0.03");
|
|
93
101
|
});
|
|
94
102
|
test("should deploy MACI correctly", async () => {
|
|
95
|
-
const
|
|
96
|
-
config.VerifyingKeysRegistry.args.stateTreeDepth = config.VerifyingKeysRegistry.args.stateTreeDepth.toString();
|
|
97
|
-
config.VerifyingKeysRegistry.args.intStateTreeDepth =
|
|
98
|
-
config.VerifyingKeysRegistry.args.intStateTreeDepth.toString();
|
|
99
|
-
config.VerifyingKeysRegistry.args.voteOptionTreeDepth =
|
|
100
|
-
config.VerifyingKeysRegistry.args.voteOptionTreeDepth.toString();
|
|
101
|
-
const response = await fetch(`${LOCALHOST}/v1/deploy/maci`, {
|
|
103
|
+
const response = await fetch(`${TEST_URL}/deploy/maci`, {
|
|
102
104
|
method: "POST",
|
|
103
105
|
headers: {
|
|
104
106
|
Authorization: encryptedHeader,
|
|
105
107
|
"Content-Type": "application/json",
|
|
106
108
|
},
|
|
107
109
|
body: JSON.stringify({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
chain: ESupportedNetworks.OPTIMISM_SEPOLIA,
|
|
111
|
-
config,
|
|
110
|
+
chain: CHAIN,
|
|
111
|
+
config: testMaciDeploymentConfig,
|
|
112
112
|
}),
|
|
113
113
|
});
|
|
114
114
|
const body = (await response.json());
|
|
115
115
|
expect(response.status).toBe(201);
|
|
116
116
|
expect(body.address).not.toBe(zeroAddress);
|
|
117
117
|
// save them for next tests
|
|
118
|
+
const blockNumber = await signer.provider.getBlockNumber();
|
|
119
|
+
maciCreatedAt = BigInt(blockNumber);
|
|
118
120
|
maciAddress = body.address;
|
|
119
121
|
});
|
|
120
122
|
test("should deploy a poll correctly", async () => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
config.endDate = startDate + pollDuration;
|
|
127
|
-
const response = await fetch(`${LOCALHOST}/v1/deploy/poll`, {
|
|
123
|
+
testPollDeploymentConfig.voteOptions = testPollDeploymentConfig.voteOptions.toString();
|
|
124
|
+
const startDate = Math.floor(Date.now() / 1000) + pollStartDateExtraSeconds;
|
|
125
|
+
testPollDeploymentConfig.startDate = startDate;
|
|
126
|
+
testPollDeploymentConfig.endDate = startDate + pollDuration;
|
|
127
|
+
const response = await fetch(`${TEST_URL}/deploy/poll`, {
|
|
128
128
|
method: "POST",
|
|
129
129
|
headers: {
|
|
130
130
|
Authorization: encryptedHeader,
|
|
131
131
|
"Content-Type": "application/json",
|
|
132
132
|
},
|
|
133
133
|
body: JSON.stringify({
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
chain: ESupportedNetworks.OPTIMISM_SEPOLIA,
|
|
137
|
-
config,
|
|
134
|
+
chain: CHAIN,
|
|
135
|
+
config: testPollDeploymentConfig,
|
|
138
136
|
}),
|
|
139
137
|
});
|
|
140
138
|
const body = (await response.json());
|
|
@@ -143,36 +141,14 @@ describe("E2E Deployment Tests", () => {
|
|
|
143
141
|
// save them for next tests
|
|
144
142
|
pollId = BigInt(body.pollId);
|
|
145
143
|
});
|
|
146
|
-
test("should deploy a subgraph correctly", async () => {
|
|
147
|
-
const blockNumber = Number(await publicClient.getBlockNumber());
|
|
148
|
-
const response = await fetch(`${LOCALHOST}/v1/subgraph/deploy`, {
|
|
149
|
-
method: "POST",
|
|
150
|
-
headers: {
|
|
151
|
-
Authorization: encryptedHeader,
|
|
152
|
-
"Content-Type": "application/json",
|
|
153
|
-
},
|
|
154
|
-
body: JSON.stringify({
|
|
155
|
-
maciContractAddress: maciAddress,
|
|
156
|
-
startBlock: blockNumber,
|
|
157
|
-
network: ESupportedNetworks.OPTIMISM_SEPOLIA,
|
|
158
|
-
name: process.env.SUBGRAPH_NAME,
|
|
159
|
-
tag: `v0.0.${blockNumber}`, // different versions per test using block number
|
|
160
|
-
}),
|
|
161
|
-
});
|
|
162
|
-
const body = (await response.json());
|
|
163
|
-
const { url } = body;
|
|
164
|
-
const regex = /^https:\/\/api\.studio\.thegraph\.com\/query\/\d+\/maci-subgraph\/v0\.0\.\d+$/;
|
|
165
|
-
expect(response.status).toBe(201);
|
|
166
|
-
expect(body.url).toBeDefined();
|
|
167
|
-
expect(regex.test(url)).toBe(true);
|
|
168
|
-
});
|
|
169
144
|
test("should allow voting on a poll", async () => {
|
|
145
|
+
await sleepUntil(testPollDeploymentConfig.startDate * 1000);
|
|
170
146
|
for (let i = 0; i < NUM_USERS; i += 1) {
|
|
171
147
|
const keypairUser = new Keypair();
|
|
172
148
|
const userPublicKey = keypairUser.publicKey.serialize();
|
|
173
149
|
const userPrivateKey = keypairUser.privateKey.serialize();
|
|
174
150
|
const vote = i % 2;
|
|
175
|
-
|
|
151
|
+
VOTE_OPTIONS[String(vote)] += 1;
|
|
176
152
|
// user signs up to MACI
|
|
177
153
|
// eslint-disable-next-line no-await-in-loop
|
|
178
154
|
await signup({
|
|
@@ -186,37 +162,50 @@ describe("E2E Deployment Tests", () => {
|
|
|
186
162
|
await joinPoll({
|
|
187
163
|
maciAddress,
|
|
188
164
|
privateKey: userPrivateKey,
|
|
189
|
-
stateIndex: 1n,
|
|
190
165
|
pollId: BigInt(pollId),
|
|
191
166
|
pollJoiningZkey: pollJoiningTestZkeyPath,
|
|
192
|
-
useWasm
|
|
193
|
-
|
|
194
|
-
|
|
167
|
+
useWasm,
|
|
168
|
+
pollJoiningWasm: testPollJoiningWasmPath,
|
|
169
|
+
pollWitnessGenerator: testPollJoiningWitnessPath,
|
|
195
170
|
rapidsnark: testRapidsnarkPath,
|
|
196
171
|
sgDataArg: zeroUint256Encoded,
|
|
197
172
|
ivcpDataArg: zeroUint256Encoded,
|
|
198
173
|
signer,
|
|
199
174
|
});
|
|
200
|
-
// user publishes a vote
|
|
201
|
-
// eslint-disable-next-line no-await-in-loop
|
|
202
|
-
const publishData = await publish({
|
|
203
|
-
publicKey: userPublicKey,
|
|
204
|
-
stateIndex: 1n,
|
|
205
|
-
voteOptionIndex: BigInt(vote),
|
|
206
|
-
nonce: 1n,
|
|
207
|
-
pollId: BigInt(pollId),
|
|
208
|
-
newVoteWeight: 1n,
|
|
209
|
-
maciAddress,
|
|
210
|
-
salt: generateRandomSalt(),
|
|
211
|
-
privateKey: userPrivateKey,
|
|
212
|
-
signer,
|
|
213
|
-
});
|
|
214
|
-
expect(publishData.hash).not.toBe(zeroAddress);
|
|
215
175
|
}
|
|
216
176
|
});
|
|
177
|
+
test("should deploy a subgraph correctly", async () => {
|
|
178
|
+
const response = await fetch(`${TEST_URL}/subgraph/deploy`, {
|
|
179
|
+
method: "POST",
|
|
180
|
+
headers: {
|
|
181
|
+
Authorization: encryptedHeader,
|
|
182
|
+
"Content-Type": "application/json",
|
|
183
|
+
},
|
|
184
|
+
body: JSON.stringify({
|
|
185
|
+
maciContractAddress: maciAddress,
|
|
186
|
+
startBlock: Number(maciCreatedAt),
|
|
187
|
+
network: ESupportedChains.OptimismSepolia,
|
|
188
|
+
name: process.env.SUBGRAPH_NAME,
|
|
189
|
+
tag: `v0.0.${+new Date()}`, // different versions per test using timestamp
|
|
190
|
+
}),
|
|
191
|
+
});
|
|
192
|
+
const body = await response.json();
|
|
193
|
+
if (response.status === 400) {
|
|
194
|
+
const errorMessage = body.message;
|
|
195
|
+
if (errorMessage.includes("api.thegraph.com | 502: Bad gateway")) {
|
|
196
|
+
// eslint-disable-next-line no-console
|
|
197
|
+
console.info("It looks like there was a problem with The Graph endpoint. We are passing this test.");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const { url } = body;
|
|
202
|
+
expect(response.status).toBe(201);
|
|
203
|
+
expect(url).toBeDefined();
|
|
204
|
+
expect(REGEX_SUBGRAPH.test(url)).toBe(true);
|
|
205
|
+
});
|
|
217
206
|
test("should merge correctly", async () => {
|
|
218
|
-
await
|
|
219
|
-
const response = await fetch(`${
|
|
207
|
+
await sleepUntil((testPollDeploymentConfig.endDate + 13) * 1000); // 13 seconds of grace time after the poll end date
|
|
208
|
+
const response = await fetch(`${TEST_URL}/proof/merge`, {
|
|
220
209
|
method: "POST",
|
|
221
210
|
headers: {
|
|
222
211
|
Authorization: encryptedHeader,
|
|
@@ -225,9 +214,48 @@ describe("E2E Deployment Tests", () => {
|
|
|
225
214
|
body: JSON.stringify({
|
|
226
215
|
maciContractAddress: maciAddress,
|
|
227
216
|
pollId: Number(pollId),
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
217
|
+
chain: CHAIN,
|
|
218
|
+
}),
|
|
219
|
+
});
|
|
220
|
+
expect(response.status).toBe(201);
|
|
221
|
+
});
|
|
222
|
+
test("should generate proofs correctly", async () => {
|
|
223
|
+
const response = await fetch(`${TEST_URL}/proof/generate`, {
|
|
224
|
+
method: "POST",
|
|
225
|
+
headers: {
|
|
226
|
+
Authorization: encryptedHeader,
|
|
227
|
+
"Content-Type": "application/json",
|
|
228
|
+
},
|
|
229
|
+
body: JSON.stringify({
|
|
230
|
+
poll: Number(pollId),
|
|
231
|
+
maciContractAddress: maciAddress,
|
|
232
|
+
mode: testPollDeploymentConfig.mode,
|
|
233
|
+
startBlock: Number(maciCreatedAt),
|
|
234
|
+
blocksPerBatch: 500,
|
|
235
|
+
chain: CHAIN,
|
|
236
|
+
useWasm,
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
const body = (await response.json());
|
|
240
|
+
expect(response.status).toBe(201);
|
|
241
|
+
expect(body.processProofs).toBeDefined();
|
|
242
|
+
expect(body.processProofs.length).toBeGreaterThan(0);
|
|
243
|
+
expect(body.tallyProofs).toBeDefined();
|
|
244
|
+
expect(body.tallyProofs.length).toBeGreaterThan(0);
|
|
245
|
+
expect(body.tallyData).toBeDefined();
|
|
246
|
+
expect(body.tallyData.results).toBeDefined();
|
|
247
|
+
});
|
|
248
|
+
test("should submit results on-chain correctly", async () => {
|
|
249
|
+
const response = await fetch(`${TEST_URL}/proof/submit`, {
|
|
250
|
+
method: "POST",
|
|
251
|
+
headers: {
|
|
252
|
+
Authorization: encryptedHeader,
|
|
253
|
+
"Content-Type": "application/json",
|
|
254
|
+
},
|
|
255
|
+
body: JSON.stringify({
|
|
256
|
+
pollId: Number(pollId),
|
|
257
|
+
maciContractAddress: maciAddress,
|
|
258
|
+
chain: CHAIN,
|
|
231
259
|
}),
|
|
232
260
|
});
|
|
233
261
|
expect(response.status).toBe(201);
|