Repository navigation
fix(worker): ensure idempotent stream completion and event replay handling - #1951
Open
king-daveed wants to merge 2 commits into
Open
king-daveed wants to merge 2 commits into
king-daveed wants to merge 2 commits into
Conversation
The stream_completed handler checked for the duplicate StreamEvent row before updating the stream, which broke the documented replay contract from LabsCrypt#1763: a replayed completion must re-apply the idempotent stream update, surface P2025 when the Stream row is gone, and still broadcast. Restore the update-first ordering and assert the replay behavior in the handler test.
king-daveed
force-pushed
the
fix/tokens-withdrawn-idempotency-802
branch
from
November 24, 2026 14:46
84de818 to
6251b50
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses and resolves #802 by auditing and guaranteeing end-to-end event replay idempotency in the Soroban event indexing subsystem:
Stream Event Replay Idempotency:
backend/src/workers/soroban-event-worker.ts, guardedhandleStreamCompletedwith an upfrontexistingEventduplicate check before executingtx.stream.update, preventing redundant stream mutations on duplicate or replayed events.handleStreamCancelledandhandleTokensWithdrawnto ensure all event handlers check duplicate state in the same transaction as stream mutations.backend/src/services/indexerService.tsconfirming that replay from ledger is fully idempotent across all event types.Testing & Coverage:
backend/tests/soroban-event-worker.test.tsverifying thatstream_completedevent replay does not re-invoketx.stream.updateor duplicate stream events.tokens_withdrawnandstream_topped_upduplicate checks continue to prevent double-incrementingwithdrawnAmountanddepositedAmount.tests/token-registry.service.test.tsandtests/webhook-auth.test.ts.Closes #802