0xMiden / 0xMiden/note-transport-service
SendNote is not idempotent — duplicate send returns INTERNAL
- Langage dominant
- Rust
- Étoiles
- 3
- Forks
- 10
- Merge moyen
- 2 h 23 min
- PR mergées (30 j)
- 4
Description
Severity: high (correctness / retry safety).
### Summary
The schema has `id BLOB NOT NULL UNIQUE`, so re-sending the same note hits a UNIQUE constraint. `store_note` maps every error to `Status::internal(format!("Failed to store note: {e:?}"))` (`crates/node/src/node/grpc/mod.rs:197-199`), so a duplicate comes back as `INTERNAL: Failed to store note: ConstraintViolation(...)`.
### Impact
The standard retry-after-timeout pattern (first attempt committed, ack lost) makes the retry fail with a scary internal error. Wallets cannot distinguish "already delivered" from "server broken", which pushes clients toward *not* retrying — bad when this service is the sole holder of the payload. (`note_exists` exists in the DB API but no handler calls it.)
### Recommendation
Catch the `ConstraintViolation` in `send_note` and return `Ok(SendNoteResponse{})` (idempotent success) or `ALREADY_EXISTS`. Document `SendNote` as idempotent on `NoteId`.
---
Part of #114.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Le problème se trouve dans `crates/node/src/node/grpc/mod.rs` autour des lignes 197-199 dans la fonction `store_note`. Cherchez la gestion d'erreur pour la contrainte UNIQUE. La correction consiste à intercepter l'erreur `ConstraintViolation` et à renvoyer une réponse réussie ou un statut `ALREADY_EXISTS`. Consultez l'API de la base de données pour `note_exists` pour comprendre le contexte. Testez en tentant d'envoyer une note en double et en vérifiant la réponse.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Domaine
- backend, databases
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- Calme
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 75/100