Skip to content

feat(p2p): expose p2p connectivity (enabled + connected peer count) - #25178

Closed
spalladino wants to merge 1 commit into
spl/p2p-fatal-bind-failurefrom
spl/p2p-connectivity-signal
Closed

feat(p2p): expose p2p connectivity (enabled + connected peer count)#25178
spalladino wants to merge 1 commit into
spl/p2p-fatal-bind-failurefrom
spl/p2p-connectivity-signal

Conversation

@spalladino

@spalladino spalladino commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Adds getP2PConnectivity(), returning { enabled, connectedPeers }, so downstream subsystems can tell
whether the libp2p stack is alive and how many peers it is talking to. Until now a node running with a dead
p2p stack (zero peers) looked identical to a healthy one from the outside.

  • P2PService declares the method synchronously, matching its neighbouring getPeers / getGossipMeshPeerCount.
  • LibP2PService returns enabled: true and counts peers reported as connected by the peer manager, so
    dialing and cached peers are excluded.
  • DummyP2PService (and the TXE dummy client) return enabled: false with zero peers, encoding "p2p is
    disabled" for sandbox and single-node setups; consumers can treat disabled p2p as vacuously healthy instead
    of as a stack with no peers.
  • P2PClient forwards to the service, and P2PApi exposes it over JSON-RPC with a P2PConnectivity zod
    schema, so the node API surfaces it too.

No behavior is gated on this yet; it is the foundation for gating slashing, proposing, and sendTx on p2p
connectivity in follow-up changes.

Part of A-1701.


Part of a stacked-PR chain (bottom → top) hardening the node against running with a dead p2p stack; each PR targets the branch below it and the bottom targets merge-train/spartan-v5:

  1. fix(p2p): fail node startup when p2p service fails to start #25177 — fail node startup when the p2p service fails to start
  2. feat(p2p): expose p2p connectivity (enabled + connected peer count) #25178 — expose p2p connectivity (enabled + connected peer count)
  3. fix(slasher): do not file data-withholding offenses while peerless #25179 — do not file data-withholding offenses while peerless
  4. fix(sequencer): skip proposing when node has no connected peers #25180 — skip proposing when the node has no connected peers
  5. feat(node): report per-component health with p2p peer count on GET /status #25181 — report per-component health with p2p peer count on GET /status
  6. fix(node): reject sendTx when node has no peers to propagate the tx #25182 — reject sendTx when the node has no peers to propagate the tx
  7. feat(p2p): warn periodically while node has zero connected peers #25183 — warn periodically while the node has zero connected peers

Adds `getP2PConnectivity()`, returning `{ enabled, connectedPeers }`, so downstream subsystems can tell
whether the libp2p stack is alive and how many peers it is talking to. Until now a node running with a dead
p2p stack (zero peers) looked identical to a healthy one from the outside.

- `P2PService` declares the method synchronously, matching its neighbouring `getPeers` / `getGossipMeshPeerCount`.
- `LibP2PService` returns `enabled: true` and counts peers reported as connected by the peer manager, so
  dialing and cached peers are excluded.
- `DummyP2PService` (and the TXE dummy client) return `enabled: false` with zero peers, encoding "p2p is
  disabled" for sandbox and single-node setups; consumers can treat disabled p2p as vacuously healthy instead
  of as a stack with no peers.
- `P2PClient` forwards to the service, and `P2PApi` exposes it over JSON-RPC with a `P2PConnectivity` zod
  schema, so the node API surfaces it too.

No behavior is gated on this yet; it is the foundation for gating slashing, proposing, and sendTx on p2p
connectivity in follow-up changes.

Part of A-1701.
@spalladino

Copy link
Copy Markdown
Contributor Author

Superseded by #25185, which groups this stack's dependent layers (connectivity signal + slasher/proposer/health/sendTx gates) into one PR with a commit per concern, targeting merge-train/spartan-v5 directly. The independent fixes remain as #25177 and #25183.

@spalladino spalladino closed this Aug 12, 2026
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