Skip to content

feat(p2p): ION overlay discovery — service bit + detection + seed flag (#114)#121

Merged
LiranCohen merged 1 commit into
mainfrom
feat/fastsync-overlay-discovery
Jun 9, 2026
Merged

feat(p2p): ION overlay discovery — service bit + detection + seed flag (#114)#121
LiranCohen merged 1 commit into
mainfrom
feat/fastsync-overlay-discovery

Conversation

@LiranCohen

Copy link
Copy Markdown
Contributor

Summary

Third piece of the ION fast-sync overlay (epic #111). Lets ion-nodes find each other over the Bitcoin P2P network so a new node can fast-sync from a peer.

The service bit (rolled, as decreed 🎲)

scripts/pick_service_bit.py picks the bit by dice roll within Bitcoin's experimental range (bits 24–31, reserved for exactly this so it can't collide with NODE_NETWORK/WITNESS/COMPACT_FILTERS/…), five rolls, take the fifth:

rolls (bit positions): [26, 25, 25, 31, 30]
chosen (5th roll): bit 30
ServiceION = 1 << 30 = 0x40000000

What's here

  • internal/p2p/overlay.goServiceION = 1<<30; SpeaksION(services); Client.IONPeerCount() / IONPeerAddrs() (the discovered overlay neighbourhood among connected peers); an internal speaksION(peer) gate so later phases only send overlay messages to peers that advertised the bit (a vanilla Bitcoin peer is never sent an unknown command).
  • internal/p2p/peer.go — advertise ServiceION in our version message (we still serve no Bitcoin services).
  • internal/config + cmd/ion-node--ion-peer (repeatable) → cfg.IONPeers. No public ION seeds exist yet, so they're operator-supplied via the flag for now; the running node we stood up could be the first seed when you're ready.

ServiceION is a placeholder for the wider ecosystem and can change before any real deployment. Dialing/preferring ION peers and the wire protocol land in #115 / #118.

Tests

  • SpeaksION over defined + experimental bits — asserts no collision with defined service bits and bit == 1<<30.
  • End-to-end handshake: a stub server advertising ServiceION is counted as an ION peer; a vanilla server is not.
  • --ion-peer config plumbing; peerConfig advertises ServiceION.

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

Post-Deploy Monitoring & Validation

  • What to watch: an ion-node now advertises service bit 0x40000000 in its version; peers that are also ion-nodes become visible via IONPeerCount(). No behavior change for header/block sync.
  • Failure signal / trigger: none expected; advertising an experimental service bit is inert to vanilla Bitcoin peers.
  • Window/owner: ongoing once overlay peering (fast-sync 4/7: fast-sync wire protocol (getanchors/anchors, getcas/cas) #115+) uses it.

Part of #111. Closes #114

🤖 Generated with Claude Code

#114)

Third piece of the ION fast-sync overlay (epic #111). Lets ion-nodes find each
other over the Bitcoin P2P network so a new node can fast-sync from a peer.

- scripts/pick_service_bit.py: picks the overlay's Bitcoin service bit by dice roll
  within Bitcoin's experimental range (bits 24-31, reserved for exactly this), five
  rolls take the fifth. Result: bit 30.
- internal/p2p/overlay.go: ServiceION = 1<<30 (0x40000000); SpeaksION(services);
  Client.IONPeerCount()/IONPeerAddrs() (the discovered overlay neighbourhood among
  connected peers); speaksION(peer) gate for later phases (only send overlay
  messages to peers that advertised the bit, so a vanilla Bitcoin peer is never sent
  an unknown command).
- internal/p2p/peer.go: advertise ServiceION in our version message (we still serve
  no Bitcoin services).
- internal/config + cmd/ion-node: --ion-peer (repeatable) → cfg.IONPeers, overlay
  seed addresses. No public ION seeds exist yet, so they are operator-supplied via
  the flag; a real seed will be chosen when the ecosystem is ready.

This is a placeholder bit for the wider ecosystem; it can change before any real
overlay deployment. Dialing/preference of ION peers and the wire protocol land in
#115/#118.

Tests: SpeaksION over defined/experimental bits (asserts no collision with
NODE_NETWORK/WITNESS/etc and bit==1<<30); an end-to-end handshake where a stub
server advertising ServiceION is counted as an ION peer (and a vanilla server is
not); --ion-peer config plumbing; peerConfig advertises ServiceION. 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 297030a into main Jun 9, 2026
1 check passed
@LiranCohen LiranCohen deleted the feat/fastsync-overlay-discovery branch June 9, 2026 01:57
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.

fast-sync 3/7: ION overlay discovery & capability handshake

1 participant