Skip to content

feat(p2p): expose peer-scoring fields on /eth/v1/node/peers#695

Draft
barnabasbusa wants to merge 2 commits into
grandinetech:developfrom
barnabasbusa:bbusa/peer-scores-beacon-api
Draft

feat(p2p): expose peer-scoring fields on /eth/v1/node/peers#695
barnabasbusa wants to merge 2 commits into
grandinetech:developfrom
barnabasbusa:bbusa/peer-scores-beacon-api

Conversation

@barnabasbusa

Copy link
Copy Markdown
Contributor

Summary

Extends /eth/v1/node/peers (and /eth/v1/node/peers/{peer_id}) with four optional fields per a simplified beacon-API spec extension currently under discussion:

  • agent_version — from peer_info.client().agent_string
  • score — from peer_info.score().score()
  • disconnect_reason — from the new LastDisconnect tracker (added to the vendored eth2_libp2p fork)
  • downscore_reasons — single-element array from the new LastAction tracker

Spec proposal

ethereum/beacon-APIs#606

Companion PR

This PR depends on the corresponding submodule PR which adds LastAction / LastDisconnect tracking to the vendored eth2_libp2p fork:

What's in this PR

p2p/src/network_api.rs — extends NodePeer with 4 optional fields (#[serde(skip_serializing_if = "Option::is_none")]), adds map_disconnect_reason() / map_downscore_reason() translators (mirroring the Lighthouse PR's vocab mappings), populates the fields in NodePeer::from_peer_info(). Plus the submodule SHA bump.

Coordinated implementations

Part of a coordinated multi-client effort — see ethereum/beacon-APIs#606 for the other five client PRs.

Status

Draft. cargo build -p grandine --features default-networks clean.

Add four optional fields to NodePeer on the standard
/eth/v1/node/peers and /eth/v1/node/peers/{peer_id} endpoints
per the simplified beacon-API peer-scoring proposal:

- agent_version: libp2p identify agent string
- score: current numeric peer score
- disconnect_reason: last goodbye reason, mapped into the spec
  PeerDisconnectReason vocab
- downscore_reasons: most recent downscoring tag, mapped into the
  spec PeerScoreReason vocab

Translation between the eth2_libp2p submodule's internal
'&'static str' tags and the spec vocabularies is handled by
map_disconnect_reason and map_downscore_reason at the top of
p2p/src/network_api.rs.

Bumps the eth2_libp2p submodule to a commit that records
LastAction/LastDisconnect inside PeerInfo so the HTTP layer can
read those fields without scraping logs or Prometheus.
Per the proposed beacon-API spec
(ethereum/beacon-APIs#606), `disconnect_reason`
MUST only be populated when the peer's `state` is `disconnected` or
`disconnecting`. Only map `last_disconnect()` when the resolved
`PeerState` matches one of those variants.
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