refactor: simplify MockChainNote to always hold full note details#2764
Open
giwaov wants to merge 1 commit into0xMiden:nextfrom
Open
refactor: simplify MockChainNote to always hold full note details#2764giwaov wants to merge 1 commit into0xMiden:nextfrom
giwaov wants to merge 1 commit into0xMiden:nextfrom
Conversation
Refactor MockChainNote from an enum with Public/Private variants into a struct that always stores the full Note alongside its NoteInclusionProof. Previously, private notes in the mock chain only stored their NoteId and NoteMetadata, discarding the rest of the note details during block application. This was because the proving step shrinks private notes to headers, losing the full note data. Now, full note details are extracted from ExecutedTransaction before proving and stored in a known_notes map on MockChain. When apply_block processes output notes, it looks up non-Full notes from this map to ensure MockChainNote always contains complete note information. Key changes: - MockChainNote: enum -> struct with note + inclusion_proof fields - TryFrom<MockChainNote> for InputNote -> From (infallible conversion) - Simplified serialization (no discriminant byte needed) - Added known_notes field to MockChain for pre-prove note extraction - Renamed get_public_note -> get_note (all notes now have full details) Closes 0xMiden#2307
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.
Description
Refactors
MockChainNotefrom an enum withPublic/Privatevariants into a struct that always stores the fullNotealongside itsNoteInclusionProof.Problem
Previously, private notes in the mock chain only stored their
NoteIdandNoteMetadata, discarding the rest of the note details during block application. This happened because the proving step shrinks private notes to headers, losing the full note data. ThePublic/Privatedistinction was misleading since even private notes added viaMockChainBuilderwere treated asPublic(because they arrive asOutputNote::Full).Solution
MockChainNotefrom an enum to a struct withnote: Noteandinclusion_proof: NoteInclusionProoffieldsknown_notes: BTreeMap<NoteId, Note>field toMockChainthat captures full note details fromExecutedTransactionbefore proving strips themapply_block, non-Full output notes are looked up fromknown_notesto ensureMockChainNotealways contains complete note informationTryFrom<MockChainNote> for InputNotetoFrom(infallible, since full note is always available)get_public_notetoget_notesince all notes now have full detailsFiles Changed
crates/miden-testing/src/mock_chain/note.rs- Core refactoring ofMockChainNotecrates/miden-testing/src/mock_chain/chain.rs-known_notesfield, updatedapply_blockandadd_pending_executed_transactioncrates/miden-testing/src/kernel_tests/batch/proposed_batch.rs- Updatedget_public_note->get_notecrates/miden-testing/src/kernel_tests/tx/test_tx.rs- Updatedget_public_note->get_noteCloses #2307