feat(p2p): expose peer-scoring fields on /eth/v1/node/peers#695
Draft
barnabasbusa wants to merge 2 commits into
Draft
feat(p2p): expose peer-scoring fields on /eth/v1/node/peers#695barnabasbusa wants to merge 2 commits into
barnabasbusa wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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— frompeer_info.client().agent_stringscore— frompeer_info.score().score()disconnect_reason— from the newLastDisconnecttracker (added to the vendoredeth2_libp2pfork)downscore_reasons— single-element array from the newLastActiontrackerSpec proposal
ethereum/beacon-APIs#606
Companion PR
This PR depends on the corresponding submodule PR which adds
LastAction/LastDisconnecttracking to the vendoredeth2_libp2pfork:What's in this PR
p2p/src/network_api.rs— extendsNodePeerwith 4 optional fields (#[serde(skip_serializing_if = "Option::is_none")]), addsmap_disconnect_reason()/map_downscore_reason()translators (mirroring the Lighthouse PR's vocab mappings), populates the fields inNodePeer::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-networksclean.