Skip to content

refactor: simplify MockChainNote to always hold full note details#2764

Open
giwaov wants to merge 1 commit into0xMiden:nextfrom
giwaov:refactor/mock-chain-note-2307
Open

refactor: simplify MockChainNote to always hold full note details#2764
giwaov wants to merge 1 commit into0xMiden:nextfrom
giwaov:refactor/mock-chain-note-2307

Conversation

@giwaov
Copy link
Copy Markdown
Contributor

@giwaov giwaov commented Apr 14, 2026

Description

Refactors MockChainNote from an enum with Public/Private variants into a struct that always stores the full Note alongside its NoteInclusionProof.

Problem

Previously, private notes in the mock chain only stored their NoteId and NoteMetadata, 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. The Public/Private distinction was misleading since even private notes added via MockChainBuilder were treated as Public (because they arrive as OutputNote::Full).

Solution

  • Changed MockChainNote from an enum to a struct with note: Note and inclusion_proof: NoteInclusionProof fields
  • Added a known_notes: BTreeMap<NoteId, Note> field to MockChain that captures full note details from ExecutedTransaction before proving strips them
  • In apply_block, non-Full output notes are looked up from known_notes to ensure MockChainNote always contains complete note information
  • Changed TryFrom<MockChainNote> for InputNote to From (infallible, since full note is always available)
  • Simplified serialization by removing the discriminant byte
  • Renamed get_public_note to get_note since all notes now have full details

Files Changed

  • crates/miden-testing/src/mock_chain/note.rs - Core refactoring of MockChainNote
  • crates/miden-testing/src/mock_chain/chain.rs - known_notes field, updated apply_block and add_pending_executed_transaction
  • crates/miden-testing/src/kernel_tests/batch/proposed_batch.rs - Updated get_public_note -> get_note
  • crates/miden-testing/src/kernel_tests/tx/test_tx.rs - Updated get_public_note -> get_note

Closes #2307

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor MockChainNote to always hold the full note details

1 participant