Skip to content

fix: support --serve-info nodes via ABCI state fallback#11

Open
yangwao wants to merge 29 commits intohyperliquid-dex:mainfrom
yangwao:fix/serve-info-snapshot-fallback
Open

fix: support --serve-info nodes via ABCI state fallback#11
yangwao wants to merge 29 commits intohyperliquid-dex:mainfrom
yangwao:fix/serve-info-snapshot-fallback

Conversation

@yangwao
Copy link
Copy Markdown

@yangwao yangwao commented Mar 8, 2026

Summary

Fixes #1 — the order book server crashes with Listener fatal error: No such file or directory (os error 2) when the node is started with --serve-info, because the fileSnapshot API endpoint is not available.

  • Fallback snapshot source: When the fileSnapshot API fails (HTTP 422 from --serve-info nodes, or connection errors), the server now falls back to reading the latest periodic ABCI state .rmp file from hl/data/periodic_abci_states/ and computing L4 snapshots via hl-node --chain <chain> compute-l4-snapshots --include-users
  • Non-fatal error handling: Snapshot fetch/validation errors no longer crash the listener — errors are logged and the server retries on the next 10-second tick
  • Configurable via env vars: HL_NODE_PATH (default: hl-node on PATH) and HL_CHAIN (default: Mainnet)

How it works

  1. process_rmp_file() first tries the existing fileSnapshot API (backwards compatible with full nodes)
  2. If the API fails, it finds the latest .rmp in periodic_abci_states/{date}/ by block height
  3. Runs hl-node compute-l4-snapshots --include-users <rmp_path> <output_path>
  4. Wraps the CLI output (which lacks a height prefix) as [height, data] to match the fileSnapshot format
  5. The height is extracted from the .rmp filename (e.g., 917510000.rmp → height 917510000)

Setup for Docker

The hl-node binary needs to be accessible to the order book server container. Options:

  • Share it via a volume mount from the node container
  • Set HL_NODE_PATH to point to the binary location

Test plan

  • cargo check — compiles cleanly with no warnings
  • cargo test — all 10 tests pass
  • Verified fallback works with a --serve-info node that has periodic ABCI state files on disk
  • Verified backwards compatibility with full nodes (API path still works)

🤖 Generated with Claude Code

yangwao and others added 27 commits March 8, 2026 20:35
…e snapshots

The `fileSnapshot` API endpoint is not available when the node is started
with `--serve-info`, causing the order book server to crash with
"No such file or directory" (issue hyperliquid-dex#1).

This adds a fallback: when the API returns an error, the server reads the
latest `.rmp` file from `periodic_abci_states/` and uses `hl-node
compute-l4-snapshots` to generate the L4 snapshot JSON. The `hl-node`
binary path and chain can be configured via `HL_NODE_PATH` and `HL_CHAIN`
environment variables.

Additionally, snapshot fetch errors are now non-fatal — the listener logs
the error and retries on the next tick instead of crashing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r waits until it exits when there is no new data
Handles special addresses (Assistance Fund 0xFE, HIP-2 0xFF) that don't
emit order_status events by creating synthetic Alo Limit order entries.
Removes the spot coin subscription filter. Opt-in via --include-spot-unsafe
CLI flag since the order type assumption is an approximation.

Cherry-picked from hyperliquid-dex#10.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When running in separate Docker containers, the node and OBS have
isolated filesystems. The fileSnapshot API writes to an outPath on the
node's filesystem, but the OBS tries to read it from its own. By using
a path inside the shared volume (hl/out.json), both containers can
access the same file.

The CLI fallback still writes to the local filesystem since hl-node
runs as a subprocess of the OBS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yangwao
Copy link
Copy Markdown
Author

yangwao commented Mar 8, 2026

I made docker hub image for hyperliquid order book server if it helps someone

yangwao and others added 2 commits March 17, 2026 16:20
…etches

The fileSnapshot API was hitting port 3001 but the node serves on 4001.
Added a 30s timeout to the reqwest client so the OBS falls back quickly
when the node is unavailable instead of hanging indefinitely. Also added
an AtomicBool guard to prevent the 10s ticker from spawning overlapping
fetch_snapshot tasks that pile up hl-node subprocesses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port 4001 is the binary gossip protocol, not HTTP. The info API
(--serve-info) listens on port 3001.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Listener fatal error: No such file or directory (os error 2)

3 participants