Skip to content

Latest commit

 

History

History
81 lines (70 loc) · 3.72 KB

File metadata and controls

81 lines (70 loc) · 3.72 KB

Iroh Mode: Feature Parity with IPFS Mode

TODO

1. NAR Download from Peers ✅

  • Rewrite NAR URLs in narinfo to route through Iroh peer fetch
  • Add /iroh/nar/{peer_id}/{path} endpoint that fetches via IrohNode.fetch_nar()
  • Track which peer provided the narinfo to fetch NAR from same peer

2. Narinfo Signing ✅

  • Integrate pynacl signing for narinfo responses
  • Support NIX_SECRET_KEY_FILE environment variable
  • Sign fingerprint format: 1;storePath;narHash;narSize;refs...
  • Add --private-key CLI option

3. Store Scanning with On-the-fly NAR Generation ✅

  • Reuse scan part from scan_and_publish in ipfs_store.py
  • Skip IPFS publish step - generate NAR on-the-fly when requested
  • Add cache for frequently requested NARs (LRU or similar) - deferred, may not be needed
  • Track which hashes are available locally for tracker announcement

4. Delta Sync ✅

  • Announce local package hashes to tracker
  • Use delta sync (only send added/removed hashes)
  • Persist announced state to /var/lib/peerix/announced_state.json
  • Periodic re-sync (every 5 minutes like IPFS mode)

5. Nixpkgs Filtering ✅

  • Integrate NixpkgsFilteredStore - only serve packages in cache.nixos.org
  • Support FilteredStore with custom patterns
  • Add --no-filter and --filter-mode CLI options

6. Verified Store ✅

  • Integrate VerifiedStore wrapper
  • Verify NAR hashes against upstream cache (cache.nixos.org)
  • Add --no-verify and --upstream-cache CLI options
  • TOCTOU protection during streaming - deferred (exists in VerifiedStore but not exposed)

7. Dashboard ✅

  • Port dashboard HTML from app.py
  • Adapt for Iroh mode (show Iroh peers instead of IPFS swarm)
  • Progress tracking with Kalman filter ETA
  • Pause/resume controls for scanning
  • Show tracker peers with geo-location - deferred
  • /status endpoint with full node info
  • /dashboard-stats JSON endpoint

8. NAR Compression

  • Compress NARs on-the-fly (zstd or xz)
  • Add Compression: zstd header to narinfo
  • Make compression level configurable
  • Consider caching compressed NARs for frequently requested packages
  • Note: Nix supports zstd compression for NARs via Compression: zstd in narinfo
  • Reference: cache.nixos.org uses zstd compression, narinfo includes Compression: zstd
  • Implementation: use zstandard Python library for streaming compression

9. Iroh Streaming Reliability ✅

  • Investigate IrohError during NAR streaming (connection drops mid-transfer)
    • Root cause: Iroh QUIC buffers not fully transmitted before finish() called
    • Fix: Length-prefixed protocol with chunked sending and delays
  • Length-prefixed protocol: send 8-byte size header, then exact bytes
  • Chunked sending: 16KB chunks with 20ms delay every 64KB
  • Buffer flush delay: 500ms base + 300ms per MB before finish()
  • Tested working with files up to 1.6MB via Iroh relay
  • Report upstream bug to Iroh team about stream truncation

Completed

  • Persistent node identity (Ed25519 secret key)
  • Tracker integration for Iroh peer discovery
  • NAT traversal via Iroh relay
  • Narinfo fetch from peers
  • Basic HTTP endpoints (/nix-cache-info, /{hash}.narinfo, /nar/, /status, /peers)
  • NAR download from Iroh peers (/iroh/nar/{peer_id}/{path})
  • Narinfo signing with pynacl
  • Store scanning with package hash tracking
  • Delta sync for package hashes
  • Nixpkgs filtering (NixpkgsFilteredStore)
  • Hash verification (VerifiedStore)
  • Filtered hash caching (/var/lib/peerix/filtered_hashes.json)
  • Dashboard hash-based change detection (efficient DOM updates)
  • Dashboard with Iroh status and controls