When a note with a custom implementation of NoteInterface::get_note_type_id does not return the value as is set by macros then the code becomes broken in multiple places:
compute_note_hash_and_optionally_a_nullifier function uses an incorrect id and the code panics as a result,
- note type id in the TS artifact is incorrect which can cause various issues in tests etc.
This is caused by the fact that in the macros we use the counter value and not the one from the custom impl.:
pub comptime fn note_custom_interface(s: StructDefinition) -> Quoted {
let (packable_impl, note_packed_len) = derive_packable_if_not_implemented_and_get_len(s);
**let note_type_id = get_next_note_type_id()**;
let (indexed_fixed_fields, indexed_nullable_fields) = index_note_fields(s, &[]);
register_note(
s,
note_packed_len,
**note_type_id**,
indexed_fixed_fields,
indexed_nullable_fields,
);
...
}
I don't think we can get a hold of the note type id here because the function is comptime and hence we cannot call the runtime NoteInterface::get_note_type_id function here.
I don't really see a value of letting the user define custom get_note_type_id function so I would say trying to rethink the interface would make sense.
The #[note_custom_interface] macro is not really used much which is the reason why we have not stumbled upon this yet.
When a note with a custom implementation of
NoteInterface::get_note_type_iddoes not return the value as is set by macros then the code becomes broken in multiple places:compute_note_hash_and_optionally_a_nullifierfunction uses an incorrect id and the code panics as a result,This is caused by the fact that in the macros we use the counter value and not the one from the custom impl.:
I don't think we can get a hold of the note type id here because the function is comptime and hence we cannot call the runtime
NoteInterface::get_note_type_idfunction here.I don't really see a value of letting the user define custom
get_note_type_idfunction so I would say trying to rethink the interface would make sense.The
#[note_custom_interface]macro is not really used much which is the reason why we have not stumbled upon this yet.