0xMiden/protocol

Refactor `MockChainNote` to always hold the full note details

Open

#2 307 ouverte le 19 janv. 2026

Voir sur GitHub
 (4 commentaires) (0 réactions) (1 assigné)Rust (139 forks)github user discovery
good first issuetests

Métriques du dépôt

Stars
 (123 stars)
Métriques de merge PR
 (Merge moyen 5j 11h) (110 PRs mergées en 30 j)

Description

In tests, when we want to add a Private note at genesis, we do:

let input_note = builder.add_p2id_note(
    account.id(),
    account.id(),
    &[FungibleAsset::mock(0)],
    NoteType::Private,
)?;

and then inside of add_p2id_note, we add the note as self.add_output_note(OutputNote::Full(note.clone())); to the MockChainBuilder.

This is fine, but it causes MockChain::apply_block to later treat these notes always as Public:

  if let OutputNote::Full(note) = created_note {
      self.committed_notes
          .insert(note.id(), MockChainNote::Public(note.clone(), note_inclusion_proof));
  } else {

The current implementation (and as an extension, this PR) doesn't seem to cause issues, I think because even the MockChainNote::public but wrapping a private note contains the correct underlying note details (i.e. `note.metadata().is_private() will still be correct).

But this makes me realize that maybe the MockChainNote struct doesn't really serve its purpose and should be refactored (e.g. to always hold the full note details).

Originally posted by @mmagician in https://github.com/0xMiden/miden-base/pull/2205#discussion_r2672135301

Guide contributeur