0xMiden / 0xMiden/rust-sdk

PSwap: Collapse NoteObserver into the existing OnNoteReceived abstraction

Aperta
#2,279 3 commenti 0 reazioni 1 assegnatario Rivendicata da @VAIBHAVJINDAL3012 Vedi su GitHub
Lingua principale
Rust
Stelle
78
Fork
129
Merge medio
4g 14h
PR unite (30g)
52

Descrizione

**Context**

Follow-up from PR #2231 review ([thread](https://github.com/0xMiden/miden-client/pull/2231#discussion_r3376188324)). Quoting @igamigo's approval review:

> I'd want to remove the note observer trait and collapse it into the existing `OnNoteReceived`. The setup feels a bit more complex than it needs to be right now. The alternative could be to remove the traits and hardcode the logic, and try to do a separate PR for making it more generic (e.g., as part of #2209). This way we also reduce the diff.

**Problem**

The PSWAP tracking work introduced a new `NoteObserver` trait (`crates/rust-client/src/sync/note_observer.rs:16`) alongside the pre-existing `OnNoteReceived` screening callback. They overlap: `OnNoteReceived` filters notes, while `NoteObserver` collects filtered notes and applies follow-up logic. This is one abstraction more than necessary.

**Proposed work**

- Fold `NoteObserver`'s responsibilities into `OnNoteReceived` (or a minimal extension of it), removing the standalone trait.
- Re-express `PswapChainObserver` on top of the unified abstraction.
- Alternatively, if a clean unification isn't possible now, hardcode the PSWAP logic and pursue the generic version separately under #2209 — whichever reduces surface area.

**Acceptance criteria**

- [ ] `NoteObserver` trait removed; PSWAP discovery runs through `OnNoteReceived`.
- [ ] No behavioral change to PSWAP lineage tracking (existing `pswap_*` tests stay green).

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Look at crates/rust-client/src/sync/note_observer.rs to understand the NoteObserver trait and its usage in PswapChainObserver. Examine the existing OnNoteReceived abstraction to see how note filtering works. The goal is to merge these responsibilities, ensuring the pswap_* tests continue to pass. Start by running the existing tests to verify current behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
backend
Tipo di issue
Refactoring
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.