Skip to content

[Backend] Two indexers run concurrently - soroban-indexer.service + soroban-event-worker race on the same rows and double-count withdrawnAmount #801

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Why this matters

index.ts:32 calls sorobanIndexerService.start() AND index.ts:33 startWorkers() starts SorobanEventWorker; both poll STREAM_CONTRACT_ID and write Stream/StreamEvent. Both WITHDRAWN handlers READ-then-ADD withdrawnAmount (soroban-indexer.service.ts:216 and soroban-event-worker.ts:631) in separate transactions, so when both fetch the same new event before either commits, the increment is applied twice -> inflated withdrawnAmount -> wrong claimable. The legacy service also keeps cursor in-memory and ignores IndexerState.

Acceptance criteria

  • Remove sorobanIndexerService.start()/stop() from index.ts so only SorobanEventWorker indexes events
  • Delete or disable services/soroban-indexer.service.ts
  • Add a regression test asserting only one indexer instance polls the contract
  • Verify withdrawnAmount is not double-incremented when the same WITHDRAWN event is observed

Files to touch

  • backend/src/index.ts
  • backend/src/services/soroban-indexer.service.ts
  • backend/src/workers/soroban-event-worker.ts

Out of scope

  • Contract-side changes
  • Frontend indexer status UI

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksbugSomething isn't workingcriticaldatabasePostgreSQL / Prisma

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions