[Backend] handleTokensWithdrawn increments withdrawnAmount before the dedup guard - replay/reset double-counts and corrupts claimable
I maintainer di solito rispondono entro 7 giorni
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0
Labels: bug, backend, Stellar Wave, database, critical
The withdrawn-amount update runs before the dedup check, so replaying events under-pays recipients.
soroban-event-worker.ts:631-641 computes newWithdrawnAmount = BigInt(stream.withdrawnAmount) + BigInt(amount) and calls tx.stream.update unconditionally. The dedup check at line 643 only guards inserting the StreamEvent row, not the financial field. So when the admin POST /v1/admin/indexer/replay resets the cursor and re-polls the same ledgers, every replay adds amount again even though the StreamEvent row is skipped. withdrawnAmount inflates, claimable shrinks, and the recipient is short-changed. The replay endpoint's Swagger doc even claims it's idempotent.
What the fix has to hold to
- The stream's
withdrawnAmountonly changes when theStreamEventrow is newly created, in the same transaction - Replay/reset is genuinely idempotent
Done when
-
withdrawnAmountupdate is idempotent (mutate only on a newStreamEventinsert, same tx) - Test processes the same
tokens_withdrawnevent twice and assertswithdrawnAmountchanges once -
handleStreamCancelled/handleStreamCompletedaudited to confirm they stay idempotent - Tests + lint pass, CI green
Where to start
backend/src/workers/soroban-event-worker.ts for the ordering fix; indexerService.ts and admin.routes.ts are listed for the replay path and audit. On-chain event schema is out of scope. Medium.
- Lingua principale
- TypeScript
- Stelle
- 18
- Fork
- 250
- Merge medio
- 5g 6h
- PR unite (30g)
- 82
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di LabsCrypt/flowfi
-
backend points: 150 testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 7 giorni
-
backend points: 150 testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 7 giorni
-
backend points: 150 testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 7 giorni
-
backend points: 150 testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 7 giorni
-
backend points: 150 testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 7 giorni
Tutte le issue di LabsCrypt/flowfi
Issue simili
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
openclaw/openclaw#182077 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
aikido high security
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
dequelabs/axe-linter-action#161 ·
-
[Feature Request] Update the DimCode agent icon to the 45:32 brand markForse già presa @eric8810 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Feature]: 建议导入源后,自动切换到新导入的源Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
lyswhut/lx-music-desktop#3026 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
abhigyanpatwari/GitNexus#3704 ·
I maintainer di solito rispondono entro 1 giorno