Repository navigation
feat(hyperliquid): the archive ingests read the gateway through the shared client - #699
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>
A subscription with `raw: true` gets each notification's `result` also as the exact text received, so a caller can store it byte for byte. The WebSocket transport passes the frame text, taken before fixUnsafeIntegers rewrites it, along with single notifications; a small string-aware scanner finds params.result in any key order and copies the slice so it does not keep the frame alive. Batch frames carry no text; a raw subscription gets an error for a notification in one. Subscriptions without `raw` are unchanged. 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' into feat/hl-ingests-gateway-client
…hared client GatewayRangeStream, a direct ws client with its own extraction of the result text, is replaced by RawGateway: a bounded reader over @subsquid/hyperliquid-gateway-client with `raw: true`, which takes each result's exact text from rpc-client. A slow rescue now costs a resubscribe instead of a paused socket; maxFailures and the silence timeout carry over. One change of behaviour: a subscription that fails before its first block fails the rescue at once; the recovery retries the range after its retry delay, as for any failed rescue. 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
When the gateway is unreachable, timed-out or aborted recovery streams leave subscription calls queued because closing the handle cannot cancel them before an ID arrives. The shared client keeps reconnecting during cooldown, so repeated failed rescues accumulate pending subscriptions. Separately, the default 1,000-block buffer retains full parsed blocks alongside raw JSON even though RawGateway discards the parsed values, unnecessarily increasing memory use while uploads delay consumption.
2 open issues
What changed in this PR
Moves both Hyperliquid archive ingests onto the shared gateway client, consolidating subscription handling while preserving raw block text.
Changes:
- Adds opt-in raw notification text to RPC subscriptions and gateway streams.
- Replaces
GatewayRangeStreamwithRawGatewayfor archive rescues. - Updates integration tests, dependencies, and release notes.
| File | Description |
|---|---|
| util/rpc-client/src/transport/ws.ts | Preserves original notification frame text. |
| util/rpc-client/src/subscriptions.ts | Adds raw subscription delivery. |
| util/rpc-client/src/raw.ts | Extracts exact result text. |
| util/rpc-client/src/raw.test.ts | Tests extraction and raw subscriptions. |
| util/rpc-client/src/client.ts | Forwards text to notification listeners. |
| hyperliquid/hyperliquid-replica-cmds-ingest/src/ingest.ts | Configures RawGateway. |
| hyperliquid/hyperliquid-replica-cmds-ingest/src/fallback.ts | Updates the rescue gateway type. |
| hyperliquid/hyperliquid-replica-cmds-ingest/src/fallback.test.ts | Adapts gateway fixtures. |
| hyperliquid/hyperliquid-gateway-client/src/stream.ts | Adds raw block text support. |
| hyperliquid/hyperliquid-gateway-client/src/stream.test.ts | Tests raw delivery and missing text. |
| hyperliquid/hyperliquid-fills-ingest/src/ingest.ts | Configures RawGateway. |
| hyperliquid/hyperliquid-fills-ingest/src/fallback.ts | Updates the rescue gateway type. |
| hyperliquid/hyperliquid-fills-ingest/src/fallback.test.ts | Adapts gateway fixtures. |
| hyperliquid/hyperliquid-archive-recovery/src/gateway.ts | Replaces the standalone subscription reader. |
| hyperliquid/hyperliquid-archive-recovery/src/gateway.test.ts | Tests shared-client integration. |
| hyperliquid/hyperliquid-archive-recovery/package.json | Adds shared clients; makes ws test-only. |
| common/changes/@subsquid/rpc-client/feat-rpc-client-raw-notifications_2026-12-04-00-00.json | Records raw subscription support. |
| common/changes/@subsquid/hyperliquid-replica-cmds-ingest/hl-ingests-gateway-client_2026-12-04-00-00.json | Records replica ingest migration. |
| common/changes/@subsquid/hyperliquid-gateway-client/hl-ingests-gateway-client_2026-12-04-00-00.json | Records raw block support. |
| common/changes/@subsquid/hyperliquid-fills-ingest/hl-ingests-gateway-client_2026-12-04-00-00.json | Records fills ingest migration. |
| common/changes/@subsquid/hyperliquid-archive-recovery/hl-ingests-gateway-client_2026-12-04-00-00.json | Records the reader replacement. |
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>
…ient # Conflicts: # hyperliquid/hyperliquid-gateway-client/src/stream.ts
…ep only number and raw text Each RawGateway stream opens its own connection and closes it when the stream ends, so a subscribe call still pending on an unreachable gateway does not outlive a failed rescue. The stream's value is now the block number, so buffered blocks hold only their raw text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
When the gateway repeatedly replays blocks below the expected height, those replays reset the silence timer without advancing recovery, and no progress watchdog is enabled. The rescue can therefore wait indefinitely, occupying Recovery’s single job and preventing retries and other rescues.
1 open issue
2 resolved since last review
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 package README still tells users to use GatewayRangeStream and describes socket pausing, but the code now exports RawGateway and resubscribes slow readers instead. The documented API and recovery behavior therefore no longer match the implementation.
1 open issue
1 resolved since last review
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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eway-client # Conflicts: # hyperliquid/hyperliquid-gateway-client/README.md # hyperliquid/hyperliquid-gateway-client/src/stream.test.ts # hyperliquid/hyperliquid-gateway-client/src/stream.ts



Stacked on #698. It also merges in #697 (rpc-client raw text), so until #697 lands, this diff includes it.
This moves the gateway rescues of
hyperliquid-fills-ingestandhyperliquid-replica-cmds-ingest(#693/#694) onto@subsquid/hyperliquid-gateway-client. The subscription readers in the repo are then down to one.Changes
@subsquid/hyperliquid-gateway-client: arawoption. Each block then also carries itsresulttext exactly as received, throughrpc-client's opt-in raw subscriptions (feat(rpc-client): opt-in raw text of subscription results #697). A notification without its text fails the subscription; the value is never re-serialised.@subsquid/hyperliquid-archive-recovery:GatewayRangeStreamand its hand-rolledextractResultare replaced byRawGateway. It is a thin bounded reader: the shared stream withraw: true,maxFailures5 and a 120 s silence timeout.wsdependency goes away;wsis now a test-only dependency.RawGateway. The rescue logic, validation and storage are unchanged.Behaviour changes
Tests
RawGatewayagainst a WebSocket fake gateway: raw text byte for byte, with odd spacing and an unsafe integer; reopen after a lost connection; following the head; a rejected subscription.GatewayRangeStreambehaviours not covered here moved to the gateway client's tests in feat(hyperliquid): one lossless gateway client for both data services #698.🤖 Generated with Claude Code