Skip to content

Commit

Permalink
Merge pull request iden3#163 from iden3/in_work
Browse files Browse the repository at this point in the history
Adding changes of version 2.1.5: improving error messages, --inspect checks, efficiency and solving minor bugs
  • Loading branch information
clararod9 authored Mar 15, 2023
2 parents 3f93f4b + d19d870 commit bd6c4b7
Show file tree
Hide file tree
Showing 37 changed files with 1,402 additions and 630 deletions.
18 changes: 18 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
# Release notes
## March 15, 2023 circom 2.1.5

#### Extensions
- Definition of signals and components can be done now inside if blocks IF the condition is known at compilation time. If the condition is unknown and depends on the value of signals, then the compiler throws an error.
- Improving the --inspect option. It now detects underconstrained signals and assignments using <-- in which <== could be used.
- Improving the efficiency of the compiler. It does not execute the inspect and constraint generation phase only if there are not the corresponding flags.
- Improving --O1 simplification: removing signals that do not appear in any constraint and avoiding unnecessary constraint normalizations.
- Improving parallel: array assignments of outputs and efficiency by updating numThread while waiting and setting maxThreads to 32.
- Handling better the parser errors and improving error messages to output more information. (parser, type checking and constraint generation errors).
- Showing warnings when errors are found.
- Reducing writing time for output files.
- Updating the documentation.

#### Fixed Bugs
- Fixing a problem with the memory release of the components (in C).
- Fixing a problem with the parallel execution during the witness generation (in C).
- Fixing a bug: functions are executed even if they output signals when they contain logs or asserts.
- Fixing a bug: During the witness generation, the computation of expressions like x**x was buggy (in wasm).

## February 10, 2023 circom 2.1.4

Expand Down
117 changes: 61 additions & 56 deletions circom/src/compilation_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,70 +25,75 @@ pub struct CompilerConfig {
}

