Skip to content

p2p: internal refactor and architecture redesign #5670

@erikgrinaker

Description

@erikgrinaker

As discussed in #2067, the peer-to-peer architecture needs to be redesigned and refactored. The background and scope for this is outlined in ADR 061 (as "phase 1"), and the proposed new architecture design is described in ADR 062.

Phase I

Items that are deemed necessary to complete or at least revisit before the next major release (v0.35.0)

Phase II

Items that should be completed for a future release but are not required for a fully functional p2p layer that maintains feature and performance parity with the legacy stack.

  • New transport API
    • Consider stream-based transport API. rfc: add P2P stream proposal spec#227
    • Refactor and clean up MConnection and SecretConnection code (possibly after stream-based API).
    • Remove traffic scheduling (priorities and bandwidth limits) in MConnection, move into Router (probably requires stream API)
  • New P2P core
    • Design improved address detection and advertisement system.
      • Differentiate between listen address and advertised addresses, by detecting advertised addresses.
      • UPnP address detection.
      • Differentiate advertisement based on remote peer IP network (e.g. peers on 192.168.0.0 can get internal addresses, but not peers on public networks).
    • Improve peerStore.Ranked() performance with ordered data structure.
    • Consider CLI to manage peer database (e.g. manually evicting invalid addresses).
  • Migrate to new P2P API
    • Review P2P and reactor code to make better use of new abstractions.
  • Future work
    • Remove PeerManager.SetHeight() and GetHeight(), as reactors should not share state (requires protocol changes such that reactors retrieve this information themselves).
    • Remove V1 PEX Reactor (PEX: eventually remove v1 reactor  #6371)
    • Make PEX and MConn handshakes exchange address URLs, not IP/port endpoints.

Metadata

Metadata

Labels

C:p2pComponent: P2P pkgT:trackingTracking issue for other issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions