diff --git a/Cargo.lock b/Cargo.lock index 2f359a5bb66..58ea6f018f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "acir" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adf51cc323e2a96e381859e6ea26c14fb94cabe72353a4e2bcc2df582110927b" +checksum = "8a0f4d70cd78f13cc17b2b16953af71d1a4fd0aa923cc35e6741c1f810eccdad" dependencies = [ "acir_field", "brillig_vm", @@ -18,9 +18,9 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c386958918fac40ec59ba165c1efaf3ee8a25a7b9587794dc88736a67f08db" +checksum = "74a1bdec0ba9ddb54d3337bb487a889dd212211a7daf6fe9fb175adf107eecdc" dependencies = [ "ark-bn254", "ark-ff", @@ -32,9 +32,9 @@ dependencies = [ [[package]] name = "acvm" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0be8cf5e532200abd879e0e9a1aecfea6605387bc7fdbf3e6c51e4d3799e760e" +checksum = "6e27004072f628c96c5666068c0d9efae134423331859b60923265a017a5920b" dependencies = [ "acir", "acvm_stdlib", @@ -71,9 +71,9 @@ dependencies = [ [[package]] name = "acvm_stdlib" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89789ea350d87aeaed31cde2d655a3dbb861a71f1bbed41802e0f8c6a207f11c" +checksum = "a16b18f0dc47de9c3f60eb320dda05b31355d7d4f76239f75852cc5a518db69e" dependencies = [ "acir", ] @@ -512,12 +512,11 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60857c63a6da410360fca5f98162452561e42dbdff66a6206626b9bf3bb2a4ca" +checksum = "ae057025d1898257631c65c63071209dc41093cf9c0d77cdaae976798fa18b93" dependencies = [ "acir_field", - "num-bigint", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 5080b629347..07bb5bade78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -acvm = "0.15.0" +acvm = "0.15.1" arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } diff --git a/crates/nargo/src/ops/execute.rs b/crates/nargo/src/ops/execute.rs index d63ae45d3d8..ec3cd9bd7c6 100644 --- a/crates/nargo/src/ops/execute.rs +++ b/crates/nargo/src/ops/execute.rs @@ -1,4 +1,3 @@ -use acvm::acir::brillig_vm::ForeignCallResult; use acvm::acir::circuit::Opcode; use acvm::pwg::{solve, Blocks, PartialWitnessGeneratorStatus, UnresolvedBrilligCall}; use acvm::PartialWitnessGenerator; @@ -32,23 +31,21 @@ pub fn execute_circuit( // Execute foreign calls // TODO(#1615): "oracle_print_impl" and "oracle_print_array_impl" are just identity funcs if foreign_call_wait_info.function == "oracle_print_impl" { - let values = &foreign_call_wait_info.inputs[0]; - println!("{:?}", values[0].to_field().to_hex()); - brillig.foreign_call_results.push(ForeignCallResult { - values: vec![vec![foreign_call_wait_info.inputs[0][0]]], - }); + let value = foreign_call_wait_info.inputs[0][0]; + println!("{:?}", value.to_field().to_hex()); + brillig.foreign_call_results.push(value.into()); } else if foreign_call_wait_info.function == "oracle_print_array_impl" { let mut outputs_hex = Vec::new(); - for value in foreign_call_wait_info.inputs.clone() { - outputs_hex.push(value[0].to_field().to_hex()); + for values in foreign_call_wait_info.inputs.clone() { + for value in values { + outputs_hex.push(value.to_field().to_hex()); + } } // Join all of the hex strings using a comma let comma_separated_elements = outputs_hex.join(", "); let output_witnesses_string = "[".to_owned() + &comma_separated_elements + "]"; println!("{output_witnesses_string}"); - brillig.foreign_call_results.push(ForeignCallResult { - values: vec![vec![foreign_call_wait_info.inputs[0][0]]], - }); + brillig.foreign_call_results.push(foreign_call_wait_info.inputs[0][0].into()); } let mut next_opcodes_for_solving = vec![Opcode::Brillig(brillig)]; diff --git a/crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs b/crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs index 8d74b11332e..585b43b9db5 100644 --- a/crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs +++ b/crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs @@ -9,7 +9,7 @@ use crate::ssa_refactor::ir::{ types::{NumericType, Type}, value::{Value, ValueId}, }; -use acvm::acir::brillig_vm::{BinaryFieldOp, BinaryIntOp, RegisterIndex, RegisterValueOrArray}; +use acvm::acir::brillig_vm::{BinaryFieldOp, BinaryIntOp, RegisterIndex, RegisterOrMemory}; use acvm::FieldElement; use iter_extended::vecmap; @@ -387,12 +387,12 @@ impl<'block> BrilligBlock<'block> { &mut self, value_id: ValueId, dfg: &DataFlowGraph, - ) -> RegisterValueOrArray { + ) -> RegisterOrMemory { let register_index = self.convert_ssa_value(value_id, dfg); let typ = dfg[value_id].get_type(); match typ { - Type::Numeric(_) => RegisterValueOrArray::RegisterIndex(register_index), - Type::Array(_, size) => RegisterValueOrArray::HeapArray(register_index, size), + Type::Numeric(_) => RegisterOrMemory::RegisterIndex(register_index), + Type::Array(_, size) => RegisterOrMemory::HeapArray(register_index, size), _ => { unreachable!("type not supported for conversion into brillig register") } diff --git a/crates/noirc_evaluator/src/brillig/brillig_ir.rs b/crates/noirc_evaluator/src/brillig/brillig_ir.rs index 51f447a6777..48e18cf927a 100644 --- a/crates/noirc_evaluator/src/brillig/brillig_ir.rs +++ b/crates/noirc_evaluator/src/brillig/brillig_ir.rs @@ -14,8 +14,7 @@ use self::{ }; use acvm::{ acir::brillig_vm::{ - BinaryFieldOp, BinaryIntOp, Opcode as BrilligOpcode, RegisterIndex, RegisterValueOrArray, - Value, + BinaryFieldOp, BinaryIntOp, Opcode as BrilligOpcode, RegisterIndex, RegisterOrMemory, Value, }, FieldElement, }; @@ -419,8 +418,8 @@ impl BrilligContext { pub(crate) fn foreign_call_instruction( &mut self, func_name: String, - inputs: &[RegisterValueOrArray], - outputs: &[RegisterValueOrArray], + inputs: &[RegisterOrMemory], + outputs: &[RegisterOrMemory], ) { debug_show::foreign_call_instruction(func_name.clone(), inputs, outputs); // TODO(https://github.com/noir-lang/acvm/issues/366): Enable multiple inputs and outputs to a foreign call diff --git a/crates/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs b/crates/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs index 8fe8ad916e6..388b1f6222a 100644 --- a/crates/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs +++ b/crates/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs @@ -1,9 +1,7 @@ ///! This module contains functions for producing a higher level view disassembler of Brillig. use super::BrilligBinaryOp; use crate::brillig::brillig_ir::{ReservedRegisters, BRILLIG_MEMORY_ADDRESSING_BIT_SIZE}; -use acvm::acir::brillig_vm::{ - BinaryFieldOp, BinaryIntOp, RegisterIndex, RegisterValueOrArray, Value, -}; +use acvm::acir::brillig_vm::{BinaryFieldOp, BinaryIntOp, RegisterIndex, RegisterOrMemory, Value}; /// Controls whether debug traces are enabled const ENABLE_DEBUG_TRACE: bool = true; @@ -98,13 +96,20 @@ impl DebugToString for Value { } } -impl DebugToString for RegisterValueOrArray { +impl DebugToString for RegisterOrMemory { fn debug_to_string(&self) -> String { match self { - RegisterValueOrArray::RegisterIndex(index) => index.debug_to_string(), - RegisterValueOrArray::HeapArray(index, size) => { + RegisterOrMemory::RegisterIndex(index) => index.debug_to_string(), + RegisterOrMemory::HeapArray(index, size) => { format!("{}[0..{}]", index.debug_to_string(), size) } + RegisterOrMemory::HeapVector(location_index, length_index) => { + format!( + "{}[0..{}]", + location_index.debug_to_string(), + length_index.debug_to_string() + ) + } } } } @@ -173,8 +178,8 @@ pub(crate) fn not_instruction(condition: RegisterIndex, result: RegisterIndex) { /// Processes a foreign call instruction. pub(crate) fn foreign_call_instruction( func_name: String, - inputs: &[RegisterValueOrArray], - outputs: &[RegisterValueOrArray], + inputs: &[RegisterOrMemory], + outputs: &[RegisterOrMemory], ) { debug_println!(" FOREIGN_CALL {} ({}) => {}", func_name, inputs, outputs); }