Skip to content

Commit 15c7a1e

Browse files
authored
chore: clarify scope of packable impl detection (#24820)
Just a comment.
1 parent 4994006 commit 15c7a1e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • noir-projects/aztec-nr/aztec/src/macros

noir-projects/aztec-nr/aztec/src/macros/notes.nr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ comptime fn generate_note_properties(s: TypeDefinition) -> Quoted {
186186
let note_type_name = $note_type_name;
187187
let fields_packed_len: u32 = $accumulated_offset;
188188
let note_packed_len: u32 = <$typ as aztec::protocol::traits::Packable>::N;
189+
// We only reject custom Packable layouts whose total packed length differs from the derived
190+
// layout's. A hand-written pack() that keeps the same total length but reorders same-width fields
191+
// is deliberately not caught: the selectors are computed from declared field order and would
192+
// silently point at the wrong packed slot. Detecting it would require knowing whether Packable was
193+
// derived or hand-written, which comptime cannot currently tell us. Custom layouts must define their
194+
// PropertySelectors manually.
189195
std::static_assert(
190196
fields_packed_len == note_packed_len,
191197
f"{note_type_name}'s auto-generated note properties assume the #[derive(Packable)] layout ({fields_packed_len} fields), but its hand-written Packable packs to {note_packed_len}. Derive Packable, or define property selectors manually for the custom layout. See https://docs.aztec.network/errors/15",

0 commit comments

Comments
 (0)