From 9fb57b69e25bb304526d45f9c04fecce55ddc37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Isabel=20M=C3=A1rquez?= Date: Fri, 26 Aug 2022 22:57:46 +0200 Subject: [PATCH] New documentation and returning 0 or >0 if success or error. --- circom/src/main.rs | 4 ++-- .../circom-insight/circom-phases.md | 2 ++ .../docs/circom-language/constraint-generation.md | 1 + .../circom-language/templates-and-components.md | 15 +++++++++++++++ mkdocs/docs/getting-started/compiling-circuits.md | 4 +++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/circom/src/main.rs b/circom/src/main.rs index 3cdab3c2a..d200c533e 100644 --- a/circom/src/main.rs +++ b/circom/src/main.rs @@ -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); } } diff --git a/mkdocs/docs/circom-language/circom-insight/circom-phases.md b/mkdocs/docs/circom-language/circom-insight/circom-phases.md index 2e61d657d..cc902081d 100644 --- a/mkdocs/docs/circom-language/circom-insight/circom-phases.md +++ b/mkdocs/docs/circom-language/circom-insight/circom-phases.md @@ -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. + diff --git a/mkdocs/docs/circom-language/constraint-generation.md b/mkdocs/docs/circom-language/constraint-generation.md index 4a688e2dd..fa3df5b10 100644 --- a/mkdocs/docs/circom-language/constraint-generation.md +++ b/mkdocs/docs/circom-language/constraint-generation.md @@ -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. \ No newline at end of file diff --git a/mkdocs/docs/circom-language/templates-and-components.md b/mkdocs/docs/circom-language/templates-and-components.md index 34c0edf48..4f832ce27 100644 --- a/mkdocs/docs/circom-language/templates-and-components.md +++ b/mkdocs/docs/circom-language/templates-and-components.md @@ -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: diff --git a/mkdocs/docs/getting-started/compiling-circuits.md b/mkdocs/docs/getting-started/compiling-circuits.md index 39968d1bd..c49a2c583 100644 --- a/mkdocs/docs/getting-started/compiling-circuits.md +++ b/mkdocs/docs/getting-started/compiling-circuits.md @@ -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. \ No newline at end of file +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. \ No newline at end of file