pub fn compile(config: CompilerConfig) -> Result<(), ()> {
let circuit = compiler_interface::run_compiler(
config.vcp,
Config { debug_output: config.debug_output, produce_input_log: config.produce_input_log, wat_flag: config.wat_flag },
VERSION
)?;

if config.c_flag {
compiler_interface::write_c(&circuit, &config.c_folder, &config.c_run_name, &config.c_file, &config.dat_file)?;
println!(
"{} {} and {}",
Colour::Green.paint("Written successfully:"),
config.c_file,
config.dat_file
);
println!(
"{} {}/{}, {}, {}, {}, {}, {}, {} and {}",
Colour::Green.paint("Written successfully:"),
&config.c_folder,
"main.cpp".to_string(),
"circom.hpp".to_string(),
"calcwit.hpp".to_string(),
"calcwit.cpp".to_string(),
"fr.hpp".to_string(),
"fr.cpp".to_string(),
"fr.asm".to_string(),
"Makefile".to_string()
);
}

match (config.wat_flag, config.wasm_flag) {
(true, true) => {
compiler_interface::write_wasm(&circuit, &config.js_folder, &config.wasm_name, &config.wat_file)?;
println!("{} {}", Colour::Green.paint("Written successfully:"), config.wat_file);
let result = wat_to_wasm(&config.wat_file, &config.wasm_file);
match result {
Result::Err(report) => {
Report::print_reports(&[report], &FileLibrary::new());
return Err(());
}
Result::Ok(()) => {
println!("{} {}", Colour::Green.paint("Written successfully:"), config.wasm_file);
}
}
if config.c_flag || config.wat_flag || config.wasm_flag{
let circuit = compiler_interface::run_compiler(
config.vcp,
Config { debug_output: config.debug_output, produce_input_log: config.produce_input_log, wat_flag: config.wat_flag },
VERSION
)?;

if config.c_flag {
compiler_interface::write_c(&circuit, &config.c_folder, &config.c_run_name, &config.c_file, &config.dat_file)?;
println!(
"{} {} and {}",
Colour::Green.paint("Written successfully:"),
config.c_file,
config.dat_file
);
println!(
"{} {}/{}, {}, {}, {}, {}, {}, {} and {}",
Colour::Green.paint("Written successfully:"),
&config.c_folder,
"main.cpp".to_string(),
"circom.hpp".to_string(),
"calcwit.hpp".to_string(),
"calcwit.cpp".to_string(),
"fr.hpp".to_string(),
"fr.cpp".to_string(),
"fr.asm".to_string(),
"Makefile".to_string()
);
}
(false, true) => {
compiler_interface::write_wasm(&circuit, &config.js_folder, &config.wasm_name, &config.wat_file)?;
let result = wat_to_wasm(&config.wat_file, &config.wasm_file);
std::fs::remove_file(&config.wat_file).unwrap();
match result {
Result::Err(report) => {
Report::print_reports(&[report], &FileLibrary::new());
return Err(());

match (config.wat_flag, config.wasm_flag) {
(true, true) => {
compiler_interface::write_wasm(&circuit, &config.js_folder, &config.wasm_name, &config.wat_file)?;
println!("{} {}", Colour::Green.paint("Written successfully:"), config.wat_file);
let result = wat_to_wasm(&config.wat_file, &config.wasm_file);
match result {
Result::Err(report) => {
Report::print_reports(&[report], &FileLibrary::new());
return Err(());
}
Result::Ok(()) => {
println!("{} {}", Colour::Green.paint("Written successfully:"), config.wasm_file);
}
}
Result::Ok(()) => {
println!("{} {}", Colour::Green.paint("Written successfully:"), config.wasm_file);
}
(false, true) => {
compiler_interface::write_wasm(&circuit, &config.js_folder, &config.wasm_name, &config.wat_file)?;
let result = wat_to_wasm(&config.wat_file, &config.wasm_file);
std::fs::remove_file(&config.wat_file).unwrap();
match result {
Result::Err(report) => {
Report::print_reports(&[report], &FileLibrary::new());
return Err(());
}
Result::Ok(()) => {
println!("{} {}", Colour::Green.paint("Written successfully:"), config.wasm_file);
}
}
}
(true, false) => {
compiler_interface::write_wasm(&circuit, &config.js_folder, &config.wasm_name, &config.wat_file)?;
println!("{} {}", Colour::Green.paint("Written successfully:"), config.wat_file);
}
(false, false) => {}
}
(true, false) => {
compiler_interface::write_wasm(&circuit, &config.js_folder, &config.wasm_name, &config.wat_file)?;
println!("{} {}", Colour::Green.paint("Written successfully:"), config.wat_file);
}
(false, false) => {}
}


Ok(())
}
Expand Down
3 changes: 2 additions & 1 deletion circom/src/input_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ mod input_processing {
if route.is_file() {
Result::Ok(route)
} else {
Result::Err(eprintln!("{}", Colour::Red.paint("invalid input file")))
let route = if route.to_str().is_some() { ": ".to_owned() + route.to_str().unwrap()} else { "".to_owned() };
Result::Err(eprintln!("{}", Colour::Red.paint("Input file does not exist".to_owned() + &route)))
}
}

Expand Down
10 changes: 5 additions & 5 deletions code_producers/src/c_elements/c_code_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,20 +658,19 @@ pub fn generate_dat_file(dat_file: &mut dyn Write, producer: &CProducer) -> std:
//let hml = 256 as u32;
//dfile.write_all(&hml.to_be_bytes())?;
dat_file.write_all(&hashmap)?;
dat_file.flush()?;
//dat_file.flush()?;
let s = generate_dat_witness_to_signal_list(producer.get_witness_to_signal_list()); // list of bytes u64
//let sl = s.len() as u64; //8 bytes
//dfile.write_all(&sl.to_be_bytes())?;
dat_file.write_all(&s)?;
dat_file.flush()?;
//dat_file.flush()?;
let s = generate_dat_constant_list(producer, producer.get_field_constant_list()); // list of bytes Fr
dat_file.write_all(&s)?;
dat_file.flush()?;
//dat_file.flush()?;
//let ioml = producer.get_io_map().len() as u64;
//dfile.write_all(&ioml.to_be_bytes())?;
let iomap = generate_dat_io_signals_info(&producer, producer.get_io_map());
dat_file.write_all(&iomap)?;
dat_file.flush()?;
/*
let ml = producer.get_message_list();
let mll = ml.len() as u64;
Expand All @@ -684,6 +683,7 @@ pub fn generate_dat_file(dat_file: &mut dyn Write, producer: &CProducer) -> std:
dfile.flush()?;
}
*/
dat_file.flush()?;
Ok(())
}
pub fn generate_function_list(_producer: &CProducer, list: &TemplateListParallel) -> (String, String) {
Expand Down Expand Up @@ -972,8 +972,8 @@ pub fn generate_c_file(name: String, producer: &CProducer) -> std::io::Result<()
// code.append(&mut ml_def);
for l in code {
cfile.write_all(l.as_bytes())?;
cfile.flush()?;
}
cfile.flush()?;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/circuit_design/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ fn write_main_inputs_log(vcp: &VCP) {
let length = signal.size();
let msg = format!("{} {}\n", name, length);
writer.write_all(msg.as_bytes()).unwrap();
writer.flush().unwrap();
}
writer.flush().unwrap();
}
}

Expand Down
Loading

0 comments on commit bd6c4b7

Please sign in to comment.