From 099c17b0c83ef5c0b4368ce2167d3d5422fa0c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Thu, 9 Jan 2025 18:36:07 -0300 Subject: [PATCH] fix: max_note_len computation (#10438) We were simply adding all note lengths instead of finding the largest one, resulting in an unncessarily large array. I couldn't think of a simple and robust way to write a test for this so I just didn't, but I did check manually that it does what you'd expect. --- noir-projects/aztec-nr/aztec/src/macros/mod.nr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/noir-projects/aztec-nr/aztec/src/macros/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/mod.nr index 883a2028326..aa688409088 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/mod.nr @@ -114,7 +114,11 @@ comptime fn generate_compute_note_hash_and_optionally_a_nullifier() -> Quoted { max_note_length = notes.fold( 0, |acc, (_, (_, len, _, _)): (Type, (StructDefinition, u32, Field, [(Quoted, u32, bool)]))| { - acc + len + if len > acc { + len + } else { + acc + } }, );