Skip to content

feat(api): fast-sync CAS content gateway over HTTP (#115)#123

Merged
LiranCohen merged 1 commit into
mainfrom
feat/fastsync-cas-gateway
Jun 9, 2026
Merged

feat(api): fast-sync CAS content gateway over HTTP (#115)#123
LiranCohen merged 1 commit into
mainfrom
feat/fastsync-cas-gateway

Conversation

@LiranCohen

Copy link
Copy Markdown
Contributor

Summary

Option B of the fast-sync overlay (epic #111), reframed for web/browser wallets that can't speak Bitcoin P2P: an optional, IPFS-free, self-verifying content endpoint.

  • GET /fastsync/cas/<cid> — backed by a CASGateway (the node's CAS). CORS-open (the data is public and content-addressed, nothing to protect), OPTIONS preflight, GET-only, 404 on not-found, immutable Cache-Control (content is immutable by CID), bounded to 4 MiB.
  • Mounted only when WithCASGateway is set (like /stats); enabled by --serve-fast-sync on the serve command.

A client MUST verify multihash(body) == cid, so this is a trustless IPFS replacement — the node serving it doesn't have to be trusted. It's also the cure for the IPFS-unpinning availability gap we observed live (pendingRetryable).

Why CAS first / what's next

serve and start run as separate processes. The /fastsync/anchors endpoint reads the bundle store, which is bbolt (single-process lock) from #113 — so it needs the bundle store moved into the concurrent-safe main store first. That's the next slice. CAS-by-CID needs only the filesystem CAS + cas client, so it ships cleanly now and delivers the primary web-wallet value immediately.

Both endpoints will share the transport-agnostic serving core with Option C (#122, native P2P via vendored btcd wire).

Tests

TestFastSyncCASGateway: present CID → 200 + CORS + body; missing → 404; OPTIONS → 204; POST → 405; route absent without a gateway.

go test -race ./... green (28 packages).

Post-Deploy Monitoring & Validation

  • What to watch: with --serve-fast-sync, serve logs the gateway endpoint at startup. GET /fastsync/cas/<cid> returns content the node holds in its CAS cache. Web wallets get an IPFS-free, CORS-open content source.
  • Failure signal / trigger: 404 for a CID the node should hold → CAS cache miss (content not yet fetched); 502 → upstream CAS/IPFS error.
  • Window/owner: when a serve node runs with --serve-fast-sync.

Part of #111. Advances #115 (CAS slice; anchors endpoint to follow).

🤖 Generated with Claude Code

Option B of the fast-sync overlay (epic #111), reframed for web/browser wallets that
cannot speak Bitcoin P2P. An optional, IPFS-free, self-verifying content endpoint.

- internal/api/resolution.go: GET /fastsync/cas/<cid> backed by a CASGateway (the
  node's CAS satisfies it). CORS-open (the data is public + self-verifying, so there
  is nothing to protect), OPTIONS preflight, GET-only, 404 on not-found via
  cas.ErrNotFound, immutable Cache-Control (content-addressed). Bounded to 4 MiB.
  Mounted only when WithCASGateway is set (like /stats).
- internal/config + cmd/ion-node: --serve-fast-sync enables the gateway on `serve`.

A client MUST verify sha256/multihash(body) == the CID, so this is a trustless IPFS
replacement, not a trusted source. The /fastsync/anchors endpoint needs the bundle
store moved into the concurrent-safe main store first (serve and start are separate
processes; the #113 bbolt store takes a single-process lock) — that lands next.

Shares the eventual transport-agnostic serving core with Option C (#122, native P2P).

Test: TestFastSyncCASGateway — present cid 200 + CORS + body; missing 404; OPTIONS
204; POST 405; route absent without a gateway. go test -race ./... green.

Co-authored-by: Liran Cohen <liranlasvegas@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LiranCohen LiranCohen merged commit 4d7c830 into main Jun 9, 2026
1 check passed
@LiranCohen LiranCohen deleted the feat/fastsync-cas-gateway branch June 9, 2026 02:18
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.

1 participant