Repository navigation
feat(hyperliquid): one lossless gateway client for both data services - #698
Conversation
… made-up empty blocks A block missing from the gateway stream was filled in with an empty block timestamped 1970. The stream can lose blocks when the consumer lags behind the subscription buffer, so such a block is not known to be empty. A gap now fails the stream; the data service restarts it from its head, and the new subscription delivers the block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ehaviour Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New @subsquid/hyperliquid-gateway-client: GatewayStream reads a hyperliquid-gateway-proxy block subscription through rpc-client and delivers every block exactly once, in order. - A consumer that lags by --gateway-block-queue-size blocks closes the subscription instead of dropping its oldest block; it is reopened after the last buffered block once the consumer takes them. The default threshold is now 1000. - Blocks are numbered by their own number (fills block_number, replica height). A replay after a reopen is skipped; a skipped block reopens the subscription at it, never filled in. - Silence and staleness watchdogs and failure handling as in the fills data service: a failure before the first block fails the stream, later ones reopen it. The fills data service keeps the staleness watchdog. The replica data service no longer numbers blocks by counting from the requested one, so a replayed or skipped block can no longer be misnumbered; it keeps its parent_round check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s not fail the range Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…client # Conflicts: # hyperliquid/hyperliquid-fills-data-service/src/data-source/data-source.ts
…e shared client Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The stream can emit blocks beyond the requested upper bound, continue buffering after cancellation, and remain frozen indefinitely when repeated notifications bypass staleness checks.
3 open issues
1 file not reviewed
common/config/rush/pnpm-lock.yaml: Generated file
What changed in this PR
Replaces duplicated Hyperliquid gateway readers with a shared lossless client, following up on #696’s gap-handling fix.
Changes:
- Adds ordered streaming with replay filtering, bounded buffering, resubscription, watchdogs, and cancellation.
- Migrates both data services, uses replica block heights, and raises the queue default to 1000.
- Adds regression tests and updates package registration, dependencies, and release records.
| File | Description |
|---|---|
| rush.json | Registers the shared client. |
| hyperliquid/hyperliquid-replica-cmds-data-service/src/main.ts | Updates queue default and help. |
| hyperliquid/hyperliquid-replica-cmds-data-service/src/data-source/setup.ts | Configures height-based gateway streaming. |
| hyperliquid/hyperliquid-replica-cmds-data-service/src/data-source/gateway.ts | Removes duplicated reader. |
| hyperliquid/hyperliquid-replica-cmds-data-service/src/data-source/data-source.ts | Integrates shared streaming; preserves round checks. |
| hyperliquid/hyperliquid-replica-cmds-data-service/src/data-source/data-source.test.ts | Adds replica regression coverage. |
| hyperliquid/hyperliquid-replica-cmds-data-service/package.json | Adds client dependency and testing. |
| hyperliquid/hyperliquid-gateway-client/tsconfig.json | Configures TypeScript compilation. |
| hyperliquid/hyperliquid-gateway-client/src/stream.ts | Implements shared subscription handling. |
| hyperliquid/hyperliquid-gateway-client/src/stream.test.ts | Tests recovery, buffering, and watchdogs. |
| hyperliquid/hyperliquid-gateway-client/src/index.ts | Exports the client API. |
| hyperliquid/hyperliquid-gateway-client/package.json | Defines the new package. |
| hyperliquid/hyperliquid-fills-data-service/src/main.ts | Updates queue default and help. |
| hyperliquid/hyperliquid-fills-data-service/src/data-source/setup.ts | Configures shared streaming and staleness checks. |
| hyperliquid/hyperliquid-fills-data-service/src/data-source/gateway.ts | Removes duplicated reader. |
| hyperliquid/hyperliquid-fills-data-service/src/data-source/gateway.test.ts | Removes tests ported to shared client. |
| hyperliquid/hyperliquid-fills-data-service/src/data-source/data-source.ts | Delegates ordering and bounds to client. |
| hyperliquid/hyperliquid-fills-data-service/src/data-source/data-source.test.ts | Updates integration regression tests. |
| hyperliquid/hyperliquid-fills-data-service/package.json | Adds shared client dependency. |
| common/config/rush/repo-state.json | Updates shrinkwrap hash. |
| common/config/rush/pnpm-lock.yaml | Records dependency changes. |
| common/changes/@subsquid/hyperliquid-replica-cmds-data-service/hl-gateway-client_2026-12-04-00-00.json | Records replica service changes. |
| common/changes/@subsquid/hyperliquid-gateway-client/hl-gateway-client_2026-12-04-00-00.json | Records the new client. |
| common/changes/@subsquid/hyperliquid-fills-data-service/hl-gateway-client_2026-12-04-00-00.json | Records fills service changes. |
Review effort: Balanced
…ort while busy - following the head with an end below it returns nothing instead of a block past the end - replayed notifications count for the staleness watchdog, so a subscription stuck replaying an old block is reopened - an abort closes the subscription at once, even while the reader is busy with a batch, and an already aborted signal opens none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The overflow branch can create a replacement subscription after onResubscribe aborts the signal, allowing it to keep receiving despite cancellation.
1 open issue
3 resolved since last review
1 file not reviewed
common/config/rush/pnpm-lock.yaml: Generated file
Review effort: Balanced
…is checked Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reopen after an abort - the silence timer is reset only by a new block, so a subscription that keeps replaying blocks already delivered is reopened instead of holding the stream forever - a subscription is never opened once the signal is aborted, including by an onResubscribe hook Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The replay-staleness test can pass despite a staleness regression because the silence watchdog fires first; its silence threshold should exceed the replay loop duration.
1 open issue
1 resolved since last review
1 file not reviewed
common/config/rush/pnpm-lock.yaml: Generated file
Review effort: Balanced
…e stale watchdog itself Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # hyperliquid/hyperliquid-fills-data-service/src/data-source/data-source.test.ts # hyperliquid/hyperliquid-fills-data-service/src/data-source/data-source.ts



Stacked on #696.
The fills and replica-cmds data services each carried a copy of a gateway subscription reader. The copies had drifted apart:
This replaces both copies with one reader,
GatewayStream, in a new package,@subsquid/hyperliquid-gateway-client. The archive ingests will move to it in a follow-up.GatewayStreamblock_numberfor fills,heightfor replica).blockBufferSizeblocks, the subscription is closed instead of dropping blocks. It is reopened after the last buffered block once the consumer takes them. A slow consumer now costs a resubscribe, logged at warn level, not lost blocks.retryDelay, up to an optionalmaxFailuresin a row.tobound, abort signal, andonResubscribe(reason)hook.Data services
height, so a replayed or skipped block can no longer be misnumbered;parent_roundcheck stays, now with a message;gateway_getBlockFills.--gateway-block-queue-size: keeps its name. It is now the lag that triggers a resubscribe, and its default goes from 10 to 1000: with resubscribe semantics, 10 would resubscribe on every small hiccup.Tests
maxFailures; failure before the first block; invalid notifications.from, repeated block.Local
rush buildand the tests of all three packages pass. Arush deployof the replica data service picks up the new package.🤖 Generated with Claude Code