@maci-protocol/cli 0.0.0-ci.a584b1a → 0.0.0-ci.a874953
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/build/package.json +12 -12
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +111 -70
- package/build/ts/index.js.map +1 -1
- package/build/ts/utils/constants.d.ts +2 -0
- package/build/ts/utils/constants.d.ts.map +1 -1
- package/build/ts/utils/constants.js +7 -1
- package/build/ts/utils/constants.js.map +1 -1
- package/build/ts/utils/storage.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +16 -16
package/build/package.json
CHANGED
|
@@ -24,35 +24,35 @@
|
|
|
24
24
|
"scripts": {
|
|
25
25
|
"watch": "tsc --watch",
|
|
26
26
|
"build": "tsc -p tsconfig.build.json",
|
|
27
|
-
"postbuild": "cp package.json ./build
|
|
27
|
+
"postbuild": "cp package.json ./build",
|
|
28
28
|
"types": "tsc -p tsconfig.json --noEmit",
|
|
29
29
|
"docs": "typedoc --plugin typedoc-plugin-markdown --options ./typedoc.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@commander-js/extra-typings": "^
|
|
33
|
-
"@nomicfoundation/hardhat-toolbox": "^
|
|
34
|
-
"commander": "^
|
|
35
|
-
"dotenv": "^
|
|
36
|
-
"ethers": "^6.
|
|
37
|
-
"hardhat": "^2.
|
|
32
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
33
|
+
"@nomicfoundation/hardhat-toolbox": "^6.1.0",
|
|
34
|
+
"commander": "^14.0.0",
|
|
35
|
+
"dotenv": "^17.2.2",
|
|
36
|
+
"ethers": "^6.15.0",
|
|
37
|
+
"hardhat": "^2.25.0",
|
|
38
38
|
"@maci-protocol/domainobjs": "^3.0.0",
|
|
39
39
|
"@maci-protocol/sdk": "^1.0.0",
|
|
40
40
|
"prompt": "^1.3.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/chai": "^4.3.9",
|
|
44
|
-
"@types/chai-as-promised": "^
|
|
44
|
+
"@types/chai-as-promised": "^8.0.2",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|
|
46
|
-
"@types/node": "^
|
|
46
|
+
"@types/node": "^24.11.0",
|
|
47
47
|
"@types/prompt": "^1.1.9",
|
|
48
48
|
"@types/snarkjs": "^0.7.9",
|
|
49
49
|
"chai": "^4.3.10",
|
|
50
|
-
"chai-as-promised": "^
|
|
51
|
-
"mocha": "^11.
|
|
50
|
+
"chai-as-promised": "^8.0.1",
|
|
51
|
+
"mocha": "^11.7.2",
|
|
52
52
|
"nyc": "^17.1.0",
|
|
53
53
|
"snarkjs": "^0.7.5",
|
|
54
54
|
"ts-mocha": "^11.1.0",
|
|
55
|
-
"typescript": "^5.
|
|
55
|
+
"typescript": "^5.9.2"
|
|
56
56
|
},
|
|
57
57
|
"nyc": {
|
|
58
58
|
"reporter": [
|
package/build/ts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/index.ts"],"names":[],"mappings":";AAmDA,OAAO,WAAW,CAAC"}
|
package/build/ts/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
45
45
|
const path_1 = __importDefault(require("path"));
|
|
46
46
|
require("./cliInit");
|
|
47
47
|
const utils_1 = require("./utils");
|
|
48
|
+
const constants_1 = require("./utils/constants");
|
|
48
49
|
const defaults_1 = require("./utils/defaults");
|
|
49
50
|
// set the description version and name of the cli tool
|
|
50
51
|
const { description, version, name } = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(__dirname, "..", "package.json"), "utf8"));
|
|
@@ -89,11 +90,8 @@ program
|
|
|
89
90
|
const [contract] = await (0, sdk_1.deployFreeForAllSignUpPolicy)({ checker: checkerFactory, policy: policyFactory }, signer, true);
|
|
90
91
|
signupPolicyContractAddress = await contract.getAddress();
|
|
91
92
|
}
|
|
92
|
-
// deploy a verifier contract
|
|
93
|
-
const verifierContract = await (0, sdk_1.deployVerifier)(signer, true);
|
|
94
|
-
const verifierContractAddress = await verifierContract.getAddress();
|
|
95
93
|
// deploy MACI, PollFactory and poseidon
|
|
96
|
-
const { maciContractAddress, pollFactoryContractAddress, tallyFactoryContractAddress, messageProcessorFactoryContractAddress, poseidonAddresses, } = await (0, sdk_1.deployMaci)({
|
|
94
|
+
const { maciContractAddress, pollFactoryContractAddress, tallyFactoryContractAddress, messageProcessorFactoryContractAddress, poseidonAddresses, verifierContractAddress, verifyingKeysRegistryContractAddress, } = await (0, sdk_1.deployMaci)({
|
|
97
95
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
98
96
|
poseidonAddresses: {
|
|
99
97
|
poseidonT3,
|
|
@@ -110,6 +108,7 @@ program
|
|
|
110
108
|
data: {
|
|
111
109
|
[args.signupPolicyContractName]: { address: signupPolicyContractAddress, args: [] },
|
|
112
110
|
[sdk_1.EContracts.Verifier]: { address: verifierContractAddress, args: [] },
|
|
111
|
+
[sdk_1.EContracts.VerifyingKeysRegistry]: { address: verifyingKeysRegistryContractAddress, args: [] },
|
|
113
112
|
[sdk_1.EContracts.MACI]: {
|
|
114
113
|
address: maciContractAddress,
|
|
115
114
|
args: [
|
|
@@ -140,16 +139,16 @@ program
|
|
|
140
139
|
program
|
|
141
140
|
.command("checkVerifyingKeys")
|
|
142
141
|
.description("check that the verifying keys in the contract match the local ones")
|
|
143
|
-
.option("-
|
|
142
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
144
143
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
145
144
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
146
145
|
.option("-k, --vk-contract <vkContract>", "the VerifyingKeysRegistry contract address")
|
|
147
146
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
148
|
-
.requiredOption("-i, --
|
|
147
|
+
.requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
|
|
149
148
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
150
149
|
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
151
|
-
.requiredOption("-p, --
|
|
152
|
-
.requiredOption("-t, --tally-
|
|
150
|
+
.requiredOption("-p, --message-processor-zkey <messageProcessorZkeyPath>", "the message processor zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
151
|
+
.requiredOption("-t, --vote-tally-zkey <voteTallyZkeyPath>", "the vote tally zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
153
152
|
.requiredOption("--poll-joining-zkey <pollJoiningZkey>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
154
153
|
.requiredOption("--poll-joined-zkey <pollJoinedZkey>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
155
154
|
.action(async (args) => {
|
|
@@ -164,15 +163,15 @@ program
|
|
|
164
163
|
(0, sdk_1.logYellow)({ quiet: args.quiet, text: (0, sdk_1.info)("Retrieving verifying keys from the contract...") });
|
|
165
164
|
await (0, sdk_1.checkVerifyingKeys)({
|
|
166
165
|
stateTreeDepth: args.stateTreeDepth,
|
|
167
|
-
|
|
166
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
168
167
|
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
169
168
|
messageBatchSize: args.messageBatchSize,
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
messageProcessorZkeyPath: args.messageProcessorZkey,
|
|
170
|
+
voteTallyZkeyPath: args.voteTallyZkey,
|
|
172
171
|
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
173
172
|
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
174
173
|
verifyingKeysRegistry: contractAddress,
|
|
175
|
-
|
|
174
|
+
mode: args.mode,
|
|
176
175
|
signer,
|
|
177
176
|
});
|
|
178
177
|
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)("Verifying keys match") });
|
|
@@ -197,9 +196,15 @@ program
|
|
|
197
196
|
.option("-s, --seed <seed>", "seed value for keypair", (value) => (value ? BigInt(value) : undefined), undefined)
|
|
198
197
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
199
198
|
.action((args) => {
|
|
200
|
-
const { publicKey, privateKey } = (0, sdk_1.generateKeypair)({ seed: args.seed });
|
|
199
|
+
const { publicKey, privateKey, publicKeyAsContractParam } = (0, sdk_1.generateKeypair)({ seed: args.seed });
|
|
201
200
|
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Public key: ${publicKey}`) });
|
|
202
201
|
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Private key: ${privateKey}`) });
|
|
202
|
+
(0, sdk_1.logGreen)({
|
|
203
|
+
quiet: args.quiet,
|
|
204
|
+
text: (0, sdk_1.success)(`Public key as contract param:
|
|
205
|
+
X: ${publicKeyAsContractParam.x}
|
|
206
|
+
Y: ${publicKeyAsContractParam.y}`),
|
|
207
|
+
});
|
|
203
208
|
});
|
|
204
209
|
program
|
|
205
210
|
.command("deployVerifyingKeysRegistry")
|
|
@@ -255,14 +260,14 @@ program
|
|
|
255
260
|
.option("-k, --verifyingKeysRegistryAddress <verifyingKeysRegistryAddress>", "the vk registry contract address")
|
|
256
261
|
.requiredOption("--start <pollStartDate>", "the poll start date", parseInt)
|
|
257
262
|
.requiredOption("--end <pollEndDate>", "the poll end date", parseInt)
|
|
258
|
-
.requiredOption("-i, --
|
|
263
|
+
.requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the int state tree depth", parseInt)
|
|
259
264
|
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
260
265
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
261
266
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
262
267
|
.requiredOption("-p, --public-key <publicKey>", "the coordinator public key")
|
|
263
|
-
.option("-
|
|
268
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
264
269
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
265
|
-
.option("
|
|
270
|
+
.option("--relayers <relayers>", "the relayer addresses", (value) => value.split(",").map((item) => item.trim()))
|
|
266
271
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
267
272
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
268
273
|
.option("-o, --vote-options <voteOptions>", "the number of vote options", parseInt)
|
|
@@ -274,11 +279,12 @@ program
|
|
|
274
279
|
(0, utils_1.banner)(args.quiet);
|
|
275
280
|
const signer = await getSigner();
|
|
276
281
|
const network = await signer.provider?.getNetwork();
|
|
277
|
-
const [
|
|
282
|
+
const [maciAddress, initialVoiceCreditProxyAddress, initialVoiceCreditProxyFactoryAddress] = (0, utils_1.readContractAddresses)({
|
|
278
283
|
contractNames: [
|
|
279
284
|
sdk_1.EContracts.VerifyingKeysRegistry,
|
|
280
285
|
sdk_1.EContracts.MACI,
|
|
281
286
|
sdk_1.EContracts.ConstantInitialVoiceCreditProxy,
|
|
287
|
+
sdk_1.EContracts.ConstantInitialVoiceCreditProxyFactory,
|
|
282
288
|
sdk_1.EContracts.Verifier,
|
|
283
289
|
],
|
|
284
290
|
network: network?.name,
|
|
@@ -298,19 +304,18 @@ program
|
|
|
298
304
|
initialVoiceCredits: args.initialVoiceCredits || defaults_1.DEFAULT_INITIAL_VOICE_CREDITS,
|
|
299
305
|
pollStartTimestamp: args.start,
|
|
300
306
|
pollEndTimestamp: args.end,
|
|
301
|
-
|
|
307
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
302
308
|
messageBatchSize: args.messageBatchSize,
|
|
303
309
|
stateTreeDepth: args.stateTreeDepth,
|
|
304
310
|
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
305
311
|
coordinatorPublicKey: domainobjs_1.PublicKey.deserialize(args.publicKey),
|
|
306
312
|
maciAddress,
|
|
307
|
-
verifyingKeysRegistryContractAddress: verifyingKeysRegistryAddress,
|
|
308
313
|
relayers: args.relayers ?? [ethers_1.ZeroAddress],
|
|
309
|
-
mode: args.
|
|
314
|
+
mode: args.mode,
|
|
310
315
|
signer,
|
|
311
316
|
voteOptions: args.voteOptions ?? defaults_1.DEFAULT_VOTE_OPTIONS,
|
|
312
|
-
verifierContractAddress,
|
|
313
317
|
policyContractAddress: signupPolicyContractAddress,
|
|
318
|
+
initialVoiceCreditProxyFactoryAddress,
|
|
314
319
|
initialVoiceCreditProxyContractAddress: initialVoiceCreditProxyAddress,
|
|
315
320
|
});
|
|
316
321
|
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)(`Poll ID: ${pollId}`) });
|
|
@@ -337,7 +342,6 @@ program
|
|
|
337
342
|
.command("joinPoll")
|
|
338
343
|
.description("join the poll")
|
|
339
344
|
.requiredOption("-k, --private-key <privateKey>", "the private key")
|
|
340
|
-
.option("-i, --state-index <stateIndex>", "the user's state index", BigInt)
|
|
341
345
|
.option("-s, --sg-data <sgData>", "the signup policy data")
|
|
342
346
|
.option("-v, --ivcp-data <ivcpData>", "the initial voice credit proxy data")
|
|
343
347
|
.option("-n, --new-voice-credit-balance <newVoiceCreditBalance>", "the voice credit balance of the user for the poll", BigInt)
|
|
@@ -349,11 +353,11 @@ program
|
|
|
349
353
|
.option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
|
|
350
354
|
.option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
|
|
351
355
|
.option("--transaction-hash <transactionHash>", "transaction hash of MACI contract creation")
|
|
352
|
-
.option("--poll-wasm <
|
|
356
|
+
.option("--poll-joining-wasm <pollJoiningWasm>", "the path to the poll joining wasm binary")
|
|
353
357
|
.requiredOption("--poll-joining-zkey <pollZkeyPath>", "the poll join zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
354
358
|
.option("-w, --wasm", "whether to use the wasm binaries")
|
|
355
359
|
.option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
|
|
356
|
-
.option("-g, --poll-
|
|
360
|
+
.option("-g, --poll-witness-generator <pollWitnessGenerator>", "the path to the poll witness generation binary")
|
|
357
361
|
.action(async (args) => {
|
|
358
362
|
try {
|
|
359
363
|
const signer = await getSigner();
|
|
@@ -367,7 +371,6 @@ program
|
|
|
367
371
|
const data = await (0, sdk_1.joinPoll)({
|
|
368
372
|
maciAddress,
|
|
369
373
|
privateKey,
|
|
370
|
-
stateIndex: args.stateIndex,
|
|
371
374
|
stateFile: args.stateFile,
|
|
372
375
|
pollId: args.pollId,
|
|
373
376
|
signer,
|
|
@@ -375,10 +378,10 @@ program
|
|
|
375
378
|
endBlock: args.endBlock,
|
|
376
379
|
blocksPerBatch: args.blocksPerBatch,
|
|
377
380
|
pollJoiningZkey: args.pollJoiningZkey,
|
|
378
|
-
|
|
381
|
+
pollJoiningWasm: args.pollJoiningWasm,
|
|
379
382
|
useWasm: args.wasm,
|
|
380
383
|
rapidsnark: args.rapidsnark,
|
|
381
|
-
|
|
384
|
+
pollWitnessGenerator: args.pollWitnessGenerator,
|
|
382
385
|
sgDataArg: args.sgData ?? utils_1.DEFAULT_SG_DATA,
|
|
383
386
|
ivcpDataArg: args.ivcpData ?? utils_1.DEFAULT_IVCP_DATA,
|
|
384
387
|
});
|
|
@@ -394,17 +397,19 @@ program
|
|
|
394
397
|
.command("setVerifyingKeys")
|
|
395
398
|
.description("set the verifying keys")
|
|
396
399
|
.requiredOption("-s, --state-tree-depth <stateTreeDepth>", "the state tree depth", parseInt)
|
|
397
|
-
.requiredOption("-i, --
|
|
400
|
+
.requiredOption("-i, --tally-processing-state-tree-depth <tallyProcessingStateTreeDepth>", "the intermediate state tree depth", parseInt)
|
|
398
401
|
.requiredOption("-v, --vote-option-tree-depth <voteOptionTreeDepth>", "the vote option tree depth", parseInt)
|
|
399
402
|
.requiredOption("-b, --message-batch-size <messageBatchSize>", "the message batch size", parseInt)
|
|
400
403
|
.option("--poll-state-tree-depth <pollStateTreeDepth>", "the poll state tree depth", parseInt)
|
|
401
404
|
.option("--poll-joining-zkey <pollJoiningZkeyPath>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
402
405
|
.option("--poll-joined-zkey <pollJoinedZkeyPath>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
403
|
-
.option("--
|
|
404
|
-
.option("--tally-
|
|
405
|
-
.option("--
|
|
406
|
-
.option("--tally-
|
|
407
|
-
.option("
|
|
406
|
+
.option("--message-processor-zkey-qv <messageProcessorZkeyPathQv>", "the message processor qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
407
|
+
.option("--vote-tally-zkey-qv <voteTallyZkeyPathQv>", "the vote tally qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
408
|
+
.option("--message-processor-zkey-non-qv <messageProcessorZkeyPathNonQv>", "the message processor non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
409
|
+
.option("--vote-tally-zkey-non-qv <voteTallyZkeyPathNonQv>", "the vote tally non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
410
|
+
.option("--message-processor-zkey-full <messageProcessorZkeyPathFull>", "the message processor full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
411
|
+
.option("--vote-tally-zkey-full <tallyVotesZkeyPathFull>", "the vote tally full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
412
|
+
.option("-m, --modes <modes>", "Comma-separated list of voting modes (qv, non-qv, full)", (value) => value.split(",").map((v) => constants_1.MODE_NAME_TO_ENUM[v.trim()]), [sdk_1.EMode.QV])
|
|
408
413
|
.option("-k, --vk-registry <vkRegistry>", "the vk registry contract address")
|
|
409
414
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
410
415
|
.option("-r, --rpc-provider <provider>", "the rpc provider URL")
|
|
@@ -417,24 +422,45 @@ program
|
|
|
417
422
|
network: network?.name,
|
|
418
423
|
defaultAddresses: [args.vkRegistry],
|
|
419
424
|
});
|
|
420
|
-
const
|
|
425
|
+
const processKeys = {
|
|
426
|
+
[sdk_1.EMode.QV]: args.messageProcessorZkeyQv,
|
|
427
|
+
[sdk_1.EMode.NON_QV]: args.messageProcessorZkeyNonQv,
|
|
428
|
+
[sdk_1.EMode.FULL]: args.messageProcessorZkeyFull,
|
|
429
|
+
};
|
|
430
|
+
const tallyKeys = {
|
|
431
|
+
[sdk_1.EMode.QV]: args.voteTallyZkeyQv,
|
|
432
|
+
[sdk_1.EMode.NON_QV]: args.voteTallyZkeyNonQv,
|
|
433
|
+
[sdk_1.EMode.FULL]: args.voteTallyZkeyFull,
|
|
434
|
+
};
|
|
435
|
+
const { pollJoiningVerifyingKey, pollJoinedVerifyingKey } = await (0, sdk_1.extractAllVerifyingKeys)({
|
|
421
436
|
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
422
437
|
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
423
|
-
|
|
424
|
-
|
|
438
|
+
});
|
|
439
|
+
const keysResults = await Promise.all(args.modes.map((mode) => (0, sdk_1.extractAllVerifyingKeys)({
|
|
440
|
+
messageProcessorZkeyPath: processKeys[mode],
|
|
441
|
+
voteTallyZkeyPath: tallyKeys[mode],
|
|
442
|
+
})));
|
|
443
|
+
const processVerifyingKeys = [];
|
|
444
|
+
const tallyVerifyingKeys = [];
|
|
445
|
+
keysResults.forEach(({ processVerifyingKey, tallyVerifyingKey }, idx) => {
|
|
446
|
+
if (!processVerifyingKey || !tallyVerifyingKey) {
|
|
447
|
+
throw new Error(`Verifying keys for mode ${args.modes[idx]} are not valid`);
|
|
448
|
+
}
|
|
449
|
+
processVerifyingKeys.push(processVerifyingKey);
|
|
450
|
+
tallyVerifyingKeys.push(tallyVerifyingKey);
|
|
425
451
|
});
|
|
426
452
|
await (0, sdk_1.setVerifyingKeys)({
|
|
427
453
|
stateTreeDepth: args.stateTreeDepth,
|
|
428
|
-
|
|
454
|
+
tallyProcessingStateTreeDepth: args.tallyProcessingStateTreeDepth,
|
|
429
455
|
voteOptionTreeDepth: args.voteOptionTreeDepth,
|
|
430
456
|
messageBatchSize: args.messageBatchSize,
|
|
431
457
|
pollStateTreeDepth: args.pollStateTreeDepth || args.stateTreeDepth,
|
|
432
458
|
pollJoiningVerifyingKey: pollJoiningVerifyingKey,
|
|
433
459
|
pollJoinedVerifyingKey: pollJoinedVerifyingKey,
|
|
434
|
-
|
|
435
|
-
|
|
460
|
+
processMessagesVerifyingKeys: processVerifyingKeys,
|
|
461
|
+
tallyVotesVerifyingKeys: tallyVerifyingKeys,
|
|
436
462
|
verifyingKeysRegistryAddress,
|
|
437
|
-
|
|
463
|
+
modes: args.modes,
|
|
438
464
|
signer,
|
|
439
465
|
});
|
|
440
466
|
}
|
|
@@ -466,7 +492,7 @@ program
|
|
|
466
492
|
defaultAddresses: [args.maciAddress],
|
|
467
493
|
});
|
|
468
494
|
const privateKey = args.privateKey || (await (0, utils_1.promptSensitiveValue)("Insert your MACI private key"));
|
|
469
|
-
await (0, sdk_1.publish)({
|
|
495
|
+
const { hash } = await (0, sdk_1.publish)({
|
|
470
496
|
publicKey: args.publicKey,
|
|
471
497
|
stateIndex: args.stateIndex,
|
|
472
498
|
voteOptionIndex: args.voteOptionIndex,
|
|
@@ -478,6 +504,10 @@ program
|
|
|
478
504
|
privateKey,
|
|
479
505
|
signer,
|
|
480
506
|
});
|
|
507
|
+
(0, sdk_1.logGreen)({
|
|
508
|
+
quiet: args.quiet,
|
|
509
|
+
text: (0, sdk_1.success)(`Message published successfully. Transaction hash: ${hash}`),
|
|
510
|
+
});
|
|
481
511
|
}
|
|
482
512
|
catch (error) {
|
|
483
513
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -535,18 +565,20 @@ program
|
|
|
535
565
|
.description("extract vkey to json file")
|
|
536
566
|
.requiredOption("--poll-joining-zkey <pollJoiningZkey>", "the poll joining zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
537
567
|
.requiredOption("--poll-joined-zkey <pollJoinedZkey>", "the poll joined zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
538
|
-
.requiredOption("--
|
|
539
|
-
.requiredOption("--tally-
|
|
540
|
-
.requiredOption("--
|
|
541
|
-
.requiredOption("--
|
|
568
|
+
.requiredOption("--message-processor-zkey-qv <messageProcessorZkeyPathQv>", "the message processor qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
569
|
+
.requiredOption("--vote-tally-zkey-qv <voteTallyZkeyPathQv>", "the vote tally qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
570
|
+
.requiredOption("--message-processor-zkey-non-qv <messageProcessorZkeyPathNonQv>", "the message processor non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
571
|
+
.requiredOption("--message-processor-zkey-full <messageProcessorZkeyPathFull>", "the message processor full zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
572
|
+
.requiredOption("--vote-tally-zkey-non-qv <voteTallyZkeyPathNonQv>", "the vote tally non-qv zkey path (see different options for zkey files to use specific circuits https://maci.pse.dev/docs/trusted-setup, https://maci.pse.dev/docs/testing/#pre-compiled-artifacts-for-testing)")
|
|
542
573
|
.requiredOption("-o, --output-file <outputFile>", "the output file path of extracted vkeys")
|
|
543
574
|
.action(async (args) => {
|
|
544
575
|
try {
|
|
545
576
|
await (0, sdk_1.extractVerifyingKeyToFile)({
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
577
|
+
messageProcessorZkeyPathQv: args.messageProcessorZkeyQv,
|
|
578
|
+
messageProcessorZkeyPathFull: args.messageProcessorZkeyFull,
|
|
579
|
+
voteTallyZkeyPathQv: args.voteTallyZkeyQv,
|
|
580
|
+
messageProcessorZkeyPathNonQv: args.messageProcessorZkeyNonQv,
|
|
581
|
+
voteTallyZkeyPathNonQv: args.voteTallyZkeyNonQv,
|
|
550
582
|
pollJoiningZkeyPath: args.pollJoiningZkey,
|
|
551
583
|
pollJoinedZkeyPath: args.pollJoinedZkey,
|
|
552
584
|
outputFilePath: args.outputFile,
|
|
@@ -667,6 +699,7 @@ program
|
|
|
667
699
|
.description("Get deployed poll from MACI contract")
|
|
668
700
|
.option("-p, --poll <poll>", "the poll id")
|
|
669
701
|
.option("-x, --maci-address <maciAddress>", "the MACI contract address")
|
|
702
|
+
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
670
703
|
.action(async (args) => {
|
|
671
704
|
try {
|
|
672
705
|
const signer = await getSigner();
|
|
@@ -681,15 +714,22 @@ program
|
|
|
681
714
|
maciAddress,
|
|
682
715
|
signer,
|
|
683
716
|
});
|
|
717
|
+
const modeNames = {
|
|
718
|
+
[sdk_1.EMode.QV]: "Quadratic Voting",
|
|
719
|
+
[sdk_1.EMode.NON_QV]: "Non-Quadratic Voting",
|
|
720
|
+
[sdk_1.EMode.FULL]: "Full Credits Voting",
|
|
721
|
+
};
|
|
722
|
+
const status = details.isOpen ? "Open" : "Closed";
|
|
684
723
|
(0, sdk_1.logGreen)({
|
|
685
|
-
quiet:
|
|
724
|
+
quiet: args.quiet,
|
|
686
725
|
text: (0, sdk_1.success)([
|
|
687
726
|
`ID: ${details.id}`,
|
|
688
727
|
`Start time: ${new Date(Number(details.startDate) * 1000).toString()}`,
|
|
689
728
|
`End time: ${new Date(Number(details.endDate) * 1000).toString()}`,
|
|
729
|
+
`Status: ${status}`,
|
|
690
730
|
`Number of signups ${details.totalSignups}`,
|
|
691
731
|
`State tree merged: ${details.isMerged}`,
|
|
692
|
-
`Mode: ${details.mode
|
|
732
|
+
`Mode: ${modeNames[details.mode]}`,
|
|
693
733
|
].join("\n")),
|
|
694
734
|
});
|
|
695
735
|
}
|
|
@@ -757,6 +797,7 @@ program
|
|
|
757
797
|
totalVoteOptions: pollParams.totalVoteOptions,
|
|
758
798
|
voteOptionTreeDepth: pollParams.voteOptionTreeDepth,
|
|
759
799
|
});
|
|
800
|
+
(0, sdk_1.logGreen)({ quiet: args.quiet, text: (0, sdk_1.success)("The tally commitment is correct") });
|
|
760
801
|
}
|
|
761
802
|
catch (error) {
|
|
762
803
|
program.error(error.message, { exitCode: 1 });
|
|
@@ -770,27 +811,27 @@ program
|
|
|
770
811
|
.requiredOption("-o, --poll-id <pollId>", "the poll id", BigInt)
|
|
771
812
|
.requiredOption("-t, --tally-file <tallyFile>", "the tally file with results, per vote option spent credits, spent voice credits total")
|
|
772
813
|
.option("-r, --rapidsnark <rapidsnark>", "the path to the rapidsnark binary")
|
|
773
|
-
.option("-g, --
|
|
774
|
-
.option("--
|
|
775
|
-
.option("--tally-
|
|
776
|
-
.option("--tally-
|
|
814
|
+
.option("-g, --message-processor-witness-generator <messageProcessorWitnessGenerator>", "the path to the process witness generation binary")
|
|
815
|
+
.option("--message-processor-witnessDat <messageProcessorWitnessDat>", "the path to the process witness dat file")
|
|
816
|
+
.option("--vote-tally-witness-generator <voteTallyWitnessGenerator>", "the path to the tally witness generation binary")
|
|
817
|
+
.option("--vote-tally-witnessDat <voteTallyWitnessDat>", "the path to the tally witness dat file")
|
|
777
818
|
.requiredOption("--poll-joining-zkey <processJoinZkey>", "the path to the poll join zkey")
|
|
778
|
-
.requiredOption("--
|
|
779
|
-
.requiredOption("--tally-zkey <
|
|
819
|
+
.requiredOption("--message-processor-zkey <messageProcessorZkey>", "the path to the process zkey")
|
|
820
|
+
.requiredOption("--vote-tally-zkey <voteTallyZkey>", "the path to the tally zkey")
|
|
780
821
|
.option("-q, --quiet <quiet>", "whether to print values to the console", (value) => value === "true", false)
|
|
781
822
|
.option("-p, --rpc-provider <provider>", "the rpc provider URL")
|
|
782
823
|
.requiredOption("-f, --output <outputDir>", "the output directory for proofs")
|
|
783
824
|
.option("--transaction-hash <transactionHash>", "transaction hash of MACI contract creation")
|
|
784
825
|
.option("-w, --wasm", "whether to use the wasm binaries")
|
|
785
|
-
.option("--
|
|
786
|
-
.option("--tally-wasm <
|
|
826
|
+
.option("--message-processor-wasm <messageProcessorWasm>", "the path to the process witness generation wasm binary")
|
|
827
|
+
.option("--vote-tally-wasm <voteTallyWasm>", "the path to the tally witness generation wasm binary")
|
|
787
828
|
.option("--state-file <stateFile>", "the path to the state file containing the serialized maci state")
|
|
788
829
|
.option("--start-block <startBlock>", "the block number to start looking for events from", parseInt)
|
|
789
830
|
.option("--end-block <endBlock>", "the block number to end looking for events from", parseInt)
|
|
790
831
|
.option("--blocks-per-batch <blockPerBatch>", "the number of blocks to process per batch", parseInt)
|
|
791
|
-
.option("-
|
|
832
|
+
.option("-m, --mode <mode>", "Voting mode (qv, non-qv, full)", (value) => constants_1.MODE_NAME_TO_ENUM[value], sdk_1.EMode.QV)
|
|
792
833
|
.option("-b, --ipfs-message-backup-files <ipfsMessageBackupFiles>", "Backup files for ipfs messages (name format: ipfsHash1.json, ipfsHash2.json, ..., ipfsHashN.json)", (value) => value?.split(/\s*,\s*/))
|
|
793
|
-
.action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch, privateKey, transactionHash, output, tallyFile,
|
|
834
|
+
.action(async ({ quiet, maciAddress, pollId, ipfsMessageBackupFiles, stateFile, startBlock, endBlock, blocksPerBatch, privateKey, transactionHash, output, tallyFile, voteTallyZkey, voteTallyWitnessGenerator, voteTallyWasm, messageProcessorZkey, messageProcessorWitnessGenerator, messageProcessorWasm, mode, voteTallyWitnessDat, messageProcessorWitnessDat, wasm, rapidsnark, }) => {
|
|
794
835
|
try {
|
|
795
836
|
(0, utils_1.banner)(quiet);
|
|
796
837
|
const signer = await getSigner();
|
|
@@ -814,15 +855,15 @@ program
|
|
|
814
855
|
signer,
|
|
815
856
|
outputDir: output,
|
|
816
857
|
tallyFile,
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
858
|
+
voteTallyZkey,
|
|
859
|
+
voteTallyWitnessGenerator,
|
|
860
|
+
voteTallyWasm,
|
|
861
|
+
messageProcessorZkey,
|
|
862
|
+
messageProcessorWitnessGenerator,
|
|
863
|
+
messageProcessorWasm,
|
|
864
|
+
mode,
|
|
865
|
+
voteTallyWitnessDatFile: voteTallyWitnessDat,
|
|
866
|
+
messageProcessorWitnessDatFile: messageProcessorWitnessDat,
|
|
826
867
|
useWasm: wasm,
|
|
827
868
|
rapidsnark,
|
|
828
869
|
});
|