perf(protocol): stop re-hashing input-note storage on read - #3659
Draft
mmagician wants to merge 1 commit into
Draft
perf(protocol): stop re-hashing input-note storage on read#3659mmagician wants to merge 1 commit into
mmagician wants to merge 1 commit into
Conversation
This was referenced Aug 21, 2026
mmagician
marked this pull request as draft
August 21, 2026 08:24
Base automatically changed from
mmagician-claude/fix-l05-note-storage-count-verify
to
next
August 21, 2026 08:26
The prologue now verifies every input note's storage against its authenticated commitment at load time, so re-computing that commitment on each read is redundant: the advice map rejects rebinding a key to different values, so the preimage returned for the note's storage commitment is the one the prologue verified. Adds a non-hashing `protocol_utils::mem::write_elements_to_memory` and moves the storage copy into `input_note_internal`, shared by `input_note::get_storage`, `active_note::get_storage` and `active_note::get_bounded_storage`. The public `active_note::write_storage_to_memory` is removed rather than left unverified: it took a caller-supplied commitment, so dropping the hash in place would have turned a self-verifying public procedure into one that trusts any word handed to it. Its non-hashing replacement lives in `input_note_internal`, which is a private module, so every caller sources the commitment from prologue-verified kernel memory. The standards wrapper `note::input_note_get_storage` is replaced by the new `input_note::get_storage`, resolving its TODO.
mmagician
force-pushed
the
mmagician-claude/skip-redundant-note-storage-rehash
branch
from
August 21, 2026 13:55
4c24768 to
75e5df3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #3641.
Addresses bobbinth's question on #3641 about recovering the hashing cost elsewhere.
#3641 makes the prologue verify every input note's storage against its authenticated commitment at load time. That makes the re-verification on every read redundant, so reads now copy the storage from the advice map without recomputing its commitment. Two facts make that safe:
NOTE_STORAGE_COMMITMENT-> preimage for every input note, andAdviceProvider::insert_into_mapraisesMapKeyAlreadyPresentinmiden-processor), so the preimage returned for a verified commitment cannot change mid-transaction.protocol_utils::mem::write_elements_to_memoryis the non-hashing counterpart ofpipe_elements_preimage_to_memory: the sameadv_pipecopy, without the Poseidon2 permutations.active_note::write_storage_to_memoryis removed rather than left unverified. It took a caller-supplied commitment, so dropping the hash in place would have turned a self-verifying public procedure into one that trusts any word handed to it. Both of its callers source the commitment from prologue-verified kernel memory, so they move to a newinput_note::get_storage, which also resolves theTODO: Move this to miden::protocol::input_noteon the standards wrapper.The other candidate — having the prologue write the preimage into note memory so readers just copy it — is not viable:
MAX_NOTE_STORAGE_ITEMS(1024) xMAX_INPUT_NOTES_PER_TX(1024) is up to ~1M elements of kernel memory, which is why the prologue writes to procedure locals and discards them.🤖 Generated with Claude Code
https://claude.ai/code/session_015bLUPBgD8T6Edt2141yrvQ