Skip to content

Improve Handling of Large Circuits #24

@moven0831

Description

@moven0831

Problems

Currently, if the circuit size is too large, it will suffer from errors in different aspects. These circuits can often be processed correctly using CLI, but cannot be set up properly with noir-rs.

Details

Known issues of the SRS setup for large circuits:

  • get_circuit_sizes throws a fatal runtime error: Rust cannot catch foreign exceptions, aborting. This indicates that a foreign exception (likely from C/C++ code) cannot be caught by Rust, resulting in program termination.
    • this error can be reproduced using a circuit size of 2^26+1
      pub unsafe fn get_circuit_sizes(constraint_system_buf: &[u8], recursive: bool) -> CircuitSizes {
      let mut total = 0;
      let mut subgroup = 0;
      let honk_recursion = true;
      bindgen::acir_get_circuit_sizes(
      constraint_system_buf.to_buffer().as_slice().as_ptr(),
      &recursive,
      &honk_recursion,
      &mut total,
      &mut subgroup,
      );
      CircuitSizes {
      total: total.to_be(),
      subgroup: subgroup.to_be(),
      }
      }
  • download_g1_data occasionally encounters timeout errors when handling large circuit sizes
    • this error can be reliably reproduced using circuit sizes exceeding 2^23
    • these functions are used in get_srs()
      fn download_g1_data(num_points: u32) -> Vec<u8> {
      let g1_end: u32 = num_points * 64 - 1;
      let mut headers = HeaderMap::new();
      headers.insert(
      RANGE,
      format!("bytes={}-{}", 0, g1_end).parse().unwrap(),
      );
      let response = Client::new()
      .get(
      "https://crs.aztec.network/g1.dat",
      )
      .headers(headers)
      .send()
      .unwrap();
      response.bytes().unwrap().to_vec()
      }

Acceptance Requirements

  • Identify the root cause and implement proper handling of unsafe C/C++ code calls
  • Determine the appropriate APIs for g1 data download or relax the timeout constraints for https://crs.aztec.network/g1.dat
  • Support setup, proving, and verification operations for circuits larger than 2^26

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions