From 426fc34486d1472b326efac17c2a4a68ee1a62de Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 18 Dec 2023 19:13:55 +0000 Subject: [PATCH] chore: Rename `NpLanguage` to `ExpressionWidth` (#3834) # Description NpLanguage does not encapsulate what we want to describe here. We simply want to specify an expression width and a particular backend will need to decide as to what configuration their backend supports. To elaborate, imagine a new np language came out which was popular; before this PR, we may need to add in another variant. However, with this change, the new backend will just target whatever width makes sense for this new proving system. ## Problem\* Resolves ## Summary\* ## Additional Context ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- acvm-repo/acvm/src/compiler/mod.rs | 9 ++++-- .../acvm/src/compiler/transformers/csat.rs | 2 +- .../acvm/src/compiler/transformers/mod.rs | 17 ++++++----- acvm-repo/acvm/src/lib.rs | 16 ++++++---- compiler/wasm/src/compile.rs | 8 ++--- compiler/wasm/src/compile_new.rs | 4 +-- tooling/backend_interface/src/cli/info.rs | 18 +++++------ tooling/backend_interface/src/proof_system.rs | 18 ++++++----- tooling/lsp/src/requests/profile_run.rs | 6 ++-- tooling/nargo/src/ops/compile.rs | 16 +++++----- tooling/nargo/src/ops/optimize.rs | 17 +++++++---- .../nargo_cli/src/cli/codegen_verifier_cmd.rs | 10 +++---- tooling/nargo_cli/src/cli/compile_cmd.rs | 24 +++++++-------- tooling/nargo_cli/src/cli/debug_cmd.rs | 4 +-- tooling/nargo_cli/src/cli/execute_cmd.rs | 4 +-- tooling/nargo_cli/src/cli/info_cmd.rs | 30 +++++++++---------- tooling/nargo_cli/src/cli/prove_cmd.rs | 5 ++-- tooling/nargo_cli/src/cli/verify_cmd.rs | 5 ++-- 18 files changed, 118 insertions(+), 95 deletions(-) diff --git a/acvm-repo/acvm/src/compiler/mod.rs b/acvm-repo/acvm/src/compiler/mod.rs index 1a73f841f3d..ccb043914d6 100644 --- a/acvm-repo/acvm/src/compiler/mod.rs +++ b/acvm-repo/acvm/src/compiler/mod.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use acir::circuit::{Circuit, OpcodeLocation}; -use crate::Language; +use crate::ExpressionWidth; // The various passes that we can use over ACIR mod optimizers; @@ -69,11 +69,14 @@ fn transform_assert_messages( } /// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] specific optimizations to a [`Circuit`]. -pub fn compile(acir: Circuit, np_language: Language) -> (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) = - transform_internal(acir, np_language, acir_opcode_positions); + transform_internal(acir, expression_width, acir_opcode_positions); let transformation_map = AcirTransformationMap::new(acir_opcode_positions); diff --git a/acvm-repo/acvm/src/compiler/transformers/csat.rs b/acvm-repo/acvm/src/compiler/transformers/csat.rs index 9f89ac4671a..0d1ab87aae5 100644 --- a/acvm-repo/acvm/src/compiler/transformers/csat.rs +++ b/acvm-repo/acvm/src/compiler/transformers/csat.rs @@ -9,7 +9,7 @@ use indexmap::IndexMap; /// A transformer which processes any [`Expression`]s to break them up such that they /// fit within the [`ProofSystemCompiler`][crate::ProofSystemCompiler]'s width. /// -/// This transformer is only used when targetting the [`PLONKCSat`][crate::Language::PLONKCSat] language. +/// This transformer is only used when targeting the [`Bounded`][crate::ExpressionWidth::Bounded] configuration. /// /// This is done by creating intermediate variables to hold partial calculations and then combining them /// to calculate the original expression. diff --git a/acvm-repo/acvm/src/compiler/transformers/mod.rs b/acvm-repo/acvm/src/compiler/transformers/mod.rs index fc406ba2b54..2a3e28c536a 100644 --- a/acvm-repo/acvm/src/compiler/transformers/mod.rs +++ b/acvm-repo/acvm/src/compiler/transformers/mod.rs @@ -5,7 +5,7 @@ use acir::{ }; use indexmap::IndexMap; -use crate::Language; +use crate::ExpressionWidth; mod csat; mod r1cs; @@ -16,13 +16,16 @@ 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, np_language: Language) -> (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(); let (mut acir, acir_opcode_positions) = - transform_internal(acir, np_language, acir_opcode_positions); + transform_internal(acir, expression_width, acir_opcode_positions); let transformation_map = AcirTransformationMap::new(acir_opcode_positions); @@ -36,17 +39,17 @@ pub fn transform(acir: Circuit, np_language: Language) -> (Circuit, AcirTransfor /// Accepts an injected `acir_opcode_positions` to allow transformations to be applied directly after optimizations. pub(super) fn transform_internal( acir: Circuit, - np_language: Language, + expression_width: ExpressionWidth, acir_opcode_positions: Vec, ) -> (Circuit, Vec) { log::trace!("Start circuit transformation"); - let mut transformer = match &np_language { - crate::Language::R1CS => { + let mut transformer = match &expression_width { + crate::ExpressionWidth::Unbounded => { let transformer = R1CSTransformer::new(acir); return (transformer.transform(), acir_opcode_positions); } - crate::Language::PLONKCSat { width } => { + crate::ExpressionWidth::Bounded { width } => { let mut csat = CSatTransformer::new(*width); for value in acir.circuit_arguments() { csat.mark_solvable(value); diff --git a/acvm-repo/acvm/src/lib.rs b/acvm-repo/acvm/src/lib.rs index 0ab037a2e4b..626bb2c9b91 100644 --- a/acvm-repo/acvm/src/lib.rs +++ b/acvm-repo/acvm/src/lib.rs @@ -18,10 +18,16 @@ pub use brillig_vm; // re-export blackbox solver pub use acvm_blackbox_solver as blackbox_solver; -/// Supported NP complete languages -/// This might need to be in ACIR instead +/// 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 +/// finite fan-in. #[derive(Debug, Clone, Copy)] -pub enum Language { - R1CS, - PLONKCSat { width: usize }, +pub enum ExpressionWidth { + Unbounded, + Bounded { width: usize }, } diff --git a/compiler/wasm/src/compile.rs b/compiler/wasm/src/compile.rs index 8685d6093e6..4012effd947 100644 --- a/compiler/wasm/src/compile.rs +++ b/compiler/wasm/src/compile.rs @@ -178,8 +178,8 @@ pub fn compile( let compile_options = CompileOptions::default(); - // For now we default to plonk width = 3, though we can add it as a parameter - let np_language = acvm::Language::PLONKCSat { width: 3 }; + // For now we default to a bounded width of 3, though we can add it as a parameter + let expression_width = acvm::ExpressionWidth::Bounded { width: 3 }; if contracts.unwrap_or_default() { let compiled_contract = compile_contract(&mut context, crate_id, &compile_options) @@ -192,7 +192,7 @@ pub fn compile( })? .0; - let optimized_contract = nargo::ops::optimize_contract(compiled_contract, np_language); + let optimized_contract = nargo::ops::optimize_contract(compiled_contract, expression_width); let compile_output = preprocess_contract(optimized_contract); Ok(JsCompileResult::new(compile_output)) @@ -207,7 +207,7 @@ pub fn compile( })? .0; - let optimized_program = nargo::ops::optimize_program(compiled_program, np_language); + let optimized_program = nargo::ops::optimize_program(compiled_program, expression_width); let compile_output = preprocess_program(optimized_program); Ok(JsCompileResult::new(compile_output)) diff --git a/compiler/wasm/src/compile_new.rs b/compiler/wasm/src/compile_new.rs index 2e80fa1c1e4..cd09d0fcc49 100644 --- a/compiler/wasm/src/compile_new.rs +++ b/compiler/wasm/src/compile_new.rs @@ -89,7 +89,7 @@ impl CompilerContext { program_width: usize, ) -> Result { let compile_options = CompileOptions::default(); - let np_language = acvm::Language::PLONKCSat { width: program_width }; + let np_language = acvm::ExpressionWidth::Bounded { width: program_width }; let root_crate_id = *self.context.root_crate_id(); @@ -115,7 +115,7 @@ impl CompilerContext { program_width: usize, ) -> Result { let compile_options = CompileOptions::default(); - let np_language = acvm::Language::PLONKCSat { width: program_width }; + let np_language = acvm::ExpressionWidth::Bounded { width: program_width }; let root_crate_id = *self.context.root_crate_id(); let compiled_contract = diff --git a/tooling/backend_interface/src/cli/info.rs b/tooling/backend_interface/src/cli/info.rs index 1aa2e640b15..81b811f0e32 100644 --- a/tooling/backend_interface/src/cli/info.rs +++ b/tooling/backend_interface/src/cli/info.rs @@ -1,4 +1,4 @@ -use acvm::Language; +use acvm::ExpressionWidth; use serde::Deserialize; use std::path::{Path, PathBuf}; @@ -28,7 +28,7 @@ struct LanguageResponse { } impl InfoCommand { - pub(crate) fn run(self, binary_path: &Path) -> Result { + pub(crate) fn run(self, binary_path: &Path) -> Result { let mut command = std::process::Command::new(binary_path); command.arg("info").arg("-c").arg(self.crs_path).arg("-o").arg("-"); @@ -41,16 +41,16 @@ impl InfoCommand { let backend_info: InfoResponse = serde_json::from_slice(&output.stdout).expect("Backend should return valid json"); - let language: Language = match backend_info.language.name.as_str() { + let expression_width: ExpressionWidth = match backend_info.language.name.as_str() { "PLONK-CSAT" => { let width = backend_info.language.width.unwrap(); - Language::PLONKCSat { width } + ExpressionWidth::Bounded { width } } - "R1CS" => Language::R1CS, - _ => panic!("Unknown langauge"), + "R1CS" => ExpressionWidth::Unbounded, + _ => panic!("Unknown Expression width configuration"), }; - Ok(language) + Ok(expression_width) } } @@ -59,9 +59,9 @@ fn info_command() -> Result<(), BackendError> { let backend = crate::get_mock_backend()?; let crs_path = backend.backend_directory(); - let language = InfoCommand { crs_path }.run(backend.binary_path())?; + let expression_width = InfoCommand { crs_path }.run(backend.binary_path())?; - assert!(matches!(language, Language::PLONKCSat { width: 3 })); + assert!(matches!(expression_width, ExpressionWidth::Bounded { width: 3 })); Ok(()) } diff --git a/tooling/backend_interface/src/proof_system.rs b/tooling/backend_interface/src/proof_system.rs index 1de4b352bf7..01842a81da9 100644 --- a/tooling/backend_interface/src/proof_system.rs +++ b/tooling/backend_interface/src/proof_system.rs @@ -3,8 +3,8 @@ use std::io::Write; use std::path::Path; use acvm::acir::{circuit::Circuit, native_types::WitnessMap}; +use acvm::ExpressionWidth; use acvm::FieldElement; -use acvm::Language; use tempfile::tempdir; use crate::cli::{ @@ -30,20 +30,22 @@ impl Backend { .run(binary_path) } - pub fn get_backend_info(&self) -> Result { + pub fn get_backend_info(&self) -> Result { let binary_path = self.assert_binary_exists()?; self.assert_correct_version()?; InfoCommand { crs_path: self.crs_directory() }.run(binary_path) } - /// If we cannot get a valid backend, returns Plonk with width 3 + /// If we cannot get a valid backend, returns `ExpressionWidth::Bound { width: 3 }`` /// The function also prints a message saying we could not find a backend - pub fn get_backend_info_or_default(&self) -> Language { - if let Ok(language) = self.get_backend_info() { - language + pub fn get_backend_info_or_default(&self) -> ExpressionWidth { + if let Ok(expression_width) = self.get_backend_info() { + expression_width } else { - log::warn!("No valid backend found, defaulting to Plonk with width 3"); - Language::PLONKCSat { width: 3 } + log::warn!( + "No valid backend found, ExpressionWidth defaulting to Bounded with a width of 3" + ); + ExpressionWidth::Bounded { width: 3 } } } diff --git a/tooling/lsp/src/requests/profile_run.rs b/tooling/lsp/src/requests/profile_run.rs index 231003e1e83..4c4d7f11fde 100644 --- a/tooling/lsp/src/requests/profile_run.rs +++ b/tooling/lsp/src/requests/profile_run.rs @@ -3,7 +3,7 @@ use std::{ future::{self, Future}, }; -use acvm::Language; +use acvm::ExpressionWidth; use async_lsp::{ErrorCode, ResponseError}; use nargo::artifacts::debug::DebugArtifact; use nargo_toml::{find_package_manifest, resolve_workspace_from_toml, PackageSelection}; @@ -57,13 +57,13 @@ fn on_profile_run_request_inner( .cloned() .partition(|package| package.is_binary()); - let np_language = Language::PLONKCSat { width: 3 }; + let expression_width = ExpressionWidth::Bounded { width: 3 }; let (compiled_programs, compiled_contracts) = nargo::ops::compile_workspace( &workspace, &binary_packages, &contract_packages, - np_language, + expression_width, &CompileOptions::default(), ) .map_err(|err| ResponseError::new(ErrorCode::REQUEST_FAILED, err))?; diff --git a/tooling/nargo/src/ops/compile.rs b/tooling/nargo/src/ops/compile.rs index c23ab242ae4..1a9e0a6c115 100644 --- a/tooling/nargo/src/ops/compile.rs +++ b/tooling/nargo/src/ops/compile.rs @@ -1,4 +1,4 @@ -use acvm::Language; +use acvm::ExpressionWidth; use fm::FileManager; use noirc_driver::{CompilationResult, CompileOptions, CompiledContract, CompiledProgram}; @@ -17,18 +17,18 @@ pub fn compile_workspace( workspace: &Workspace, binary_packages: &[Package], contract_packages: &[Package], - np_language: Language, + expression_width: ExpressionWidth, compile_options: &CompileOptions, ) -> Result<(Vec, Vec), CompileError> { // Compile all of the packages in parallel. let program_results: Vec<(FileManager, CompilationResult)> = binary_packages .par_iter() - .map(|package| compile_program(workspace, package, compile_options, np_language)) + .map(|package| compile_program(workspace, package, compile_options, expression_width)) .collect(); let contract_results: Vec<(FileManager, CompilationResult)> = contract_packages .par_iter() - .map(|package| compile_contract(package, compile_options, np_language)) + .map(|package| compile_contract(package, compile_options, expression_width)) .collect(); // Report any warnings/errors which were encountered during compilation. @@ -62,7 +62,7 @@ pub fn compile_program( workspace: &Workspace, package: &Package, compile_options: &CompileOptions, - np_language: Language, + expression_width: ExpressionWidth, ) -> (FileManager, CompilationResult) { let (mut context, crate_id) = prepare_package(package); @@ -79,7 +79,7 @@ pub fn compile_program( }; // Apply backend specific optimizations. - let optimized_program = crate::ops::optimize_program(program, np_language); + let optimized_program = crate::ops::optimize_program(program, expression_width); (context.file_manager, Ok((optimized_program, warnings))) } @@ -87,7 +87,7 @@ pub fn compile_program( fn compile_contract( package: &Package, compile_options: &CompileOptions, - np_language: Language, + expression_width: ExpressionWidth, ) -> (FileManager, CompilationResult) { let (mut context, crate_id) = prepare_package(package); let (contract, warnings) = @@ -98,7 +98,7 @@ fn compile_contract( } }; - let optimized_contract = crate::ops::optimize_contract(contract, np_language); + let optimized_contract = crate::ops::optimize_contract(contract, expression_width); (context.file_manager, Ok((optimized_contract, warnings))) } diff --git a/tooling/nargo/src/ops/optimize.rs b/tooling/nargo/src/ops/optimize.rs index 6f96a49d04f..d3a36dd65ac 100644 --- a/tooling/nargo/src/ops/optimize.rs +++ b/tooling/nargo/src/ops/optimize.rs @@ -1,19 +1,26 @@ -use acvm::Language; +use acvm::ExpressionWidth; use iter_extended::vecmap; use noirc_driver::{CompiledContract, CompiledProgram}; -pub fn optimize_program(mut program: CompiledProgram, np_language: Language) -> CompiledProgram { - let (optimized_circuit, location_map) = acvm::compiler::compile(program.circuit, np_language); +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, np_language: Language) -> 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, np_language); + acvm::compiler::compile(func.bytecode, expression_width); func.bytecode = optimized_bytecode; func.debug.update_acir(location_map); func diff --git a/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs b/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs index dfda25043f3..b72ce01e1a9 100644 --- a/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -6,7 +6,7 @@ use super::{ use crate::backends::Backend; use crate::errors::CliError; -use acvm::Language; +use acvm::ExpressionWidth; use bb_abstraction_leaks::ACVM_BACKEND_BARRETENBERG; use clap::Args; use nargo::package::Package; @@ -45,14 +45,14 @@ pub(crate) fn run( Some(NOIR_ARTIFACT_VERSION_STRING.to_string()), )?; - let np_language = backend.get_backend_info()?; + let expression_width = backend.get_backend_info()?; for package in &workspace { let smart_contract_string = smart_contract_for_package( &workspace, backend, package, &args.compile_options, - np_language, + expression_width, )?; let contract_dir = workspace.contracts_directory_path(package); @@ -71,9 +71,9 @@ fn smart_contract_for_package( backend: &Backend, package: &Package, compile_options: &CompileOptions, - np_language: Language, + expression_width: ExpressionWidth, ) -> Result { - let program = compile_bin_package(workspace, package, compile_options, np_language)?; + let program = compile_bin_package(workspace, package, compile_options, expression_width)?; let mut smart_contract_string = backend.eth_contract(&program.circuit)?; diff --git a/tooling/nargo_cli/src/cli/compile_cmd.rs b/tooling/nargo_cli/src/cli/compile_cmd.rs index b686adf6f50..5ee053c5088 100644 --- a/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -1,6 +1,6 @@ use std::path::Path; -use acvm::Language; +use acvm::ExpressionWidth; use fm::FileManager; use iter_extended::vecmap; use nargo::artifacts::contract::PreprocessedContract; @@ -67,12 +67,12 @@ pub(crate) fn run( .cloned() .partition(|package| package.is_binary()); - let np_language = backend.get_backend_info_or_default(); + let expression_width = backend.get_backend_info_or_default(); let (_, compiled_contracts) = compile_workspace( &workspace, &binary_packages, &contract_packages, - np_language, + expression_width, &args.compile_options, )?; @@ -88,18 +88,18 @@ pub(super) fn compile_workspace( workspace: &Workspace, binary_packages: &[Package], contract_packages: &[Package], - np_language: Language, + expression_width: ExpressionWidth, compile_options: &CompileOptions, ) -> Result<(Vec, Vec), CliError> { // Compile all of the packages in parallel. let program_results: Vec<(FileManager, CompilationResult)> = binary_packages .par_iter() - .map(|package| compile_program(workspace, package, compile_options, np_language)) + .map(|package| compile_program(workspace, package, compile_options, expression_width)) .collect(); let contract_results: Vec<(FileManager, CompilationResult)> = contract_packages .par_iter() - .map(|package| compile_contract(package, compile_options, np_language)) + .map(|package| compile_contract(package, compile_options, expression_width)) .collect(); // Report any warnings/errors which were encountered during compilation. @@ -133,14 +133,14 @@ pub(crate) fn compile_bin_package( workspace: &Workspace, package: &Package, compile_options: &CompileOptions, - np_language: Language, + expression_width: ExpressionWidth, ) -> Result { if package.is_library() { return Err(CompileError::LibraryCrate(package.name.clone()).into()); } let (file_manager, compilation_result) = - compile_program(workspace, package, compile_options, np_language); + compile_program(workspace, package, compile_options, expression_width); let program = report_errors( compilation_result, @@ -156,7 +156,7 @@ fn compile_program( workspace: &Workspace, package: &Package, compile_options: &CompileOptions, - np_language: Language, + expression_width: ExpressionWidth, ) -> (FileManager, CompilationResult) { let (mut context, crate_id) = prepare_package(package); @@ -196,7 +196,7 @@ fn compile_program( }; // Apply backend specific optimizations. - let optimized_program = nargo::ops::optimize_program(program, np_language); + let optimized_program = nargo::ops::optimize_program(program, expression_width); let only_acir = compile_options.only_acir; save_program(optimized_program.clone(), package, &workspace.target_directory_path(), only_acir); @@ -206,7 +206,7 @@ fn compile_program( fn compile_contract( package: &Package, compile_options: &CompileOptions, - np_language: Language, + expression_width: ExpressionWidth, ) -> (FileManager, CompilationResult) { let (mut context, crate_id) = prepare_package(package); let (contract, warnings) = @@ -217,7 +217,7 @@ fn compile_contract( } }; - let optimized_contract = nargo::ops::optimize_contract(contract, np_language); + let optimized_contract = nargo::ops::optimize_contract(contract, expression_width); (context.file_manager, Ok((optimized_contract, warnings))) } diff --git a/tooling/nargo_cli/src/cli/debug_cmd.rs b/tooling/nargo_cli/src/cli/debug_cmd.rs index ba07b3b096c..6eab626a08d 100644 --- a/tooling/nargo_cli/src/cli/debug_cmd.rs +++ b/tooling/nargo_cli/src/cli/debug_cmd.rs @@ -49,7 +49,7 @@ pub(crate) fn run( Some(NOIR_ARTIFACT_VERSION_STRING.to_string()), )?; let target_dir = &workspace.target_directory_path(); - let np_language = backend.get_backend_info()?; + let expression_width = backend.get_backend_info()?; let Some(package) = workspace.into_iter().find(|p| p.is_binary()) else { println!( @@ -59,7 +59,7 @@ pub(crate) fn run( }; let compiled_program = - compile_bin_package(&workspace, package, &args.compile_options, np_language)?; + compile_bin_package(&workspace, package, &args.compile_options, expression_width)?; run_async(package, compiled_program, &args.prover_name, &args.witness_name, target_dir) } diff --git a/tooling/nargo_cli/src/cli/execute_cmd.rs b/tooling/nargo_cli/src/cli/execute_cmd.rs index ac3d80fe1fe..10760f43a45 100644 --- a/tooling/nargo_cli/src/cli/execute_cmd.rs +++ b/tooling/nargo_cli/src/cli/execute_cmd.rs @@ -56,10 +56,10 @@ pub(crate) fn run( )?; let target_dir = &workspace.target_directory_path(); - let np_language = backend.get_backend_info_or_default(); + let expression_width = backend.get_backend_info_or_default(); for package in &workspace { let compiled_program = - compile_bin_package(&workspace, package, &args.compile_options, np_language)?; + compile_bin_package(&workspace, package, &args.compile_options, expression_width)?; let (return_value, solved_witness) = execute_program_and_decode(compiled_program, package, &args.prover_name)?; diff --git a/tooling/nargo_cli/src/cli/info_cmd.rs b/tooling/nargo_cli/src/cli/info_cmd.rs index 9c2f10aab80..e25051c1df7 100644 --- a/tooling/nargo_cli/src/cli/info_cmd.rs +++ b/tooling/nargo_cli/src/cli/info_cmd.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use acvm::Language; +use acvm::ExpressionWidth; use backend_interface::BackendError; use clap::Args; use iter_extended::vecmap; @@ -67,12 +67,12 @@ pub(crate) fn run( .cloned() .partition(|package| package.is_binary()); - let np_language = backend.get_backend_info_or_default(); + let expression_width = backend.get_backend_info_or_default(); let (compiled_programs, compiled_contracts) = compile_workspace( &workspace, &binary_packages, &contract_packages, - np_language, + expression_width, &args.compile_options, )?; @@ -97,13 +97,13 @@ pub(crate) fn run( .into_par_iter() .zip(compiled_programs) .map(|(package, program)| { - count_opcodes_and_gates_in_program(backend, program, &package, np_language) + count_opcodes_and_gates_in_program(backend, program, &package, expression_width) }) .collect::>()?; let contract_info = compiled_contracts .into_par_iter() - .map(|contract| count_opcodes_and_gates_in_contract(backend, contract, np_language)) + .map(|contract| count_opcodes_and_gates_in_contract(backend, contract, expression_width)) .collect::>()?; let info_report = InfoReport { programs: program_info, contracts: contract_info }; @@ -114,7 +114,7 @@ pub(crate) fn run( } else { // Otherwise print human-readable table. if !info_report.programs.is_empty() { - let mut program_table = table!([Fm->"Package", Fm->"Language", Fm->"ACIR Opcodes", Fm->"Backend Circuit Size"]); + let mut program_table = table!([Fm->"Package", Fm->"Expression Width", Fm->"ACIR Opcodes", Fm->"Backend Circuit Size"]); for program in info_report.programs { program_table.add_row(program.into()); @@ -125,7 +125,7 @@ pub(crate) fn run( let mut contract_table = table!([ Fm->"Contract", Fm->"Function", - Fm->"Language", + Fm->"Expression Width", Fm->"ACIR Opcodes", Fm->"Backend Circuit Size" ]); @@ -202,7 +202,7 @@ struct InfoReport { struct ProgramInfo { name: String, #[serde(skip)] - language: Language, + expression_width: ExpressionWidth, acir_opcodes: usize, circuit_size: u32, } @@ -211,7 +211,7 @@ impl From for Row { fn from(program_info: ProgramInfo) -> Self { row![ Fm->format!("{}", program_info.name), - format!("{:?}", program_info.language), + format!("{:?}", program_info.expression_width), Fc->format!("{}", program_info.acir_opcodes), Fc->format!("{}", program_info.circuit_size), ] @@ -222,7 +222,7 @@ impl From for Row { struct ContractInfo { name: String, #[serde(skip)] - language: Language, + expression_width: ExpressionWidth, functions: Vec, } @@ -239,7 +239,7 @@ impl From for Vec { row![ Fm->format!("{}", contract_info.name), Fc->format!("{}", function.name), - format!("{:?}", contract_info.language), + format!("{:?}", contract_info.expression_width), Fc->format!("{}", function.acir_opcodes), Fc->format!("{}", function.circuit_size), ] @@ -251,11 +251,11 @@ fn count_opcodes_and_gates_in_program( backend: &Backend, compiled_program: CompiledProgram, package: &Package, - language: Language, + expression_width: ExpressionWidth, ) -> Result { Ok(ProgramInfo { name: package.name.to_string(), - language, + expression_width, acir_opcodes: compiled_program.circuit.opcodes.len(), circuit_size: backend.get_exact_circuit_size(&compiled_program.circuit)?, }) @@ -264,7 +264,7 @@ fn count_opcodes_and_gates_in_program( fn count_opcodes_and_gates_in_contract( backend: &Backend, contract: CompiledContract, - language: Language, + expression_width: ExpressionWidth, ) -> Result { let functions = contract .functions @@ -278,5 +278,5 @@ fn count_opcodes_and_gates_in_contract( }) .collect::>()?; - Ok(ContractInfo { name: contract.name, language, functions }) + Ok(ContractInfo { name: contract.name, expression_width, functions }) } diff --git a/tooling/nargo_cli/src/cli/prove_cmd.rs b/tooling/nargo_cli/src/cli/prove_cmd.rs index da8812fc93b..cb1751e7cef 100644 --- a/tooling/nargo_cli/src/cli/prove_cmd.rs +++ b/tooling/nargo_cli/src/cli/prove_cmd.rs @@ -57,9 +57,10 @@ pub(crate) fn run( Some(NOIR_ARTIFACT_VERSION_STRING.to_string()), )?; - let np_language = backend.get_backend_info()?; + let expression_width = backend.get_backend_info()?; for package in &workspace { - let program = compile_bin_package(&workspace, package, &args.compile_options, np_language)?; + let program = + compile_bin_package(&workspace, package, &args.compile_options, expression_width)?; prove_package( backend, diff --git a/tooling/nargo_cli/src/cli/verify_cmd.rs b/tooling/nargo_cli/src/cli/verify_cmd.rs index 53b046a5b76..9659286b5ab 100644 --- a/tooling/nargo_cli/src/cli/verify_cmd.rs +++ b/tooling/nargo_cli/src/cli/verify_cmd.rs @@ -48,9 +48,10 @@ pub(crate) fn run( Some(NOIR_ARTIFACT_VERSION_STRING.to_string()), )?; - let np_language = backend.get_backend_info()?; + let expression_width = backend.get_backend_info()?; for package in &workspace { - let program = compile_bin_package(&workspace, package, &args.compile_options, np_language)?; + let program = + compile_bin_package(&workspace, package, &args.compile_options, expression_width)?; verify_package(backend, &workspace, package, program, &args.verifier_name)?; }