Skip to content

Commit

Permalink
docs(website): update trouble shooting doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kittybest committed Apr 8, 2024
1 parent 4268850 commit 706f31f
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 51 deletions.
107 changes: 56 additions & 51 deletions website/src/scripts/setupTypedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,62 +26,67 @@ function updateMdFiles(file: string, sidebarInfo: string) {
}

// read all dir in typedoc/ -> rename README.md as index.md -> remove upper navigations
const directories = fs.readdirSync(TYPEDOC_DIR);
directories.forEach((dir) => {
const dirname = path.resolve(TYPEDOC_DIR, dir);
const label = fitFormat(dir);

// only do things if it's a directory
if (fs.statSync(dirname).isDirectory()) {
const readmeFile = path.resolve(dirname, "README.md");

if (fs.existsSync(readmeFile)) {
updateMdFiles(readmeFile, generateSidebarString({ title: label, label }));
fs.renameSync(readmeFile, path.resolve(dirname, "index.md"));
}

// remove the first two lines of navigator
const modulesFile = path.resolve(dirname, "modules.md");
try {
const directories = fs.readdirSync(TYPEDOC_DIR);
directories.forEach((dir) => {
const dirname = path.resolve(TYPEDOC_DIR, dir);
const label = fitFormat(dir);

// only do things if it's a directory
if (fs.statSync(dirname).isDirectory()) {
const readmeFile = path.resolve(dirname, "README.md");

if (fs.existsSync(readmeFile)) {
updateMdFiles(readmeFile, generateSidebarString({ title: label, label }));
fs.renameSync(readmeFile, path.resolve(dirname, "index.md"));
}

if (fs.existsSync(modulesFile)) {
updateMdFiles(modulesFile, generateSidebarString({ title: `${label} Module`, label: "module", position: 1 }));
}
// remove the first two lines of navigator
const modulesFile = path.resolve(dirname, "modules.md");

const innerDirs = fs.readdirSync(dirname);
innerDirs.forEach((innerDir) => {
const innerDirname = path.resolve(dirname, innerDir);

if (fs.statSync(innerDirname).isDirectory()) {
const innerFiles = fs.readdirSync(innerDirname);
innerFiles.forEach((innerFile) => {
const innerLabel = innerFile.split(".")[0];
updateMdFiles(
path.resolve(innerDirname, innerFile),
generateSidebarString({ title: innerLabel, label: innerLabel }),
);
});
if (fs.existsSync(modulesFile)) {
updateMdFiles(modulesFile, generateSidebarString({ title: `${label} Module`, label: "module", position: 1 }));
}
});

const innerDirs = fs.readdirSync(dirname);
innerDirs.forEach((innerDir) => {
const innerDirname = path.resolve(dirname, innerDir);

if (fs.statSync(innerDirname).isDirectory()) {
const innerFiles = fs.readdirSync(innerDirname);
innerFiles.forEach((innerFile) => {
const innerLabel = innerFile.split(".")[0];
updateMdFiles(
path.resolve(innerDirname, innerFile),
generateSidebarString({ title: innerLabel, label: innerLabel }),
);
});
}
});
}
});

// insert index page
insertIndexPage(TYPEDOC_DIR, { title: "Typedoc", label: "Typedoc" });

// find the target moving directory
const versionFile = path.resolve(__dirname, "../../versions.json");
let versionDir = "";
try {
const versionContent = fs.readFileSync(versionFile, "utf8");
if (versionContent) {
const versionContentJson = JSON.parse(versionContent) as string[];
versionDir = path.resolve(__dirname, `../../versioned_docs/version-${versionContentJson[0]}/typedoc`);
}
} catch (e) {
versionDir = path.resolve(__dirname, "../../docs/typedoc");
}
});

// insert index page
insertIndexPage(TYPEDOC_DIR, { title: "Typedoc", label: "Typedoc" });
// move the typedoc/ directory to target directory
copyDirectory(TYPEDOC_DIR, versionDir);

// find the target moving directory
const versionFile = path.resolve(__dirname, "../../versions.json");
let versionDir = "";
try {
const versionContent = fs.readFileSync(versionFile, "utf8");
if (versionContent) {
const versionContentJson = JSON.parse(versionContent) as string[];
versionDir = path.resolve(__dirname, `../../versioned_docs/version-${versionContentJson[0]}/typedoc`);
}
fs.rmSync(TYPEDOC_DIR, { recursive: true, force: true });
} catch (e) {
versionDir = path.resolve(__dirname, "../../docs/typedoc");
// eslint-disable-next-line no-console
console.log("No update to typedocs");
}

// move the typedoc/ directory to target directory
copyDirectory(TYPEDOC_DIR, versionDir);

fs.rmSync(TYPEDOC_DIR, { recursive: true, force: true });
102 changes: 102 additions & 0 deletions website/versioned_docs/version-v1.3_alpha/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,105 @@ You can generate the missing `.dat` files using the following command:
```bash
pnpm build:circuits-c
```

## contracts: `prove` command failure

### Case `Commitment mismatch`

If your log looks like following, that's because you have already run the `prove` command before. You could either do

1. update MACI up-to-date, and try again
2. go to `cli`, and run `genProof` command

```
Error: commitment mismatch
at Prover.validateCommitment (/Users/zhanyuzhen/Documents/maci/contracts/tasks/helpers/Prover.ts:458:13)
at Prover.proveTally (/Users/zhanyuzhen/Documents/maci/contracts/tasks/helpers/Prover.ts:390:12)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SimpleTaskDefinition.action (/Users/zhanyuzhen/Documents/maci/contracts/tasks/runner/prove.ts:235:7)
at async Environment._runTaskDefinition (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
at async Environment.run (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
at async main (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/cli/cli.ts:323:7)
 ELIFECYCLE  Command failed with exit code 1.
 ELIFECYCLE  Command failed with exit code 1.
```

## General Failure

### Case `AssertionError`

This could happen when you run `prove` in the `contracts` package, or run `genProofs` in the `cli` package. If your log looks like following, there are two possible reasons:

1. Your MACI keypair for coordinator is generated wrongly, please generate a new pair and run the whole process again.
2. The provided private key is unmatched to the public key which deployed the poll, need to input the correct private key.

```
An unexpected error occurred:
AssertionError [ERR_ASSERTION]: false == true
at genMaciStateFromContract (/Users/zhanyuzhen/Documents/maci/contracts/ts/genMaciState.ts:156:9)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SimpleTaskDefinition.action (/Users/zhanyuzhen/Documents/maci/contracts/tasks/runner/prove.ts:127:25)
at async Environment._runTaskDefinition (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
at async Environment.run (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
at async main (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/cli/cli.ts:323:7) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
```

### Cannot filter non-indexed parameters

If you encountered error log looks like this:

```
TypeError: cannot filter non-indexed parameters; must be null (argument="contract._messageRoot", value=4658669366154318429589992378027343879410506110087584229116806667655891474709, code=INVALID_ARGUMENT, version=6.11.1)
at makeError (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/utils/errors.ts:687:21)
at assert (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/utils/errors.ts:715:25)
at assertArgument (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/utils/errors.ts:727:5)
at /Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/interface.ts:1047:31
at Array.forEach (<anonymous>)
at Interface.encodeFilterTopics (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/interface.ts:1042:16)
at /Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/contract/contract.ts:108:39
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getSubInfo (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/contract/contract.ts:502:18)
at async Proxy.queryFilter (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/contract/contract.ts:938:38) {
code: 'INVALID_ARGUMENT',
argument: 'contract._messageRoot',
value: 4658669366154318429589992378027343879410506110087584229116806667655891474709n,
shortMessage: 'cannot filter non-indexed parameters; must be null'
}
```

This could happen during running `genProofs` in `cli` package, or running `prove` in `contracts` package.
Be aware that we updated several parameters to `indexed` one:

```javascript
event MergeMaciStateAqSubRoots(uint256 indexed _numSrQueueOps);
event MergeMaciStateAq(uint256 indexed _stateRoot, uint256 indexed _numSignups);
event MergeMessageAqSubRoots(uint256 indexed _numSrQueueOps);
event MergeMessageAq(uint256 indexed _messageRoot);
```

Please remember to pull the latest MACI repo and run build in the `contracts` package.

### Verifier contract found the proof invalid

If your log looks like following, that's because the zkey and wasm files added to the [`VkRegistry` contract](/docs/contracts#vkregistry) are different from what you use to run the **prove** command. Check if you're using the correct zkey and wasm files.

```
Error: The verifier contract found the proof invalid.
at Prover.proveMessageProcessing (/Users/zhanyuzhen/Documents/maci/contracts/tasks/helpers/Prover.ts:215:15)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SimpleTaskDefinition.action (/Users/zhanyuzhen/Documents/maci/contracts/tasks/runner/prove.ts:185:7)
at async Environment._runTaskDefinition (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
at async Environment.run (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
at async main (/Users/zhanyuzhen/Documents/maci/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/cli/cli.ts:323:7)
```

### The on-chain verification of total spent voice credits failed

If you ran the `verify` command and got this error, check if your deployed poll is using quadratic voting or not.

0 comments on commit 706f31f

Please sign in to comment.