Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Dec 16, 2023
1 parent 730b566 commit 1fd6e43
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
5 changes: 4 additions & 1 deletion acvm-repo/acvm/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ fn transform_assert_messages(
}

/// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] specific optimizations to a [`Circuit`].
pub fn compile(acir: Circuit, expression_width: ExpressionWidth) -> (Circuit, AcirTransformationMap) {
pub fn compile(
acir: Circuit,
expression_width: ExpressionWidth,
) -> (Circuit, AcirTransformationMap) {
let (acir, acir_opcode_positions) = optimize_internal(acir);

let (mut acir, acir_opcode_positions) =
Expand Down
5 changes: 4 additions & 1 deletion acvm-repo/acvm/src/compiler/transformers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ pub(crate) use r1cs::R1CSTransformer;
use super::{transform_assert_messages, AcirTransformationMap};

/// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] specific optimizations to a [`Circuit`].
pub fn transform(acir: Circuit, expression_width: ExpressionWidth) -> (Circuit, AcirTransformationMap) {
pub fn transform(
acir: Circuit,
expression_width: ExpressionWidth,
) -> (Circuit, AcirTransformationMap) {
// Track original acir opcode positions throughout the transformation passes of the compilation
// by applying the modifications done to the circuit opcodes and also to the opcode_positions (delete and insert)
let acir_opcode_positions = acir.opcodes.iter().enumerate().map(|(i, _)| i).collect();
Expand Down
6 changes: 3 additions & 3 deletions acvm-repo/acvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ pub use brillig_vm;
pub use acvm_blackbox_solver as blackbox_solver;

/// Specifies the maximum width of the expressions which will be constrained.
///
///
/// Unbounded Expressions are useful if you are eventually going to pass the ACIR
/// into a proving system which supports R1CS.
///
///
/// Bounded Expressions are useful if you are eventually going to pass the ACIR
/// into a proving system which supports PLONK, where arithmetic expressions have a
/// into a proving system which supports PLONK, where arithmetic expressions have a
/// finite fan-in.
#[derive(Debug, Clone, Copy)]
pub enum ExpressionWidth {
Expand Down
2 changes: 1 addition & 1 deletion tooling/backend_interface/src/proof_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::io::Write;
use std::path::Path;

use acvm::acir::{circuit::Circuit, native_types::WitnessMap};
use acvm::FieldElement;
use acvm::ExpressionWidth;
use acvm::FieldElement;
use tempfile::tempdir;

use crate::cli::{
Expand Down
13 changes: 10 additions & 3 deletions tooling/nargo/src/ops/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ use acvm::ExpressionWidth;
use iter_extended::vecmap;
use noirc_driver::{CompiledContract, CompiledProgram};

pub fn optimize_program(mut program: CompiledProgram, expression_width: ExpressionWidth) -> CompiledProgram {
let (optimized_circuit, location_map) = acvm::compiler::compile(program.circuit, expression_width);
pub fn optimize_program(
mut program: CompiledProgram,
expression_width: ExpressionWidth,
) -> CompiledProgram {
let (optimized_circuit, location_map) =
acvm::compiler::compile(program.circuit, expression_width);

program.circuit = optimized_circuit;
program.debug.update_acir(location_map);
program
}

pub fn optimize_contract(contract: CompiledContract, expression_width: ExpressionWidth) -> CompiledContract {
pub fn optimize_contract(
contract: CompiledContract,
expression_width: ExpressionWidth,
) -> CompiledContract {
let functions = vecmap(contract.functions, |mut func| {
let (optimized_bytecode, location_map) =
acvm::compiler::compile(func.bytecode, expression_width);
Expand Down
3 changes: 2 additions & 1 deletion tooling/nargo_cli/src/cli/prove_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ pub(crate) fn run(

let expression_width = backend.get_backend_info()?;
for package in &workspace {
let program = compile_bin_package(&workspace, package, &args.compile_options, expression_width)?;
let program =
compile_bin_package(&workspace, package, &args.compile_options, expression_width)?;

prove_package(
backend,
Expand Down
3 changes: 2 additions & 1 deletion tooling/nargo_cli/src/cli/verify_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ pub(crate) fn run(

let expression_width = backend.get_backend_info()?;
for package in &workspace {
let program = compile_bin_package(&workspace, package, &args.compile_options, expression_width)?;
let program =
compile_bin_package(&workspace, package, &args.compile_options, expression_width)?;

verify_package(backend, &workspace, package, program, &args.verifier_name)?;
}
Expand Down

0 comments on commit 1fd6e43

Please sign in to comment.