Skip to content

Use type system to skip "note has been inserted" check #8589

@benesjan

Description

@benesjan

In compute_raw_note_log function we check whether a note hash of a note for which we are computing log for was already inserted:

    let note_exists = context.note_hashes.storage.any(|n: NoteHash| n.counter == note_hash_counter);
    assert(note_exists, "Can only emit a note log for an existing note.");

This costs gates and it should not be necessary because we have the information of whether a note has been inserted "somewhere else" in the codebase. One way how we could communicate that the note hash has indeed been inserted is to use the type system and wrap a note that has been inserted in smt. like InsertedNote struct.

Note: The only relevant place where we insert the note hash is in the create_note function in lifecycle.nr so wrapping the note there should be enough.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions