feat(peer_manager): track LastAction and LastDisconnect on PeerInfo#27
Draft
barnabasbusa wants to merge 1 commit into
Draft
feat(peer_manager): track LastAction and LastDisconnect on PeerInfo#27barnabasbusa wants to merge 1 commit into
barnabasbusa wants to merge 1 commit into
Conversation
Adds two optional fields to PeerInfo:
- last_action: { reason, source, action, delta, seconds_ago }
populated from PeerDB::report_peer (skipped for trusted peers)
- last_disconnect: { reason, code, direction, seconds_ago }
populated from PeerManager::goodbye_peer (direction=sent) and
the inbound goodbye handler in service/mod.rs (direction=received)
Also replaces the single "handle_rpc_error" report-peer msg with
rpc_error_msg() which maps each RPCError variant (and inner
RpcErrorResponse code) to a stable static tag:
rpc_incomplete_stream, rpc_invalid_data, rpc_ssz_decode_error,
rpc_io_error, rpc_negotiation_timeout, rpc_stream_timeout,
rpc_unsupported_protocol, rpc_unknown_status,
rpc_resource_unavailable, rpc_server_error, rpc_invalid_request,
rpc_rate_limited, rpc_blobs_not_found.
Both fields use #[serde(skip_serializing_if = "Option::is_none")]
so they only appear after the first relevant event, keeping the
existing JSON shape backwards-compatible.
Lets external tooling display per-peer downscore reasons across
clients without scraping logs or Prometheus.
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
Adds
LastActionandLastDisconnecttracking toPeerInfo, mirroring the pattern from upstream Lighthouse'sbbusa/peer-scores-last-eventbranch (also a draft). Used by grandinetech/grandine#NNN to expose peer-scoring fields on/eth/v1/node/peersper a simplified beacon-API spec extension (ethereum/beacon-APIs#606).What's in this PR
peer_manager/peerdb/score.rs— newLastAction,LastDisconnect,DisconnectDirectiontypes +serialize_instant_seconds_agohelper.PeerActionandReportSourcemadeSerialize + Clone + Copyfor downstream use.peer_manager/peerdb/peer_info.rs—last_action/last_disconnectfields + accessorslast_action()/last_disconnect()and setters.peer_manager/peerdb.rs—record_last_disconnect()method;report_peer()updated to populateLastActionwith pre/post-score delta.peer_manager/mod.rs—rpc_error_msg()(per-RPCErrorgranular tags, with Grandine-specificSszReadError/SszWriteErrorvariants) andgoodbye_reason_name().goodbye_peer()recordsLastDisconnect{direction: Sent}.service/mod.rs—RequestType::Goodbyehandler callsrecord_last_disconnect()withDisconnectDirection::Received.Spec proposal
ethereum/beacon-APIs#606
Coordinated implementations
Part of a coordinated multi-client effort.
Status
Draft. Builds clean as part of
cargo build -p grandine --features default-networks.