Skip to content

refactor(rust-client): collapse NoteObserver into OnNoteReceived#2322

Open
VAIBHAVJINDAL3012 wants to merge 1 commit into
0xMiden:nextfrom
VAIBHAVJINDAL3012:vaibhav/2279-collapse-note-observer
Open

refactor(rust-client): collapse NoteObserver into OnNoteReceived#2322
VAIBHAVJINDAL3012 wants to merge 1 commit into
0xMiden:nextfrom
VAIBHAVJINDAL3012:vaibhav/2279-collapse-note-observer

Conversation

@VAIBHAVJINDAL3012

Copy link
Copy Markdown
Contributor

Summary

Implements #2279 — folds the standalone NoteObserver trait into the pre-existing OnNoteReceived, removing one abstraction (follow-up from the PR 2231 review).

  • StateSync now holds a single Vec<Arc<dyn OnNoteReceived>> (the screener plus any additional observers) rather than a separate screener + observer list — matching the "list of OnNoteReceived" direction from rust-sdk 2209.
  • on_note_received now takes committed_note / public_note by reference and gains an attachments: Option<&NoteAttachments> parameter; the trait gains defaulted name() and a post-sync apply() method (folded in from NoteObserver).
  • NoteUpdateAction gains an Observe variant — "mark the block relevant, don't store the note" — replacing the observer's old Ok(true) block-relevance signal.
  • When multiple observers vote on a note, verdicts fold by precedence: Commit > Insert > Observe > Discard (first observer at the winning precedence supplies the payload).
  • PswapChainObserver is re-expressed as an OnNoteReceived.

No behavioral change to PSWAP lineage tracking.

@VAIBHAVJINDAL3012

Copy link
Copy Markdown
Contributor Author

There is small discussion required for the following-
In the case of failure while syncing notes, should be abort the sync or just log it and continue.

Fold the standalone NoteObserver trait into OnNoteReceived, removing one abstraction. StateSync now holds a list of OnNoteReceived observers instead of a single screener plus a separate observer list. on_note_received takes the committed/public note by reference and gains the note's attachments; the trait gains defaulted name() and post-sync apply() hooks. NoteUpdateAction gains an Observe variant that marks a block relevant without storing the note; when multiple observers vote, verdicts fold by precedence (Commit > Insert > Observe > Discard). PswapChainObserver is re-expressed as an OnNoteReceived. No behavioral change to PSWAP lineage tracking.

Also extends pswap_multi_round_chain_tracking_test with a private-note case (registering the actual minted round notes), confirming private multi-round lineage tracking works end-to-end.

Attachments are passed as a separate parameter for now; moving them onto CommittedNote is deferred to a follow-up (0xMiden#2118).
@VAIBHAVJINDAL3012
VAIBHAVJINDAL3012 force-pushed the vaibhav/2279-collapse-note-observer branch from 7bec4e2 to 83ceddb Compare July 14, 2026 21:24
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.

1 participant