Skip to content

Improve legacy vs peer syncing#565

Draft
oskarszoon wants to merge 4 commits intobsv-blockchain:mainfrom
oskarszoon:feature/legacy-peer-registry
Draft

Improve legacy vs peer syncing#565
oskarszoon wants to merge 4 commits intobsv-blockchain:mainfrom
oskarszoon:feature/legacy-peer-registry

Conversation

@oskarszoon
Copy link
Contributor

No description provided.

…rchestration

Implements the improve-legacy-peer-sync OpenSpec change. Summary of what changed:

Adds CentralizedPeerRegistry to the blockchain service — a transport-agnostic
store for peers from both P2P (HTTP/DataHub) and Legacy (wire protocol) services.
Includes reputation scoring, atomic file persistence, and TTL-based cleanup.
Exposed over a new PeerRegistryService gRPC endpoint (RegisterPeer,
UpdatePeerMetrics, RemovePeer, ListPeers).

P2P registers connected peers in the centralized registry on connect/disconnect
and reports bytes/height changes. Legacy registers wire-protocol peers on version
handshake and removes them on disconnect.

Adds CatchupTransport interface with two implementations:
- HTTPTransport: wraps existing DataHub HTTP fetch logic
- WireTransport: delegates to Legacy's new FetchHeadersFromPeer /
  FetchBlockFromPeer gRPC methods, which send getheaders/getdata wire protocol
  messages to a connected legacy peer

BlockValidation now drives catchup independently via the centralized peer
registry. A registry poller detects when any peer (HTTP or wire) reports a
height higher than our best block and initiates catchup. Peer selection is
transport-agnostic (ranked by reputation score); the transport is dispatched
based on the selected peer's TransportType.

- Removes LEGACYSYNCING FSM state and LEGACYSYNC event — CATCHINGBLOCKS is the
  single catchup state. Proto enum slots reserved for backward wire compat.
- Removes Kafka-based catchup trigger from P2P SyncCoordinator
- Removes LegacySync() from blockchain service interface and server

BlockValidation is wired with a PeerRegistryClient and WireTransport at startup.
@oskarszoon oskarszoon force-pushed the feature/legacy-peer-registry branch from cd79d69 to 37eeff4 Compare March 18, 2026 12:22
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