feat(api): fast-sync CAS content gateway over HTTP (#115)#123
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aCASGateway(the node's CAS). CORS-open (the data is public and content-addressed, nothing to protect), OPTIONS preflight, GET-only,404on not-found, immutableCache-Control(content is immutable by CID), bounded to 4 MiB.WithCASGatewayis set (like/stats); enabled by--serve-fast-syncon theservecommand.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
serveandstartrun as separate processes. The/fastsync/anchorsendpoint 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
--serve-fast-sync,servelogs 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.servenode runs with--serve-fast-sync.Part of #111. Advances #115 (CAS slice; anchors endpoint to follow).
🤖 Generated with Claude Code