diff --git a/Cargo.lock b/Cargo.lock index af7b202252c..23bc67e252e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "acir" version = "0.15.1" -source = "git+https://github.com/noir-lang/acvm?rev=f1c7940f4ac618c7b440b6ed30199f85cbe72cca#f1c7940f4ac618c7b440b6ed30199f85cbe72cca" +source = "git+https://github.com/noir-lang/acvm?rev=fefa4fbf52f92050946f2ff605798e032a4b91c9#fefa4fbf52f92050946f2ff605798e032a4b91c9" dependencies = [ "acir_field", "brillig_vm", @@ -18,7 +18,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.15.1" -source = "git+https://github.com/noir-lang/acvm?rev=f1c7940f4ac618c7b440b6ed30199f85cbe72cca#f1c7940f4ac618c7b440b6ed30199f85cbe72cca" +source = "git+https://github.com/noir-lang/acvm?rev=fefa4fbf52f92050946f2ff605798e032a4b91c9#fefa4fbf52f92050946f2ff605798e032a4b91c9" dependencies = [ "ark-bn254", "ark-ff", @@ -31,7 +31,7 @@ dependencies = [ [[package]] name = "acvm" version = "0.15.1" -source = "git+https://github.com/noir-lang/acvm?rev=f1c7940f4ac618c7b440b6ed30199f85cbe72cca#f1c7940f4ac618c7b440b6ed30199f85cbe72cca" +source = "git+https://github.com/noir-lang/acvm?rev=fefa4fbf52f92050946f2ff605798e032a4b91c9#fefa4fbf52f92050946f2ff605798e032a4b91c9" dependencies = [ "acir", "acvm_stdlib", @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.5.1" -source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=c1575d20d9e7c664e71a79512ad3329c0d8a6a4d#c1575d20d9e7c664e71a79512ad3329c0d8a6a4d" +source = "git+https://github.com/noir-lang/acvm-backend-barretenberg?rev=447515eff1bed7522c55ec24053b9168bf628553#447515eff1bed7522c55ec24053b9168bf628553" dependencies = [ "acvm", "barretenberg-sys", @@ -68,7 +68,7 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.15.1" -source = "git+https://github.com/noir-lang/acvm?rev=f1c7940f4ac618c7b440b6ed30199f85cbe72cca#f1c7940f4ac618c7b440b6ed30199f85cbe72cca" +source = "git+https://github.com/noir-lang/acvm?rev=fefa4fbf52f92050946f2ff605798e032a4b91c9#fefa4fbf52f92050946f2ff605798e032a4b91c9" dependencies = [ "acir", ] @@ -509,7 +509,7 @@ dependencies = [ [[package]] name = "brillig_vm" version = "0.15.1" -source = "git+https://github.com/noir-lang/acvm?rev=f1c7940f4ac618c7b440b6ed30199f85cbe72cca#f1c7940f4ac618c7b440b6ed30199f85cbe72cca" +source = "git+https://github.com/noir-lang/acvm?rev=fefa4fbf52f92050946f2ff605798e032a4b91c9#fefa4fbf52f92050946f2ff605798e032a4b91c9" dependencies = [ "acir_field", "blake2", diff --git a/Cargo.toml b/Cargo.toml index e70ca8a0c72..3e3ded5748e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,6 @@ wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" [patch.crates-io] -acvm = { git = "https://github.com/noir-lang/acvm", rev = "f1c7940f4ac618c7b440b6ed30199f85cbe72cca" } -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "c1575d20d9e7c664e71a79512ad3329c0d8a6a4d" } +acvm = { git = "https://github.com/noir-lang/acvm", rev = "fefa4fbf52f92050946f2ff605798e032a4b91c9" } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "447515eff1bed7522c55ec24053b9168bf628553" } async-lsp = { git = "https://github.com/oxalica/async-lsp", rev = "09dbcc11046f7a188a80137f8d36484d86c78c78" } diff --git a/crates/lsp/src/lib.rs b/crates/lsp/src/lib.rs index 7b99e5ac02b..68fd9215ae5 100644 --- a/crates/lsp/src/lib.rs +++ b/crates/lsp/src/lib.rs @@ -136,7 +136,7 @@ fn on_code_lens_request( async move { // TODO: Requiring `Language` and `is_opcode_supported` to construct a driver makes for some real stinky code // The driver should not require knowledge of the backend; instead should be implemented as an independent pass (in nargo?) - let mut driver = Driver::new(&Language::R1CS, Box::new(|_op| false)); + let mut driver = Driver::new(Language::R1CS, Box::new(|_op| false)); let file_path = ¶ms.text_document.uri.to_file_path().unwrap(); @@ -224,7 +224,7 @@ fn on_did_save_text_document( ) -> ControlFlow> { // TODO: Requiring `Language` and `is_opcode_supported` to construct a driver makes for some real stinky code // The driver should not require knowledge of the backend; instead should be implemented as an independent pass (in nargo?) - let mut driver = Driver::new(&Language::R1CS, Box::new(|_op| false)); + let mut driver = Driver::new(Language::R1CS, Box::new(|_op| false)); let file_path = ¶ms.text_document.uri.to_file_path().unwrap(); diff --git a/crates/nargo/src/ops/execute.rs b/crates/nargo/src/ops/execute.rs index 94a2a8f6b9d..792f8763424 100644 --- a/crates/nargo/src/ops/execute.rs +++ b/crates/nargo/src/ops/execute.rs @@ -1,5 +1,5 @@ use acvm::acir::brillig_vm::ForeignCallResult; -use acvm::pwg::{ForeignCallWaitInfo, PartialWitnessGeneratorStatus, ACVM}; +use acvm::pwg::{ACVMStatus, ForeignCallWaitInfo, ACVM}; use acvm::BlackBoxFunctionSolver; use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap}; @@ -15,15 +15,17 @@ pub fn execute_circuit( // TODO(#1615): Nargo only supports "oracle_print_**_impl" functions that print a singular value or an array and nothing else // This should be expanded in a general logging refactor loop { - let solver_status = acvm.solve()?; + let solver_status = acvm.solve(); match solver_status { - PartialWitnessGeneratorStatus::Solved => break, - PartialWitnessGeneratorStatus::RequiresForeignCall => { - let foreign_call = - acvm.get_pending_foreign_call().expect("Should be waiting on a foreign call"); - - let foreign_call_result = execute_foreign_call(foreign_call); + ACVMStatus::Solved => break, + ACVMStatus::InProgress => { + unreachable!("Execution should not stop while in `InProgress` state.") + } + ACVMStatus::Failure(error) => return Err(error.into()), + ACVMStatus::RequiresForeignCall(unresolved_brillig_call) => { + let foreign_call_result = + execute_foreign_call(&unresolved_brillig_call.foreign_call_wait_info); acvm.resolve_pending_foreign_call(foreign_call_result); } } diff --git a/crates/nargo_cli/src/cli/mod.rs b/crates/nargo_cli/src/cli/mod.rs index 0066d7c9135..1724886755d 100644 --- a/crates/nargo_cli/src/cli/mod.rs +++ b/crates/nargo_cli/src/cli/mod.rs @@ -179,7 +179,7 @@ mod tests { /// This is used for tests. fn file_compiles>(root_file: P) -> bool { let mut driver = Driver::new( - &acvm::Language::R1CS, + acvm::Language::R1CS, #[allow(deprecated)] Box::new(acvm::pwg::default_is_opcode_supported(acvm::Language::R1CS)), ); diff --git a/crates/nargo_cli/src/resolver.rs b/crates/nargo_cli/src/resolver.rs index 19eafb07065..d584bd16749 100644 --- a/crates/nargo_cli/src/resolver.rs +++ b/crates/nargo_cli/src/resolver.rs @@ -73,7 +73,7 @@ impl<'a> Resolver<'a> { np_language: Language, is_opcode_supported: Box bool>, ) -> Result { - let mut driver = Driver::new(&np_language, is_opcode_supported); + let mut driver = Driver::new(np_language, is_opcode_supported); let (entry_path, crate_type) = super::lib_or_bin(dir_path)?; let manifest_path = super::find_package_manifest(dir_path)?; diff --git a/crates/noirc_driver/src/lib.rs b/crates/noirc_driver/src/lib.rs index c09ffe6b43c..4a212839c80 100644 --- a/crates/noirc_driver/src/lib.rs +++ b/crates/noirc_driver/src/lib.rs @@ -73,8 +73,8 @@ pub type Warnings = Vec; pub type ErrorsAndWarnings = Vec; impl Driver { - pub fn new(language: &Language, is_opcode_supported: Box bool>) -> Self { - Driver { context: Context::default(), language: language.clone(), is_opcode_supported } + pub fn new(language: Language, is_opcode_supported: Box bool>) -> Self { + Driver { context: Context::default(), language, is_opcode_supported } } // TODO(#1599): Move control of the FileManager into nargo @@ -86,7 +86,7 @@ impl Driver { // with the restricted version which only uses one file pub fn compile_file( root_file: PathBuf, - language: &Language, + language: Language, is_opcode_supported: Box bool>, ) -> Result<(CompiledProgram, Warnings), ErrorsAndWarnings> { let mut driver = Driver::new(language, is_opcode_supported); @@ -345,12 +345,10 @@ impl Driver { ) -> Result { let program = monomorphize(main_function, &self.context.def_interner); - let np_language = self.language.clone(); - let circuit_abi = if options.experimental_ssa { experimental_create_circuit( program, - np_language, + self.language, &self.is_opcode_supported, options.show_ssa, options.show_output, @@ -358,7 +356,7 @@ impl Driver { } else { create_circuit( program, - np_language, + self.language, &self.is_opcode_supported, options.show_ssa, options.show_output, @@ -408,6 +406,6 @@ impl Driver { impl Default for Driver { fn default() -> Self { #[allow(deprecated)] - Self::new(&Language::R1CS, Box::new(acvm::pwg::default_is_opcode_supported(Language::R1CS))) + Self::new(Language::R1CS, Box::new(acvm::pwg::default_is_opcode_supported(Language::R1CS))) } } diff --git a/crates/noirc_driver/src/main.rs b/crates/noirc_driver/src/main.rs index 0dbc0fc1573..ff2f397070a 100644 --- a/crates/noirc_driver/src/main.rs +++ b/crates/noirc_driver/src/main.rs @@ -7,7 +7,7 @@ fn main() { const ROOT_DIR_MAIN: &str = "example_real_project/main.nr"; let mut driver = Driver::new( - &Language::R1CS, + Language::R1CS, #[allow(deprecated)] Box::new(acvm::pwg::default_is_opcode_supported(Language::R1CS)), ); diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index ce97fc06fd5..8d8eefdb1fb 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -115,7 +115,7 @@ fn permutation_layer( mod test { use acvm::{ acir::native_types::WitnessMap, - pwg::{OpcodeResolutionError, PartialWitnessGeneratorStatus, ACVM}, + pwg::{ACVMStatus, OpcodeResolutionError, ACVM}, BlackBoxFunctionSolver, FieldElement, }; @@ -192,11 +192,11 @@ mod test { } // compute the network output by solving the constraints let backend = MockBackend {}; - let acvm = ACVM::new(backend, eval.opcodes.clone(), initial_witness); - let solver_status = acvm.solve().expect("Could not solve permutation constraints"); - assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); - let solved_witness = acvm.finalize(); + let mut acvm = ACVM::new(backend, eval.opcodes.clone(), initial_witness); + let solver_status = acvm.solve(); + assert_eq!(solver_status, ACVMStatus::Solved, "Incomplete solution"); + let solved_witness = acvm.finalize(); let mut b_val = Vec::new(); for i in 0..output.len() { b_val.push(solved_witness[&b_wit[i]]); diff --git a/crates/wasm/src/compile.rs b/crates/wasm/src/compile.rs index ba1c2bacd14..d4b3d5f3996 100644 --- a/crates/wasm/src/compile.rs +++ b/crates/wasm/src/compile.rs @@ -76,7 +76,7 @@ pub fn compile(args: JsValue) -> JsValue { // For now we default to plonk width = 3, though we can add it as a parameter let language = acvm::Language::PLONKCSat { width: 3 }; let mut driver = noirc_driver::Driver::new( - &language, + language, #[allow(deprecated)] Box::new(acvm::pwg::default_is_opcode_supported(language.clone())), );