Skip to content

Commit

Permalink
New documentation and returning 0 or >0 if success or error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Isabel Márquez authored and Miguel Isabel Márquez committed Aug 26, 2022
1 parent ccf9add commit 9fb57b6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions circom/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ fn main() {
let result = start();
if result.is_err() {
eprintln!("{}", Colour::Red.paint("previous errors were found"));
std::process::exit(exitcode::DATAERR);
std::process::exit(1);
} else {
println!("{}", Colour::Green.paint("Everything went okay, circom safe"));
std::process::exit(exitcode::OK);
std::process::exit(0);
}
}

Expand Down
2 changes: 2 additions & 0 deletions mkdocs/docs/circom-language/circom-insight/circom-phases.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ description: >-
1. The **construction** phase, where the constraints are generated.
2. The **code generation** phase, where the code to compute the witness is generated.

If an error is produced in any of these two phases, circom will finish with an error code greater than 0. Otherwise, if the compiler finish successfully, it finishes returning 0.

1 change: 1 addition & 0 deletions mkdocs/docs/circom-language/constraint-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ The following example shows the generation of expressions:

The last instruction produces the constraint `b === a * a + 3`.

Finally, programmers sometimes misuse operator `<--`, when starting to work in circom. They usually assign using this operator an expression which is quadratic and, as a consequence, no constraint is added. In this case, the operator needed to both performing the assignment and adding the constraint is operator `<==`. Since version 2.0.8, we throw a warning in this case.
15 changes: 15 additions & 0 deletions mkdocs/docs/circom-language/templates-and-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,21 @@ template parallel NameTemplate(...){...}

If this tag is used, the resulting C++ file will contain the parallelized code to compute the witness. Parallelization becomes particularly relevant when dealing with large circuits.

Notice that the previous parallelism is declared at template level. Sometimes, it can be useful declare the parallelism for each component. Since version 2.0.8, the tag parallel can be also used at component level, with the parallel tag indicated right before the call to the template.

```text
component comp = parallel NameTemplate(...){...}
```
A real example of use case is the following piece of code from the rollup code:
```
component rollupTx[nTx];
for (i = 0; i < nTx; i++) {
rollupTx[i] = parallel RollupTx(nLevels, maxFeeTx);
}
```

It is important to highlight again that this parallelism can only be exploited in C++ witness generator.

## Custom templates

Since version 2.0.6, the language allows the definition of a new type of templates, custom templates. This new construction works similarly to standard templates: they are declared analogously, just adding the keyword `custom` in its declaration after `template`; and are instantiated in the exact same way. That is, a custom template `Example` is defined and then instantiated as follows:
Expand Down
4 changes: 3 additions & 1 deletion mkdocs/docs/getting-started/compiling-circuits.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ With these options we generate three types of files:
* `--sym` : it generates the file `multiplier2.sym` , a symbols file required for debugging or for printing the constraint system in an annotated mode.
* `--c` : it generates the directory `multiplier2_cpp` that contains several files (multiplier2.cpp, multiplier2.dat, and other common files for every compiled program like main.cpp, MakeFile, etc) needed to compile the C code to generate the witness.

We can use the option -o to specify the directory where these files are created.
We can use the option `-o` to specify the directory where these files are created.

Since version 2.0.8, we can use the option `-l` to indicate the directory where the directive `include` should look for the circuits indicated.

0 comments on commit 9fb57b6

Please sign in to comment.