From 6e82f71a0fd6d724cf7b3094b6a0d35e05ca7bbb Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:50:20 +0000 Subject: [PATCH 1/5] feat: aztec public-vm macro --- noir/aztec_macros/src/lib.rs | 12 ++++++++++++ .../contracts/avm_test_contract/src/main.nr | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index b8cda78ff34..2e209eb37ab 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -424,6 +424,10 @@ fn transform_module( transform_function("Public", func, storage_defined) .map_err(|err| (err, crate_graph.root_file_id))?; has_transformed_module = true; + } else if is_custom_attribute(&secondary_attribute, "aztec(public-vm)") { + transform_vm_function(func, storage_defined) + .map_err(|err| (err, crate_graph.root_file_id))?; + has_transformed_module = true; } } // Add the storage struct to the beginning of the function if it is unconstrained in an aztec contract @@ -585,6 +589,14 @@ fn generate_storage_implementation(module: &mut SortedModule) -> Result<(), Azte Ok(()) } +// Transform a function to work with AVM bytecode +fn transform_vm_function(func: &mut NoirFunction, _storage_defined: bool) -> Result<(), AztecMacroError> { + // No need to abstract the return values in this way + + func.def.is_open = true; + Ok(()) +} + /// If it does, it will insert the following things: /// - A new Input that is provided for a kernel app circuit, named: {Public/Private}ContextInputs /// - Hashes all of the function input variables diff --git a/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr index 00e35dfe6ba..a1cce52ae63 100644 --- a/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -10,7 +10,8 @@ contract AvmTest { fn constructor() {} // Function name prefix "avm_" flags it for transpilation - unconstrained fn avm_addArgsReturn(argA: Field, argB: Field) -> pub Field { + #[aztec(public-avm)] + fn addArgsReturn(argA: Field, argB: Field) -> pub Field { argA + argB } From 1937067198279a55ce9c544d0eb19c2adf005f94 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 2 Feb 2024 22:08:37 +0000 Subject: [PATCH 2/5] fix: update compiler to work with outputted contract --- avm-transpiler/src/instructions.rs | 18 ++++++++++++++---- avm-transpiler/src/transpile.rs | 16 ++++++++++++++-- avm-transpiler/src/transpile_contract.rs | 4 ++-- .../acir-simulator/src/avm/index.test.ts | 5 +++-- .../serialization/bytecode_serialization.ts | 1 - .../contracts/avm_test_contract/src/main.nr | 4 ++-- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/avm-transpiler/src/instructions.rs b/avm-transpiler/src/instructions.rs index efc195cc5b0..c745c4c1868 100644 --- a/avm-transpiler/src/instructions.rs +++ b/avm-transpiler/src/instructions.rs @@ -1,3 +1,6 @@ +use std::fmt::{Formatter, Debug}; +use std::fmt; + use crate::opcodes::AvmOpcode; /// Common values of the indirect instruction flag @@ -55,8 +58,7 @@ impl AvmInstruction { // TODO(4271): add in_tag alongside its support in TS if let Some(dst_tag) = self.dst_tag { // TODO(4271): make 8 bits when TS supports deserialization of 8 bit flags - //bytes.push(dst_tag as u8); - bytes.extend_from_slice(&(dst_tag as u32).to_be_bytes()); + bytes.extend_from_slice(&(dst_tag as u8).to_be_bytes()); } for operand in &self.operands { bytes.extend_from_slice(&operand.to_be_bytes()); @@ -64,6 +66,13 @@ impl AvmInstruction { bytes } } + +impl Debug for AvmInstruction { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.to_string()) + } +} + impl Default for AvmInstruction { fn default() -> Self { AvmInstruction { @@ -95,7 +104,7 @@ pub enum AvmTypeTag { pub enum AvmOperand { U32 { value: u32 }, // TODO(4267): Support operands of size other than 32 bits (for SET) - //U128 { value: u128 }, + U128 { value: u128 }, } impl AvmOperand { pub fn to_string(&self) -> String { @@ -103,13 +112,14 @@ impl AvmOperand { AvmOperand::U32 { value } => format!(" U32:{}", value), // TODO(4267): Support operands of size other than 32 bits (for SET) //AvmOperand::U128 { value } => format!("U128:{}", value), + AvmOperand::U128 { value } => format!(" U128:{}", value), } } pub fn to_be_bytes(&self) -> Vec { match self { AvmOperand::U32 { value } => value.to_be_bytes().to_vec(), // TODO(4267): Support operands of size other than 32 bits (for SET) - //AvmOperand::U128 { value } => value.to_be_bytes().to_vec(), + AvmOperand::U128 { value } => value.to_be_bytes().to_vec(), } } } diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index 9785e41c7a1..268ff02d201 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -38,6 +38,9 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { // TODO(4268): set in_tag to `field` avm_instrs.push(AvmInstruction { opcode: avm_opcode, + indirect: Some(0), + // TEMPORARY - instruction set currently expects this + dst_tag: Some(AvmTypeTag::UINT32), operands: vec![ AvmOperand::U32 { value: lhs.to_usize() as u32, @@ -80,6 +83,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { // TODO(4268): support u8..u128 and use in_tag avm_instrs.push(AvmInstruction { opcode: avm_opcode, + indirect: Some(0), operands: vec![ AvmOperand::U32 { value: lhs.to_usize() as u32, @@ -97,6 +101,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { BrilligOpcode::CalldataCopy { destination_address, size, offset } => { avm_instrs.push(AvmInstruction { opcode: AvmOpcode::CALLDATACOPY, + indirect: Some(0), operands: vec![ AvmOperand::U32 { value: *offset as u32, // cdOffset (calldata offset) @@ -125,6 +130,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { let avm_loc = brillig_pcs_to_avm_pcs[*location]; avm_instrs.push(AvmInstruction { opcode: AvmOpcode::JUMPI, + indirect: Some(0), operands: vec![ AvmOperand::U32 { value: avm_loc as u32, @@ -139,12 +145,15 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { BrilligOpcode::Const { destination, value } => { avm_instrs.push(AvmInstruction { opcode: AvmOpcode::SET, + indirect: Some(0), dst_tag: Some(AvmTypeTag::UINT32), operands: vec![ // TODO(4267): support u8..u128 and use dst_tag - AvmOperand::U32 { - value: value.to_usize() as u32, + // value - temporarily as u128 + AvmOperand::U128 { + value: value.to_usize() as u128, }, + // dest offset AvmOperand::U32 { value: destination.to_usize() as u32, }, @@ -158,6 +167,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { } => { avm_instrs.push(AvmInstruction { opcode: AvmOpcode::MOV, + indirect: Some(0), operands: vec![ AvmOperand::U32 { value: source.to_usize() as u32, @@ -223,6 +233,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { BrilligOpcode::Stop { return_data_offset, return_data_size } => { avm_instrs.push(AvmInstruction { opcode: AvmOpcode::RETURN, + indirect: Some(0), operands: vec![ AvmOperand::U32 { value: *return_data_offset as u32}, AvmOperand::U32 { value: *return_data_size as u32}, @@ -234,6 +245,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { // TODO(https://github.com/noir-lang/noir/issues/3113): Trap should support return data avm_instrs.push(AvmInstruction { opcode: AvmOpcode::REVERT, + indirect: Some(0), operands: vec![ //AvmOperand::U32 { value: *return_data_offset as u32}, //AvmOperand::U32 { value: *return_data_size as u32}, diff --git a/avm-transpiler/src/transpile_contract.rs b/avm-transpiler/src/transpile_contract.rs index 2a8b762139f..296048c3d21 100644 --- a/avm-transpiler/src/transpile_contract.rs +++ b/avm-transpiler/src/transpile_contract.rs @@ -76,10 +76,10 @@ pub enum AvmOrAcirContractFunction { impl From for TranspiledContract { fn from(contract: CompiledAcirContract) -> Self { let mut functions = Vec::new(); + let re = Regex::new(r"avm_.*$").unwrap(); for function in contract.functions { // TODO(4269): once functions are tagged for transpilation to AVM, check tag - let re = Regex::new(r"avm_.*$").unwrap(); - if function.function_type == ContractFunctionType::Unconstrained + if function.function_type == ContractFunctionType::Open && re.is_match(function.name.as_str()) { info!( diff --git a/yarn-project/acir-simulator/src/avm/index.test.ts b/yarn-project/acir-simulator/src/avm/index.test.ts index 9826a89d8e5..a9e05a97ea2 100644 --- a/yarn-project/acir-simulator/src/avm/index.test.ts +++ b/yarn-project/acir-simulator/src/avm/index.test.ts @@ -39,7 +39,7 @@ describe('avm', () => { describe('testing transpiled Noir contracts', () => { // TODO(https://github.com/AztecProtocol/aztec-packages/issues/4361): sync wire format w/transpiler. - it.skip('Should execute contract function that performs addition', async () => { + it('Should execute contract function that performs addition', async () => { const calldata: Fr[] = [new Fr(1), new Fr(2)]; const journal = mock(); @@ -47,7 +47,8 @@ describe('avm', () => { const addArtifact = AvmTestContractArtifact.functions.find(f => f.name === 'avm_addArgsReturn')!; // Decode bytecode into instructions - const instructions = decodeFromBytecode(Buffer.from(addArtifact.bytecode, 'base64')); + const instructionsBytecode = Buffer.from(addArtifact.bytecode, 'base64'); + const instructions = decodeFromBytecode(instructionsBytecode); // Execute instructions const context = new AvmMachineState(initExecutionEnvironment({ calldata })); diff --git a/yarn-project/acir-simulator/src/avm/serialization/bytecode_serialization.ts b/yarn-project/acir-simulator/src/avm/serialization/bytecode_serialization.ts index b0285018980..8b200e5800c 100644 --- a/yarn-project/acir-simulator/src/avm/serialization/bytecode_serialization.ts +++ b/yarn-project/acir-simulator/src/avm/serialization/bytecode_serialization.ts @@ -56,7 +56,6 @@ const INSTRUCTION_SET: InstructionSet = new Map pub Field { + #[aztec(public-vm)] + fn avm_addArgsReturn(argA: Field, argB: Field) -> pub Field { argA + argB } From 139678ab12cd269c7514420827b877428f009d90 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 2 Feb 2024 22:18:45 +0000 Subject: [PATCH 3/5] feat: prefix with avm_ in macro --- avm-transpiler/src/transpile_contract.rs | 2 ++ noir/aztec_macros/src/lib.rs | 7 +++++-- .../noir-contracts/contracts/avm_test_contract/src/main.nr | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/avm-transpiler/src/transpile_contract.rs b/avm-transpiler/src/transpile_contract.rs index 296048c3d21..7ee0ec56414 100644 --- a/avm-transpiler/src/transpile_contract.rs +++ b/avm-transpiler/src/transpile_contract.rs @@ -76,6 +76,8 @@ pub enum AvmOrAcirContractFunction { impl From for TranspiledContract { fn from(contract: CompiledAcirContract) -> Self { let mut functions = Vec::new(); + + // Note, in aztec_macros/lib.rs, avm_ prefix is pushed to function names with the #[aztec(public-vm)] tag let re = Regex::new(r"avm_.*$").unwrap(); for function in contract.functions { // TODO(4269): once functions are tagged for transpilation to AVM, check tag diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 2e209eb37ab..bedd3aa01c1 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -591,9 +591,12 @@ fn generate_storage_implementation(module: &mut SortedModule) -> Result<(), Azte // Transform a function to work with AVM bytecode fn transform_vm_function(func: &mut NoirFunction, _storage_defined: bool) -> Result<(), AztecMacroError> { - // No need to abstract the return values in this way - + // We want the function to be seen as a public function func.def.is_open = true; + + // NOTE: the line below is a temporary hack to trigger external transpilation tools + // It will be removed once the transpiler is integrated into the Noir compiler + func.def.name.0.contents = format!("avm_{}", func.def.name.0.contents); Ok(()) } diff --git a/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr index 1598c86d8b6..6abbfef234c 100644 --- a/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -11,7 +11,7 @@ contract AvmTest { // Function name prefix "avm_" flags it for transpilation #[aztec(public-vm)] - fn avm_addArgsReturn(argA: Field, argB: Field) -> pub Field { + fn addArgsReturn(argA: Field, argB: Field) -> pub Field { argA + argB } From a19bac6b17eb8652dc24be6f1a88b942fcf15108 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 2 Feb 2024 22:36:37 +0000 Subject: [PATCH 4/5] fix: cleanup --- avm-transpiler/src/instructions.rs | 5 ++--- avm-transpiler/src/main.rs | 11 +++------- avm-transpiler/src/transpile.rs | 21 ++++++++----------- avm-transpiler/src/transpile_contract.rs | 2 +- avm-transpiler/src/utils.rs | 16 +++++++------- noir/aztec_macros/src/lib.rs | 5 ++++- .../contracts/avm_test_contract/src/main.nr | 2 +- 7 files changed, 27 insertions(+), 35 deletions(-) diff --git a/avm-transpiler/src/instructions.rs b/avm-transpiler/src/instructions.rs index c745c4c1868..198b327f8e3 100644 --- a/avm-transpiler/src/instructions.rs +++ b/avm-transpiler/src/instructions.rs @@ -1,5 +1,5 @@ -use std::fmt::{Formatter, Debug}; use std::fmt; +use std::fmt::{Debug, Formatter}; use crate::opcodes::AvmOpcode; @@ -39,7 +39,7 @@ impl AvmInstruction { if let Some(dst_tag) = self.dst_tag { out_str += format!(", dst_tag: {}", dst_tag as u8).as_str(); } - if self.operands.len() > 0 { + if !self.operands.is_empty() { out_str += ", operands: ["; for operand in &self.operands { out_str += format!("{}, ", operand.to_string()).as_str(); @@ -111,7 +111,6 @@ impl AvmOperand { match self { AvmOperand::U32 { value } => format!(" U32:{}", value), // TODO(4267): Support operands of size other than 32 bits (for SET) - //AvmOperand::U128 { value } => format!("U128:{}", value), AvmOperand::U128 { value } => format!(" U128:{}", value), } } diff --git a/avm-transpiler/src/main.rs b/avm-transpiler/src/main.rs index 064bf343bbf..c81d1e0d682 100644 --- a/avm-transpiler/src/main.rs +++ b/avm-transpiler/src/main.rs @@ -25,14 +25,9 @@ fn main() { serde_json::from_str(&contract_json).expect("Unable to parse json"); // Skip if contract has "transpiled: true" flag! - if let Some(transpiled) = raw_json_obj.get("transpiled") { - match transpiled { - serde_json::Value::Bool(true) => { - warn!("Contract already transpiled. Skipping."); - return; // nothing to transpile - } - _ => (), - } + if let Some(serde_json::Value::Bool(true)) = raw_json_obj.get("transpiled") { + warn!("Contract already transpiled. Skipping."); + return; } // Parse json into contract object let contract: CompiledAcirContract = diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index 268ff02d201..3a871fdc862 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -11,7 +11,7 @@ use crate::utils::{dbg_print_avm_program, dbg_print_brillig_program}; /// Transpile a Brillig program to AVM bytecode pub fn brillig_to_avm(brillig: &Brillig) -> Vec { - dbg_print_brillig_program(&brillig); + dbg_print_brillig_program(brillig); let mut avm_instrs: Vec = Vec::new(); @@ -39,7 +39,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { avm_instrs.push(AvmInstruction { opcode: avm_opcode, indirect: Some(0), - // TEMPORARY - instruction set currently expects this + // TEMPORARY - typescript wireFormat expects this dst_tag: Some(AvmTypeTag::UINT32), operands: vec![ AvmOperand::U32 { @@ -52,7 +52,6 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { value: destination.to_usize() as u32, }, ], - ..Default::default() }); } BrilligOpcode::BinaryIntOp { @@ -146,11 +145,11 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { avm_instrs.push(AvmInstruction { opcode: AvmOpcode::SET, indirect: Some(0), - dst_tag: Some(AvmTypeTag::UINT32), + dst_tag: Some(AvmTypeTag::UINT128), operands: vec![ // TODO(4267): support u8..u128 and use dst_tag - // value - temporarily as u128 - AvmOperand::U128 { + // value - temporarily as u128 - matching wireFormat in typescript + AvmOperand::U128 { value: value.to_usize() as u128, }, // dest offset @@ -158,7 +157,6 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { value: destination.to_usize() as u32, }, ], - ..Default::default() }); } BrilligOpcode::Mov { @@ -266,9 +264,8 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { // Constructing bytecode from instructions let mut bytecode = Vec::new(); - for i in 0..avm_instrs.len() { - let instr_bytes = avm_instrs[i].to_bytes(); - bytecode.extend_from_slice(&instr_bytes); + for instruction in avm_instrs { + bytecode.extend_from_slice(&instruction.to_bytes()); } bytecode } @@ -284,8 +281,8 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { /// returns: an array where each index is a Brillig pc, /// and each value is the corresponding AVM pc. fn map_brillig_pcs_to_avm_pcs(initial_offset: usize, brillig: &Brillig) -> Vec { - let mut pc_map = Vec::with_capacity(brillig.bytecode.len()); - pc_map.resize(brillig.bytecode.len(), 0); + let mut pc_map = vec![0; brillig.bytecode.len()]; + pc_map[0] = initial_offset; for i in 0..brillig.bytecode.len() - 1 { let num_avm_instrs_for_this_brillig_instr = match &brillig.bytecode[i] { diff --git a/avm-transpiler/src/transpile_contract.rs b/avm-transpiler/src/transpile_contract.rs index 7ee0ec56414..9b342b4d870 100644 --- a/avm-transpiler/src/transpile_contract.rs +++ b/avm-transpiler/src/transpile_contract.rs @@ -93,7 +93,7 @@ impl From for TranspiledContract { let brillig = extract_brillig_from_acir(&acir_circuit.opcodes); // Transpile to AVM - let avm_bytecode = brillig_to_avm(&brillig); + let avm_bytecode = brillig_to_avm(brillig); // Push modified function entry to ABI functions.push(AvmOrAcirContractFunction::Avm(AvmContractFunction { diff --git a/avm-transpiler/src/utils.rs b/avm-transpiler/src/utils.rs index 2f31c900450..e7a633e7c15 100644 --- a/avm-transpiler/src/utils.rs +++ b/avm-transpiler/src/utils.rs @@ -14,28 +14,26 @@ pub fn extract_brillig_from_acir(opcodes: &Vec) -> &Brillig { panic!("There should only be one brillig opcode"); } let opcode = &opcodes[0]; - let brillig = match opcode { + match opcode { Opcode::Brillig(brillig) => brillig, _ => panic!("Tried to extract a Brillig program from its ACIR wrapper opcode, but the opcode doesn't contain Brillig!"), - }; - brillig + } } /// Print inputs, outputs, and instructions in a Brillig program pub fn dbg_print_brillig_program(brillig: &Brillig) { debug!("Printing Brillig program..."); debug!("\tInputs: {:?}", brillig.inputs); - for i in 0..brillig.bytecode.len() { - let instr = &brillig.bytecode[i]; - debug!("\tPC:{0} {1:?}", i, instr); + for (i, instruction) in brillig.bytecode.iter().enumerate() { + debug!("\tPC:{0} {1:?}", i, instruction); } debug!("\tOutputs: {:?}", brillig.outputs); } /// Print each instruction in an AVM program -pub fn dbg_print_avm_program(avm_program: &Vec) { +pub fn dbg_print_avm_program(avm_program: &[AvmInstruction]) { debug!("Printing AVM program..."); - for i in 0..avm_program.len() { - debug!("\tPC:{0}: {1}", i, &avm_program[i].to_string()); + for (i, instruction) in avm_program.iter().enumerate() { + debug!("\tPC:{0}: {1}", i, &instruction.to_string()); } } diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index bedd3aa01c1..d366b094878 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -590,7 +590,10 @@ fn generate_storage_implementation(module: &mut SortedModule) -> Result<(), Azte } // Transform a function to work with AVM bytecode -fn transform_vm_function(func: &mut NoirFunction, _storage_defined: bool) -> Result<(), AztecMacroError> { +fn transform_vm_function( + func: &mut NoirFunction, + _storage_defined: bool, +) -> Result<(), AztecMacroError> { // We want the function to be seen as a public function func.def.is_open = true; diff --git a/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr index 6abbfef234c..28dbf5576d0 100644 --- a/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -9,7 +9,7 @@ contract AvmTest { #[aztec(private)] fn constructor() {} - // Function name prefix "avm_" flags it for transpilation + // Public-vm macro will prefix avm to the function name for transpilation #[aztec(public-vm)] fn addArgsReturn(argA: Field, argB: Field) -> pub Field { argA + argB From fbe00539e9b44851cf96b9fae3e3a72490b109c4 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Fri, 2 Feb 2024 23:30:43 +0000 Subject: [PATCH 5/5] fix: review --- avm-transpiler/src/transpile.rs | 2 +- noir/aztec_macros/src/lib.rs | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index 3a871fdc862..e4f112f9ee8 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -39,7 +39,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec { avm_instrs.push(AvmInstruction { opcode: avm_opcode, indirect: Some(0), - // TEMPORARY - typescript wireFormat expects this + // TODO(4268): TEMPORARY - typescript wireFormat expects this dst_tag: Some(AvmTypeTag::UINT32), operands: vec![ AvmOperand::U32 { diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index d366b094878..228664c83fb 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -589,20 +589,6 @@ fn generate_storage_implementation(module: &mut SortedModule) -> Result<(), Azte Ok(()) } -// Transform a function to work with AVM bytecode -fn transform_vm_function( - func: &mut NoirFunction, - _storage_defined: bool, -) -> Result<(), AztecMacroError> { - // We want the function to be seen as a public function - func.def.is_open = true; - - // NOTE: the line below is a temporary hack to trigger external transpilation tools - // It will be removed once the transpiler is integrated into the Noir compiler - func.def.name.0.contents = format!("avm_{}", func.def.name.0.contents); - Ok(()) -} - /// If it does, it will insert the following things: /// - A new Input that is provided for a kernel app circuit, named: {Public/Private}ContextInputs /// - Hashes all of the function input variables @@ -654,6 +640,20 @@ fn transform_function( Ok(()) } +/// Transform a function to work with AVM bytecode +fn transform_vm_function( + func: &mut NoirFunction, + _storage_defined: bool, +) -> Result<(), AztecMacroError> { + // We want the function to be seen as a public function + func.def.is_open = true; + + // NOTE: the line below is a temporary hack to trigger external transpilation tools + // It will be removed once the transpiler is integrated into the Noir compiler + func.def.name.0.contents = format!("avm_{}", func.def.name.0.contents); + Ok(()) +} + /// Transform Unconstrained /// /// Inserts the following code at the beginning of an unconstrained function