feat(#91): ChainExchange client — gateway-free header-chain fetch#110
Open
Reiers wants to merge 1 commit into
Open
feat(#91): ChainExchange client — gateway-free header-chain fetch#110Reiers wants to merge 1 commit into
Reiers wants to merge 1 commit into
Conversation
…r libp2p Adds the requesting half of /fil/chain/xchg/0.0.1 (the responder landed in #17). A bridge-off Lantern (#76, --no-fallback-rpc) can now backfill a gossip head+N gap by pulling the whole verified header chain from a real Filecoin peer in ONE request, with zero upstream RPC (no Glif, no gateway). This is Stage A of the snapshot-free full-node epic (#87). net/chainxchg/client.go - Client.FetchTipsetChain(head, length): headers-only request, walks parent-ward newest->oldest. Handwritten CBOR both directions (same zero-dependency policy as the responder), cross-checked against Lotus chain/exchange cbor_gen layout. - Trust model: every header CID-verified; level 0 must equal the requested head set, each deeper level must equal the previous level's Parents, heights strictly decreasing. Caller derives head from already-verified data (a gossip block's Parents / the quorum anchor), so a malicious peer can only refuse, never splice. - Partial (101) responses accepted; NotFound (201)/GoAway (202) fail that peer and rotate to the next. Bounded response read (32 MiB), peer cap, trusted-floor-first peer ordering, observable ClientStats. net/blockingest/blockingest.go - ChainFetcher interface + SetChainFetcher: in parent-walk (bridge-off) mode the ingestor prefers ONE ChainExchange request over the per-CID bitswap walk, falling back to the walk on error (or surfacing the error when there is no per-CID source). net/chainxchg/client_test.go - Two-host libp2p harness: happy path, partial, NotFound, spliced-chain rejection, no-peers. Full suite green, build+vet+fmt clean. Stacks on feat/108-no-fallback-rpc (#76 scaffolding). Server-side chain serving remains a separate follow-up.
This was referenced Jul 2, 2026
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.
Closes the client half of #91 (Stage A of #87). The responder side landed in #17; this adds the requester so a bridge-off Lantern (#76, `--no-fallback-rpc`) can backfill a gossip head+N gap by pulling the whole CID-verified header chain from a real Filecoin peer in ONE request — zero upstream RPC (no Glif, no gateway).
What's in
net/chainxchg/client.go—Client.FetchTipsetChain(head, length), headers-only, parent-ward. Handwritten CBOR both directions (zero-dep, cross-checked vs Lotuschain/exchangecbor_gen). Trust model: every header CID-verified, level 0 == requested head set, each deeper level == previous level'sParents, heights strictly decreasing → a bad peer can only refuse, never splice. Partial(101) accepted; NotFound(201)/GoAway(202) rotate to next peer. Bounded 32 MiB read, peer cap, trusted-floor-first ordering,ClientStats.net/blockingest/blockingest.go—ChainFetcherinterface +SetChainFetcher; parent-walk (bridge-off) mode prefers one ChainExchange request over the per-CID bitswap walk, falling back on error.net/chainxchg/client_test.go— two-host libp2p harness: happy path, partial, NotFound, spliced-chain rejection, no-peers.Evidence
go build ./...OKgo vet ./net/chainxchg/ ./net/blockingest/cleangofmt -lcleango test -count=1 ./net/chainxchg/ ./net/blockingest/→ both okScope / follow-ups
SetChainFetcheron the ingestor + use it for the anchor seed, which also finishes Boot anchor Glif-independence under --no-fallback-rpc (#76 follow-up) #109) is the next commit.feat/108-no-fallback-rpc([Tracking] Lantern bridge-off parity for stock Curio (maxboom / PR #1311) #76 scaffolding); rebase tomainonce feat(#76): --no-fallback-rpc for a provably Glif-free standalone daemon #108 lands.