Skip to content

[Backend] Stream.streamId / StreamEvent.streamId typed Int (int4) but on-chain IDs are u64 - overflow/insert failure #829

Description

@grantfox-oss

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

Labels: bug, backend, Stellar Wave, database, critical

Stream IDs are u64 on chain but Int in the database, so any large ID crashes the indexer.

schema.prisma:30 types streamId Int @unique and :70 types StreamEvent.streamId Int, both of which map to Postgres int4 (max 2,147,483,647). The contract keys streams by u64 (types.rs:25, events.rs:9) and the worker stores Number(decodeU64(...)) at soroban-event-worker.ts:438. Once a stream_id goes past int4 max, the insert fails with "value out of range for type integer", which blows up the indexer transaction and drops the stream along with all its events.

What the fix has to hold to

  • Stream.streamId, StreamEvent.streamId and the relation reference are BigInt
  • The on-chain identifier type stays as it is
  • A u64 id above 2^31 survives a full round-trip through the worker

Done when

  • streamId columns and the FK relation changed to BigInt
  • migration added to convert the columns and FK
  • test covering a u64 stream id > 2^31 persisting through the worker
  • tests + CI green

Where to start
backend/prisma/schema.prisma for the type change plus a migration, and backend/src/workers/soroban-event-worker.ts where the value is decoded and stored. Changing the on-chain identifier type is out of scope. Watch for other spots that read streamId as a JS Number.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Stellar WaveIssues in the Stellar wave programbackendBackend related tasksbugSomething isn't workingcriticaldatabasePostgreSQL / Prisma

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions